Solutions – Practical 2
The auxiliary functions, gcd, and red (reduce), are hidden by the signature, so we don’t need to make them local. These auxiliary functions clearly deal with integers, so we don’t need (but could have) type constriants on the later function that use red. Some type constraints on the last two functions are needed to disambiguate * and ~.
Notice the use of local functions, and the way in which a 4-tuple is passed to min4 and max4.
The definition of equality given here is very strict. We consider each interval to represent an indeterminate number that lies somewhere in the interval. We can only know that two indeterminate numbers are equal under the conditions given here. However, you could also argue that we only know that they are different when the intervals are disjoint. Proper resolution of this dilemma would require non-boolean truth values. ©Michael Fourman 1994-2006