From 3aa4a2b58221a3e83b17d0c04c9a6e9c41e5500c Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Sat, 19 Nov 2022 21:39:00 +0100 Subject: refactor: separate primitive types from nodes --- subprojects/frontend/src/index.tsx | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'subprojects/frontend/src/index.tsx') 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,26 +10,23 @@ const initialValue = `class Family { } class Person { - Person[] children opposite parent - Person[0..1] parent opposite children + refers Person[] children opposite parent + refers Person[0..1] parent opposite children int age - TaxStatus taxStatus + refers TaxStatus taxStatus } enum TaxStatus { child, student, adult, retired } -int ageDifference(Person p, Person q) = - children(p, q), age(p, pAge), age(q, qAge) -> qAge - pAge. - -error invalidAgeDifference(Person p, Person q) <-> - children(p, q), ageDifference(p, q) <= 0. - % A child cannot have any dependents. pred invalidTaxStatus(Person p) <-> taxStatus(p, child), children(p, _q) +; + parent(p, q), + age(q) < age(p) ; taxStatus(p, retired), parent(p, q), @@ -44,10 +41,8 @@ children(anne, ciri). ?children(bob, ciri). default children(ciri, *): false. taxStatus(anne, adult). -age(anne, 35). -bobAge: 27. -age(bob, bobAge). -!age(ciri, bobAge). +age(bob) in 21..35. +age(ciri) = 10. scope Family = 1, Person += 5..10. `; -- cgit v1.2.3-54-g00ecf