diff options
Diffstat (limited to 'subprojects/frontend/src/index.tsx')
-rw-r--r-- | subprojects/frontend/src/index.tsx | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/subprojects/frontend/src/index.tsx b/subprojects/frontend/src/index.tsx index b42b8062..0165d7c1 100644 --- a/subprojects/frontend/src/index.tsx +++ b/subprojects/frontend/src/index.tsx | |||
@@ -10,27 +10,24 @@ const initialValue = `class Family { | |||
10 | } | 10 | } |
11 | 11 | ||
12 | class Person { | 12 | class Person { |
13 | Person[] children opposite parent | 13 | refers Person[] children opposite parent |
14 | Person[0..1] parent opposite children | 14 | refers Person[0..1] parent opposite children |
15 | int age | 15 | int age |
16 | TaxStatus taxStatus | 16 | refers TaxStatus taxStatus |
17 | } | 17 | } |
18 | 18 | ||
19 | enum TaxStatus { | 19 | enum TaxStatus { |
20 | child, student, adult, retired | 20 | child, student, adult, retired |
21 | } | 21 | } |
22 | 22 | ||
23 | int ageDifference(Person p, Person q) = | ||
24 | children(p, q), age(p, pAge), age(q, qAge) -> qAge - pAge. | ||
25 | |||
26 | error invalidAgeDifference(Person p, Person q) <-> | ||
27 | children(p, q), ageDifference(p, q) <= 0. | ||
28 | |||
29 | % A child cannot have any dependents. | 23 | % A child cannot have any dependents. |
30 | pred invalidTaxStatus(Person p) <-> | 24 | pred invalidTaxStatus(Person p) <-> |
31 | taxStatus(p, child), | 25 | taxStatus(p, child), |
32 | children(p, _q) | 26 | children(p, _q) |
33 | ; | 27 | ; |
28 | parent(p, q), | ||
29 | age(q) < age(p) | ||
30 | ; | ||
34 | taxStatus(p, retired), | 31 | taxStatus(p, retired), |
35 | parent(p, q), | 32 | parent(p, q), |
36 | !taxStatus(q, retired). | 33 | !taxStatus(q, retired). |
@@ -44,10 +41,8 @@ children(anne, ciri). | |||
44 | ?children(bob, ciri). | 41 | ?children(bob, ciri). |
45 | default children(ciri, *): false. | 42 | default children(ciri, *): false. |
46 | taxStatus(anne, adult). | 43 | taxStatus(anne, adult). |
47 | age(anne, 35). | 44 | age(bob) in 21..35. |
48 | bobAge: 27. | 45 | age(ciri) = 10. |
49 | age(bob, bobAge). | ||
50 | !age(ciri, bobAge). | ||
51 | 46 | ||
52 | scope Family = 1, Person += 5..10. | 47 | scope Family = 1, Person += 5..10. |
53 | `; | 48 | `; |