Labs 02
http://alloy.mit.edu/alloy4/tutorial4/
Checking FOL identities and counterexamples.
Formulas from Predicate Logic Informally have no counterexamples.
'Variations' such as:
Relational identities
Sample Alloy Code
FOL
sig D { }
sig P in D { }
sig Q in D { }
// this shows no counterexample
//check { (all x:D| (x in P) and (x in Q)) => (all x:D| x in P) and (all x:D| x in Q) }
// this shows counterexample
check { (all x:D| (x in P) or (x in Q)) => (all x:D| x in P) or (all x:D| x in Q) }
Relations
// declaring binary relations r1,r2,s on A
sig A {
r1 : set A,
r2 : set A,
s : set A
}
// no counterexamples here:
// check { (r1 + r2).s = (r1.s + r2.s) }
// a counterexample here:
// check { (r1 & r2).s = (r1.s & r2.s) }