Advertisement
Guest User

Untitled

a guest
Jun 11th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. module forum
  2.  
  3. abstract sig Subforum{
  4. name: one String
  5. }
  6.  
  7. //post type with either link or text data
  8. abstract sig PostType{
  9. content: one String
  10. }
  11.  
  12. sig PostTypeLink extends PostType {
  13. }
  14.  
  15. sig PostTypeText extends PostType {
  16. }
  17.  
  18. abstract sig Account{
  19. username: one String,
  20. password: one String,
  21. }
  22.  
  23. sig Admin extends Account{
  24. domain: Subforum
  25. }
  26.  
  27. sig Moderator extends Account{
  28. domain: one Subforum
  29. }
  30.  
  31. sig User extends Account{
  32. }
  33.  
  34. sig Post{
  35. subforum: one Subforum,
  36. title: String,
  37. //upvotes: Int,
  38. //downvotes: Int,
  39. Vote: all User,
  40. Type: one PostType,
  41. poster: one User
  42. }
  43.  
  44. sig Reply extends Post{
  45. parent: lone Post
  46. }
  47.  
  48. //facts
  49. fact commentMustHavePost{
  50. }
  51.  
  52. fact oneRolePerAccount{
  53. disj[User, Moderator, Admin]
  54. }
  55.  
  56. fact uniqueUsernames{
  57. all a, a': Account | a.username != a'.username
  58. }
  59.  
  60. pred onVotePerUserForPost[p: Post, a: Account]{
  61. one v: a | {
  62. all u
  63. }
  64. }
  65.  
  66. pred oneAccountPerPost[p: Post, a: Account]{
  67. all p: Post | #p.poster = 1
  68. }
  69.  
  70. assert oneAccountPerPost{
  71. all p: Post | one a: Account | oneAccountPerPost[p, a]
  72. }
  73.  
  74. pred demo {
  75. //for running in Alloy
  76. //This is just for testing, but we can fill it in with something meaningful if we want
  77. }
  78.  
  79. run demo for 3 Account, 2 Post, 5 Reply, 3 Subforum, 3 PostType
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement