Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module forum
- abstract sig Subforum{
- name: one String
- }
- //post type with either link or text data
- abstract sig PostType{
- content: one String
- }
- sig PostTypeLink extends PostType {
- }
- sig PostTypeText extends PostType {
- }
- abstract sig Account{
- username: one String,
- password: one String,
- }
- sig Admin extends Account{
- domain: Subforum
- }
- sig Moderator extends Account{
- domain: one Subforum
- }
- sig User extends Account{
- }
- sig Post{
- subforum: one Subforum,
- title: String,
- //upvotes: Int,
- //downvotes: Int,
- Vote: all User,
- Type: one PostType,
- poster: one User
- }
- sig Reply extends Post{
- parent: lone Post
- }
- //facts
- fact commentMustHavePost{
- }
- fact oneRolePerAccount{
- disj[User, Moderator, Admin]
- }
- fact uniqueUsernames{
- all a, a': Account | a.username != a'.username
- }
- pred onVotePerUserForPost[p: Post, a: Account]{
- one v: a | {
- all u
- }
- }
- pred oneAccountPerPost[p: Post, a: Account]{
- all p: Post | #p.poster = 1
- }
- assert oneAccountPerPost{
- all p: Post | one a: Account | oneAccountPerPost[p, a]
- }
- pred demo {
- //for running in Alloy
- //This is just for testing, but we can fill it in with something meaningful if we want
- }
- run demo for 3 Account, 2 Post, 5 Reply, 3 Subforum, 3 PostType
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement