| ```clafer abstract Person Name -> string Surname -> string DateOfBirth -> string or Gender Male Female xor MaritalStatus NeverMarried Married Divorced Address Street -> string UnitNo -> string ? City -> string Country -> string PostalCode -> string ``` |
form of a `Person` `Name` is a point about the Person and it should be text `DateOfBirth` is a date at least one of `Male` and `Female` must be chosen (or) `Male` is a point about `Gender` and it is indirectly a point about `Person` exactly one of `NeverMarried`, `Married`, and `Divorced` must be chosen (xor) points about a `Person` related to address are grouped below `Address` itself holds no value `UnitNo` is an optional point but can only be given when `Street` is given |
| ```clafer JohnDoe : Person [ Name = "John" ] [ Surname = "Doe" ] [ DateOfBirth = "01-02-1985" ] [ Male ] [ Married ] [ Street = "123 Main St." ] [ City = "Great Town" ] [ Country = "Canada" ] [ PostalCode = "A1B 2C3" ] ``` |
`JohnDoe` is an example of a `Person` (precisely an *instance specification*) the value of `Name` is `John` the value of date is a string formatted appropriately he is a `Male` he is `Married` his address does not have a `UnitNo` also has `Address` but do not need to assert explicitly; `Address` is assumed present because its children are present, e.g., `Street` |
| ```clafer abstract Student : Person StudentId -> string ``` ```clafer abstract WaitingLine participants -> Person * ``` |
form of a `Student` that "is a" `Person`. `StudentId` is a property specific to a `Student` The `WaitingLine` consists of many (as indicated by *) participants who can also be students. |
| ```clafer MaryJane : Student [ Name = "Mary Jane" ] [ StudentId = "MJ13421354" ] ``` | Need to fill in the form for the `Person` here |
| ```clafer BusLine : WaitingLine [ JohnDoe in participants ] [ MaryJane in participants ] ``` |
`JohnDoe` and `MaryJane` are participants in the `BusLine`.
|
| ```clafer JohnAndMaryLine : WaitingLine [ participants = JohnDoe, MaryJane ] ``` | The line consists of exactly `JohnDoe` and `MaryJane`. |
| ```clafer abstract TwoPersonLine : WaitingLine [ # participants = 2 ] ``` | A specialized concept with a restriction: the line consists of exactly 2 participants. |
| ```clafer abstract OneToTenPersonLine : WaitingLine [ # participants >= 1 ] [ # participants <= 10] ``` | The line consists of at least one and at most 10 participants. |
| ```clafer enum NorthAmericanCountry = Canada | USA | Mexico abstract Person2 Country -> NorthAmericanCountry ``` | Country can only point at (link to) one of the north American countries |
| We could then specify that `JohnDoe2` comes from Canada as follows: ```clafer JohnDoe2 : Person2 [ Country = Canada ] ``` | Country points to Canada (note that quotes are removed because we link to the clafer Canada instead of specifying the country’s name!) |