-
Notifications
You must be signed in to change notification settings - Fork 0
Description
When you define an "eq" or "ord" clause for a type, it creates eq_T, ord_T, max_T and min_T functions. The LRM says that these functions have the signature "T * T +> bool" or "T * T +> T", which is as you might expect. But actually both VDMJ and Overture create functions of this form:
types
R ::
a : nat
b : nat
eq r1 = r2 == r1 = r2
ord r1 < r2 == r1.a < r2.a;
T = nat
eq t1 = t2 == t1 = t2
ord t1 < t2 == t1 < t2;
> env
ord_R = (R * R +> bool)
max_R = (R * R +> R)
min_R = (R * R +> R)
ord_T = (nat * nat +> bool) <--- NOTE
max_T = (T * T +> T)
min_T = (T * T +> T)
eq_T = (nat * nat +> bool) <--- NOTE
eq_R = (R * R +> bool)
>
Note that all of the functions use the type as a parameter apart from eq/ord of the named type T. The reason for this is that the eq and ord clauses shown simply compare their arguments, and if they were of type T that would recurse (stack overflow). So they are created using the RHS of the named type, "nat" in this case.
So firstly we have an inconsistency, since eq_R is defined in terms of Rs, and that stack overflows in the example above(!). You cannot directly compare records, so the ord_R function is OK, but again it is inconsistent with ord_T's signature. The min_/max_ functions are fine, as they are created internally rather than using a user clause.
Lastly, the LRM says that the signatures of these functions are all R * R +> ... or T * T +> ....
We need to be consistent, decide how to solve the "eq a = b == a = b" and "ord a < b == a < b" cases, and then maybe update the LRM (and possibly the tools!)