@ -95,7 +95,6 @@ let equal_trm x y =
Int . equal i j
Int . equal i j
| _ -> equal_trm x y
| _ -> equal_trm x y
let sort_trm x y = if compare_trm x y < = 0 then ( x , y ) else ( y , x )
let zero = Z Z . zero
let zero = Z Z . zero
let one = Z Z . one
let one = Z Z . one
let _ Neg x = Neg x
let _ Neg x = Neg x
@ -211,53 +210,55 @@ end = struct
let _ Tt = Tt
let _ Tt = Tt
let _ Ff = Ff
let _ Ff = Ff
type equal_or_separate = Equal | Separate | Unknown
(* * classification of terms as either semantically equal or disequal, or
if semantic relationship is unknown , as either syntactically less than
or greater than * )
type compare_semantic_syntactic = SemEq | SemDq | SynLt | SynGt
let equal_or_separate d e : equal_or_separate =
let compare_semantic_syntactic d e =
match ( d , e ) with
match ( d , e ) with
| Z y , Z z -> if Z . equal y z then Equal else Separate
| Z y , Z z -> if Z . equal y z then SemEq else SemDq
| Q q , Q r -> if Q . equal q r then Equal else Separate
| Q q , Q r -> if Q . equal q r then SemEq else SemDq
| Z z , Q q | Q q , Z z ->
| Z z , Q q | Q q , Z z -> if Q . equal ( Q . of_z z ) q then SemEq else SemDq
if Q . equal ( Q . of_z z ) q then Equal else Separate
| _ ->
| _ -> if equal_trm d e then Equal else Unknown
let ord = compare_trm d e in
if ord < 0 then SynLt else if ord = 0 then SemEq else SynGt
let _ Eq0 x =
let _ Eq0 x =
match equal_or_separate zero x with
match compare_semantic_syntactic zero x with
(* 0 = 0 ==> tt *)
(* 0 = 0 ==> tt *)
| Equal -> Tt
| Sem Eq -> Tt
(* 0 = N ==> ff for N ≢ 0 *)
(* 0 = N ==> ff for N ≢ 0 *)
| Se parate -> Ff
| Se mDq -> Ff
| Unknown -> Eq0 x
| SynLt | SynGt -> Eq0 x
let _ Dq0 x =
let _ Dq0 x =
match equal_or_separate zero x with
match compare_semantic_syntactic zero x with
(* 0 ≠ 0 ==> ff *)
(* 0 ≠ 0 ==> ff *)
| Equal -> Ff
| Sem Eq -> Ff
(* 0 ≠ N ==> tt for N ≢ 0 *)
(* 0 ≠ N ==> tt for N ≢ 0 *)
| Se parate -> Tt
| Se mDq -> Tt
| Unknown -> Dq0 x
| SynLt | SynGt -> Dq0 x
let _ Eq x y =
let _ Eq x y =
if x = = zero then _ Eq0 y
if x = = zero then _ Eq0 y
else if y = = zero then _ Eq0 x
else if y = = zero then _ Eq0 x
else
else
match equal_or_separate x y with
match compare_semantic_syntactic x y with
| Equal -> Tt
| SemEq -> Tt
| Separate -> Ff
| SemDq -> Ff
| Unknown ->
| SynLt -> Eq ( x , y )
let x , y = sort_trm x y in
| SynGt -> Eq ( y , x )
Eq ( x , y )
let _ Dq x y =
let _ Dq x y =
if x = = zero then _ Dq0 y
if x = = zero then _ Dq0 y
else if y = = zero then _ Dq0 x
else if y = = zero then _ Dq0 x
else
else
match equal_or_separate x y with
match compare_semantic_syntactic x y with
| Equal -> Ff
| SemEq -> Ff
| Separate -> Tt
| SemDq -> Tt
| Unknown ->
| SynLt -> Dq ( x , y )
let x , y = sort_trm x y in
| SynGt -> Dq ( y , x )
Dq ( x , y )
let _ Gt0 = function
let _ Gt0 = function
| Z z -> if Z . gt z Z . zero then Tt else Ff
| Z z -> if Z . gt z Z . zero then Tt else Ff