Sayed Ali Farhaad SE
Sayed Ali Farhaad SE
Submitted By:
Roll No: 38
Class: BS SE
Semester: 5th
• Load family-1.als.
• Execute it.
• Analyze the metamodel.
Metamodel:
1
Source Code:
Exercise 2:
2
• Load family-2.als
• Execute it
Metamodel:
3
Source Code:
4
-- Define the parents relation as an auxiliary one
no p: Person | p in p.^parents
all p: Person | (lone (p.parents & Man)) and (lone (p.parents & Woman))
} run {} for
Exercise 3:
• Load family-3.als.
• Execute it.
• Look at the generated instance.
5
Source Code:
abstract sig Person {
6
sig Man, Woman extends Person {}
fact {
no p: Person | p in p.^parents
all p: Person | (lone (p.parents & Man)) and (lone (p.parents & Woman))
Exercise 4:
• Load family-4.als.
• Execute it.
7
• Look at the generated counter--‐examples.
• Why is Siblings Sibling false?
• Why is No Incest false?
Siblings Sibling:
8
NoIncest:
9
Source Code:
abstract sig Person {
fact {
no p: Person | p in p.^parents
all p: Person | (lone (p.parents & Man)) and (lone (p.parents & Woman))
10
check parentsArentsiblings for 10 assert
siblingsSiblings {
check siblingsSiblings
assert NoIncest {
no p: Married |
} check
NoIncest
Exercise 5:
11
12
Source Code:
abstract sig Person {
13
-- Two persons are blood relatives iff they have a common ancestor
fact {
no p: Person | p in p.^parents
all p: Person | (lone (p.parents & Man)) and (lone (p.parents & Woman))
q: Person |
Exercise 6:
14
sig Time {}
15
abstract sig Person { children:
Time
parentsDef {
all t: Time |
parents.t = ~(children.t)
16
-- A person P's siblings are those people with the same parents as P (excluding P)
some p.parents.t
else no p.siblings.t
fact staticOld {
let s = p.spouse.t |
17
-- A person can't be married to a blood relative
18