forked from AlloyTools/org.alloytools.alloy
-
Notifications
You must be signed in to change notification settings - Fork 9
Social Network
Alcino Cunha edited this page Oct 10, 2019
·
4 revisions
Consider the following model of distributed social network.
sig User {}
sig Post {}
sig DistributedSN {
servers : set Server,
friends : User -> User
}
sig Server {
posts : User -> Post,
capacity : Int
}
- Write the following invariants:
- Each post is owned by at most one user
- A user cannot be his or her own friend
- Friendship is a symmetric relation
- Server capacity is positive
- Servers cannot exceed their capacity
- Explore different (alternative) replication strategies for posts:
- Each post is stored in at most one server
- Each post is stored in at least two servers
- Specify the following operations ensuring they preserve the above invariants
-
addPost[n1,n2:DistributedSN,u:User,p:Post]
: add postp
by useru
. -
delPost[n1,n2:DistributedSN,u:User,p:Post]
: delete postp
from useru
. -
addFriend[n1,n2:DistributedSN,u,v:User]
: addv
as fried ofu
. -
addServer[n1,n2:DistributedSN,s:Server]
: add new servers
to networkn1
. -
delServer[n1,n2:DistributedSN,s:Server]
: delete servers
from networkn1
.
-
- Check the following algebraic properties of these operations:
-
delPost
undosaddPost
-
delServer
undosaddServer
-