-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwild_life_walk.als
More file actions
124 lines (114 loc) · 2.94 KB
/
wild_life_walk.als
File metadata and controls
124 lines (114 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
abstract sig Couple {
husband : one MaleName,
wife : one FemaleName,
surname : one SurName,
animal : one Animal,
bird : one Bird
}
enum SurName { Connor, Carver, Jones, Porter, White }
enum MaleName{ Paul, Peter, Jim, Tom, Mike }
enum FemaleName { Joanna, Marjorie, Olivia, Patricia, Sandra }
enum Animal { Beaver, Rabbit, Coyote, Woodchuck, Fox }
enum Bird { Eagle, Goose, Pheasant, Swan, WildTurkey }
/*
* NOTE TO PROF ::>
* So I tried to make this work with only one instance, but was not entirely sure of why it is
* producing 4 possible results. There was an option to do it without let statements, but
* I haven't had time to try that.
*/
fact One_to_One_Mappings {
/* These one-to-one mappings only work using the '=' operator since
there is exactly the same number of enum's and Couples
*/
Couple.husband = MaleName
Couple.wife = FemaleName
Couple.surname = SurName
Couple.animal = Animal
Couple.bird = Bird
}
// FILL IN THE FOLLOWING FACTS
/* Fact #1 - Tom, who wasn’t married to Olivia, saw a fox.
The couple that saw the beaver also saw wild turkeys
*/
fact F1 {
let t = husband.Tom {
t.wife != Olivia
t.animal = Fox
}
let c = animal.Beaver {
c.bird = WildTurkey
}
}
/* Fact #2 - Patricia Carver didn’t see the pheasant. Paul didn’t see the eagle.
The Jones’s saw a coyote. Jim’s last name wasn’t White
*/
fact F2 {
let p = wife.Patricia { // GIVEN: Patrica's surname is Carver
p.surname = Carver
p.bird != Pheasant
}
let p1 = husband.Paul {
p1.bird != Eagle
}
let j = surname.Jones {
j.animal = Coyote
}
let j1 = husband.Jim {
j1.surname != White
}
}
/* Fact #3 - The Porters didn’t see the swans. Tom wasn’t married to Sandra and his last name wasn’t Jones.
The Connors spotted a rabbit
*/
fact F3 {
let p = surname.Porter {
p.bird != Swan
}
let t = husband.Tom {
t.wife != Sandra
t.surname != Jones
surname.Connor.animal = Rabbit
}
}
/* Fact #4 - The couple who saw the coyote didn’t see the swan.
Mike, whose last name wasn’t Connor, didn’t see the woodchuck. Sandra saw the goose
*/
fact F4 {
let c = animal.Coyote {
c.bird != Swan
}
let m = husband.Mike {
m.surname != Connor
m.animal != Woodchuck
}
let s = wife.Sandra {
s.bird = Goose
}
}
/* Fact #5 - Peter and his wife Joanna didn’t see the wild turkeys.
Jim, whose last name wasn’t Jones, saw the pheasant but not the woodchuck.
*/
fact F5 {
let p = husband.Peter {
p.wife = Joanna
p.bird != WildTurkey
}
let j = husband.Jim {
j.surname != Jones
j.bird = Pheasant
j.animal = Woodchuck
}
}
/* Fact #6 - Marjorie White didn’t see the swans. Paul Porter didn’t see the beaver
*/
fact F6 {
let m = wife.Marjorie {
m.surname = White
m.bird != Swan
}
let p = husband.Paul {
p.surname != Porter
p.animal != Beaver
}
}
run { } for 5