-
Notifications
You must be signed in to change notification settings - Fork 1
/
deploymarket.spec
106 lines (90 loc) · 2.77 KB
/
deploymarket.spec
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
/* Four sisters riddle
* -------------------
*/
// The months
definition September() returns uint8 = 9;
definition October() returns uint8 = 10;
definition November() returns uint8 = 11;
definition December() returns uint8 = 12;
/** @title Find the sister's birth months
* See Birth Months riddle from:
* https://www.braingle.com/brainteasers/teaser.php?op=2&id=52499&comm=0
*
* The parameters to the rule are the sisters' birth months.
*/
rule sistersBirthMonths(
uint8 Sara,
uint8 Ophelia,
uint8 Nora,
uint8 Dawn
) {
// Each sister was born in one of the four months
require Sara >= September() && Sara <= December();
require Ophelia >= September() && Ophelia <= December();
require Nora >= September() && Nora <= December();
require Dawn >= September() && Dawn <= December();
// "None of us have an initial that matches the initial of her birth month."
require (
Sara != September() &&
Ophelia != October() &&
Nora != November() &&
Dawn != December()
);
// Ophelia is not the girl who was born in September
require Ophelia != September();
// Nora is not the girl who was born in September
require Nora != September();
// Nora's birth month does not start with a vowel
require Nora != October();
// The sisters were born on different months
require (
Sara != Ophelia &&
Sara != Nora &&
Sara != Dawn &&
Ophelia != Nora &&
Ophelia != Dawn &&
Nora != Dawn
);
satisfy true;
}
/// @title Verify that the solution is unique
rule solutionIsUnique(
uint8 Sara,
uint8 Ophelia,
uint8 Nora,
uint8 Dawn
) {
// Each sister was born in one of the four months
require Sara >= September() && Sara <= December();
require Ophelia >= September() && Ophelia <= December();
require Nora >= September() && Nora <= December();
require Dawn >= September() && Dawn <= December();
// "None of us have an initial that matches the initial of her birth month."
require (
Sara != September() &&
Ophelia != October() &&
Nora != November() &&
Dawn != December()
);
// Ophelia is not the girl who was born in September
require Ophelia != September();
// Nora is not the girl who was born in September
require Nora != September();
// Nora's birth month does not start with a vowel
require Nora != October();
// The sisters were born on different months
require (
Sara != Ophelia &&
Sara != Nora &&
Sara != Dawn &&
Ophelia != Nora &&
Ophelia != Dawn &&
Nora != Dawn
);
assert (
Sara == October() &&
Ophelia == November() &&
Nora == December() &&
Dawn == September()
);
}