less complex organization of cooper source code
authorhaftmann
Mon May 10 13:58:18 2010 +0200 (2010-05-10)
changeset 367983981db162131
parent 36797 cb074cec7a30
child 36799 628fe06cbeff
less complex organization of cooper source code
src/HOL/Decision_Procs/Cooper.thy
src/HOL/IsaMakefile
src/HOL/Presburger.thy
src/HOL/Tools/Qelim/cooper.ML
src/HOL/Tools/Qelim/cooper_data.ML
src/HOL/Tools/Qelim/cooper_procedure.ML
src/HOL/Tools/Qelim/generated_cooper.ML
     1.1 --- a/src/HOL/Decision_Procs/Cooper.thy	Mon May 10 12:25:49 2010 +0200
     1.2 +++ b/src/HOL/Decision_Procs/Cooper.thy	Mon May 10 13:58:18 2010 +0200
     1.3 @@ -1910,7 +1910,7 @@
     1.4  ML {* @{code cooper_test} () *}
     1.5  
     1.6  (*
     1.7 -code_reflect Generated_Cooper
     1.8 +code_reflect Cooper_Procedure
     1.9    functions pa
    1.10    file "~~/src/HOL/Tools/Qelim/generated_cooper.ML"
    1.11  *)
     2.1 --- a/src/HOL/IsaMakefile	Mon May 10 12:25:49 2010 +0200
     2.2 +++ b/src/HOL/IsaMakefile	Mon May 10 13:58:18 2010 +0200
     2.3 @@ -302,7 +302,6 @@
     2.4    Tools/Predicate_Compile/predicate_compile_specialisation.ML \
     2.5    Tools/Predicate_Compile/predicate_compile_pred.ML \
     2.6    Tools/quickcheck_generators.ML \
     2.7 -  Tools/Qelim/cooper_data.ML \
     2.8    Tools/Qelim/cooper.ML \
     2.9    Tools/Qelim/generated_cooper.ML \
    2.10    Tools/Qelim/presburger.ML \
     3.1 --- a/src/HOL/Presburger.thy	Mon May 10 12:25:49 2010 +0200
     3.2 +++ b/src/HOL/Presburger.thy	Mon May 10 13:58:18 2010 +0200
     3.3 @@ -8,14 +8,11 @@
     3.4  imports Groebner_Basis SetInterval
     3.5  uses
     3.6    "Tools/Qelim/qelim.ML"
     3.7 -  "Tools/Qelim/cooper_data.ML"
     3.8 -  "Tools/Qelim/generated_cooper.ML"
     3.9 +  "Tools/Qelim/cooper_procedure.ML"
    3.10    ("Tools/Qelim/cooper.ML")
    3.11    ("Tools/Qelim/presburger.ML")
    3.12  begin
    3.13  
    3.14 -setup CooperData.setup
    3.15 -
    3.16  subsection{* The @{text "-\<infinity>"} and @{text "+\<infinity>"} Properties *}
    3.17  
    3.18  
    3.19 @@ -405,28 +402,9 @@
    3.20    "(((number_of v)::int) = (number_of w)) = iszero ((number_of (v + (uminus w)))::int)"
    3.21    by (rule eq_number_of_eq)
    3.22  
    3.23 -declare dvd_eq_mod_eq_0[symmetric, presburger]
    3.24 -declare mod_1[presburger] 
    3.25 -declare mod_0[presburger]
    3.26 -declare mod_by_1[presburger]
    3.27 -declare zmod_zero[presburger]
    3.28 -declare zmod_self[presburger]
    3.29 -declare mod_self[presburger]
    3.30 -declare mod_by_0[presburger]
    3.31 -declare mod_div_trivial[presburger]
    3.32 -declare div_mod_equality2[presburger]
    3.33 -declare div_mod_equality[presburger]
    3.34 -declare mod_div_equality2[presburger]
    3.35 -declare mod_div_equality[presburger]
    3.36 -declare mod_mult_self1[presburger]
    3.37 -declare mod_mult_self2[presburger]
    3.38 -declare zdiv_zmod_equality2[presburger]
    3.39 -declare zdiv_zmod_equality[presburger]
    3.40 -declare mod2_Suc_Suc[presburger]
    3.41 -lemma [presburger]: "(a::int) div 0 = 0" and [presburger]: "a mod 0 = a"
    3.42 -by simp_all
    3.43 +use "Tools/Qelim/cooper.ML"
    3.44  
    3.45 -use "Tools/Qelim/cooper.ML"
    3.46 +setup CooperData.setup
    3.47  oracle linzqe_oracle = Coopereif.cooper_oracle
    3.48  
    3.49  use "Tools/Qelim/presburger.ML"
    3.50 @@ -451,6 +429,27 @@
    3.51  end
    3.52  *} "Cooper's algorithm for Presburger arithmetic"
    3.53  
    3.54 +declare dvd_eq_mod_eq_0[symmetric, presburger]
    3.55 +declare mod_1[presburger] 
    3.56 +declare mod_0[presburger]
    3.57 +declare mod_by_1[presburger]
    3.58 +declare zmod_zero[presburger]
    3.59 +declare zmod_self[presburger]
    3.60 +declare mod_self[presburger]
    3.61 +declare mod_by_0[presburger]
    3.62 +declare mod_div_trivial[presburger]
    3.63 +declare div_mod_equality2[presburger]
    3.64 +declare div_mod_equality[presburger]
    3.65 +declare mod_div_equality2[presburger]
    3.66 +declare mod_div_equality[presburger]
    3.67 +declare mod_mult_self1[presburger]
    3.68 +declare mod_mult_self2[presburger]
    3.69 +declare zdiv_zmod_equality2[presburger]
    3.70 +declare zdiv_zmod_equality[presburger]
    3.71 +declare mod2_Suc_Suc[presburger]
    3.72 +lemma [presburger]: "(a::int) div 0 = 0" and [presburger]: "a mod 0 = a"
    3.73 +by simp_all
    3.74 +
    3.75  lemma [presburger, algebra]: "m mod 2 = (1::nat) \<longleftrightarrow> \<not> 2 dvd m " by presburger
    3.76  lemma [presburger, algebra]: "m mod 2 = Suc 0 \<longleftrightarrow> \<not> 2 dvd m " by presburger
    3.77  lemma [presburger, algebra]: "m mod (Suc (Suc 0)) = (1::nat) \<longleftrightarrow> \<not> 2 dvd m " by presburger
     4.1 --- a/src/HOL/Tools/Qelim/cooper.ML	Mon May 10 12:25:49 2010 +0200
     4.2 +++ b/src/HOL/Tools/Qelim/cooper.ML	Mon May 10 13:58:18 2010 +0200
     4.3 @@ -2,12 +2,101 @@
     4.4      Author:     Amine Chaieb, TU Muenchen
     4.5  *)
     4.6  
     4.7 +signature COOPER_DATA =
     4.8 +sig
     4.9 +  type entry
    4.10 +  val get: Proof.context -> entry
    4.11 +  val del: term list -> attribute
    4.12 +  val add: term list -> attribute 
    4.13 +  val setup: theory -> theory
    4.14 +end;
    4.15 +
    4.16  signature COOPER =
    4.17  sig
    4.18 -  val cooper_conv : Proof.context -> conv
    4.19 +  val cooper_conv: Proof.context -> conv
    4.20    exception COOPER of string * exn
    4.21  end;
    4.22  
    4.23 +signature COOPER_REIFY =
    4.24 +sig
    4.25 +  val cooper_oracle: cterm -> cterm
    4.26 +end;
    4.27 +
    4.28 +structure CooperData : COOPER_DATA =
    4.29 +struct
    4.30 +
    4.31 +type entry = simpset * (term list);
    4.32 +
    4.33 +val allowed_consts = 
    4.34 +  [@{term "op + :: int => _"}, @{term "op + :: nat => _"},
    4.35 +   @{term "op - :: int => _"}, @{term "op - :: nat => _"},
    4.36 +   @{term "op * :: int => _"}, @{term "op * :: nat => _"},
    4.37 +   @{term "op div :: int => _"}, @{term "op div :: nat => _"},
    4.38 +   @{term "op mod :: int => _"}, @{term "op mod :: nat => _"},
    4.39 +   @{term "Int.Bit0"}, @{term "Int.Bit1"},
    4.40 +   @{term "op &"}, @{term "op |"}, @{term "op -->"}, 
    4.41 +   @{term "op = :: int => _"}, @{term "op = :: nat => _"}, @{term "op = :: bool => _"},
    4.42 +   @{term "op < :: int => _"}, @{term "op < :: nat => _"},
    4.43 +   @{term "op <= :: int => _"}, @{term "op <= :: nat => _"},
    4.44 +   @{term "op dvd :: int => _"}, @{term "op dvd :: nat => _"},
    4.45 +   @{term "abs :: int => _"},
    4.46 +   @{term "max :: int => _"}, @{term "max :: nat => _"},
    4.47 +   @{term "min :: int => _"}, @{term "min :: nat => _"},
    4.48 +   @{term "uminus :: int => _"}, (*@ {term "uminus :: nat => _"},*)
    4.49 +   @{term "Not"}, @{term "Suc"},
    4.50 +   @{term "Ex :: (int => _) => _"}, @{term "Ex :: (nat => _) => _"},
    4.51 +   @{term "All :: (int => _) => _"}, @{term "All :: (nat => _) => _"},
    4.52 +   @{term "nat"}, @{term "int"},
    4.53 +   @{term "Int.Bit0"}, @{term "Int.Bit1"},
    4.54 +   @{term "Int.Pls"}, @{term "Int.Min"},
    4.55 +   @{term "Int.number_of :: int => int"}, @{term "Int.number_of :: int => nat"},
    4.56 +   @{term "0::int"}, @{term "1::int"}, @{term "0::nat"}, @{term "1::nat"},
    4.57 +   @{term "True"}, @{term "False"}];
    4.58 +
    4.59 +structure Data = Generic_Data
    4.60 +(
    4.61 +  type T = simpset * term list;
    4.62 +  val empty = (HOL_ss, allowed_consts);
    4.63 +  val extend  = I;
    4.64 +  fun merge ((ss1, ts1), (ss2, ts2)) =
    4.65 +    (merge_ss (ss1, ss2), Library.merge (op aconv) (ts1, ts2));
    4.66 +);
    4.67 +
    4.68 +val get = Data.get o Context.Proof;
    4.69 +
    4.70 +fun add ts = Thm.declaration_attribute (fn th => fn context => 
    4.71 +  context |> Data.map (fn (ss,ts') => 
    4.72 +     (ss addsimps [th], merge (op aconv) (ts',ts) ))) 
    4.73 +
    4.74 +fun del ts = Thm.declaration_attribute (fn th => fn context => 
    4.75 +  context |> Data.map (fn (ss,ts') => 
    4.76 +     (ss delsimps [th], subtract (op aconv) ts' ts ))) 
    4.77 +
    4.78 +
    4.79 +(* theory setup *)
    4.80 +
    4.81 +local
    4.82 +
    4.83 +fun keyword k = Scan.lift (Args.$$$ k -- Args.colon) >> K ();
    4.84 +
    4.85 +val constsN = "consts";
    4.86 +val any_keyword = keyword constsN
    4.87 +val thms = Scan.repeat (Scan.unless any_keyword Attrib.multi_thm) >> flat;
    4.88 +val terms = thms >> map (term_of o Drule.dest_term);
    4.89 +
    4.90 +fun optional scan = Scan.optional scan [];
    4.91 +
    4.92 +in
    4.93 +
    4.94 +val setup =
    4.95 +  Attrib.setup @{binding presburger}
    4.96 +    ((Scan.lift (Args.$$$ "del") |-- optional (keyword constsN |-- terms)) >> del ||
    4.97 +      optional (keyword constsN |-- terms) >> add) "Cooper data";
    4.98 +
    4.99 +end;
   4.100 +
   4.101 +end;
   4.102 +
   4.103  structure Cooper: COOPER =
   4.104  struct
   4.105  
   4.106 @@ -519,58 +608,54 @@
   4.107  end;
   4.108  end;
   4.109  
   4.110 -
   4.111 -
   4.112 -structure Coopereif =
   4.113 +structure Coopereif : COOPER_REIFY =
   4.114  struct
   4.115  
   4.116 -fun member eq = Library.member eq;
   4.117 -
   4.118  fun cooper s = raise Cooper.COOPER ("Cooper oracle failed", ERROR s);
   4.119  fun i_of_term vs t = case t
   4.120   of Free (xn, xT) => (case AList.lookup (op aconv) vs t
   4.121       of NONE   => cooper "Variable not found in the list!"
   4.122 -      | SOME n => Generated_Cooper.Bound n)
   4.123 -  | @{term "0::int"} => Generated_Cooper.C 0
   4.124 -  | @{term "1::int"} => Generated_Cooper.C 1
   4.125 -  | Term.Bound i => Generated_Cooper.Bound i
   4.126 -  | Const(@{const_name Groups.uminus},_)$t' => Generated_Cooper.Neg (i_of_term vs t')
   4.127 -  | Const(@{const_name Groups.plus},_)$t1$t2 => Generated_Cooper.Add (i_of_term vs t1,i_of_term vs t2)
   4.128 -  | Const(@{const_name Groups.minus},_)$t1$t2 => Generated_Cooper.Sub (i_of_term vs t1,i_of_term vs t2)
   4.129 +      | SOME n => Cooper_Procedure.Bound n)
   4.130 +  | @{term "0::int"} => Cooper_Procedure.C 0
   4.131 +  | @{term "1::int"} => Cooper_Procedure.C 1
   4.132 +  | Term.Bound i => Cooper_Procedure.Bound i
   4.133 +  | Const(@{const_name Groups.uminus},_)$t' => Cooper_Procedure.Neg (i_of_term vs t')
   4.134 +  | Const(@{const_name Groups.plus},_)$t1$t2 => Cooper_Procedure.Add (i_of_term vs t1,i_of_term vs t2)
   4.135 +  | Const(@{const_name Groups.minus},_)$t1$t2 => Cooper_Procedure.Sub (i_of_term vs t1,i_of_term vs t2)
   4.136    | Const(@{const_name Groups.times},_)$t1$t2 =>
   4.137 -     (Generated_Cooper.Mul (HOLogic.dest_number t1 |> snd, i_of_term vs t2)
   4.138 +     (Cooper_Procedure.Mul (HOLogic.dest_number t1 |> snd, i_of_term vs t2)
   4.139      handle TERM _ =>
   4.140 -       (Generated_Cooper.Mul (HOLogic.dest_number t2 |> snd, i_of_term vs t1)
   4.141 +       (Cooper_Procedure.Mul (HOLogic.dest_number t2 |> snd, i_of_term vs t1)
   4.142          handle TERM _ => cooper "Reification: Unsupported kind of multiplication"))
   4.143 -  | _ => (Generated_Cooper.C (HOLogic.dest_number t |> snd)
   4.144 +  | _ => (Cooper_Procedure.C (HOLogic.dest_number t |> snd)
   4.145             handle TERM _ => cooper "Reification: unknown term");
   4.146  
   4.147  fun qf_of_term ps vs t =  case t
   4.148 - of Const("True",_) => Generated_Cooper.T
   4.149 -  | Const("False",_) => Generated_Cooper.F
   4.150 -  | Const(@{const_name Orderings.less},_)$t1$t2 => Generated_Cooper.Lt (Generated_Cooper.Sub (i_of_term vs t1,i_of_term vs t2))
   4.151 -  | Const(@{const_name Orderings.less_eq},_)$t1$t2 => Generated_Cooper.Le (Generated_Cooper.Sub(i_of_term vs t1,i_of_term vs t2))
   4.152 + of Const("True",_) => Cooper_Procedure.T
   4.153 +  | Const("False",_) => Cooper_Procedure.F
   4.154 +  | Const(@{const_name Orderings.less},_)$t1$t2 => Cooper_Procedure.Lt (Cooper_Procedure.Sub (i_of_term vs t1,i_of_term vs t2))
   4.155 +  | Const(@{const_name Orderings.less_eq},_)$t1$t2 => Cooper_Procedure.Le (Cooper_Procedure.Sub(i_of_term vs t1,i_of_term vs t2))
   4.156    | Const(@{const_name Rings.dvd},_)$t1$t2 =>
   4.157 -      (Generated_Cooper.Dvd(HOLogic.dest_number t1 |> snd, i_of_term vs t2) handle _ => cooper "Reification: unsupported dvd")  (* FIXME avoid handle _ *)
   4.158 -  | @{term "op = :: int => _"}$t1$t2 => Generated_Cooper.Eq (Generated_Cooper.Sub (i_of_term vs t1,i_of_term vs t2))
   4.159 -  | @{term "op = :: bool => _ "}$t1$t2 => Generated_Cooper.Iff(qf_of_term ps vs t1,qf_of_term ps vs t2)
   4.160 -  | Const("op &",_)$t1$t2 => Generated_Cooper.And(qf_of_term ps vs t1,qf_of_term ps vs t2)
   4.161 -  | Const("op |",_)$t1$t2 => Generated_Cooper.Or(qf_of_term ps vs t1,qf_of_term ps vs t2)
   4.162 -  | Const("op -->",_)$t1$t2 => Generated_Cooper.Imp(qf_of_term ps vs t1,qf_of_term ps vs t2)
   4.163 -  | Const (@{const_name Not},_)$t' => Generated_Cooper.Not(qf_of_term ps vs t')
   4.164 +      (Cooper_Procedure.Dvd(HOLogic.dest_number t1 |> snd, i_of_term vs t2) handle _ => cooper "Reification: unsupported dvd")  (* FIXME avoid handle _ *)
   4.165 +  | @{term "op = :: int => _"}$t1$t2 => Cooper_Procedure.Eq (Cooper_Procedure.Sub (i_of_term vs t1,i_of_term vs t2))
   4.166 +  | @{term "op = :: bool => _ "}$t1$t2 => Cooper_Procedure.Iff(qf_of_term ps vs t1,qf_of_term ps vs t2)
   4.167 +  | Const("op &",_)$t1$t2 => Cooper_Procedure.And(qf_of_term ps vs t1,qf_of_term ps vs t2)
   4.168 +  | Const("op |",_)$t1$t2 => Cooper_Procedure.Or(qf_of_term ps vs t1,qf_of_term ps vs t2)
   4.169 +  | Const("op -->",_)$t1$t2 => Cooper_Procedure.Imp(qf_of_term ps vs t1,qf_of_term ps vs t2)
   4.170 +  | Const (@{const_name Not},_)$t' => Cooper_Procedure.Not(qf_of_term ps vs t')
   4.171    | Const("Ex",_)$Abs(xn,xT,p) =>
   4.172       let val (xn',p') = variant_abs (xn,xT,p)
   4.173           val vs' = (Free (xn',xT), 0) :: (map (fn(v,n) => (v,1+ n)) vs)
   4.174 -     in Generated_Cooper.E (qf_of_term ps vs' p')
   4.175 +     in Cooper_Procedure.E (qf_of_term ps vs' p')
   4.176       end
   4.177    | Const("All",_)$Abs(xn,xT,p) =>
   4.178       let val (xn',p') = variant_abs (xn,xT,p)
   4.179           val vs' = (Free (xn',xT), 0) :: (map (fn(v,n) => (v,1+ n)) vs)
   4.180 -     in Generated_Cooper.A (qf_of_term ps vs' p')
   4.181 +     in Cooper_Procedure.A (qf_of_term ps vs' p')
   4.182       end
   4.183    | _ =>(case AList.lookup (op aconv) ps t of
   4.184             NONE => cooper "Reification: unknown term!"
   4.185 -         | SOME n => Generated_Cooper.Closed n);
   4.186 +         | SOME n => Cooper_Procedure.Closed n);
   4.187  
   4.188  local
   4.189   val ops = [@{term "op &"}, @{term "op |"}, @{term "op -->"}, @{term "op = :: bool => _"},
   4.190 @@ -596,35 +681,35 @@
   4.191            else myassoc2 xs v;
   4.192  
   4.193  fun term_of_i vs t = case t
   4.194 - of Generated_Cooper.C i => HOLogic.mk_number HOLogic.intT i
   4.195 -  | Generated_Cooper.Bound n => the (myassoc2 vs n)
   4.196 -  | Generated_Cooper.Neg t' => @{term "uminus :: int => _"} $ term_of_i vs t'
   4.197 -  | Generated_Cooper.Add (t1, t2) => @{term "op + :: int => _"} $ term_of_i vs t1 $ term_of_i vs t2
   4.198 -  | Generated_Cooper.Sub (t1, t2) => @{term "op - :: int => _"} $ term_of_i vs t1 $ term_of_i vs t2
   4.199 -  | Generated_Cooper.Mul (i, t2) => @{term "op * :: int => _"} $
   4.200 + of Cooper_Procedure.C i => HOLogic.mk_number HOLogic.intT i
   4.201 +  | Cooper_Procedure.Bound n => the (myassoc2 vs n)
   4.202 +  | Cooper_Procedure.Neg t' => @{term "uminus :: int => _"} $ term_of_i vs t'
   4.203 +  | Cooper_Procedure.Add (t1, t2) => @{term "op + :: int => _"} $ term_of_i vs t1 $ term_of_i vs t2
   4.204 +  | Cooper_Procedure.Sub (t1, t2) => @{term "op - :: int => _"} $ term_of_i vs t1 $ term_of_i vs t2
   4.205 +  | Cooper_Procedure.Mul (i, t2) => @{term "op * :: int => _"} $
   4.206        HOLogic.mk_number HOLogic.intT i $ term_of_i vs t2
   4.207 -  | Generated_Cooper.Cn (n, i, t') => term_of_i vs (Generated_Cooper.Add (Generated_Cooper.Mul (i, Generated_Cooper.Bound n), t'));
   4.208 +  | Cooper_Procedure.Cn (n, i, t') => term_of_i vs (Cooper_Procedure.Add (Cooper_Procedure.Mul (i, Cooper_Procedure.Bound n), t'));
   4.209  
   4.210  fun term_of_qf ps vs t =
   4.211   case t of
   4.212 -   Generated_Cooper.T => HOLogic.true_const
   4.213 - | Generated_Cooper.F => HOLogic.false_const
   4.214 - | Generated_Cooper.Lt t' => @{term "op < :: int => _ "}$ term_of_i vs t'$ @{term "0::int"}
   4.215 - | Generated_Cooper.Le t' => @{term "op <= :: int => _ "}$ term_of_i vs t' $ @{term "0::int"}
   4.216 - | Generated_Cooper.Gt t' => @{term "op < :: int => _ "}$ @{term "0::int"}$ term_of_i vs t'
   4.217 - | Generated_Cooper.Ge t' => @{term "op <= :: int => _ "}$ @{term "0::int"}$ term_of_i vs t'
   4.218 - | Generated_Cooper.Eq t' => @{term "op = :: int => _ "}$ term_of_i vs t'$ @{term "0::int"}
   4.219 - | Generated_Cooper.NEq t' => term_of_qf ps vs (Generated_Cooper.Not (Generated_Cooper.Eq t'))
   4.220 - | Generated_Cooper.Dvd(i,t') => @{term "op dvd :: int => _ "} $
   4.221 +   Cooper_Procedure.T => HOLogic.true_const
   4.222 + | Cooper_Procedure.F => HOLogic.false_const
   4.223 + | Cooper_Procedure.Lt t' => @{term "op < :: int => _ "}$ term_of_i vs t'$ @{term "0::int"}
   4.224 + | Cooper_Procedure.Le t' => @{term "op <= :: int => _ "}$ term_of_i vs t' $ @{term "0::int"}
   4.225 + | Cooper_Procedure.Gt t' => @{term "op < :: int => _ "}$ @{term "0::int"}$ term_of_i vs t'
   4.226 + | Cooper_Procedure.Ge t' => @{term "op <= :: int => _ "}$ @{term "0::int"}$ term_of_i vs t'
   4.227 + | Cooper_Procedure.Eq t' => @{term "op = :: int => _ "}$ term_of_i vs t'$ @{term "0::int"}
   4.228 + | Cooper_Procedure.NEq t' => term_of_qf ps vs (Cooper_Procedure.Not (Cooper_Procedure.Eq t'))
   4.229 + | Cooper_Procedure.Dvd(i,t') => @{term "op dvd :: int => _ "} $
   4.230      HOLogic.mk_number HOLogic.intT i $ term_of_i vs t'
   4.231 - | Generated_Cooper.NDvd(i,t')=> term_of_qf ps vs (Generated_Cooper.Not(Generated_Cooper.Dvd(i,t')))
   4.232 - | Generated_Cooper.Not t' => HOLogic.Not$(term_of_qf ps vs t')
   4.233 - | Generated_Cooper.And(t1,t2) => HOLogic.conj$(term_of_qf ps vs t1)$(term_of_qf ps vs t2)
   4.234 - | Generated_Cooper.Or(t1,t2) => HOLogic.disj$(term_of_qf ps vs t1)$(term_of_qf ps vs t2)
   4.235 - | Generated_Cooper.Imp(t1,t2) => HOLogic.imp$(term_of_qf ps vs t1)$(term_of_qf ps vs t2)
   4.236 - | Generated_Cooper.Iff(t1,t2) => @{term "op = :: bool => _"} $ term_of_qf ps vs t1 $ term_of_qf ps vs t2
   4.237 - | Generated_Cooper.Closed n => the (myassoc2 ps n)
   4.238 - | Generated_Cooper.NClosed n => term_of_qf ps vs (Generated_Cooper.Not (Generated_Cooper.Closed n))
   4.239 + | Cooper_Procedure.NDvd(i,t')=> term_of_qf ps vs (Cooper_Procedure.Not(Cooper_Procedure.Dvd(i,t')))
   4.240 + | Cooper_Procedure.Not t' => HOLogic.Not$(term_of_qf ps vs t')
   4.241 + | Cooper_Procedure.And(t1,t2) => HOLogic.conj$(term_of_qf ps vs t1)$(term_of_qf ps vs t2)
   4.242 + | Cooper_Procedure.Or(t1,t2) => HOLogic.disj$(term_of_qf ps vs t1)$(term_of_qf ps vs t2)
   4.243 + | Cooper_Procedure.Imp(t1,t2) => HOLogic.imp$(term_of_qf ps vs t1)$(term_of_qf ps vs t2)
   4.244 + | Cooper_Procedure.Iff(t1,t2) => @{term "op = :: bool => _"} $ term_of_qf ps vs t1 $ term_of_qf ps vs t2
   4.245 + | Cooper_Procedure.Closed n => the (myassoc2 ps n)
   4.246 + | Cooper_Procedure.NClosed n => term_of_qf ps vs (Cooper_Procedure.Not (Cooper_Procedure.Closed n))
   4.247   | _ => cooper "If this is raised, Isabelle/HOL or code generator is inconsistent!";
   4.248  
   4.249  fun cooper_oracle ct =
   4.250 @@ -634,7 +719,7 @@
   4.251      val (vs, ps) = pairself (map_index swap) (OldTerm.term_frees t, term_bools [] t);
   4.252    in
   4.253      Thm.cterm_of thy (Logic.mk_equals (HOLogic.mk_Trueprop t,
   4.254 -      HOLogic.mk_Trueprop (term_of_qf ps vs (Generated_Cooper.pa (qf_of_term ps vs t)))))
   4.255 +      HOLogic.mk_Trueprop (term_of_qf ps vs (Cooper_Procedure.pa (qf_of_term ps vs t)))))
   4.256    end;
   4.257  
   4.258  end;
     5.1 --- a/src/HOL/Tools/Qelim/cooper_data.ML	Mon May 10 12:25:49 2010 +0200
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,87 +0,0 @@
     5.4 -(*  Title:      HOL/Tools/Qelim/cooper_data.ML
     5.5 -    Author:     Amine Chaieb, TU Muenchen
     5.6 -*)
     5.7 -
     5.8 -signature COOPER_DATA =
     5.9 -sig
    5.10 -  type entry
    5.11 -  val get: Proof.context -> entry
    5.12 -  val del: term list -> attribute
    5.13 -  val add: term list -> attribute 
    5.14 -  val setup: theory -> theory
    5.15 -end;
    5.16 -
    5.17 -structure CooperData : COOPER_DATA =
    5.18 -struct
    5.19 -
    5.20 -type entry = simpset * (term list);
    5.21 -
    5.22 -val allowed_consts = 
    5.23 -  [@{term "op + :: int => _"}, @{term "op + :: nat => _"},
    5.24 -   @{term "op - :: int => _"}, @{term "op - :: nat => _"},
    5.25 -   @{term "op * :: int => _"}, @{term "op * :: nat => _"},
    5.26 -   @{term "op div :: int => _"}, @{term "op div :: nat => _"},
    5.27 -   @{term "op mod :: int => _"}, @{term "op mod :: nat => _"},
    5.28 -   @{term "Int.Bit0"}, @{term "Int.Bit1"},
    5.29 -   @{term "op &"}, @{term "op |"}, @{term "op -->"}, 
    5.30 -   @{term "op = :: int => _"}, @{term "op = :: nat => _"}, @{term "op = :: bool => _"},
    5.31 -   @{term "op < :: int => _"}, @{term "op < :: nat => _"},
    5.32 -   @{term "op <= :: int => _"}, @{term "op <= :: nat => _"},
    5.33 -   @{term "op dvd :: int => _"}, @{term "op dvd :: nat => _"},
    5.34 -   @{term "abs :: int => _"},
    5.35 -   @{term "max :: int => _"}, @{term "max :: nat => _"},
    5.36 -   @{term "min :: int => _"}, @{term "min :: nat => _"},
    5.37 -   @{term "uminus :: int => _"}, (*@ {term "uminus :: nat => _"},*)
    5.38 -   @{term "Not"}, @{term "Suc"},
    5.39 -   @{term "Ex :: (int => _) => _"}, @{term "Ex :: (nat => _) => _"},
    5.40 -   @{term "All :: (int => _) => _"}, @{term "All :: (nat => _) => _"},
    5.41 -   @{term "nat"}, @{term "int"},
    5.42 -   @{term "Int.Bit0"}, @{term "Int.Bit1"},
    5.43 -   @{term "Int.Pls"}, @{term "Int.Min"},
    5.44 -   @{term "Int.number_of :: int => int"}, @{term "Int.number_of :: int => nat"},
    5.45 -   @{term "0::int"}, @{term "1::int"}, @{term "0::nat"}, @{term "1::nat"},
    5.46 -   @{term "True"}, @{term "False"}];
    5.47 -
    5.48 -structure Data = Generic_Data
    5.49 -(
    5.50 -  type T = simpset * term list;
    5.51 -  val empty = (HOL_ss, allowed_consts);
    5.52 -  val extend  = I;
    5.53 -  fun merge ((ss1, ts1), (ss2, ts2)) =
    5.54 -    (merge_ss (ss1, ss2), Library.merge (op aconv) (ts1, ts2));
    5.55 -);
    5.56 -
    5.57 -val get = Data.get o Context.Proof;
    5.58 -
    5.59 -fun add ts = Thm.declaration_attribute (fn th => fn context => 
    5.60 -  context |> Data.map (fn (ss,ts') => 
    5.61 -     (ss addsimps [th], merge (op aconv) (ts',ts) ))) 
    5.62 -
    5.63 -fun del ts = Thm.declaration_attribute (fn th => fn context => 
    5.64 -  context |> Data.map (fn (ss,ts') => 
    5.65 -     (ss delsimps [th], subtract (op aconv) ts' ts ))) 
    5.66 -
    5.67 -
    5.68 -(* theory setup *)
    5.69 -
    5.70 -local
    5.71 -
    5.72 -fun keyword k = Scan.lift (Args.$$$ k -- Args.colon) >> K ();
    5.73 -
    5.74 -val constsN = "consts";
    5.75 -val any_keyword = keyword constsN
    5.76 -val thms = Scan.repeat (Scan.unless any_keyword Attrib.multi_thm) >> flat;
    5.77 -val terms = thms >> map (term_of o Drule.dest_term);
    5.78 -
    5.79 -fun optional scan = Scan.optional scan [];
    5.80 -
    5.81 -in
    5.82 -
    5.83 -val setup =
    5.84 -  Attrib.setup @{binding presburger}
    5.85 -    ((Scan.lift (Args.$$$ "del") |-- optional (keyword constsN |-- terms)) >> del ||
    5.86 -      optional (keyword constsN |-- terms) >> add) "Cooper data";
    5.87 -
    5.88 -end;
    5.89 -
    5.90 -end;
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/src/HOL/Tools/Qelim/cooper_procedure.ML	Mon May 10 13:58:18 2010 +0200
     6.3 @@ -0,0 +1,2274 @@
     6.4 +(* Generated from Cooper.thy; DO NOT EDIT! *)
     6.5 +
     6.6 +structure Cooper_Procedure : sig
     6.7 +  type 'a eq
     6.8 +  val eq : 'a eq -> 'a -> 'a -> bool
     6.9 +  val eqa : 'a eq -> 'a -> 'a -> bool
    6.10 +  val leta : 'a -> ('a -> 'b) -> 'b
    6.11 +  val suc : IntInf.int -> IntInf.int
    6.12 +  datatype num = C of IntInf.int | Bound of IntInf.int |
    6.13 +    Cn of IntInf.int * IntInf.int * num | Neg of num | Add of num * num |
    6.14 +    Sub of num * num | Mul of IntInf.int * num
    6.15 +  datatype fm = T | F | Lt of num | Le of num | Gt of num | Ge of num |
    6.16 +    Eq of num | NEq of num | Dvd of IntInf.int * num | NDvd of IntInf.int * num
    6.17 +    | Not of fm | And of fm * fm | Or of fm * fm | Imp of fm * fm |
    6.18 +    Iff of fm * fm | E of fm | A of fm | Closed of IntInf.int |
    6.19 +    NClosed of IntInf.int
    6.20 +  val map : ('a -> 'b) -> 'a list -> 'b list
    6.21 +  val append : 'a list -> 'a list -> 'a list
    6.22 +  val disjuncts : fm -> fm list
    6.23 +  val fm_case :
    6.24 +    'a -> 'a -> (num -> 'a) ->
    6.25 +                  (num -> 'a) ->
    6.26 +                    (num -> 'a) ->
    6.27 +                      (num -> 'a) ->
    6.28 +                        (num -> 'a) ->
    6.29 +                          (num -> 'a) ->
    6.30 +                            (IntInf.int -> num -> 'a) ->
    6.31 +                              (IntInf.int -> num -> 'a) ->
    6.32 +                                (fm -> 'a) ->
    6.33 +                                  (fm -> fm -> 'a) ->
    6.34 +                                    (fm -> fm -> 'a) ->
    6.35 +                                      (fm -> fm -> 'a) ->
    6.36 +(fm -> fm -> 'a) ->
    6.37 +  (fm -> 'a) ->
    6.38 +    (fm -> 'a) -> (IntInf.int -> 'a) -> (IntInf.int -> 'a) -> fm -> 'a
    6.39 +  val eq_num : num -> num -> bool
    6.40 +  val eq_fm : fm -> fm -> bool
    6.41 +  val djf : ('a -> fm) -> 'a -> fm -> fm
    6.42 +  val foldr : ('a -> 'b -> 'b) -> 'a list -> 'b -> 'b
    6.43 +  val evaldjf : ('a -> fm) -> 'a list -> fm
    6.44 +  val dj : (fm -> fm) -> fm -> fm
    6.45 +  val disj : fm -> fm -> fm
    6.46 +  val minus_nat : IntInf.int -> IntInf.int -> IntInf.int
    6.47 +  val decrnum : num -> num
    6.48 +  val decr : fm -> fm
    6.49 +  val concat_map : ('a -> 'b list) -> 'a list -> 'b list
    6.50 +  val numsubst0 : num -> num -> num
    6.51 +  val subst0 : num -> fm -> fm
    6.52 +  val minusinf : fm -> fm
    6.53 +  val eq_int : IntInf.int eq
    6.54 +  val zero_int : IntInf.int
    6.55 +  type 'a zero
    6.56 +  val zero : 'a zero -> 'a
    6.57 +  val zero_inta : IntInf.int zero
    6.58 +  type 'a times
    6.59 +  val times : 'a times -> 'a -> 'a -> 'a
    6.60 +  type 'a no_zero_divisors
    6.61 +  val times_no_zero_divisors : 'a no_zero_divisors -> 'a times
    6.62 +  val zero_no_zero_divisors : 'a no_zero_divisors -> 'a zero
    6.63 +  val times_int : IntInf.int times
    6.64 +  val no_zero_divisors_int : IntInf.int no_zero_divisors
    6.65 +  type 'a one
    6.66 +  val one : 'a one -> 'a
    6.67 +  type 'a zero_neq_one
    6.68 +  val one_zero_neq_one : 'a zero_neq_one -> 'a one
    6.69 +  val zero_zero_neq_one : 'a zero_neq_one -> 'a zero
    6.70 +  type 'a semigroup_mult
    6.71 +  val times_semigroup_mult : 'a semigroup_mult -> 'a times
    6.72 +  type 'a plus
    6.73 +  val plus : 'a plus -> 'a -> 'a -> 'a
    6.74 +  type 'a semigroup_add
    6.75 +  val plus_semigroup_add : 'a semigroup_add -> 'a plus
    6.76 +  type 'a ab_semigroup_add
    6.77 +  val semigroup_add_ab_semigroup_add : 'a ab_semigroup_add -> 'a semigroup_add
    6.78 +  type 'a semiring
    6.79 +  val ab_semigroup_add_semiring : 'a semiring -> 'a ab_semigroup_add
    6.80 +  val semigroup_mult_semiring : 'a semiring -> 'a semigroup_mult
    6.81 +  type 'a mult_zero
    6.82 +  val times_mult_zero : 'a mult_zero -> 'a times
    6.83 +  val zero_mult_zero : 'a mult_zero -> 'a zero
    6.84 +  type 'a monoid_add
    6.85 +  val semigroup_add_monoid_add : 'a monoid_add -> 'a semigroup_add
    6.86 +  val zero_monoid_add : 'a monoid_add -> 'a zero
    6.87 +  type 'a comm_monoid_add
    6.88 +  val ab_semigroup_add_comm_monoid_add :
    6.89 +    'a comm_monoid_add -> 'a ab_semigroup_add
    6.90 +  val monoid_add_comm_monoid_add : 'a comm_monoid_add -> 'a monoid_add
    6.91 +  type 'a semiring_0
    6.92 +  val comm_monoid_add_semiring_0 : 'a semiring_0 -> 'a comm_monoid_add
    6.93 +  val mult_zero_semiring_0 : 'a semiring_0 -> 'a mult_zero
    6.94 +  val semiring_semiring_0 : 'a semiring_0 -> 'a semiring
    6.95 +  type 'a power
    6.96 +  val one_power : 'a power -> 'a one
    6.97 +  val times_power : 'a power -> 'a times
    6.98 +  type 'a monoid_mult
    6.99 +  val semigroup_mult_monoid_mult : 'a monoid_mult -> 'a semigroup_mult
   6.100 +  val power_monoid_mult : 'a monoid_mult -> 'a power
   6.101 +  type 'a semiring_1
   6.102 +  val monoid_mult_semiring_1 : 'a semiring_1 -> 'a monoid_mult
   6.103 +  val semiring_0_semiring_1 : 'a semiring_1 -> 'a semiring_0
   6.104 +  val zero_neq_one_semiring_1 : 'a semiring_1 -> 'a zero_neq_one
   6.105 +  type 'a cancel_semigroup_add
   6.106 +  val semigroup_add_cancel_semigroup_add :
   6.107 +    'a cancel_semigroup_add -> 'a semigroup_add
   6.108 +  type 'a cancel_ab_semigroup_add
   6.109 +  val ab_semigroup_add_cancel_ab_semigroup_add :
   6.110 +    'a cancel_ab_semigroup_add -> 'a ab_semigroup_add
   6.111 +  val cancel_semigroup_add_cancel_ab_semigroup_add :
   6.112 +    'a cancel_ab_semigroup_add -> 'a cancel_semigroup_add
   6.113 +  type 'a cancel_comm_monoid_add
   6.114 +  val cancel_ab_semigroup_add_cancel_comm_monoid_add :
   6.115 +    'a cancel_comm_monoid_add -> 'a cancel_ab_semigroup_add
   6.116 +  val comm_monoid_add_cancel_comm_monoid_add :
   6.117 +    'a cancel_comm_monoid_add -> 'a comm_monoid_add
   6.118 +  type 'a semiring_0_cancel
   6.119 +  val cancel_comm_monoid_add_semiring_0_cancel :
   6.120 +    'a semiring_0_cancel -> 'a cancel_comm_monoid_add
   6.121 +  val semiring_0_semiring_0_cancel : 'a semiring_0_cancel -> 'a semiring_0
   6.122 +  type 'a semiring_1_cancel
   6.123 +  val semiring_0_cancel_semiring_1_cancel :
   6.124 +    'a semiring_1_cancel -> 'a semiring_0_cancel
   6.125 +  val semiring_1_semiring_1_cancel : 'a semiring_1_cancel -> 'a semiring_1
   6.126 +  type 'a dvd
   6.127 +  val times_dvd : 'a dvd -> 'a times
   6.128 +  type 'a ab_semigroup_mult
   6.129 +  val semigroup_mult_ab_semigroup_mult :
   6.130 +    'a ab_semigroup_mult -> 'a semigroup_mult
   6.131 +  type 'a comm_semiring
   6.132 +  val ab_semigroup_mult_comm_semiring : 'a comm_semiring -> 'a ab_semigroup_mult
   6.133 +  val semiring_comm_semiring : 'a comm_semiring -> 'a semiring
   6.134 +  type 'a comm_semiring_0
   6.135 +  val comm_semiring_comm_semiring_0 : 'a comm_semiring_0 -> 'a comm_semiring
   6.136 +  val semiring_0_comm_semiring_0 : 'a comm_semiring_0 -> 'a semiring_0
   6.137 +  type 'a comm_monoid_mult
   6.138 +  val ab_semigroup_mult_comm_monoid_mult :
   6.139 +    'a comm_monoid_mult -> 'a ab_semigroup_mult
   6.140 +  val monoid_mult_comm_monoid_mult : 'a comm_monoid_mult -> 'a monoid_mult
   6.141 +  type 'a comm_semiring_1
   6.142 +  val comm_monoid_mult_comm_semiring_1 :
   6.143 +    'a comm_semiring_1 -> 'a comm_monoid_mult
   6.144 +  val comm_semiring_0_comm_semiring_1 : 'a comm_semiring_1 -> 'a comm_semiring_0
   6.145 +  val dvd_comm_semiring_1 : 'a comm_semiring_1 -> 'a dvd
   6.146 +  val semiring_1_comm_semiring_1 : 'a comm_semiring_1 -> 'a semiring_1
   6.147 +  type 'a comm_semiring_0_cancel
   6.148 +  val comm_semiring_0_comm_semiring_0_cancel :
   6.149 +    'a comm_semiring_0_cancel -> 'a comm_semiring_0
   6.150 +  val semiring_0_cancel_comm_semiring_0_cancel :
   6.151 +    'a comm_semiring_0_cancel -> 'a semiring_0_cancel
   6.152 +  type 'a comm_semiring_1_cancel
   6.153 +  val comm_semiring_0_cancel_comm_semiring_1_cancel :
   6.154 +    'a comm_semiring_1_cancel -> 'a comm_semiring_0_cancel
   6.155 +  val comm_semiring_1_comm_semiring_1_cancel :
   6.156 +    'a comm_semiring_1_cancel -> 'a comm_semiring_1
   6.157 +  val semiring_1_cancel_comm_semiring_1_cancel :
   6.158 +    'a comm_semiring_1_cancel -> 'a semiring_1_cancel
   6.159 +  type 'a diva
   6.160 +  val dvd_div : 'a diva -> 'a dvd
   6.161 +  val diva : 'a diva -> 'a -> 'a -> 'a
   6.162 +  val moda : 'a diva -> 'a -> 'a -> 'a
   6.163 +  type 'a semiring_div
   6.164 +  val div_semiring_div : 'a semiring_div -> 'a diva
   6.165 +  val comm_semiring_1_cancel_semiring_div :
   6.166 +    'a semiring_div -> 'a comm_semiring_1_cancel
   6.167 +  val no_zero_divisors_semiring_div : 'a semiring_div -> 'a no_zero_divisors
   6.168 +  val one_int : IntInf.int
   6.169 +  val one_inta : IntInf.int one
   6.170 +  val zero_neq_one_int : IntInf.int zero_neq_one
   6.171 +  val semigroup_mult_int : IntInf.int semigroup_mult
   6.172 +  val plus_int : IntInf.int plus
   6.173 +  val semigroup_add_int : IntInf.int semigroup_add
   6.174 +  val ab_semigroup_add_int : IntInf.int ab_semigroup_add
   6.175 +  val semiring_int : IntInf.int semiring
   6.176 +  val mult_zero_int : IntInf.int mult_zero
   6.177 +  val monoid_add_int : IntInf.int monoid_add
   6.178 +  val comm_monoid_add_int : IntInf.int comm_monoid_add
   6.179 +  val semiring_0_int : IntInf.int semiring_0
   6.180 +  val power_int : IntInf.int power
   6.181 +  val monoid_mult_int : IntInf.int monoid_mult
   6.182 +  val semiring_1_int : IntInf.int semiring_1
   6.183 +  val cancel_semigroup_add_int : IntInf.int cancel_semigroup_add
   6.184 +  val cancel_ab_semigroup_add_int : IntInf.int cancel_ab_semigroup_add
   6.185 +  val cancel_comm_monoid_add_int : IntInf.int cancel_comm_monoid_add
   6.186 +  val semiring_0_cancel_int : IntInf.int semiring_0_cancel
   6.187 +  val semiring_1_cancel_int : IntInf.int semiring_1_cancel
   6.188 +  val dvd_int : IntInf.int dvd
   6.189 +  val ab_semigroup_mult_int : IntInf.int ab_semigroup_mult
   6.190 +  val comm_semiring_int : IntInf.int comm_semiring
   6.191 +  val comm_semiring_0_int : IntInf.int comm_semiring_0
   6.192 +  val comm_monoid_mult_int : IntInf.int comm_monoid_mult
   6.193 +  val comm_semiring_1_int : IntInf.int comm_semiring_1
   6.194 +  val comm_semiring_0_cancel_int : IntInf.int comm_semiring_0_cancel
   6.195 +  val comm_semiring_1_cancel_int : IntInf.int comm_semiring_1_cancel
   6.196 +  val abs_int : IntInf.int -> IntInf.int
   6.197 +  val split : ('a -> 'b -> 'c) -> 'a * 'b -> 'c
   6.198 +  val sgn_int : IntInf.int -> IntInf.int
   6.199 +  val apsnd : ('a -> 'b) -> 'c * 'a -> 'c * 'b
   6.200 +  val divmod_int : IntInf.int -> IntInf.int -> IntInf.int * IntInf.int
   6.201 +  val snd : 'a * 'b -> 'b
   6.202 +  val mod_int : IntInf.int -> IntInf.int -> IntInf.int
   6.203 +  val fst : 'a * 'b -> 'a
   6.204 +  val div_int : IntInf.int -> IntInf.int -> IntInf.int
   6.205 +  val div_inta : IntInf.int diva
   6.206 +  val semiring_div_int : IntInf.int semiring_div
   6.207 +  val dvd : 'a semiring_div * 'a eq -> 'a -> 'a -> bool
   6.208 +  val num_case :
   6.209 +    (IntInf.int -> 'a) ->
   6.210 +      (IntInf.int -> 'a) ->
   6.211 +        (IntInf.int -> IntInf.int -> num -> 'a) ->
   6.212 +          (num -> 'a) ->
   6.213 +            (num -> num -> 'a) ->
   6.214 +              (num -> num -> 'a) -> (IntInf.int -> num -> 'a) -> num -> 'a
   6.215 +  val nummul : IntInf.int -> num -> num
   6.216 +  val numneg : num -> num
   6.217 +  val numadd : num * num -> num
   6.218 +  val numsub : num -> num -> num
   6.219 +  val simpnum : num -> num
   6.220 +  val nota : fm -> fm
   6.221 +  val iffa : fm -> fm -> fm
   6.222 +  val impa : fm -> fm -> fm
   6.223 +  val conj : fm -> fm -> fm
   6.224 +  val simpfm : fm -> fm
   6.225 +  val iupt : IntInf.int -> IntInf.int -> IntInf.int list
   6.226 +  val mirror : fm -> fm
   6.227 +  val size_list : 'a list -> IntInf.int
   6.228 +  val alpha : fm -> num list
   6.229 +  val beta : fm -> num list
   6.230 +  val eq_numa : num eq
   6.231 +  val member : 'a eq -> 'a -> 'a list -> bool
   6.232 +  val remdups : 'a eq -> 'a list -> 'a list
   6.233 +  val gcd_int : IntInf.int -> IntInf.int -> IntInf.int
   6.234 +  val lcm_int : IntInf.int -> IntInf.int -> IntInf.int
   6.235 +  val delta : fm -> IntInf.int
   6.236 +  val a_beta : fm -> IntInf.int -> fm
   6.237 +  val zeta : fm -> IntInf.int
   6.238 +  val zsplit0 : num -> IntInf.int * num
   6.239 +  val zlfm : fm -> fm
   6.240 +  val unita : fm -> fm * (num list * IntInf.int)
   6.241 +  val cooper : fm -> fm
   6.242 +  val prep : fm -> fm
   6.243 +  val qelim : fm -> (fm -> fm) -> fm
   6.244 +  val pa : fm -> fm
   6.245 +end = struct
   6.246 +
   6.247 +type 'a eq = {eq : 'a -> 'a -> bool};
   6.248 +val eq = #eq : 'a eq -> 'a -> 'a -> bool;
   6.249 +
   6.250 +fun eqa A_ a b = eq A_ a b;
   6.251 +
   6.252 +fun leta s f = f s;
   6.253 +
   6.254 +fun suc n = IntInf.+ (n, (1 : IntInf.int));
   6.255 +
   6.256 +datatype num = C of IntInf.int | Bound of IntInf.int |
   6.257 +  Cn of IntInf.int * IntInf.int * num | Neg of num | Add of num * num |
   6.258 +  Sub of num * num | Mul of IntInf.int * num;
   6.259 +
   6.260 +datatype fm = T | F | Lt of num | Le of num | Gt of num | Ge of num | Eq of num
   6.261 +  | NEq of num | Dvd of IntInf.int * num | NDvd of IntInf.int * num | Not of fm
   6.262 +  | And of fm * fm | Or of fm * fm | Imp of fm * fm | Iff of fm * fm | E of fm |
   6.263 +  A of fm | Closed of IntInf.int | NClosed of IntInf.int;
   6.264 +
   6.265 +fun map f [] = []
   6.266 +  | map f (x :: xs) = f x :: map f xs;
   6.267 +
   6.268 +fun append [] ys = ys
   6.269 +  | append (x :: xs) ys = x :: append xs ys;
   6.270 +
   6.271 +fun disjuncts (Or (p, q)) = append (disjuncts p) (disjuncts q)
   6.272 +  | disjuncts F = []
   6.273 +  | disjuncts T = [T]
   6.274 +  | disjuncts (Lt u) = [Lt u]
   6.275 +  | disjuncts (Le v) = [Le v]
   6.276 +  | disjuncts (Gt w) = [Gt w]
   6.277 +  | disjuncts (Ge x) = [Ge x]
   6.278 +  | disjuncts (Eq y) = [Eq y]
   6.279 +  | disjuncts (NEq z) = [NEq z]
   6.280 +  | disjuncts (Dvd (aa, ab)) = [Dvd (aa, ab)]
   6.281 +  | disjuncts (NDvd (ac, ad)) = [NDvd (ac, ad)]
   6.282 +  | disjuncts (Not ae) = [Not ae]
   6.283 +  | disjuncts (And (af, ag)) = [And (af, ag)]
   6.284 +  | disjuncts (Imp (aj, ak)) = [Imp (aj, ak)]
   6.285 +  | disjuncts (Iff (al, am)) = [Iff (al, am)]
   6.286 +  | disjuncts (E an) = [E an]
   6.287 +  | disjuncts (A ao) = [A ao]
   6.288 +  | disjuncts (Closed ap) = [Closed ap]
   6.289 +  | disjuncts (NClosed aq) = [NClosed aq];
   6.290 +
   6.291 +fun fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
   6.292 +  (NClosed nat) = f19 nat
   6.293 +  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
   6.294 +    (Closed nat) = f18 nat
   6.295 +  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
   6.296 +    (A fm) = f17 fm
   6.297 +  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
   6.298 +    (E fm) = f16 fm
   6.299 +  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
   6.300 +    (Iff (fm1, fm2)) = f15 fm1 fm2
   6.301 +  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
   6.302 +    (Imp (fm1, fm2)) = f14 fm1 fm2
   6.303 +  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
   6.304 +    (Or (fm1, fm2)) = f13 fm1 fm2
   6.305 +  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
   6.306 +    (And (fm1, fm2)) = f12 fm1 fm2
   6.307 +  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
   6.308 +    (Not fm) = f11 fm
   6.309 +  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
   6.310 +    (NDvd (inta, num)) = f10 inta num
   6.311 +  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
   6.312 +    (Dvd (inta, num)) = f9 inta num
   6.313 +  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
   6.314 +    (NEq num) = f8 num
   6.315 +  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
   6.316 +    (Eq num) = f7 num
   6.317 +  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
   6.318 +    (Ge num) = f6 num
   6.319 +  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
   6.320 +    (Gt num) = f5 num
   6.321 +  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
   6.322 +    (Le num) = f4 num
   6.323 +  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
   6.324 +    (Lt num) = f3 num
   6.325 +  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19 F
   6.326 +    = f2
   6.327 +  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19 T
   6.328 +    = f1;
   6.329 +
   6.330 +fun eq_num (C intaa) (C inta) = ((intaa : IntInf.int) = inta)
   6.331 +  | eq_num (Bound nata) (Bound nat) = ((nata : IntInf.int) = nat)
   6.332 +  | eq_num (Cn (nata, intaa, numa)) (Cn (nat, inta, num)) =
   6.333 +    ((nata : IntInf.int) = nat) andalso
   6.334 +      (((intaa : IntInf.int) = inta) andalso eq_num numa num)
   6.335 +  | eq_num (Neg numa) (Neg num) = eq_num numa num
   6.336 +  | eq_num (Add (num1a, num2a)) (Add (num1, num2)) =
   6.337 +    eq_num num1a num1 andalso eq_num num2a num2
   6.338 +  | eq_num (Sub (num1a, num2a)) (Sub (num1, num2)) =
   6.339 +    eq_num num1a num1 andalso eq_num num2a num2
   6.340 +  | eq_num (Mul (intaa, numa)) (Mul (inta, num)) =
   6.341 +    ((intaa : IntInf.int) = inta) andalso eq_num numa num
   6.342 +  | eq_num (C inta) (Bound nat) = false
   6.343 +  | eq_num (Bound nat) (C inta) = false
   6.344 +  | eq_num (C intaa) (Cn (nat, inta, num)) = false
   6.345 +  | eq_num (Cn (nat, intaa, num)) (C inta) = false
   6.346 +  | eq_num (C inta) (Neg num) = false
   6.347 +  | eq_num (Neg num) (C inta) = false
   6.348 +  | eq_num (C inta) (Add (num1, num2)) = false
   6.349 +  | eq_num (Add (num1, num2)) (C inta) = false
   6.350 +  | eq_num (C inta) (Sub (num1, num2)) = false
   6.351 +  | eq_num (Sub (num1, num2)) (C inta) = false
   6.352 +  | eq_num (C intaa) (Mul (inta, num)) = false
   6.353 +  | eq_num (Mul (intaa, num)) (C inta) = false
   6.354 +  | eq_num (Bound nata) (Cn (nat, inta, num)) = false
   6.355 +  | eq_num (Cn (nata, inta, num)) (Bound nat) = false
   6.356 +  | eq_num (Bound nat) (Neg num) = false
   6.357 +  | eq_num (Neg num) (Bound nat) = false
   6.358 +  | eq_num (Bound nat) (Add (num1, num2)) = false
   6.359 +  | eq_num (Add (num1, num2)) (Bound nat) = false
   6.360 +  | eq_num (Bound nat) (Sub (num1, num2)) = false
   6.361 +  | eq_num (Sub (num1, num2)) (Bound nat) = false
   6.362 +  | eq_num (Bound nat) (Mul (inta, num)) = false
   6.363 +  | eq_num (Mul (inta, num)) (Bound nat) = false
   6.364 +  | eq_num (Cn (nat, inta, numa)) (Neg num) = false
   6.365 +  | eq_num (Neg numa) (Cn (nat, inta, num)) = false
   6.366 +  | eq_num (Cn (nat, inta, num)) (Add (num1, num2)) = false
   6.367 +  | eq_num (Add (num1, num2)) (Cn (nat, inta, num)) = false
   6.368 +  | eq_num (Cn (nat, inta, num)) (Sub (num1, num2)) = false
   6.369 +  | eq_num (Sub (num1, num2)) (Cn (nat, inta, num)) = false
   6.370 +  | eq_num (Cn (nat, intaa, numa)) (Mul (inta, num)) = false
   6.371 +  | eq_num (Mul (intaa, numa)) (Cn (nat, inta, num)) = false
   6.372 +  | eq_num (Neg num) (Add (num1, num2)) = false
   6.373 +  | eq_num (Add (num1, num2)) (Neg num) = false
   6.374 +  | eq_num (Neg num) (Sub (num1, num2)) = false
   6.375 +  | eq_num (Sub (num1, num2)) (Neg num) = false
   6.376 +  | eq_num (Neg numa) (Mul (inta, num)) = false
   6.377 +  | eq_num (Mul (inta, numa)) (Neg num) = false
   6.378 +  | eq_num (Add (num1a, num2a)) (Sub (num1, num2)) = false
   6.379 +  | eq_num (Sub (num1a, num2a)) (Add (num1, num2)) = false
   6.380 +  | eq_num (Add (num1, num2)) (Mul (inta, num)) = false
   6.381 +  | eq_num (Mul (inta, num)) (Add (num1, num2)) = false
   6.382 +  | eq_num (Sub (num1, num2)) (Mul (inta, num)) = false
   6.383 +  | eq_num (Mul (inta, num)) (Sub (num1, num2)) = false;
   6.384 +
   6.385 +fun eq_fm T T = true
   6.386 +  | eq_fm F F = true
   6.387 +  | eq_fm (Lt numa) (Lt num) = eq_num numa num
   6.388 +  | eq_fm (Le numa) (Le num) = eq_num numa num
   6.389 +  | eq_fm (Gt numa) (Gt num) = eq_num numa num
   6.390 +  | eq_fm (Ge numa) (Ge num) = eq_num numa num
   6.391 +  | eq_fm (Eq numa) (Eq num) = eq_num numa num
   6.392 +  | eq_fm (NEq numa) (NEq num) = eq_num numa num
   6.393 +  | eq_fm (Dvd (intaa, numa)) (Dvd (inta, num)) =
   6.394 +    ((intaa : IntInf.int) = inta) andalso eq_num numa num
   6.395 +  | eq_fm (NDvd (intaa, numa)) (NDvd (inta, num)) =
   6.396 +    ((intaa : IntInf.int) = inta) andalso eq_num numa num
   6.397 +  | eq_fm (Not fma) (Not fm) = eq_fm fma fm
   6.398 +  | eq_fm (And (fm1a, fm2a)) (And (fm1, fm2)) =
   6.399 +    eq_fm fm1a fm1 andalso eq_fm fm2a fm2
   6.400 +  | eq_fm (Or (fm1a, fm2a)) (Or (fm1, fm2)) =
   6.401 +    eq_fm fm1a fm1 andalso eq_fm fm2a fm2
   6.402 +  | eq_fm (Imp (fm1a, fm2a)) (Imp (fm1, fm2)) =
   6.403 +    eq_fm fm1a fm1 andalso eq_fm fm2a fm2
   6.404 +  | eq_fm (Iff (fm1a, fm2a)) (Iff (fm1, fm2)) =
   6.405 +    eq_fm fm1a fm1 andalso eq_fm fm2a fm2
   6.406 +  | eq_fm (E fma) (E fm) = eq_fm fma fm
   6.407 +  | eq_fm (A fma) (A fm) = eq_fm fma fm
   6.408 +  | eq_fm (Closed nata) (Closed nat) = ((nata : IntInf.int) = nat)
   6.409 +  | eq_fm (NClosed nata) (NClosed nat) = ((nata : IntInf.int) = nat)
   6.410 +  | eq_fm T F = false
   6.411 +  | eq_fm F T = false
   6.412 +  | eq_fm T (Lt num) = false
   6.413 +  | eq_fm (Lt num) T = false
   6.414 +  | eq_fm T (Le num) = false
   6.415 +  | eq_fm (Le num) T = false
   6.416 +  | eq_fm T (Gt num) = false
   6.417 +  | eq_fm (Gt num) T = false
   6.418 +  | eq_fm T (Ge num) = false
   6.419 +  | eq_fm (Ge num) T = false
   6.420 +  | eq_fm T (Eq num) = false
   6.421 +  | eq_fm (Eq num) T = false
   6.422 +  | eq_fm T (NEq num) = false
   6.423 +  | eq_fm (NEq num) T = false
   6.424 +  | eq_fm T (Dvd (inta, num)) = false
   6.425 +  | eq_fm (Dvd (inta, num)) T = false
   6.426 +  | eq_fm T (NDvd (inta, num)) = false
   6.427 +  | eq_fm (NDvd (inta, num)) T = false
   6.428 +  | eq_fm T (Not fm) = false
   6.429 +  | eq_fm (Not fm) T = false
   6.430 +  | eq_fm T (And (fm1, fm2)) = false
   6.431 +  | eq_fm (And (fm1, fm2)) T = false
   6.432 +  | eq_fm T (Or (fm1, fm2)) = false
   6.433 +  | eq_fm (Or (fm1, fm2)) T = false
   6.434 +  | eq_fm T (Imp (fm1, fm2)) = false
   6.435 +  | eq_fm (Imp (fm1, fm2)) T = false
   6.436 +  | eq_fm T (Iff (fm1, fm2)) = false
   6.437 +  | eq_fm (Iff (fm1, fm2)) T = false
   6.438 +  | eq_fm T (E fm) = false
   6.439 +  | eq_fm (E fm) T = false
   6.440 +  | eq_fm T (A fm) = false
   6.441 +  | eq_fm (A fm) T = false
   6.442 +  | eq_fm T (Closed nat) = false
   6.443 +  | eq_fm (Closed nat) T = false
   6.444 +  | eq_fm T (NClosed nat) = false
   6.445 +  | eq_fm (NClosed nat) T = false
   6.446 +  | eq_fm F (Lt num) = false
   6.447 +  | eq_fm (Lt num) F = false
   6.448 +  | eq_fm F (Le num) = false
   6.449 +  | eq_fm (Le num) F = false
   6.450 +  | eq_fm F (Gt num) = false
   6.451 +  | eq_fm (Gt num) F = false
   6.452 +  | eq_fm F (Ge num) = false
   6.453 +  | eq_fm (Ge num) F = false
   6.454 +  | eq_fm F (Eq num) = false
   6.455 +  | eq_fm (Eq num) F = false
   6.456 +  | eq_fm F (NEq num) = false
   6.457 +  | eq_fm (NEq num) F = false
   6.458 +  | eq_fm F (Dvd (inta, num)) = false
   6.459 +  | eq_fm (Dvd (inta, num)) F = false
   6.460 +  | eq_fm F (NDvd (inta, num)) = false
   6.461 +  | eq_fm (NDvd (inta, num)) F = false
   6.462 +  | eq_fm F (Not fm) = false
   6.463 +  | eq_fm (Not fm) F = false
   6.464 +  | eq_fm F (And (fm1, fm2)) = false
   6.465 +  | eq_fm (And (fm1, fm2)) F = false
   6.466 +  | eq_fm F (Or (fm1, fm2)) = false
   6.467 +  | eq_fm (Or (fm1, fm2)) F = false
   6.468 +  | eq_fm F (Imp (fm1, fm2)) = false
   6.469 +  | eq_fm (Imp (fm1, fm2)) F = false
   6.470 +  | eq_fm F (Iff (fm1, fm2)) = false
   6.471 +  | eq_fm (Iff (fm1, fm2)) F = false
   6.472 +  | eq_fm F (E fm) = false
   6.473 +  | eq_fm (E fm) F = false
   6.474 +  | eq_fm F (A fm) = false
   6.475 +  | eq_fm (A fm) F = false
   6.476 +  | eq_fm F (Closed nat) = false
   6.477 +  | eq_fm (Closed nat) F = false
   6.478 +  | eq_fm F (NClosed nat) = false
   6.479 +  | eq_fm (NClosed nat) F = false
   6.480 +  | eq_fm (Lt numa) (Le num) = false
   6.481 +  | eq_fm (Le numa) (Lt num) = false
   6.482 +  | eq_fm (Lt numa) (Gt num) = false
   6.483 +  | eq_fm (Gt numa) (Lt num) = false
   6.484 +  | eq_fm (Lt numa) (Ge num) = false
   6.485 +  | eq_fm (Ge numa) (Lt num) = false
   6.486 +  | eq_fm (Lt numa) (Eq num) = false
   6.487 +  | eq_fm (Eq numa) (Lt num) = false
   6.488 +  | eq_fm (Lt numa) (NEq num) = false
   6.489 +  | eq_fm (NEq numa) (Lt num) = false
   6.490 +  | eq_fm (Lt numa) (Dvd (inta, num)) = false
   6.491 +  | eq_fm (Dvd (inta, numa)) (Lt num) = false
   6.492 +  | eq_fm (Lt numa) (NDvd (inta, num)) = false
   6.493 +  | eq_fm (NDvd (inta, numa)) (Lt num) = false
   6.494 +  | eq_fm (Lt num) (Not fm) = false
   6.495 +  | eq_fm (Not fm) (Lt num) = false
   6.496 +  | eq_fm (Lt num) (And (fm1, fm2)) = false
   6.497 +  | eq_fm (And (fm1, fm2)) (Lt num) = false
   6.498 +  | eq_fm (Lt num) (Or (fm1, fm2)) = false
   6.499 +  | eq_fm (Or (fm1, fm2)) (Lt num) = false
   6.500 +  | eq_fm (Lt num) (Imp (fm1, fm2)) = false
   6.501 +  | eq_fm (Imp (fm1, fm2)) (Lt num) = false
   6.502 +  | eq_fm (Lt num) (Iff (fm1, fm2)) = false
   6.503 +  | eq_fm (Iff (fm1, fm2)) (Lt num) = false
   6.504 +  | eq_fm (Lt num) (E fm) = false
   6.505 +  | eq_fm (E fm) (Lt num) = false
   6.506 +  | eq_fm (Lt num) (A fm) = false
   6.507 +  | eq_fm (A fm) (Lt num) = false
   6.508 +  | eq_fm (Lt num) (Closed nat) = false
   6.509 +  | eq_fm (Closed nat) (Lt num) = false
   6.510 +  | eq_fm (Lt num) (NClosed nat) = false
   6.511 +  | eq_fm (NClosed nat) (Lt num) = false
   6.512 +  | eq_fm (Le numa) (Gt num) = false
   6.513 +  | eq_fm (Gt numa) (Le num) = false
   6.514 +  | eq_fm (Le numa) (Ge num) = false
   6.515 +  | eq_fm (Ge numa) (Le num) = false
   6.516 +  | eq_fm (Le numa) (Eq num) = false
   6.517 +  | eq_fm (Eq numa) (Le num) = false
   6.518 +  | eq_fm (Le numa) (NEq num) = false
   6.519 +  | eq_fm (NEq numa) (Le num) = false
   6.520 +  | eq_fm (Le numa) (Dvd (inta, num)) = false
   6.521 +  | eq_fm (Dvd (inta, numa)) (Le num) = false
   6.522 +  | eq_fm (Le numa) (NDvd (inta, num)) = false
   6.523 +  | eq_fm (NDvd (inta, numa)) (Le num) = false
   6.524 +  | eq_fm (Le num) (Not fm) = false
   6.525 +  | eq_fm (Not fm) (Le num) = false
   6.526 +  | eq_fm (Le num) (And (fm1, fm2)) = false
   6.527 +  | eq_fm (And (fm1, fm2)) (Le num) = false
   6.528 +  | eq_fm (Le num) (Or (fm1, fm2)) = false
   6.529 +  | eq_fm (Or (fm1, fm2)) (Le num) = false
   6.530 +  | eq_fm (Le num) (Imp (fm1, fm2)) = false
   6.531 +  | eq_fm (Imp (fm1, fm2)) (Le num) = false
   6.532 +  | eq_fm (Le num) (Iff (fm1, fm2)) = false
   6.533 +  | eq_fm (Iff (fm1, fm2)) (Le num) = false
   6.534 +  | eq_fm (Le num) (E fm) = false
   6.535 +  | eq_fm (E fm) (Le num) = false
   6.536 +  | eq_fm (Le num) (A fm) = false
   6.537 +  | eq_fm (A fm) (Le num) = false
   6.538 +  | eq_fm (Le num) (Closed nat) = false
   6.539 +  | eq_fm (Closed nat) (Le num) = false
   6.540 +  | eq_fm (Le num) (NClosed nat) = false
   6.541 +  | eq_fm (NClosed nat) (Le num) = false
   6.542 +  | eq_fm (Gt numa) (Ge num) = false
   6.543 +  | eq_fm (Ge numa) (Gt num) = false
   6.544 +  | eq_fm (Gt numa) (Eq num) = false
   6.545 +  | eq_fm (Eq numa) (Gt num) = false
   6.546 +  | eq_fm (Gt numa) (NEq num) = false
   6.547 +  | eq_fm (NEq numa) (Gt num) = false
   6.548 +  | eq_fm (Gt numa) (Dvd (inta, num)) = false
   6.549 +  | eq_fm (Dvd (inta, numa)) (Gt num) = false
   6.550 +  | eq_fm (Gt numa) (NDvd (inta, num)) = false
   6.551 +  | eq_fm (NDvd (inta, numa)) (Gt num) = false
   6.552 +  | eq_fm (Gt num) (Not fm) = false
   6.553 +  | eq_fm (Not fm) (Gt num) = false
   6.554 +  | eq_fm (Gt num) (And (fm1, fm2)) = false
   6.555 +  | eq_fm (And (fm1, fm2)) (Gt num) = false
   6.556 +  | eq_fm (Gt num) (Or (fm1, fm2)) = false
   6.557 +  | eq_fm (Or (fm1, fm2)) (Gt num) = false
   6.558 +  | eq_fm (Gt num) (Imp (fm1, fm2)) = false
   6.559 +  | eq_fm (Imp (fm1, fm2)) (Gt num) = false
   6.560 +  | eq_fm (Gt num) (Iff (fm1, fm2)) = false
   6.561 +  | eq_fm (Iff (fm1, fm2)) (Gt num) = false
   6.562 +  | eq_fm (Gt num) (E fm) = false
   6.563 +  | eq_fm (E fm) (Gt num) = false
   6.564 +  | eq_fm (Gt num) (A fm) = false
   6.565 +  | eq_fm (A fm) (Gt num) = false
   6.566 +  | eq_fm (Gt num) (Closed nat) = false
   6.567 +  | eq_fm (Closed nat) (Gt num) = false
   6.568 +  | eq_fm (Gt num) (NClosed nat) = false
   6.569 +  | eq_fm (NClosed nat) (Gt num) = false
   6.570 +  | eq_fm (Ge numa) (Eq num) = false
   6.571 +  | eq_fm (Eq numa) (Ge num) = false
   6.572 +  | eq_fm (Ge numa) (NEq num) = false
   6.573 +  | eq_fm (NEq numa) (Ge num) = false
   6.574 +  | eq_fm (Ge numa) (Dvd (inta, num)) = false
   6.575 +  | eq_fm (Dvd (inta, numa)) (Ge num) = false
   6.576 +  | eq_fm (Ge numa) (NDvd (inta, num)) = false
   6.577 +  | eq_fm (NDvd (inta, numa)) (Ge num) = false
   6.578 +  | eq_fm (Ge num) (Not fm) = false
   6.579 +  | eq_fm (Not fm) (Ge num) = false
   6.580 +  | eq_fm (Ge num) (And (fm1, fm2)) = false
   6.581 +  | eq_fm (And (fm1, fm2)) (Ge num) = false
   6.582 +  | eq_fm (Ge num) (Or (fm1, fm2)) = false
   6.583 +  | eq_fm (Or (fm1, fm2)) (Ge num) = false
   6.584 +  | eq_fm (Ge num) (Imp (fm1, fm2)) = false
   6.585 +  | eq_fm (Imp (fm1, fm2)) (Ge num) = false
   6.586 +  | eq_fm (Ge num) (Iff (fm1, fm2)) = false
   6.587 +  | eq_fm (Iff (fm1, fm2)) (Ge num) = false
   6.588 +  | eq_fm (Ge num) (E fm) = false
   6.589 +  | eq_fm (E fm) (Ge num) = false
   6.590 +  | eq_fm (Ge num) (A fm) = false
   6.591 +  | eq_fm (A fm) (Ge num) = false
   6.592 +  | eq_fm (Ge num) (Closed nat) = false
   6.593 +  | eq_fm (Closed nat) (Ge num) = false
   6.594 +  | eq_fm (Ge num) (NClosed nat) = false
   6.595 +  | eq_fm (NClosed nat) (Ge num) = false
   6.596 +  | eq_fm (Eq numa) (NEq num) = false
   6.597 +  | eq_fm (NEq numa) (Eq num) = false
   6.598 +  | eq_fm (Eq numa) (Dvd (inta, num)) = false
   6.599 +  | eq_fm (Dvd (inta, numa)) (Eq num) = false
   6.600 +  | eq_fm (Eq numa) (NDvd (inta, num)) = false
   6.601 +  | eq_fm (NDvd (inta, numa)) (Eq num) = false
   6.602 +  | eq_fm (Eq num) (Not fm) = false
   6.603 +  | eq_fm (Not fm) (Eq num) = false
   6.604 +  | eq_fm (Eq num) (And (fm1, fm2)) = false
   6.605 +  | eq_fm (And (fm1, fm2)) (Eq num) = false
   6.606 +  | eq_fm (Eq num) (Or (fm1, fm2)) = false
   6.607 +  | eq_fm (Or (fm1, fm2)) (Eq num) = false
   6.608 +  | eq_fm (Eq num) (Imp (fm1, fm2)) = false
   6.609 +  | eq_fm (Imp (fm1, fm2)) (Eq num) = false
   6.610 +  | eq_fm (Eq num) (Iff (fm1, fm2)) = false
   6.611 +  | eq_fm (Iff (fm1, fm2)) (Eq num) = false
   6.612 +  | eq_fm (Eq num) (E fm) = false
   6.613 +  | eq_fm (E fm) (Eq num) = false
   6.614 +  | eq_fm (Eq num) (A fm) = false
   6.615 +  | eq_fm (A fm) (Eq num) = false
   6.616 +  | eq_fm (Eq num) (Closed nat) = false
   6.617 +  | eq_fm (Closed nat) (Eq num) = false
   6.618 +  | eq_fm (Eq num) (NClosed nat) = false
   6.619 +  | eq_fm (NClosed nat) (Eq num) = false
   6.620 +  | eq_fm (NEq numa) (Dvd (inta, num)) = false
   6.621 +  | eq_fm (Dvd (inta, numa)) (NEq num) = false
   6.622 +  | eq_fm (NEq numa) (NDvd (inta, num)) = false
   6.623 +  | eq_fm (NDvd (inta, numa)) (NEq num) = false
   6.624 +  | eq_fm (NEq num) (Not fm) = false
   6.625 +  | eq_fm (Not fm) (NEq num) = false
   6.626 +  | eq_fm (NEq num) (And (fm1, fm2)) = false
   6.627 +  | eq_fm (And (fm1, fm2)) (NEq num) = false
   6.628 +  | eq_fm (NEq num) (Or (fm1, fm2)) = false
   6.629 +  | eq_fm (Or (fm1, fm2)) (NEq num) = false
   6.630 +  | eq_fm (NEq num) (Imp (fm1, fm2)) = false
   6.631 +  | eq_fm (Imp (fm1, fm2)) (NEq num) = false
   6.632 +  | eq_fm (NEq num) (Iff (fm1, fm2)) = false
   6.633 +  | eq_fm (Iff (fm1, fm2)) (NEq num) = false
   6.634 +  | eq_fm (NEq num) (E fm) = false
   6.635 +  | eq_fm (E fm) (NEq num) = false
   6.636 +  | eq_fm (NEq num) (A fm) = false
   6.637 +  | eq_fm (A fm) (NEq num) = false
   6.638 +  | eq_fm (NEq num) (Closed nat) = false
   6.639 +  | eq_fm (Closed nat) (NEq num) = false
   6.640 +  | eq_fm (NEq num) (NClosed nat) = false
   6.641 +  | eq_fm (NClosed nat) (NEq num) = false
   6.642 +  | eq_fm (Dvd (intaa, numa)) (NDvd (inta, num)) = false
   6.643 +  | eq_fm (NDvd (intaa, numa)) (Dvd (inta, num)) = false
   6.644 +  | eq_fm (Dvd (inta, num)) (Not fm) = false
   6.645 +  | eq_fm (Not fm) (Dvd (inta, num)) = false
   6.646 +  | eq_fm (Dvd (inta, num)) (And (fm1, fm2)) = false
   6.647 +  | eq_fm (And (fm1, fm2)) (Dvd (inta, num)) = false
   6.648 +  | eq_fm (Dvd (inta, num)) (Or (fm1, fm2)) = false
   6.649 +  | eq_fm (Or (fm1, fm2)) (Dvd (inta, num)) = false
   6.650 +  | eq_fm (Dvd (inta, num)) (Imp (fm1, fm2)) = false
   6.651 +  | eq_fm (Imp (fm1, fm2)) (Dvd (inta, num)) = false
   6.652 +  | eq_fm (Dvd (inta, num)) (Iff (fm1, fm2)) = false
   6.653 +  | eq_fm (Iff (fm1, fm2)) (Dvd (inta, num)) = false
   6.654 +  | eq_fm (Dvd (inta, num)) (E fm) = false
   6.655 +  | eq_fm (E fm) (Dvd (inta, num)) = false
   6.656 +  | eq_fm (Dvd (inta, num)) (A fm) = false
   6.657 +  | eq_fm (A fm) (Dvd (inta, num)) = false
   6.658 +  | eq_fm (Dvd (inta, num)) (Closed nat) = false
   6.659 +  | eq_fm (Closed nat) (Dvd (inta, num)) = false
   6.660 +  | eq_fm (Dvd (inta, num)) (NClosed nat) = false
   6.661 +  | eq_fm (NClosed nat) (Dvd (inta, num)) = false
   6.662 +  | eq_fm (NDvd (inta, num)) (Not fm) = false
   6.663 +  | eq_fm (Not fm) (NDvd (inta, num)) = false
   6.664 +  | eq_fm (NDvd (inta, num)) (And (fm1, fm2)) = false
   6.665 +  | eq_fm (And (fm1, fm2)) (NDvd (inta, num)) = false
   6.666 +  | eq_fm (NDvd (inta, num)) (Or (fm1, fm2)) = false
   6.667 +  | eq_fm (Or (fm1, fm2)) (NDvd (inta, num)) = false
   6.668 +  | eq_fm (NDvd (inta, num)) (Imp (fm1, fm2)) = false
   6.669 +  | eq_fm (Imp (fm1, fm2)) (NDvd (inta, num)) = false
   6.670 +  | eq_fm (NDvd (inta, num)) (Iff (fm1, fm2)) = false
   6.671 +  | eq_fm (Iff (fm1, fm2)) (NDvd (inta, num)) = false
   6.672 +  | eq_fm (NDvd (inta, num)) (E fm) = false
   6.673 +  | eq_fm (E fm) (NDvd (inta, num)) = false
   6.674 +  | eq_fm (NDvd (inta, num)) (A fm) = false
   6.675 +  | eq_fm (A fm) (NDvd (inta, num)) = false
   6.676 +  | eq_fm (NDvd (inta, num)) (Closed nat) = false
   6.677 +  | eq_fm (Closed nat) (NDvd (inta, num)) = false
   6.678 +  | eq_fm (NDvd (inta, num)) (NClosed nat) = false
   6.679 +  | eq_fm (NClosed nat) (NDvd (inta, num)) = false
   6.680 +  | eq_fm (Not fm) (And (fm1, fm2)) = false
   6.681 +  | eq_fm (And (fm1, fm2)) (Not fm) = false
   6.682 +  | eq_fm (Not fm) (Or (fm1, fm2)) = false
   6.683 +  | eq_fm (Or (fm1, fm2)) (Not fm) = false
   6.684 +  | eq_fm (Not fm) (Imp (fm1, fm2)) = false
   6.685 +  | eq_fm (Imp (fm1, fm2)) (Not fm) = false
   6.686 +  | eq_fm (Not fm) (Iff (fm1, fm2)) = false
   6.687 +  | eq_fm (Iff (fm1, fm2)) (Not fm) = false
   6.688 +  | eq_fm (Not fma) (E fm) = false
   6.689 +  | eq_fm (E fma) (Not fm) = false
   6.690 +  | eq_fm (Not fma) (A fm) = false
   6.691 +  | eq_fm (A fma) (Not fm) = false
   6.692 +  | eq_fm (Not fm) (Closed nat) = false
   6.693 +  | eq_fm (Closed nat) (Not fm) = false
   6.694 +  | eq_fm (Not fm) (NClosed nat) = false
   6.695 +  | eq_fm (NClosed nat) (Not fm) = false
   6.696 +  | eq_fm (And (fm1a, fm2a)) (Or (fm1, fm2)) = false
   6.697 +  | eq_fm (Or (fm1a, fm2a)) (And (fm1, fm2)) = false
   6.698 +  | eq_fm (And (fm1a, fm2a)) (Imp (fm1, fm2)) = false
   6.699 +  | eq_fm (Imp (fm1a, fm2a)) (And (fm1, fm2)) = false
   6.700 +  | eq_fm (And (fm1a, fm2a)) (Iff (fm1, fm2)) = false
   6.701 +  | eq_fm (Iff (fm1a, fm2a)) (And (fm1, fm2)) = false
   6.702 +  | eq_fm (And (fm1, fm2)) (E fm) = false
   6.703 +  | eq_fm (E fm) (And (fm1, fm2)) = false
   6.704 +  | eq_fm (And (fm1, fm2)) (A fm) = false
   6.705 +  | eq_fm (A fm) (And (fm1, fm2)) = false
   6.706 +  | eq_fm (And (fm1, fm2)) (Closed nat) = false
   6.707 +  | eq_fm (Closed nat) (And (fm1, fm2)) = false
   6.708 +  | eq_fm (And (fm1, fm2)) (NClosed nat) = false
   6.709 +  | eq_fm (NClosed nat) (And (fm1, fm2)) = false
   6.710 +  | eq_fm (Or (fm1a, fm2a)) (Imp (fm1, fm2)) = false
   6.711 +  | eq_fm (Imp (fm1a, fm2a)) (Or (fm1, fm2)) = false
   6.712 +  | eq_fm (Or (fm1a, fm2a)) (Iff (fm1, fm2)) = false
   6.713 +  | eq_fm (Iff (fm1a, fm2a)) (Or (fm1, fm2)) = false
   6.714 +  | eq_fm (Or (fm1, fm2)) (E fm) = false
   6.715 +  | eq_fm (E fm) (Or (fm1, fm2)) = false
   6.716 +  | eq_fm (Or (fm1, fm2)) (A fm) = false
   6.717 +  | eq_fm (A fm) (Or (fm1, fm2)) = false
   6.718 +  | eq_fm (Or (fm1, fm2)) (Closed nat) = false
   6.719 +  | eq_fm (Closed nat) (Or (fm1, fm2)) = false
   6.720 +  | eq_fm (Or (fm1, fm2)) (NClosed nat) = false
   6.721 +  | eq_fm (NClosed nat) (Or (fm1, fm2)) = false
   6.722 +  | eq_fm (Imp (fm1a, fm2a)) (Iff (fm1, fm2)) = false
   6.723 +  | eq_fm (Iff (fm1a, fm2a)) (Imp (fm1, fm2)) = false
   6.724 +  | eq_fm (Imp (fm1, fm2)) (E fm) = false
   6.725 +  | eq_fm (E fm) (Imp (fm1, fm2)) = false
   6.726 +  | eq_fm (Imp (fm1, fm2)) (A fm) = false
   6.727 +  | eq_fm (A fm) (Imp (fm1, fm2)) = false
   6.728 +  | eq_fm (Imp (fm1, fm2)) (Closed nat) = false
   6.729 +  | eq_fm (Closed nat) (Imp (fm1, fm2)) = false
   6.730 +  | eq_fm (Imp (fm1, fm2)) (NClosed nat) = false
   6.731 +  | eq_fm (NClosed nat) (Imp (fm1, fm2)) = false
   6.732 +  | eq_fm (Iff (fm1, fm2)) (E fm) = false
   6.733 +  | eq_fm (E fm) (Iff (fm1, fm2)) = false
   6.734 +  | eq_fm (Iff (fm1, fm2)) (A fm) = false
   6.735 +  | eq_fm (A fm) (Iff (fm1, fm2)) = false
   6.736 +  | eq_fm (Iff (fm1, fm2)) (Closed nat) = false
   6.737 +  | eq_fm (Closed nat) (Iff (fm1, fm2)) = false
   6.738 +  | eq_fm (Iff (fm1, fm2)) (NClosed nat) = false
   6.739 +  | eq_fm (NClosed nat) (Iff (fm1, fm2)) = false
   6.740 +  | eq_fm (E fma) (A fm) = false
   6.741 +  | eq_fm (A fma) (E fm) = false
   6.742 +  | eq_fm (E fm) (Closed nat) = false
   6.743 +  | eq_fm (Closed nat) (E fm) = false
   6.744 +  | eq_fm (E fm) (NClosed nat) = false
   6.745 +  | eq_fm (NClosed nat) (E fm) = false
   6.746 +  | eq_fm (A fm) (Closed nat) = false
   6.747 +  | eq_fm (Closed nat) (A fm) = false
   6.748 +  | eq_fm (A fm) (NClosed nat) = false
   6.749 +  | eq_fm (NClosed nat) (A fm) = false
   6.750 +  | eq_fm (Closed nata) (NClosed nat) = false
   6.751 +  | eq_fm (NClosed nata) (Closed nat) = false;
   6.752 +
   6.753 +fun djf f p q =
   6.754 +  (if eq_fm q T then T
   6.755 +    else (if eq_fm q F then f p
   6.756 +           else (case f p of T => T | F => q | Lt _ => Or (f p, q)
   6.757 +                  | Le _ => Or (f p, q) | Gt _ => Or (f p, q)
   6.758 +                  | Ge _ => Or (f p, q) | Eq _ => Or (f p, q)
   6.759 +                  | NEq _ => Or (f p, q) | Dvd (_, _) => Or (f p, q)
   6.760 +                  | NDvd (_, _) => Or (f p, q) | Not _ => Or (f p, q)
   6.761 +                  | And (_, _) => Or (f p, q) | Or (_, _) => Or (f p, q)
   6.762 +                  | Imp (_, _) => Or (f p, q) | Iff (_, _) => Or (f p, q)
   6.763 +                  | E _ => Or (f p, q) | A _ => Or (f p, q)
   6.764 +                  | Closed _ => Or (f p, q) | NClosed _ => Or (f p, q))));
   6.765 +
   6.766 +fun foldr f [] a = a
   6.767 +  | foldr f (x :: xs) a = f x (foldr f xs a);
   6.768 +
   6.769 +fun evaldjf f ps = foldr (djf f) ps F;
   6.770 +
   6.771 +fun dj f p = evaldjf f (disjuncts p);
   6.772 +
   6.773 +fun disj p q =
   6.774 +  (if eq_fm p T orelse eq_fm q T then T
   6.775 +    else (if eq_fm p F then q else (if eq_fm q F then p else Or (p, q))));
   6.776 +
   6.777 +fun minus_nat n m = IntInf.max (0, (IntInf.- (n, m)));
   6.778 +
   6.779 +fun decrnum (Bound n) = Bound (minus_nat n (1 : IntInf.int))
   6.780 +  | decrnum (Neg a) = Neg (decrnum a)
   6.781 +  | decrnum (Add (a, b)) = Add (decrnum a, decrnum b)
   6.782 +  | decrnum (Sub (a, b)) = Sub (decrnum a, decrnum b)
   6.783 +  | decrnum (Mul (c, a)) = Mul (c, decrnum a)
   6.784 +  | decrnum (Cn (n, i, a)) = Cn (minus_nat n (1 : IntInf.int), i, decrnum a)
   6.785 +  | decrnum (C u) = C u;
   6.786 +
   6.787 +fun decr (Lt a) = Lt (decrnum a)
   6.788 +  | decr (Le a) = Le (decrnum a)
   6.789 +  | decr (Gt a) = Gt (decrnum a)
   6.790 +  | decr (Ge a) = Ge (decrnum a)
   6.791 +  | decr (Eq a) = Eq (decrnum a)
   6.792 +  | decr (NEq a) = NEq (decrnum a)
   6.793 +  | decr (Dvd (i, a)) = Dvd (i, decrnum a)
   6.794 +  | decr (NDvd (i, a)) = NDvd (i, decrnum a)
   6.795 +  | decr (Not p) = Not (decr p)
   6.796 +  | decr (And (p, q)) = And (decr p, decr q)
   6.797 +  | decr (Or (p, q)) = Or (decr p, decr q)
   6.798 +  | decr (Imp (p, q)) = Imp (decr p, decr q)
   6.799 +  | decr (Iff (p, q)) = Iff (decr p, decr q)
   6.800 +  | decr T = T
   6.801 +  | decr F = F
   6.802 +  | decr (E ao) = E ao
   6.803 +  | decr (A ap) = A ap
   6.804 +  | decr (Closed aq) = Closed aq
   6.805 +  | decr (NClosed ar) = NClosed ar;
   6.806 +
   6.807 +fun concat_map f [] = []
   6.808 +  | concat_map f (x :: xs) = append (f x) (concat_map f xs);
   6.809 +
   6.810 +fun numsubst0 t (C c) = C c
   6.811 +  | numsubst0 t (Bound n) =
   6.812 +    (if ((n : IntInf.int) = (0 : IntInf.int)) then t else Bound n)
   6.813 +  | numsubst0 t (Neg a) = Neg (numsubst0 t a)
   6.814 +  | numsubst0 t (Add (a, b)) = Add (numsubst0 t a, numsubst0 t b)
   6.815 +  | numsubst0 t (Sub (a, b)) = Sub (numsubst0 t a, numsubst0 t b)
   6.816 +  | numsubst0 t (Mul (i, a)) = Mul (i, numsubst0 t a)
   6.817 +  | numsubst0 t (Cn (v, i, a)) =
   6.818 +    (if ((v : IntInf.int) = (0 : IntInf.int))
   6.819 +      then Add (Mul (i, t), numsubst0 t a)
   6.820 +      else Cn (suc (minus_nat v (1 : IntInf.int)), i, numsubst0 t a));
   6.821 +
   6.822 +fun subst0 t T = T
   6.823 +  | subst0 t F = F
   6.824 +  | subst0 t (Lt a) = Lt (numsubst0 t a)
   6.825 +  | subst0 t (Le a) = Le (numsubst0 t a)
   6.826 +  | subst0 t (Gt a) = Gt (numsubst0 t a)
   6.827 +  | subst0 t (Ge a) = Ge (numsubst0 t a)
   6.828 +  | subst0 t (Eq a) = Eq (numsubst0 t a)
   6.829 +  | subst0 t (NEq a) = NEq (numsubst0 t a)
   6.830 +  | subst0 t (Dvd (i, a)) = Dvd (i, numsubst0 t a)
   6.831 +  | subst0 t (NDvd (i, a)) = NDvd (i, numsubst0 t a)
   6.832 +  | subst0 t (Not p) = Not (subst0 t p)
   6.833 +  | subst0 t (And (p, q)) = And (subst0 t p, subst0 t q)
   6.834 +  | subst0 t (Or (p, q)) = Or (subst0 t p, subst0 t q)
   6.835 +  | subst0 t (Imp (p, q)) = Imp (subst0 t p, subst0 t q)
   6.836 +  | subst0 t (Iff (p, q)) = Iff (subst0 t p, subst0 t q)
   6.837 +  | subst0 t (Closed p) = Closed p
   6.838 +  | subst0 t (NClosed p) = NClosed p;
   6.839 +
   6.840 +fun minusinf (And (p, q)) = And (minusinf p, minusinf q)
   6.841 +  | minusinf (Or (p, q)) = Or (minusinf p, minusinf q)
   6.842 +  | minusinf T = T
   6.843 +  | minusinf F = F
   6.844 +  | minusinf (Lt (C bo)) = Lt (C bo)
   6.845 +  | minusinf (Lt (Bound bp)) = Lt (Bound bp)
   6.846 +  | minusinf (Lt (Neg bt)) = Lt (Neg bt)
   6.847 +  | minusinf (Lt (Add (bu, bv))) = Lt (Add (bu, bv))
   6.848 +  | minusinf (Lt (Sub (bw, bx))) = Lt (Sub (bw, bx))
   6.849 +  | minusinf (Lt (Mul (by, bz))) = Lt (Mul (by, bz))
   6.850 +  | minusinf (Le (C co)) = Le (C co)
   6.851 +  | minusinf (Le (Bound cp)) = Le (Bound cp)
   6.852 +  | minusinf (Le (Neg ct)) = Le (Neg ct)
   6.853 +  | minusinf (Le (Add (cu, cv))) = Le (Add (cu, cv))
   6.854 +  | minusinf (Le (Sub (cw, cx))) = Le (Sub (cw, cx))
   6.855 +  | minusinf (Le (Mul (cy, cz))) = Le (Mul (cy, cz))
   6.856 +  | minusinf (Gt (C doa)) = Gt (C doa)
   6.857 +  | minusinf (Gt (Bound dp)) = Gt (Bound dp)
   6.858 +  | minusinf (Gt (Neg dt)) = Gt (Neg dt)
   6.859 +  | minusinf (Gt (Add (du, dv))) = Gt (Add (du, dv))
   6.860 +  | minusinf (Gt (Sub (dw, dx))) = Gt (Sub (dw, dx))
   6.861 +  | minusinf (Gt (Mul (dy, dz))) = Gt (Mul (dy, dz))
   6.862 +  | minusinf (Ge (C eo)) = Ge (C eo)
   6.863 +  | minusinf (Ge (Bound ep)) = Ge (Bound ep)
   6.864 +  | minusinf (Ge (Neg et)) = Ge (Neg et)
   6.865 +  | minusinf (Ge (Add (eu, ev))) = Ge (Add (eu, ev))
   6.866 +  | minusinf (Ge (Sub (ew, ex))) = Ge (Sub (ew, ex))
   6.867 +  | minusinf (Ge (Mul (ey, ez))) = Ge (Mul (ey, ez))
   6.868 +  | minusinf (Eq (C fo)) = Eq (C fo)
   6.869 +  | minusinf (Eq (Bound fp)) = Eq (Bound fp)
   6.870 +  | minusinf (Eq (Neg ft)) = Eq (Neg ft)
   6.871 +  | minusinf (Eq (Add (fu, fv))) = Eq (Add (fu, fv))
   6.872 +  | minusinf (Eq (Sub (fw, fx))) = Eq (Sub (fw, fx))
   6.873 +  | minusinf (Eq (Mul (fy, fz))) = Eq (Mul (fy, fz))
   6.874 +  | minusinf (NEq (C go)) = NEq (C go)
   6.875 +  | minusinf (NEq (Bound gp)) = NEq (Bound gp)
   6.876 +  | minusinf (NEq (Neg gt)) = NEq (Neg gt)
   6.877 +  | minusinf (NEq (Add (gu, gv))) = NEq (Add (gu, gv))
   6.878 +  | minusinf (NEq (Sub (gw, gx))) = NEq (Sub (gw, gx))
   6.879 +  | minusinf (NEq (Mul (gy, gz))) = NEq (Mul (gy, gz))
   6.880 +  | minusinf (Dvd (aa, ab)) = Dvd (aa, ab)
   6.881 +  | minusinf (NDvd (ac, ad)) = NDvd (ac, ad)
   6.882 +  | minusinf (Not ae) = Not ae
   6.883 +  | minusinf (Imp (aj, ak)) = Imp (aj, ak)
   6.884 +  | minusinf (Iff (al, am)) = Iff (al, am)
   6.885 +  | minusinf (E an) = E an
   6.886 +  | minusinf (A ao) = A ao
   6.887 +  | minusinf (Closed ap) = Closed ap
   6.888 +  | minusinf (NClosed aq) = NClosed aq
   6.889 +  | minusinf (Lt (Cn (cm, c, e))) =
   6.890 +    (if ((cm : IntInf.int) = (0 : IntInf.int)) then T
   6.891 +      else Lt (Cn (suc (minus_nat cm (1 : IntInf.int)), c, e)))
   6.892 +  | minusinf (Le (Cn (dm, c, e))) =
   6.893 +    (if ((dm : IntInf.int) = (0 : IntInf.int)) then T
   6.894 +      else Le (Cn (suc (minus_nat dm (1 : IntInf.int)), c, e)))
   6.895 +  | minusinf (Gt (Cn (em, c, e))) =
   6.896 +    (if ((em : IntInf.int) = (0 : IntInf.int)) then F
   6.897 +      else Gt (Cn (suc (minus_nat em (1 : IntInf.int)), c, e)))
   6.898 +  | minusinf (Ge (Cn (fm, c, e))) =
   6.899 +    (if ((fm : IntInf.int) = (0 : IntInf.int)) then F
   6.900 +      else Ge (Cn (suc (minus_nat fm (1 : IntInf.int)), c, e)))
   6.901 +  | minusinf (Eq (Cn (gm, c, e))) =
   6.902 +    (if ((gm : IntInf.int) = (0 : IntInf.int)) then F
   6.903 +      else Eq (Cn (suc (minus_nat gm (1 : IntInf.int)), c, e)))
   6.904 +  | minusinf (NEq (Cn (hm, c, e))) =
   6.905 +    (if ((hm : IntInf.int) = (0 : IntInf.int)) then T
   6.906 +      else NEq (Cn (suc (minus_nat hm (1 : IntInf.int)), c, e)));
   6.907 +
   6.908 +val eq_int = {eq = (fn a => fn b => ((a : IntInf.int) = b))} : IntInf.int eq;
   6.909 +
   6.910 +val zero_int : IntInf.int = (0 : IntInf.int);
   6.911 +
   6.912 +type 'a zero = {zero : 'a};
   6.913 +val zero = #zero : 'a zero -> 'a;
   6.914 +
   6.915 +val zero_inta = {zero = zero_int} : IntInf.int zero;
   6.916 +
   6.917 +type 'a times = {times : 'a -> 'a -> 'a};
   6.918 +val times = #times : 'a times -> 'a -> 'a -> 'a;
   6.919 +
   6.920 +type 'a no_zero_divisors =
   6.921 +  {times_no_zero_divisors : 'a times, zero_no_zero_divisors : 'a zero};
   6.922 +val times_no_zero_divisors = #times_no_zero_divisors :
   6.923 +  'a no_zero_divisors -> 'a times;
   6.924 +val zero_no_zero_divisors = #zero_no_zero_divisors :
   6.925 +  'a no_zero_divisors -> 'a zero;
   6.926 +
   6.927 +val times_int = {times = (fn a => fn b => IntInf.* (a, b))} : IntInf.int times;
   6.928 +
   6.929 +val no_zero_divisors_int =
   6.930 +  {times_no_zero_divisors = times_int, zero_no_zero_divisors = zero_inta} :
   6.931 +  IntInf.int no_zero_divisors;
   6.932 +
   6.933 +type 'a one = {one : 'a};
   6.934 +val one = #one : 'a one -> 'a;
   6.935 +
   6.936 +type 'a zero_neq_one = {one_zero_neq_one : 'a one, zero_zero_neq_one : 'a zero};
   6.937 +val one_zero_neq_one = #one_zero_neq_one : 'a zero_neq_one -> 'a one;
   6.938 +val zero_zero_neq_one = #zero_zero_neq_one : 'a zero_neq_one -> 'a zero;
   6.939 +
   6.940 +type 'a semigroup_mult = {times_semigroup_mult : 'a times};
   6.941 +val times_semigroup_mult = #times_semigroup_mult :
   6.942 +  'a semigroup_mult -> 'a times;
   6.943 +
   6.944 +type 'a plus = {plus : 'a -> 'a -> 'a};
   6.945 +val plus = #plus : 'a plus -> 'a -> 'a -> 'a;
   6.946 +
   6.947 +type 'a semigroup_add = {plus_semigroup_add : 'a plus};
   6.948 +val plus_semigroup_add = #plus_semigroup_add : 'a semigroup_add -> 'a plus;
   6.949 +
   6.950 +type 'a ab_semigroup_add = {semigroup_add_ab_semigroup_add : 'a semigroup_add};
   6.951 +val semigroup_add_ab_semigroup_add = #semigroup_add_ab_semigroup_add :
   6.952 +  'a ab_semigroup_add -> 'a semigroup_add;
   6.953 +
   6.954 +type 'a semiring =
   6.955 +  {ab_semigroup_add_semiring : 'a ab_semigroup_add,
   6.956 +    semigroup_mult_semiring : 'a semigroup_mult};
   6.957 +val ab_semigroup_add_semiring = #ab_semigroup_add_semiring :
   6.958 +  'a semiring -> 'a ab_semigroup_add;
   6.959 +val semigroup_mult_semiring = #semigroup_mult_semiring :
   6.960 +  'a semiring -> 'a semigroup_mult;
   6.961 +
   6.962 +type 'a mult_zero = {times_mult_zero : 'a times, zero_mult_zero : 'a zero};
   6.963 +val times_mult_zero = #times_mult_zero : 'a mult_zero -> 'a times;
   6.964 +val zero_mult_zero = #zero_mult_zero : 'a mult_zero -> 'a zero;
   6.965 +
   6.966 +type 'a monoid_add =
   6.967 +  {semigroup_add_monoid_add : 'a semigroup_add, zero_monoid_add : 'a zero};
   6.968 +val semigroup_add_monoid_add = #semigroup_add_monoid_add :
   6.969 +  'a monoid_add -> 'a semigroup_add;
   6.970 +val zero_monoid_add = #zero_monoid_add : 'a monoid_add -> 'a zero;
   6.971 +
   6.972 +type 'a comm_monoid_add =
   6.973 +  {ab_semigroup_add_comm_monoid_add : 'a ab_semigroup_add,
   6.974 +    monoid_add_comm_monoid_add : 'a monoid_add};
   6.975 +val ab_semigroup_add_comm_monoid_add = #ab_semigroup_add_comm_monoid_add :
   6.976 +  'a comm_monoid_add -> 'a ab_semigroup_add;
   6.977 +val monoid_add_comm_monoid_add = #monoid_add_comm_monoid_add :
   6.978 +  'a comm_monoid_add -> 'a monoid_add;
   6.979 +
   6.980 +type 'a semiring_0 =
   6.981 +  {comm_monoid_add_semiring_0 : 'a comm_monoid_add,
   6.982 +    mult_zero_semiring_0 : 'a mult_zero, semiring_semiring_0 : 'a semiring};
   6.983 +val comm_monoid_add_semiring_0 = #comm_monoid_add_semiring_0 :
   6.984 +  'a semiring_0 -> 'a comm_monoid_add;
   6.985 +val mult_zero_semiring_0 = #mult_zero_semiring_0 :
   6.986 +  'a semiring_0 -> 'a mult_zero;
   6.987 +val semiring_semiring_0 = #semiring_semiring_0 : 'a semiring_0 -> 'a semiring;
   6.988 +
   6.989 +type 'a power = {one_power : 'a one, times_power : 'a times};
   6.990 +val one_power = #one_power : 'a power -> 'a one;
   6.991 +val times_power = #times_power : 'a power -> 'a times;
   6.992 +
   6.993 +type 'a monoid_mult =
   6.994 +  {semigroup_mult_monoid_mult : 'a semigroup_mult,
   6.995 +    power_monoid_mult : 'a power};
   6.996 +val semigroup_mult_monoid_mult = #semigroup_mult_monoid_mult :
   6.997 +  'a monoid_mult -> 'a semigroup_mult;
   6.998 +val power_monoid_mult = #power_monoid_mult : 'a monoid_mult -> 'a power;
   6.999 +
  6.1000 +type 'a semiring_1 =
  6.1001 +  {monoid_mult_semiring_1 : 'a monoid_mult,
  6.1002 +    semiring_0_semiring_1 : 'a semiring_0,
  6.1003 +    zero_neq_one_semiring_1 : 'a zero_neq_one};
  6.1004 +val monoid_mult_semiring_1 = #monoid_mult_semiring_1 :
  6.1005 +  'a semiring_1 -> 'a monoid_mult;
  6.1006 +val semiring_0_semiring_1 = #semiring_0_semiring_1 :
  6.1007 +  'a semiring_1 -> 'a semiring_0;
  6.1008 +val zero_neq_one_semiring_1 = #zero_neq_one_semiring_1 :
  6.1009 +  'a semiring_1 -> 'a zero_neq_one;
  6.1010 +
  6.1011 +type 'a cancel_semigroup_add =
  6.1012 +  {semigroup_add_cancel_semigroup_add : 'a semigroup_add};
  6.1013 +val semigroup_add_cancel_semigroup_add = #semigroup_add_cancel_semigroup_add :
  6.1014 +  'a cancel_semigroup_add -> 'a semigroup_add;
  6.1015 +
  6.1016 +type 'a cancel_ab_semigroup_add =
  6.1017 +  {ab_semigroup_add_cancel_ab_semigroup_add : 'a ab_semigroup_add,
  6.1018 +    cancel_semigroup_add_cancel_ab_semigroup_add : 'a cancel_semigroup_add};
  6.1019 +val ab_semigroup_add_cancel_ab_semigroup_add =
  6.1020 +  #ab_semigroup_add_cancel_ab_semigroup_add :
  6.1021 +  'a cancel_ab_semigroup_add -> 'a ab_semigroup_add;
  6.1022 +val cancel_semigroup_add_cancel_ab_semigroup_add =
  6.1023 +  #cancel_semigroup_add_cancel_ab_semigroup_add :
  6.1024 +  'a cancel_ab_semigroup_add -> 'a cancel_semigroup_add;
  6.1025 +
  6.1026 +type 'a cancel_comm_monoid_add =
  6.1027 +  {cancel_ab_semigroup_add_cancel_comm_monoid_add : 'a cancel_ab_semigroup_add,
  6.1028 +    comm_monoid_add_cancel_comm_monoid_add : 'a comm_monoid_add};
  6.1029 +val cancel_ab_semigroup_add_cancel_comm_monoid_add =
  6.1030 +  #cancel_ab_semigroup_add_cancel_comm_monoid_add :
  6.1031 +  'a cancel_comm_monoid_add -> 'a cancel_ab_semigroup_add;
  6.1032 +val comm_monoid_add_cancel_comm_monoid_add =
  6.1033 +  #comm_monoid_add_cancel_comm_monoid_add :
  6.1034 +  'a cancel_comm_monoid_add -> 'a comm_monoid_add;
  6.1035 +
  6.1036 +type 'a semiring_0_cancel =
  6.1037 +  {cancel_comm_monoid_add_semiring_0_cancel : 'a cancel_comm_monoid_add,
  6.1038 +    semiring_0_semiring_0_cancel : 'a semiring_0};
  6.1039 +val cancel_comm_monoid_add_semiring_0_cancel =
  6.1040 +  #cancel_comm_monoid_add_semiring_0_cancel :
  6.1041 +  'a semiring_0_cancel -> 'a cancel_comm_monoid_add;
  6.1042 +val semiring_0_semiring_0_cancel = #semiring_0_semiring_0_cancel :
  6.1043 +  'a semiring_0_cancel -> 'a semiring_0;
  6.1044 +
  6.1045 +type 'a semiring_1_cancel =
  6.1046 +  {semiring_0_cancel_semiring_1_cancel : 'a semiring_0_cancel,
  6.1047 +    semiring_1_semiring_1_cancel : 'a semiring_1};
  6.1048 +val semiring_0_cancel_semiring_1_cancel = #semiring_0_cancel_semiring_1_cancel :
  6.1049 +  'a semiring_1_cancel -> 'a semiring_0_cancel;
  6.1050 +val semiring_1_semiring_1_cancel = #semiring_1_semiring_1_cancel :
  6.1051 +  'a semiring_1_cancel -> 'a semiring_1;
  6.1052 +
  6.1053 +type 'a dvd = {times_dvd : 'a times};
  6.1054 +val times_dvd = #times_dvd : 'a dvd -> 'a times;
  6.1055 +
  6.1056 +type 'a ab_semigroup_mult =
  6.1057 +  {semigroup_mult_ab_semigroup_mult : 'a semigroup_mult};
  6.1058 +val semigroup_mult_ab_semigroup_mult = #semigroup_mult_ab_semigroup_mult :
  6.1059 +  'a ab_semigroup_mult -> 'a semigroup_mult;
  6.1060 +
  6.1061 +type 'a comm_semiring =
  6.1062 +  {ab_semigroup_mult_comm_semiring : 'a ab_semigroup_mult,
  6.1063 +    semiring_comm_semiring : 'a semiring};
  6.1064 +val ab_semigroup_mult_comm_semiring = #ab_semigroup_mult_comm_semiring :
  6.1065 +  'a comm_semiring -> 'a ab_semigroup_mult;
  6.1066 +val semiring_comm_semiring = #semiring_comm_semiring :
  6.1067 +  'a comm_semiring -> 'a semiring;
  6.1068 +
  6.1069 +type 'a comm_semiring_0 =
  6.1070 +  {comm_semiring_comm_semiring_0 : 'a comm_semiring,
  6.1071 +    semiring_0_comm_semiring_0 : 'a semiring_0};
  6.1072 +val comm_semiring_comm_semiring_0 = #comm_semiring_comm_semiring_0 :
  6.1073 +  'a comm_semiring_0 -> 'a comm_semiring;
  6.1074 +val semiring_0_comm_semiring_0 = #semiring_0_comm_semiring_0 :
  6.1075 +  'a comm_semiring_0 -> 'a semiring_0;
  6.1076 +
  6.1077 +type 'a comm_monoid_mult =
  6.1078 +  {ab_semigroup_mult_comm_monoid_mult : 'a ab_semigroup_mult,
  6.1079 +    monoid_mult_comm_monoid_mult : 'a monoid_mult};
  6.1080 +val ab_semigroup_mult_comm_monoid_mult = #ab_semigroup_mult_comm_monoid_mult :
  6.1081 +  'a comm_monoid_mult -> 'a ab_semigroup_mult;
  6.1082 +val monoid_mult_comm_monoid_mult = #monoid_mult_comm_monoid_mult :
  6.1083 +  'a comm_monoid_mult -> 'a monoid_mult;
  6.1084 +
  6.1085 +type 'a comm_semiring_1 =
  6.1086 +  {comm_monoid_mult_comm_semiring_1 : 'a comm_monoid_mult,
  6.1087 +    comm_semiring_0_comm_semiring_1 : 'a comm_semiring_0,
  6.1088 +    dvd_comm_semiring_1 : 'a dvd, semiring_1_comm_semiring_1 : 'a semiring_1};
  6.1089 +val comm_monoid_mult_comm_semiring_1 = #comm_monoid_mult_comm_semiring_1 :
  6.1090 +  'a comm_semiring_1 -> 'a comm_monoid_mult;
  6.1091 +val comm_semiring_0_comm_semiring_1 = #comm_semiring_0_comm_semiring_1 :
  6.1092 +  'a comm_semiring_1 -> 'a comm_semiring_0;
  6.1093 +val dvd_comm_semiring_1 = #dvd_comm_semiring_1 : 'a comm_semiring_1 -> 'a dvd;
  6.1094 +val semiring_1_comm_semiring_1 = #semiring_1_comm_semiring_1 :
  6.1095 +  'a comm_semiring_1 -> 'a semiring_1;
  6.1096 +
  6.1097 +type 'a comm_semiring_0_cancel =
  6.1098 +  {comm_semiring_0_comm_semiring_0_cancel : 'a comm_semiring_0,
  6.1099 +    semiring_0_cancel_comm_semiring_0_cancel : 'a semiring_0_cancel};
  6.1100 +val comm_semiring_0_comm_semiring_0_cancel =
  6.1101 +  #comm_semiring_0_comm_semiring_0_cancel :
  6.1102 +  'a comm_semiring_0_cancel -> 'a comm_semiring_0;
  6.1103 +val semiring_0_cancel_comm_semiring_0_cancel =
  6.1104 +  #semiring_0_cancel_comm_semiring_0_cancel :
  6.1105 +  'a comm_semiring_0_cancel -> 'a semiring_0_cancel;
  6.1106 +
  6.1107 +type 'a comm_semiring_1_cancel =
  6.1108 +  {comm_semiring_0_cancel_comm_semiring_1_cancel : 'a comm_semiring_0_cancel,
  6.1109 +    comm_semiring_1_comm_semiring_1_cancel : 'a comm_semiring_1,
  6.1110 +    semiring_1_cancel_comm_semiring_1_cancel : 'a semiring_1_cancel};
  6.1111 +val comm_semiring_0_cancel_comm_semiring_1_cancel =
  6.1112 +  #comm_semiring_0_cancel_comm_semiring_1_cancel :
  6.1113 +  'a comm_semiring_1_cancel -> 'a comm_semiring_0_cancel;
  6.1114 +val comm_semiring_1_comm_semiring_1_cancel =
  6.1115 +  #comm_semiring_1_comm_semiring_1_cancel :
  6.1116 +  'a comm_semiring_1_cancel -> 'a comm_semiring_1;
  6.1117 +val semiring_1_cancel_comm_semiring_1_cancel =
  6.1118 +  #semiring_1_cancel_comm_semiring_1_cancel :
  6.1119 +  'a comm_semiring_1_cancel -> 'a semiring_1_cancel;
  6.1120 +
  6.1121 +type 'a diva = {dvd_div : 'a dvd, diva : 'a -> 'a -> 'a, moda : 'a -> 'a -> 'a};
  6.1122 +val dvd_div = #dvd_div : 'a diva -> 'a dvd;
  6.1123 +val diva = #diva : 'a diva -> 'a -> 'a -> 'a;
  6.1124 +val moda = #moda : 'a diva -> 'a -> 'a -> 'a;
  6.1125 +
  6.1126 +type 'a semiring_div =
  6.1127 +  {div_semiring_div : 'a diva,
  6.1128 +    comm_semiring_1_cancel_semiring_div : 'a comm_semiring_1_cancel,
  6.1129 +    no_zero_divisors_semiring_div : 'a no_zero_divisors};
  6.1130 +val div_semiring_div = #div_semiring_div : 'a semiring_div -> 'a diva;
  6.1131 +val comm_semiring_1_cancel_semiring_div = #comm_semiring_1_cancel_semiring_div :
  6.1132 +  'a semiring_div -> 'a comm_semiring_1_cancel;
  6.1133 +val no_zero_divisors_semiring_div = #no_zero_divisors_semiring_div :
  6.1134 +  'a semiring_div -> 'a no_zero_divisors;
  6.1135 +
  6.1136 +val one_int : IntInf.int = (1 : IntInf.int);
  6.1137 +
  6.1138 +val one_inta = {one = one_int} : IntInf.int one;
  6.1139 +
  6.1140 +val zero_neq_one_int =
  6.1141 +  {one_zero_neq_one = one_inta, zero_zero_neq_one = zero_inta} :
  6.1142 +  IntInf.int zero_neq_one;
  6.1143 +
  6.1144 +val semigroup_mult_int = {times_semigroup_mult = times_int} :
  6.1145 +  IntInf.int semigroup_mult;
  6.1146 +
  6.1147 +val plus_int = {plus = (fn a => fn b => IntInf.+ (a, b))} : IntInf.int plus;
  6.1148 +
  6.1149 +val semigroup_add_int = {plus_semigroup_add = plus_int} :
  6.1150 +  IntInf.int semigroup_add;
  6.1151 +
  6.1152 +val ab_semigroup_add_int = {semigroup_add_ab_semigroup_add = semigroup_add_int}
  6.1153 +  : IntInf.int ab_semigroup_add;
  6.1154 +
  6.1155 +val semiring_int =
  6.1156 +  {ab_semigroup_add_semiring = ab_semigroup_add_int,
  6.1157 +    semigroup_mult_semiring = semigroup_mult_int}
  6.1158 +  : IntInf.int semiring;
  6.1159 +
  6.1160 +val mult_zero_int = {times_mult_zero = times_int, zero_mult_zero = zero_inta} :
  6.1161 +  IntInf.int mult_zero;
  6.1162 +
  6.1163 +val monoid_add_int =
  6.1164 +  {semigroup_add_monoid_add = semigroup_add_int, zero_monoid_add = zero_inta} :
  6.1165 +  IntInf.int monoid_add;
  6.1166 +
  6.1167 +val comm_monoid_add_int =
  6.1168 +  {ab_semigroup_add_comm_monoid_add = ab_semigroup_add_int,
  6.1169 +    monoid_add_comm_monoid_add = monoid_add_int}
  6.1170 +  : IntInf.int comm_monoid_add;
  6.1171 +
  6.1172 +val semiring_0_int =
  6.1173 +  {comm_monoid_add_semiring_0 = comm_monoid_add_int,
  6.1174 +    mult_zero_semiring_0 = mult_zero_int, semiring_semiring_0 = semiring_int}
  6.1175 +  : IntInf.int semiring_0;
  6.1176 +
  6.1177 +val power_int = {one_power = one_inta, times_power = times_int} :
  6.1178 +  IntInf.int power;
  6.1179 +
  6.1180 +val monoid_mult_int =
  6.1181 +  {semigroup_mult_monoid_mult = semigroup_mult_int,
  6.1182 +    power_monoid_mult = power_int}
  6.1183 +  : IntInf.int monoid_mult;
  6.1184 +
  6.1185 +val semiring_1_int =
  6.1186 +  {monoid_mult_semiring_1 = monoid_mult_int,
  6.1187 +    semiring_0_semiring_1 = semiring_0_int,
  6.1188 +    zero_neq_one_semiring_1 = zero_neq_one_int}
  6.1189 +  : IntInf.int semiring_1;
  6.1190 +
  6.1191 +val cancel_semigroup_add_int =
  6.1192 +  {semigroup_add_cancel_semigroup_add = semigroup_add_int} :
  6.1193 +  IntInf.int cancel_semigroup_add;
  6.1194 +
  6.1195 +val cancel_ab_semigroup_add_int =
  6.1196 +  {ab_semigroup_add_cancel_ab_semigroup_add = ab_semigroup_add_int,
  6.1197 +    cancel_semigroup_add_cancel_ab_semigroup_add = cancel_semigroup_add_int}
  6.1198 +  : IntInf.int cancel_ab_semigroup_add;
  6.1199 +
  6.1200 +val cancel_comm_monoid_add_int =
  6.1201 +  {cancel_ab_semigroup_add_cancel_comm_monoid_add = cancel_ab_semigroup_add_int,
  6.1202 +    comm_monoid_add_cancel_comm_monoid_add = comm_monoid_add_int}
  6.1203 +  : IntInf.int cancel_comm_monoid_add;
  6.1204 +
  6.1205 +val semiring_0_cancel_int =
  6.1206 +  {cancel_comm_monoid_add_semiring_0_cancel = cancel_comm_monoid_add_int,
  6.1207 +    semiring_0_semiring_0_cancel = semiring_0_int}
  6.1208 +  : IntInf.int semiring_0_cancel;
  6.1209 +
  6.1210 +val semiring_1_cancel_int =
  6.1211 +  {semiring_0_cancel_semiring_1_cancel = semiring_0_cancel_int,
  6.1212 +    semiring_1_semiring_1_cancel = semiring_1_int}
  6.1213 +  : IntInf.int semiring_1_cancel;
  6.1214 +
  6.1215 +val dvd_int = {times_dvd = times_int} : IntInf.int dvd;
  6.1216 +
  6.1217 +val ab_semigroup_mult_int =
  6.1218 +  {semigroup_mult_ab_semigroup_mult = semigroup_mult_int} :
  6.1219 +  IntInf.int ab_semigroup_mult;
  6.1220 +
  6.1221 +val comm_semiring_int =
  6.1222 +  {ab_semigroup_mult_comm_semiring = ab_semigroup_mult_int,
  6.1223 +    semiring_comm_semiring = semiring_int}
  6.1224 +  : IntInf.int comm_semiring;
  6.1225 +
  6.1226 +val comm_semiring_0_int =
  6.1227 +  {comm_semiring_comm_semiring_0 = comm_semiring_int,
  6.1228 +    semiring_0_comm_semiring_0 = semiring_0_int}
  6.1229 +  : IntInf.int comm_semiring_0;
  6.1230 +
  6.1231 +val comm_monoid_mult_int =
  6.1232 +  {ab_semigroup_mult_comm_monoid_mult = ab_semigroup_mult_int,
  6.1233 +    monoid_mult_comm_monoid_mult = monoid_mult_int}
  6.1234 +  : IntInf.int comm_monoid_mult;
  6.1235 +
  6.1236 +val comm_semiring_1_int =
  6.1237 +  {comm_monoid_mult_comm_semiring_1 = comm_monoid_mult_int,
  6.1238 +    comm_semiring_0_comm_semiring_1 = comm_semiring_0_int,
  6.1239 +    dvd_comm_semiring_1 = dvd_int, semiring_1_comm_semiring_1 = semiring_1_int}
  6.1240 +  : IntInf.int comm_semiring_1;
  6.1241 +
  6.1242 +val comm_semiring_0_cancel_int =
  6.1243 +  {comm_semiring_0_comm_semiring_0_cancel = comm_semiring_0_int,
  6.1244 +    semiring_0_cancel_comm_semiring_0_cancel = semiring_0_cancel_int}
  6.1245 +  : IntInf.int comm_semiring_0_cancel;
  6.1246 +
  6.1247 +val comm_semiring_1_cancel_int =
  6.1248 +  {comm_semiring_0_cancel_comm_semiring_1_cancel = comm_semiring_0_cancel_int,
  6.1249 +    comm_semiring_1_comm_semiring_1_cancel = comm_semiring_1_int,
  6.1250 +    semiring_1_cancel_comm_semiring_1_cancel = semiring_1_cancel_int}
  6.1251 +  : IntInf.int comm_semiring_1_cancel;
  6.1252 +
  6.1253 +fun abs_int i = (if IntInf.< (i, (0 : IntInf.int)) then IntInf.~ i else i);
  6.1254 +
  6.1255 +fun split f (a, b) = f a b;
  6.1256 +
  6.1257 +fun sgn_int i =
  6.1258 +  (if ((i : IntInf.int) = (0 : IntInf.int)) then (0 : IntInf.int)
  6.1259 +    else (if IntInf.< ((0 : IntInf.int), i) then (1 : IntInf.int)
  6.1260 +           else IntInf.~ (1 : IntInf.int)));
  6.1261 +
  6.1262 +fun apsnd f (x, y) = (x, f y);
  6.1263 +
  6.1264 +fun divmod_int k l =
  6.1265 +  (if ((k : IntInf.int) = (0 : IntInf.int))
  6.1266 +    then ((0 : IntInf.int), (0 : IntInf.int))
  6.1267 +    else (if ((l : IntInf.int) = (0 : IntInf.int)) then ((0 : IntInf.int), k)
  6.1268 +           else apsnd (fn a => IntInf.* (sgn_int l, a))
  6.1269 +                  (if (((sgn_int k) : IntInf.int) = (sgn_int l))
  6.1270 +                    then IntInf.divMod (IntInf.abs k, IntInf.abs l)
  6.1271 +                    else let
  6.1272 +                           val (r, s) =
  6.1273 +                             IntInf.divMod (IntInf.abs k, IntInf.abs l);
  6.1274 +                         in
  6.1275 +                           (if ((s : IntInf.int) = (0 : IntInf.int))
  6.1276 +                             then (IntInf.~ r, (0 : IntInf.int))
  6.1277 +                             else (IntInf.- (IntInf.~ r, (1 : IntInf.int)),
  6.1278 +                                    IntInf.- (abs_int l, s)))
  6.1279 +                         end)));
  6.1280 +
  6.1281 +fun snd (a, b) = b;
  6.1282 +
  6.1283 +fun mod_int a b = snd (divmod_int a b);
  6.1284 +
  6.1285 +fun fst (a, b) = a;
  6.1286 +
  6.1287 +fun div_int a b = fst (divmod_int a b);
  6.1288 +
  6.1289 +val div_inta = {dvd_div = dvd_int, diva = div_int, moda = mod_int} :
  6.1290 +  IntInf.int diva;
  6.1291 +
  6.1292 +val semiring_div_int =
  6.1293 +  {div_semiring_div = div_inta,
  6.1294 +    comm_semiring_1_cancel_semiring_div = comm_semiring_1_cancel_int,
  6.1295 +    no_zero_divisors_semiring_div = no_zero_divisors_int}
  6.1296 +  : IntInf.int semiring_div;
  6.1297 +
  6.1298 +fun dvd (A1_, A2_) a b =
  6.1299 +  eqa A2_ (moda (div_semiring_div A1_) b a)
  6.1300 +    (zero ((zero_no_zero_divisors o no_zero_divisors_semiring_div) A1_));
  6.1301 +
  6.1302 +fun num_case f1 f2 f3 f4 f5 f6 f7 (Mul (inta, num)) = f7 inta num
  6.1303 +  | num_case f1 f2 f3 f4 f5 f6 f7 (Sub (num1, num2)) = f6 num1 num2
  6.1304 +  | num_case f1 f2 f3 f4 f5 f6 f7 (Add (num1, num2)) = f5 num1 num2
  6.1305 +  | num_case f1 f2 f3 f4 f5 f6 f7 (Neg num) = f4 num
  6.1306 +  | num_case f1 f2 f3 f4 f5 f6 f7 (Cn (nat, inta, num)) = f3 nat inta num
  6.1307 +  | num_case f1 f2 f3 f4 f5 f6 f7 (Bound nat) = f2 nat
  6.1308 +  | num_case f1 f2 f3 f4 f5 f6 f7 (C inta) = f1 inta;
  6.1309 +
  6.1310 +fun nummul i (C j) = C (IntInf.* (i, j))
  6.1311 +  | nummul i (Cn (n, c, t)) = Cn (n, IntInf.* (c, i), nummul i t)
  6.1312 +  | nummul i (Bound v) = Mul (i, Bound v)
  6.1313 +  | nummul i (Neg v) = Mul (i, Neg v)
  6.1314 +  | nummul i (Add (v, va)) = Mul (i, Add (v, va))
  6.1315 +  | nummul i (Sub (v, va)) = Mul (i, Sub (v, va))
  6.1316 +  | nummul i (Mul (v, va)) = Mul (i, Mul (v, va));
  6.1317 +
  6.1318 +fun numneg t = nummul (IntInf.~ (1 : IntInf.int)) t;
  6.1319 +
  6.1320 +fun numadd (Cn (n1, c1, r1), Cn (n2, c2, r2)) =
  6.1321 +  (if ((n1 : IntInf.int) = n2)
  6.1322 +    then let
  6.1323 +           val c = IntInf.+ (c1, c2);
  6.1324 +         in
  6.1325 +           (if ((c : IntInf.int) = (0 : IntInf.int)) then numadd (r1, r2)
  6.1326 +             else Cn (n1, c, numadd (r1, r2)))
  6.1327 +         end
  6.1328 +    else (if IntInf.<= (n1, n2)
  6.1329 +           then Cn (n1, c1, numadd (r1, Add (Mul (c2, Bound n2), r2)))
  6.1330 +           else Cn (n2, c2, numadd (Add (Mul (c1, Bound n1), r1), r2))))
  6.1331 +  | numadd (Cn (n1, c1, r1), C dd) = Cn (n1, c1, numadd (r1, C dd))
  6.1332 +  | numadd (Cn (n1, c1, r1), Bound de) = Cn (n1, c1, numadd (r1, Bound de))
  6.1333 +  | numadd (Cn (n1, c1, r1), Neg di) = Cn (n1, c1, numadd (r1, Neg di))
  6.1334 +  | numadd (Cn (n1, c1, r1), Add (dj, dk)) =
  6.1335 +    Cn (n1, c1, numadd (r1, Add (dj, dk)))
  6.1336 +  | numadd (Cn (n1, c1, r1), Sub (dl, dm)) =
  6.1337 +    Cn (n1, c1, numadd (r1, Sub (dl, dm)))
  6.1338 +  | numadd (Cn (n1, c1, r1), Mul (dn, doa)) =
  6.1339 +    Cn (n1, c1, numadd (r1, Mul (dn, doa)))
  6.1340 +  | numadd (C w, Cn (n2, c2, r2)) = Cn (n2, c2, numadd (C w, r2))
  6.1341 +  | numadd (Bound x, Cn (n2, c2, r2)) = Cn (n2, c2, numadd (Bound x, r2))
  6.1342 +  | numadd (Neg ac, Cn (n2, c2, r2)) = Cn (n2, c2, numadd (Neg ac, r2))
  6.1343 +  | numadd (Add (ad, ae), Cn (n2, c2, r2)) =
  6.1344 +    Cn (n2, c2, numadd (Add (ad, ae), r2))
  6.1345 +  | numadd (Sub (af, ag), Cn (n2, c2, r2)) =
  6.1346 +    Cn (n2, c2, numadd (Sub (af, ag), r2))
  6.1347 +  | numadd (Mul (ah, ai), Cn (n2, c2, r2)) =
  6.1348 +    Cn (n2, c2, numadd (Mul (ah, ai), r2))
  6.1349 +  | numadd (C b1, C b2) = C (IntInf.+ (b1, b2))
  6.1350 +  | numadd (C aj, Bound bi) = Add (C aj, Bound bi)
  6.1351 +  | numadd (C aj, Neg bm) = Add (C aj, Neg bm)
  6.1352 +  | numadd (C aj, Add (bn, bo)) = Add (C aj, Add (bn, bo))
  6.1353 +  | numadd (C aj, Sub (bp, bq)) = Add (C aj, Sub (bp, bq))
  6.1354 +  | numadd (C aj, Mul (br, bs)) = Add (C aj, Mul (br, bs))
  6.1355 +  | numadd (Bound ak, C cf) = Add (Bound ak, C cf)
  6.1356 +  | numadd (Bound ak, Bound cg) = Add (Bound ak, Bound cg)
  6.1357 +  | numadd (Bound ak, Neg ck) = Add (Bound ak, Neg ck)
  6.1358 +  | numadd (Bound ak, Add (cl, cm)) = Add (Bound ak, Add (cl, cm))
  6.1359 +  | numadd (Bound ak, Sub (cn, co)) = Add (Bound ak, Sub (cn, co))
  6.1360 +  | numadd (Bound ak, Mul (cp, cq)) = Add (Bound ak, Mul (cp, cq))
  6.1361 +  | numadd (Neg ao, C en) = Add (Neg ao, C en)
  6.1362 +  | numadd (Neg ao, Bound eo) = Add (Neg ao, Bound eo)
  6.1363 +  | numadd (Neg ao, Neg es) = Add (Neg ao, Neg es)
  6.1364 +  | numadd (Neg ao, Add (et, eu)) = Add (Neg ao, Add (et, eu))
  6.1365 +  | numadd (Neg ao, Sub (ev, ew)) = Add (Neg ao, Sub (ev, ew))
  6.1366 +  | numadd (Neg ao, Mul (ex, ey)) = Add (Neg ao, Mul (ex, ey))
  6.1367 +  | numadd (Add (ap, aq), C fl) = Add (Add (ap, aq), C fl)
  6.1368 +  | numadd (Add (ap, aq), Bound fm) = Add (Add (ap, aq), Bound fm)
  6.1369 +  | numadd (Add (ap, aq), Neg fq) = Add (Add (ap, aq), Neg fq)
  6.1370 +  | numadd (Add (ap, aq), Add (fr, fs)) = Add (Add (ap, aq), Add (fr, fs))
  6.1371 +  | numadd (Add (ap, aq), Sub (ft, fu)) = Add (Add (ap, aq), Sub (ft, fu))
  6.1372 +  | numadd (Add (ap, aq), Mul (fv, fw)) = Add (Add (ap, aq), Mul (fv, fw))
  6.1373 +  | numadd (Sub (ar, asa), C gj) = Add (Sub (ar, asa), C gj)
  6.1374 +  | numadd (Sub (ar, asa), Bound gk) = Add (Sub (ar, asa), Bound gk)
  6.1375 +  | numadd (Sub (ar, asa), Neg go) = Add (Sub (ar, asa), Neg go)
  6.1376 +  | numadd (Sub (ar, asa), Add (gp, gq)) = Add (Sub (ar, asa), Add (gp, gq))
  6.1377 +  | numadd (Sub (ar, asa), Sub (gr, gs)) = Add (Sub (ar, asa), Sub (gr, gs))
  6.1378 +  | numadd (Sub (ar, asa), Mul (gt, gu)) = Add (Sub (ar, asa), Mul (gt, gu))
  6.1379 +  | numadd (Mul (at, au), C hh) = Add (Mul (at, au), C hh)
  6.1380 +  | numadd (Mul (at, au), Bound hi) = Add (Mul (at, au), Bound hi)
  6.1381 +  | numadd (Mul (at, au), Neg hm) = Add (Mul (at, au), Neg hm)
  6.1382 +  | numadd (Mul (at, au), Add (hn, ho)) = Add (Mul (at, au), Add (hn, ho))
  6.1383 +  | numadd (Mul (at, au), Sub (hp, hq)) = Add (Mul (at, au), Sub (hp, hq))
  6.1384 +  | numadd (Mul (at, au), Mul (hr, hs)) = Add (Mul (at, au), Mul (hr, hs));
  6.1385 +
  6.1386 +fun numsub s t =
  6.1387 +  (if eq_num s t then C (0 : IntInf.int) else numadd (s, numneg t));
  6.1388 +
  6.1389 +fun simpnum (C j) = C j
  6.1390 +  | simpnum (Bound n) = Cn (n, (1 : IntInf.int), C (0 : IntInf.int))
  6.1391 +  | simpnum (Neg t) = numneg (simpnum t)
  6.1392 +  | simpnum (Add (t, s)) = numadd (simpnum t, simpnum s)
  6.1393 +  | simpnum (Sub (t, s)) = numsub (simpnum t) (simpnum s)
  6.1394 +  | simpnum (Mul (i, t)) =
  6.1395 +    (if ((i : IntInf.int) = (0 : IntInf.int)) then C (0 : IntInf.int)
  6.1396 +      else nummul i (simpnum t))
  6.1397 +  | simpnum (Cn (v, va, vb)) = Cn (v, va, vb);
  6.1398 +
  6.1399 +fun nota (Not p) = p
  6.1400 +  | nota T = F
  6.1401 +  | nota F = T
  6.1402 +  | nota (Lt v) = Not (Lt v)
  6.1403 +  | nota (Le v) = Not (Le v)
  6.1404 +  | nota (Gt v) = Not (Gt v)
  6.1405 +  | nota (Ge v) = Not (Ge v)
  6.1406 +  | nota (Eq v) = Not (Eq v)
  6.1407 +  | nota (NEq v) = Not (NEq v)
  6.1408 +  | nota (Dvd (v, va)) = Not (Dvd (v, va))
  6.1409 +  | nota (NDvd (v, va)) = Not (NDvd (v, va))
  6.1410 +  | nota (And (v, va)) = Not (And (v, va))
  6.1411 +  | nota (Or (v, va)) = Not (Or (v, va))
  6.1412 +  | nota (Imp (v, va)) = Not (Imp (v, va))
  6.1413 +  | nota (Iff (v, va)) = Not (Iff (v, va))
  6.1414 +  | nota (E v) = Not (E v)
  6.1415 +  | nota (A v) = Not (A v)
  6.1416 +  | nota (Closed v) = Not (Closed v)
  6.1417 +  | nota (NClosed v) = Not (NClosed v);
  6.1418 +
  6.1419 +fun iffa p q =
  6.1420 +  (if eq_fm p q then T
  6.1421 +    else (if eq_fm p (nota q) orelse eq_fm (nota p) q then F
  6.1422 +           else (if eq_fm p F then nota q
  6.1423 +                  else (if eq_fm q F then nota p
  6.1424 +                         else (if eq_fm p T then q
  6.1425 +                                else (if eq_fm q T then p else Iff (p, q)))))));
  6.1426 +
  6.1427 +fun impa p q =
  6.1428 +  (if eq_fm p F orelse eq_fm q T then T
  6.1429 +    else (if eq_fm p T then q else (if eq_fm q F then nota p else Imp (p, q))));
  6.1430 +
  6.1431 +fun conj p q =
  6.1432 +  (if eq_fm p F orelse eq_fm q F then F
  6.1433 +    else (if eq_fm p T then q else (if eq_fm q T then p else And (p, q))));
  6.1434 +
  6.1435 +fun simpfm (And (p, q)) = conj (simpfm p) (simpfm q)
  6.1436 +  | simpfm (Or (p, q)) = disj (simpfm p) (simpfm q)
  6.1437 +  | simpfm (Imp (p, q)) = impa (simpfm p) (simpfm q)
  6.1438 +  | simpfm (Iff (p, q)) = iffa (simpfm p) (simpfm q)
  6.1439 +  | simpfm (Not p) = nota (simpfm p)
  6.1440 +  | simpfm (Lt a) =
  6.1441 +    let
  6.1442 +      val aa = simpnum a;
  6.1443 +    in
  6.1444 +      (case aa of C v => (if IntInf.< (v, (0 : IntInf.int)) then T else F)
  6.1445 +        | Bound _ => Lt aa | Cn (_, _, _) => Lt aa | Neg _ => Lt aa
  6.1446 +        | Add (_, _) => Lt aa | Sub (_, _) => Lt aa | Mul (_, _) => Lt aa)
  6.1447 +    end
  6.1448 +  | simpfm (Le a) =
  6.1449 +    let
  6.1450 +      val aa = simpnum a;
  6.1451 +    in
  6.1452 +      (case aa of C v => (if IntInf.<= (v, (0 : IntInf.int)) then T else F)
  6.1453 +        | Bound _ => Le aa | Cn (_, _, _) => Le aa | Neg _ => Le aa
  6.1454 +        | Add (_, _) => Le aa | Sub (_, _) => Le aa | Mul (_, _) => Le aa)
  6.1455 +    end
  6.1456 +  | simpfm (Gt a) =
  6.1457 +    let
  6.1458 +      val aa = simpnum a;
  6.1459 +    in
  6.1460 +      (case aa of C v => (if IntInf.< ((0 : IntInf.int), v) then T else F)
  6.1461 +        | Bound _ => Gt aa | Cn (_, _, _) => Gt aa | Neg _ => Gt aa
  6.1462 +        | Add (_, _) => Gt aa | Sub (_, _) => Gt aa | Mul (_, _) => Gt aa)
  6.1463 +    end
  6.1464 +  | simpfm (Ge a) =
  6.1465 +    let
  6.1466 +      val aa = simpnum a;
  6.1467 +    in
  6.1468 +      (case aa of C v => (if IntInf.<= ((0 : IntInf.int), v) then T else F)
  6.1469 +        | Bound _ => Ge aa | Cn (_, _, _) => Ge aa | Neg _ => Ge aa
  6.1470 +        | Add (_, _) => Ge aa | Sub (_, _) => Ge aa | Mul (_, _) => Ge aa)
  6.1471 +    end
  6.1472 +  | simpfm (Eq a) =
  6.1473 +    let
  6.1474 +      val aa = simpnum a;
  6.1475 +    in
  6.1476 +      (case aa
  6.1477 +        of C v => (if ((v : IntInf.int) = (0 : IntInf.int)) then T else F)
  6.1478 +        | Bound _ => Eq aa | Cn (_, _, _) => Eq aa | Neg _ => Eq aa
  6.1479 +        | Add (_, _) => Eq aa | Sub (_, _) => Eq aa | Mul (_, _) => Eq aa)
  6.1480 +    end
  6.1481 +  | simpfm (NEq a) =
  6.1482 +    let
  6.1483 +      val aa = simpnum a;
  6.1484 +    in
  6.1485 +      (case aa
  6.1486 +        of C v => (if not ((v : IntInf.int) = (0 : IntInf.int)) then T else F)
  6.1487 +        | Bound _ => NEq aa | Cn (_, _, _) => NEq aa | Neg _ => NEq aa
  6.1488 +        | Add (_, _) => NEq aa | Sub (_, _) => NEq aa | Mul (_, _) => NEq aa)
  6.1489 +    end
  6.1490 +  | simpfm (Dvd (i, a)) =
  6.1491 +    (if ((i : IntInf.int) = (0 : IntInf.int)) then simpfm (Eq a)
  6.1492 +      else (if (((abs_int i) : IntInf.int) = (1 : IntInf.int)) then T
  6.1493 +             else let
  6.1494 +                    val aa = simpnum a;
  6.1495 +                  in
  6.1496 +                    (case aa
  6.1497 +                      of C v =>
  6.1498 +                        (if dvd (semiring_div_int, eq_int) i v then T else F)
  6.1499 +                      | Bound _ => Dvd (i, aa) | Cn (_, _, _) => Dvd (i, aa)
  6.1500 +                      | Neg _ => Dvd (i, aa) | Add (_, _) => Dvd (i, aa)
  6.1501 +                      | Sub (_, _) => Dvd (i, aa) | Mul (_, _) => Dvd (i, aa))
  6.1502 +                  end))
  6.1503 +  | simpfm (NDvd (i, a)) =
  6.1504 +    (if ((i : IntInf.int) = (0 : IntInf.int)) then simpfm (NEq a)
  6.1505 +      else (if (((abs_int i) : IntInf.int) = (1 : IntInf.int)) then F
  6.1506 +             else let
  6.1507 +                    val aa = simpnum a;
  6.1508 +                  in
  6.1509 +                    (case aa
  6.1510 +                      of C v =>
  6.1511 +                        (if not (dvd (semiring_div_int, eq_int) i v) then T
  6.1512 +                          else F)
  6.1513 +                      | Bound _ => NDvd (i, aa) | Cn (_, _, _) => NDvd (i, aa)
  6.1514 +                      | Neg _ => NDvd (i, aa) | Add (_, _) => NDvd (i, aa)
  6.1515 +                      | Sub (_, _) => NDvd (i, aa) | Mul (_, _) => NDvd (i, aa))
  6.1516 +                  end))
  6.1517 +  | simpfm T = T
  6.1518 +  | simpfm F = F
  6.1519 +  | simpfm (E v) = E v
  6.1520 +  | simpfm (A v) = A v
  6.1521 +  | simpfm (Closed v) = Closed v
  6.1522 +  | simpfm (NClosed v) = NClosed v;
  6.1523 +
  6.1524 +fun iupt i j =
  6.1525 +  (if IntInf.< (j, i) then []
  6.1526 +    else i :: iupt (IntInf.+ (i, (1 : IntInf.int))) j);
  6.1527 +
  6.1528 +fun mirror (And (p, q)) = And (mirror p, mirror q)
  6.1529 +  | mirror (Or (p, q)) = Or (mirror p, mirror q)
  6.1530 +  | mirror T = T
  6.1531 +  | mirror F = F
  6.1532 +  | mirror (Lt (C bo)) = Lt (C bo)
  6.1533 +  | mirror (Lt (Bound bp)) = Lt (Bound bp)
  6.1534 +  | mirror (Lt (Neg bt)) = Lt (Neg bt)
  6.1535 +  | mirror (Lt (Add (bu, bv))) = Lt (Add (bu, bv))
  6.1536 +  | mirror (Lt (Sub (bw, bx))) = Lt (Sub (bw, bx))
  6.1537 +  | mirror (Lt (Mul (by, bz))) = Lt (Mul (by, bz))
  6.1538 +  | mirror (Le (C co)) = Le (C co)
  6.1539 +  | mirror (Le (Bound cp)) = Le (Bound cp)
  6.1540 +  | mirror (Le (Neg ct)) = Le (Neg ct)
  6.1541 +  | mirror (Le (Add (cu, cv))) = Le (Add (cu, cv))
  6.1542 +  | mirror (Le (Sub (cw, cx))) = Le (Sub (cw, cx))
  6.1543 +  | mirror (Le (Mul (cy, cz))) = Le (Mul (cy, cz))
  6.1544 +  | mirror (Gt (C doa)) = Gt (C doa)
  6.1545 +  | mirror (Gt (Bound dp)) = Gt (Bound dp)
  6.1546 +  | mirror (Gt (Neg dt)) = Gt (Neg dt)
  6.1547 +  | mirror (Gt (Add (du, dv))) = Gt (Add (du, dv))
  6.1548 +  | mirror (Gt (Sub (dw, dx))) = Gt (Sub (dw, dx))
  6.1549 +  | mirror (Gt (Mul (dy, dz))) = Gt (Mul (dy, dz))
  6.1550 +  | mirror (Ge (C eo)) = Ge (C eo)
  6.1551 +  | mirror (Ge (Bound ep)) = Ge (Bound ep)
  6.1552 +  | mirror (Ge (Neg et)) = Ge (Neg et)
  6.1553 +  | mirror (Ge (Add (eu, ev))) = Ge (Add (eu, ev))
  6.1554 +  | mirror (Ge (Sub (ew, ex))) = Ge (Sub (ew, ex))
  6.1555 +  | mirror (Ge (Mul (ey, ez))) = Ge (Mul (ey, ez))
  6.1556 +  | mirror (Eq (C fo)) = Eq (C fo)
  6.1557 +  | mirror (Eq (Bound fp)) = Eq (Bound fp)
  6.1558 +  | mirror (Eq (Neg ft)) = Eq (Neg ft)
  6.1559 +  | mirror (Eq (Add (fu, fv))) = Eq (Add (fu, fv))
  6.1560 +  | mirror (Eq (Sub (fw, fx))) = Eq (Sub (fw, fx))
  6.1561 +  | mirror (Eq (Mul (fy, fz))) = Eq (Mul (fy, fz))
  6.1562 +  | mirror (NEq (C go)) = NEq (C go)
  6.1563 +  | mirror (NEq (Bound gp)) = NEq (Bound gp)
  6.1564 +  | mirror (NEq (Neg gt)) = NEq (Neg gt)
  6.1565 +  | mirror (NEq (Add (gu, gv))) = NEq (Add (gu, gv))
  6.1566 +  | mirror (NEq (Sub (gw, gx))) = NEq (Sub (gw, gx))
  6.1567 +  | mirror (NEq (Mul (gy, gz))) = NEq (Mul (gy, gz))
  6.1568 +  | mirror (Dvd (aa, C ho)) = Dvd (aa, C ho)
  6.1569 +  | mirror (Dvd (aa, Bound hp)) = Dvd (aa, Bound hp)
  6.1570 +  | mirror (Dvd (aa, Neg ht)) = Dvd (aa, Neg ht)
  6.1571 +  | mirror (Dvd (aa, Add (hu, hv))) = Dvd (aa, Add (hu, hv))
  6.1572 +  | mirror (Dvd (aa, Sub (hw, hx))) = Dvd (aa, Sub (hw, hx))
  6.1573 +  | mirror (Dvd (aa, Mul (hy, hz))) = Dvd (aa, Mul (hy, hz))
  6.1574 +  | mirror (NDvd (ac, C io)) = NDvd (ac, C io)
  6.1575 +  | mirror (NDvd (ac, Bound ip)) = NDvd (ac, Bound ip)
  6.1576 +  | mirror (NDvd (ac, Neg it)) = NDvd (ac, Neg it)
  6.1577 +  | mirror (NDvd (ac, Add (iu, iv))) = NDvd (ac, Add (iu, iv))
  6.1578 +  | mirror (NDvd (ac, Sub (iw, ix))) = NDvd (ac, Sub (iw, ix))
  6.1579 +  | mirror (NDvd (ac, Mul (iy, iz))) = NDvd (ac, Mul (iy, iz))
  6.1580 +  | mirror (Not ae) = Not ae
  6.1581 +  | mirror (Imp (aj, ak)) = Imp (aj, ak)
  6.1582 +  | mirror (Iff (al, am)) = Iff (al, am)
  6.1583 +  | mirror (E an) = E an
  6.1584 +  | mirror (A ao) = A ao
  6.1585 +  | mirror (Closed ap) = Closed ap
  6.1586 +  | mirror (NClosed aq) = NClosed aq
  6.1587 +  | mirror (Lt (Cn (cm, c, e))) =
  6.1588 +    (if ((cm : IntInf.int) = (0 : IntInf.int))
  6.1589 +      then Gt (Cn ((0 : IntInf.int), c, Neg e))
  6.1590 +      else Lt (Cn (suc (minus_nat cm (1 : IntInf.int)), c, e)))
  6.1591 +  | mirror (Le (Cn (dm, c, e))) =
  6.1592 +    (if ((dm : IntInf.int) = (0 : IntInf.int))
  6.1593 +      then Ge (Cn ((0 : IntInf.int), c, Neg e))
  6.1594 +      else Le (Cn (suc (minus_nat dm (1 : IntInf.int)), c, e)))
  6.1595 +  | mirror (Gt (Cn (em, c, e))) =
  6.1596 +    (if ((em : IntInf.int) = (0 : IntInf.int))
  6.1597 +      then Lt (Cn ((0 : IntInf.int), c, Neg e))
  6.1598 +      else Gt (Cn (suc (minus_nat em (1 : IntInf.int)), c, e)))
  6.1599 +  | mirror (Ge (Cn (fm, c, e))) =
  6.1600 +    (if ((fm : IntInf.int) = (0 : IntInf.int))
  6.1601 +      then Le (Cn ((0 : IntInf.int), c, Neg e))
  6.1602 +      else Ge (Cn (suc (minus_nat fm (1 : IntInf.int)), c, e)))
  6.1603 +  | mirror (Eq (Cn (gm, c, e))) =
  6.1604 +    (if ((gm : IntInf.int) = (0 : IntInf.int))
  6.1605 +      then Eq (Cn ((0 : IntInf.int), c, Neg e))
  6.1606 +      else Eq (Cn (suc (minus_nat gm (1 : IntInf.int)), c, e)))
  6.1607 +  | mirror (NEq (Cn (hm, c, e))) =
  6.1608 +    (if ((hm : IntInf.int) = (0 : IntInf.int))
  6.1609 +      then NEq (Cn ((0 : IntInf.int), c, Neg e))
  6.1610 +      else NEq (Cn (suc (minus_nat hm (1 : IntInf.int)), c, e)))
  6.1611 +  | mirror (Dvd (i, Cn (im, c, e))) =
  6.1612 +    (if ((im : IntInf.int) = (0 : IntInf.int))
  6.1613 +      then Dvd (i, Cn ((0 : IntInf.int), c, Neg e))
  6.1614 +      else Dvd (i, Cn (suc (minus_nat im (1 : IntInf.int)), c, e)))
  6.1615 +  | mirror (NDvd (i, Cn (jm, c, e))) =
  6.1616 +    (if ((jm : IntInf.int) = (0 : IntInf.int))
  6.1617 +      then NDvd (i, Cn ((0 : IntInf.int), c, Neg e))
  6.1618 +      else NDvd (i, Cn (suc (minus_nat jm (1 : IntInf.int)), c, e)));
  6.1619 +
  6.1620 +fun size_list [] = (0 : IntInf.int)
  6.1621 +  | size_list (a :: lista) = IntInf.+ (size_list lista, suc (0 : IntInf.int));
  6.1622 +
  6.1623 +fun alpha (And (p, q)) = append (alpha p) (alpha q)
  6.1624 +  | alpha (Or (p, q)) = append (alpha p) (alpha q)
  6.1625 +  | alpha T = []
  6.1626 +  | alpha F = []
  6.1627 +  | alpha (Lt (C bo)) = []
  6.1628 +  | alpha (Lt (Bound bp)) = []
  6.1629 +  | alpha (Lt (Neg bt)) = []
  6.1630 +  | alpha (Lt (Add (bu, bv))) = []
  6.1631 +  | alpha (Lt (Sub (bw, bx))) = []
  6.1632 +  | alpha (Lt (Mul (by, bz))) = []
  6.1633 +  | alpha (Le (C co)) = []
  6.1634 +  | alpha (Le (Bound cp)) = []
  6.1635 +  | alpha (Le (Neg ct)) = []
  6.1636 +  | alpha (Le (Add (cu, cv))) = []
  6.1637 +  | alpha (Le (Sub (cw, cx))) = []
  6.1638 +  | alpha (Le (Mul (cy, cz))) = []
  6.1639 +  | alpha (Gt (C doa)) = []
  6.1640 +  | alpha (Gt (Bound dp)) = []
  6.1641 +  | alpha (Gt (Neg dt)) = []
  6.1642 +  | alpha (Gt (Add (du, dv))) = []
  6.1643 +  | alpha (Gt (Sub (dw, dx))) = []
  6.1644 +  | alpha (Gt (Mul (dy, dz))) = []
  6.1645 +  | alpha (Ge (C eo)) = []
  6.1646 +  | alpha (Ge (Bound ep)) = []
  6.1647 +  | alpha (Ge (Neg et)) = []
  6.1648 +  | alpha (Ge (Add (eu, ev))) = []
  6.1649 +  | alpha (Ge (Sub (ew, ex))) = []
  6.1650 +  | alpha (Ge (Mul (ey, ez))) = []
  6.1651 +  | alpha (Eq (C fo)) = []
  6.1652 +  | alpha (Eq (Bound fp)) = []
  6.1653 +  | alpha (Eq (Neg ft)) = []
  6.1654 +  | alpha (Eq (Add (fu, fv))) = []
  6.1655 +  | alpha (Eq (Sub (fw, fx))) = []
  6.1656 +  | alpha (Eq (Mul (fy, fz))) = []
  6.1657 +  | alpha (NEq (C go)) = []
  6.1658 +  | alpha (NEq (Bound gp)) = []
  6.1659 +  | alpha (NEq (Neg gt)) = []
  6.1660 +  | alpha (NEq (Add (gu, gv))) = []
  6.1661 +  | alpha (NEq (Sub (gw, gx))) = []
  6.1662 +  | alpha (NEq (Mul (gy, gz))) = []
  6.1663 +  | alpha (Dvd (aa, ab)) = []
  6.1664 +  | alpha (NDvd (ac, ad)) = []
  6.1665 +  | alpha (Not ae) = []
  6.1666 +  | alpha (Imp (aj, ak)) = []
  6.1667 +  | alpha (Iff (al, am)) = []
  6.1668 +  | alpha (E an) = []
  6.1669 +  | alpha (A ao) = []
  6.1670 +  | alpha (Closed ap) = []
  6.1671 +  | alpha (NClosed aq) = []
  6.1672 +  | alpha (Lt (Cn (cm, c, e))) =
  6.1673 +    (if ((cm : IntInf.int) = (0 : IntInf.int)) then [e] else [])
  6.1674 +  | alpha (Le (Cn (dm, c, e))) =
  6.1675 +    (if ((dm : IntInf.int) = (0 : IntInf.int))
  6.1676 +      then [Add (C (~1 : IntInf.int), e)] else [])
  6.1677 +  | alpha (Gt (Cn (em, c, e))) =
  6.1678 +    (if ((em : IntInf.int) = (0 : IntInf.int)) then [] else [])
  6.1679 +  | alpha (Ge (Cn (fm, c, e))) =
  6.1680 +    (if ((fm : IntInf.int) = (0 : IntInf.int)) then [] else [])
  6.1681 +  | alpha (Eq (Cn (gm, c, e))) =
  6.1682 +    (if ((gm : IntInf.int) = (0 : IntInf.int))
  6.1683 +      then [Add (C (~1 : IntInf.int), e)] else [])
  6.1684 +  | alpha (NEq (Cn (hm, c, e))) =
  6.1685 +    (if ((hm : IntInf.int) = (0 : IntInf.int)) then [e] else []);
  6.1686 +
  6.1687 +fun beta (And (p, q)) = append (beta p) (beta q)
  6.1688 +  | beta (Or (p, q)) = append (beta p) (beta q)
  6.1689 +  | beta T = []
  6.1690 +  | beta F = []
  6.1691 +  | beta (Lt (C bo)) = []
  6.1692 +  | beta (Lt (Bound bp)) = []
  6.1693 +  | beta (Lt (Neg bt)) = []
  6.1694 +  | beta (Lt (Add (bu, bv))) = []
  6.1695 +  | beta (Lt (Sub (bw, bx))) = []
  6.1696 +  | beta (Lt (Mul (by, bz))) = []
  6.1697 +  | beta (Le (C co)) = []
  6.1698 +  | beta (Le (Bound cp)) = []
  6.1699 +  | beta (Le (Neg ct)) = []
  6.1700 +  | beta (Le (Add (cu, cv))) = []
  6.1701 +  | beta (Le (Sub (cw, cx))) = []
  6.1702 +  | beta (Le (Mul (cy, cz))) = []
  6.1703 +  | beta (Gt (C doa)) = []
  6.1704 +  | beta (Gt (Bound dp)) = []
  6.1705 +  | beta (Gt (Neg dt)) = []
  6.1706 +  | beta (Gt (Add (du, dv))) = []
  6.1707 +  | beta (Gt (Sub (dw, dx))) = []
  6.1708 +  | beta (Gt (Mul (dy, dz))) = []
  6.1709 +  | beta (Ge (C eo)) = []
  6.1710 +  | beta (Ge (Bound ep)) = []
  6.1711 +  | beta (Ge (Neg et)) = []
  6.1712 +  | beta (Ge (Add (eu, ev))) = []
  6.1713 +  | beta (Ge (Sub (ew, ex))) = []
  6.1714 +  | beta (Ge (Mul (ey, ez))) = []
  6.1715 +  | beta (Eq (C fo)) = []
  6.1716 +  | beta (Eq (Bound fp)) = []
  6.1717 +  | beta (Eq (Neg ft)) = []
  6.1718 +  | beta (Eq (Add (fu, fv))) = []
  6.1719 +  | beta (Eq (Sub (fw, fx))) = []
  6.1720 +  | beta (Eq (Mul (fy, fz))) = []
  6.1721 +  | beta (NEq (C go)) = []
  6.1722 +  | beta (NEq (Bound gp)) = []
  6.1723 +  | beta (NEq (Neg gt)) = []
  6.1724 +  | beta (NEq (Add (gu, gv))) = []
  6.1725 +  | beta (NEq (Sub (gw, gx))) = []
  6.1726 +  | beta (NEq (Mul (gy, gz))) = []
  6.1727 +  | beta (Dvd (aa, ab)) = []
  6.1728 +  | beta (NDvd (ac, ad)) = []
  6.1729 +  | beta (Not ae) = []
  6.1730 +  | beta (Imp (aj, ak)) = []
  6.1731 +  | beta (Iff (al, am)) = []
  6.1732 +  | beta (E an) = []
  6.1733 +  | beta (A ao) = []
  6.1734 +  | beta (Closed ap) = []
  6.1735 +  | beta (NClosed aq) = []
  6.1736 +  | beta (Lt (Cn (cm, c, e))) =
  6.1737 +    (if ((cm : IntInf.int) = (0 : IntInf.int)) then [] else [])
  6.1738 +  | beta (Le (Cn (dm, c, e))) =
  6.1739 +    (if ((dm : IntInf.int) = (0 : IntInf.int)) then [] else [])
  6.1740 +  | beta (Gt (Cn (em, c, e))) =
  6.1741 +    (if ((em : IntInf.int) = (0 : IntInf.int)) then [Neg e] else [])
  6.1742 +  | beta (Ge (Cn (fm, c, e))) =
  6.1743 +    (if ((fm : IntInf.int) = (0 : IntInf.int))
  6.1744 +      then [Sub (C (~1 : IntInf.int), e)] else [])
  6.1745 +  | beta (Eq (Cn (gm, c, e))) =
  6.1746 +    (if ((gm : IntInf.int) = (0 : IntInf.int))
  6.1747 +      then [Sub (C (~1 : IntInf.int), e)] else [])
  6.1748 +  | beta (NEq (Cn (hm, c, e))) =
  6.1749 +    (if ((hm : IntInf.int) = (0 : IntInf.int)) then [Neg e] else []);
  6.1750 +
  6.1751 +val eq_numa = {eq = eq_num} : num eq;
  6.1752 +
  6.1753 +fun member A_ x [] = false
  6.1754 +  | member A_ x (y :: ys) = eqa A_ x y orelse member A_ x ys;
  6.1755 +
  6.1756 +fun remdups A_ [] = []
  6.1757 +  | remdups A_ (x :: xs) =
  6.1758 +    (if member A_ x xs then remdups A_ xs else x :: remdups A_ xs);
  6.1759 +
  6.1760 +fun gcd_int k l =
  6.1761 +  abs_int
  6.1762 +    (if ((l : IntInf.int) = (0 : IntInf.int)) then k
  6.1763 +      else gcd_int l (mod_int (abs_int k) (abs_int l)));
  6.1764 +
  6.1765 +fun lcm_int a b = div_int (IntInf.* (abs_int a, abs_int b)) (gcd_int a b);
  6.1766 +
  6.1767 +fun delta (And (p, q)) = lcm_int (delta p) (delta q)
  6.1768 +  | delta (Or (p, q)) = lcm_int (delta p) (delta q)
  6.1769 +  | delta T = (1 : IntInf.int)
  6.1770 +  | delta F = (1 : IntInf.int)
  6.1771 +  | delta (Lt u) = (1 : IntInf.int)
  6.1772 +  | delta (Le v) = (1 : IntInf.int)
  6.1773 +  | delta (Gt w) = (1 : IntInf.int)
  6.1774 +  | delta (Ge x) = (1 : IntInf.int)
  6.1775 +  | delta (Eq y) = (1 : IntInf.int)
  6.1776 +  | delta (NEq z) = (1 : IntInf.int)
  6.1777 +  | delta (Dvd (aa, C bo)) = (1 : IntInf.int)
  6.1778 +  | delta (Dvd (aa, Bound bp)) = (1 : IntInf.int)
  6.1779 +  | delta (Dvd (aa, Neg bt)) = (1 : IntInf.int)
  6.1780 +  | delta (Dvd (aa, Add (bu, bv))) = (1 : IntInf.int)
  6.1781 +  | delta (Dvd (aa, Sub (bw, bx))) = (1 : IntInf.int)
  6.1782 +  | delta (Dvd (aa, Mul (by, bz))) = (1 : IntInf.int)
  6.1783 +  | delta (NDvd (ac, C co)) = (1 : IntInf.int)
  6.1784 +  | delta (NDvd (ac, Bound cp)) = (1 : IntInf.int)
  6.1785 +  | delta (NDvd (ac, Neg ct)) = (1 : IntInf.int)
  6.1786 +  | delta (NDvd (ac, Add (cu, cv))) = (1 : IntInf.int)
  6.1787 +  | delta (NDvd (ac, Sub (cw, cx))) = (1 : IntInf.int)
  6.1788 +  | delta (NDvd (ac, Mul (cy, cz))) = (1 : IntInf.int)
  6.1789 +  | delta (Not ae) = (1 : IntInf.int)
  6.1790 +  | delta (Imp (aj, ak)) = (1 : IntInf.int)
  6.1791 +  | delta (Iff (al, am)) = (1 : IntInf.int)
  6.1792 +  | delta (E an) = (1 : IntInf.int)
  6.1793 +  | delta (A ao) = (1 : IntInf.int)
  6.1794 +  | delta (Closed ap) = (1 : IntInf.int)
  6.1795 +  | delta (NClosed aq) = (1 : IntInf.int)
  6.1796 +  | delta (Dvd (i, Cn (cm, c, e))) =
  6.1797 +    (if ((cm : IntInf.int) = (0 : IntInf.int)) then i else (1 : IntInf.int))
  6.1798 +  | delta (NDvd (i, Cn (dm, c, e))) =
  6.1799 +    (if ((dm : IntInf.int) = (0 : IntInf.int)) then i else (1 : IntInf.int));
  6.1800 +
  6.1801 +fun a_beta (And (p, q)) = (fn k => And (a_beta p k, a_beta q k))
  6.1802 +  | a_beta (Or (p, q)) = (fn k => Or (a_beta p k, a_beta q k))
  6.1803 +  | a_beta T = (fn _ => T)
  6.1804 +  | a_beta F = (fn _ => F)
  6.1805 +  | a_beta (Lt (C bo)) = (fn _ => Lt (C bo))
  6.1806 +  | a_beta (Lt (Bound bp)) = (fn _ => Lt (Bound bp))
  6.1807 +  | a_beta (Lt (Neg bt)) = (fn _ => Lt (Neg bt))
  6.1808 +  | a_beta (Lt (Add (bu, bv))) = (fn _ => Lt (Add (bu, bv)))
  6.1809 +  | a_beta (Lt (Sub (bw, bx))) = (fn _ => Lt (Sub (bw, bx)))
  6.1810 +  | a_beta (Lt (Mul (by, bz))) = (fn _ => Lt (Mul (by, bz)))
  6.1811 +  | a_beta (Le (C co)) = (fn _ => Le (C co))
  6.1812 +  | a_beta (Le (Bound cp)) = (fn _ => Le (Bound cp))
  6.1813 +  | a_beta (Le (Neg ct)) = (fn _ => Le (Neg ct))
  6.1814 +  | a_beta (Le (Add (cu, cv))) = (fn _ => Le (Add (cu, cv)))
  6.1815 +  | a_beta (Le (Sub (cw, cx))) = (fn _ => Le (Sub (cw, cx)))
  6.1816 +  | a_beta (Le (Mul (cy, cz))) = (fn _ => Le (Mul (cy, cz)))
  6.1817 +  | a_beta (Gt (C doa)) = (fn _ => Gt (C doa))
  6.1818 +  | a_beta (Gt (Bound dp)) = (fn _ => Gt (Bound dp))
  6.1819 +  | a_beta (Gt (Neg dt)) = (fn _ => Gt (Neg dt))
  6.1820 +  | a_beta (Gt (Add (du, dv))) = (fn _ => Gt (Add (du, dv)))
  6.1821 +  | a_beta (Gt (Sub (dw, dx))) = (fn _ => Gt (Sub (dw, dx)))
  6.1822 +  | a_beta (Gt (Mul (dy, dz))) = (fn _ => Gt (Mul (dy, dz)))
  6.1823 +  | a_beta (Ge (C eo)) = (fn _ => Ge (C eo))
  6.1824 +  | a_beta (Ge (Bound ep)) = (fn _ => Ge (Bound ep))
  6.1825 +  | a_beta (Ge (Neg et)) = (fn _ => Ge (Neg et))
  6.1826 +  | a_beta (Ge (Add (eu, ev))) = (fn _ => Ge (Add (eu, ev)))
  6.1827 +  | a_beta (Ge (Sub (ew, ex))) = (fn _ => Ge (Sub (ew, ex)))
  6.1828 +  | a_beta (Ge (Mul (ey, ez))) = (fn _ => Ge (Mul (ey, ez)))
  6.1829 +  | a_beta (Eq (C fo)) = (fn _ => Eq (C fo))
  6.1830 +  | a_beta (Eq (Bound fp)) = (fn _ => Eq (Bound fp))
  6.1831 +  | a_beta (Eq (Neg ft)) = (fn _ => Eq (Neg ft))
  6.1832 +  | a_beta (Eq (Add (fu, fv))) = (fn _ => Eq (Add (fu, fv)))
  6.1833 +  | a_beta (Eq (Sub (fw, fx))) = (fn _ => Eq (Sub (fw, fx)))
  6.1834 +  | a_beta (Eq (Mul (fy, fz))) = (fn _ => Eq (Mul (fy, fz)))
  6.1835 +  | a_beta (NEq (C go)) = (fn _ => NEq (C go))
  6.1836 +  | a_beta (NEq (Bound gp)) = (fn _ => NEq (Bound gp))
  6.1837 +  | a_beta (NEq (Neg gt)) = (fn _ => NEq (Neg gt))
  6.1838 +  | a_beta (NEq (Add (gu, gv))) = (fn _ => NEq (Add (gu, gv)))
  6.1839 +  | a_beta (NEq (Sub (gw, gx))) = (fn _ => NEq (Sub (gw, gx)))
  6.1840 +  | a_beta (NEq (Mul (gy, gz))) = (fn _ => NEq (Mul (gy, gz)))
  6.1841 +  | a_beta (Dvd (aa, C ho)) = (fn _ => Dvd (aa, C ho))
  6.1842 +  | a_beta (Dvd (aa, Bound hp)) = (fn _ => Dvd (aa, Bound hp))
  6.1843 +  | a_beta (Dvd (aa, Neg ht)) = (fn _ => Dvd (aa, Neg ht))
  6.1844 +  | a_beta (Dvd (aa, Add (hu, hv))) = (fn _ => Dvd (aa, Add (hu, hv)))
  6.1845 +  | a_beta (Dvd (aa, Sub (hw, hx))) = (fn _ => Dvd (aa, Sub (hw, hx)))
  6.1846 +  | a_beta (Dvd (aa, Mul (hy, hz))) = (fn _ => Dvd (aa, Mul (hy, hz)))
  6.1847 +  | a_beta (NDvd (ac, C io)) = (fn _ => NDvd (ac, C io))
  6.1848 +  | a_beta (NDvd (ac, Bound ip)) = (fn _ => NDvd (ac, Bound ip))
  6.1849 +  | a_beta (NDvd (ac, Neg it)) = (fn _ => NDvd (ac, Neg it))
  6.1850 +  | a_beta (NDvd (ac, Add (iu, iv))) = (fn _ => NDvd (ac, Add (iu, iv)))
  6.1851 +  | a_beta (NDvd (ac, Sub (iw, ix))) = (fn _ => NDvd (ac, Sub (iw, ix)))
  6.1852 +  | a_beta (NDvd (ac, Mul (iy, iz))) = (fn _ => NDvd (ac, Mul (iy, iz)))
  6.1853 +  | a_beta (Not ae) = (fn _ => Not ae)
  6.1854 +  | a_beta (Imp (aj, ak)) = (fn _ => Imp (aj, ak))
  6.1855 +  | a_beta (Iff (al, am)) = (fn _ => Iff (al, am))
  6.1856 +  | a_beta (E an) = (fn _ => E an)
  6.1857 +  | a_beta (A ao) = (fn _ => A ao)
  6.1858 +  | a_beta (Closed ap) = (fn _ => Closed ap)
  6.1859 +  | a_beta (NClosed aq) = (fn _ => NClosed aq)
  6.1860 +  | a_beta (Lt (Cn (cm, c, e))) =
  6.1861 +    (if ((cm : IntInf.int) = (0 : IntInf.int))
  6.1862 +      then (fn k =>
  6.1863 +             Lt (Cn ((0 : IntInf.int), (1 : IntInf.int), Mul (div_int k c, e))))
  6.1864 +      else (fn _ => Lt (Cn (suc (minus_nat cm (1 : IntInf.int)), c, e))))
  6.1865 +  | a_beta (Le (Cn (dm, c, e))) =
  6.1866 +    (if ((dm : IntInf.int) = (0 : IntInf.int))
  6.1867 +      then (fn k =>
  6.1868 +             Le (Cn ((0 : IntInf.int), (1 : IntInf.int), Mul (div_int k c, e))))
  6.1869 +      else (fn _ => Le (Cn (suc (minus_nat dm (1 : IntInf.int)), c, e))))
  6.1870 +  | a_beta (Gt (Cn (em, c, e))) =
  6.1871 +    (if ((em : IntInf.int) = (0 : IntInf.int))
  6.1872 +      then (fn k =>
  6.1873 +             Gt (Cn ((0 : IntInf.int), (1 : IntInf.int), Mul (div_int k c, e))))
  6.1874 +      else (fn _ => Gt (Cn (suc (minus_nat em (1 : IntInf.int)), c, e))))
  6.1875 +  | a_beta (Ge (Cn (fm, c, e))) =
  6.1876 +    (if ((fm : IntInf.int) = (0 : IntInf.int))
  6.1877 +      then (fn k =>
  6.1878 +             Ge (Cn ((0 : IntInf.int), (1 : IntInf.int), Mul (div_int k c, e))))
  6.1879 +      else (fn _ => Ge (Cn (suc (minus_nat fm (1 : IntInf.int)), c, e))))
  6.1880 +  | a_beta (Eq (Cn (gm, c, e))) =
  6.1881 +    (if ((gm : IntInf.int) = (0 : IntInf.int))
  6.1882 +      then (fn k =>
  6.1883 +             Eq (Cn ((0 : IntInf.int), (1 : IntInf.int), Mul (div_int k c, e))))
  6.1884 +      else (fn _ => Eq (Cn (suc (minus_nat gm (1 : IntInf.int)), c, e))))
  6.1885 +  | a_beta (NEq (Cn (hm, c, e))) =
  6.1886 +    (if ((hm : IntInf.int) = (0 : IntInf.int))
  6.1887 +      then (fn k =>
  6.1888 +             NEq (Cn ((0 : IntInf.int), (1 : IntInf.int),
  6.1889 +                       Mul (div_int k c, e))))
  6.1890 +      else (fn _ => NEq (Cn (suc (minus_nat hm (1 : IntInf.int)), c, e))))
  6.1891 +  | a_beta (Dvd (i, Cn (im, c, e))) =
  6.1892 +    (if ((im : IntInf.int) = (0 : IntInf.int))
  6.1893 +      then (fn k =>
  6.1894 +             Dvd (IntInf.* (div_int k c, i),
  6.1895 +                   Cn ((0 : IntInf.int), (1 : IntInf.int),
  6.1896 +                        Mul (div_int k c, e))))
  6.1897 +      else (fn _ => Dvd (i, Cn (suc (minus_nat im (1 : IntInf.int)), c, e))))
  6.1898 +  | a_beta (NDvd (i, Cn (jm, c, e))) =
  6.1899 +    (if ((jm : IntInf.int) = (0 : IntInf.int))
  6.1900 +      then (fn k =>
  6.1901 +             NDvd (IntInf.* (div_int k c, i),
  6.1902 +                    Cn ((0 : IntInf.int), (1 : IntInf.int),
  6.1903 +                         Mul (div_int k c, e))))
  6.1904 +      else (fn _ => NDvd (i, Cn (suc (minus_nat jm (1 : IntInf.int)), c, e))));
  6.1905 +
  6.1906 +fun zeta (And (p, q)) = lcm_int (zeta p) (zeta q)
  6.1907 +  | zeta (Or (p, q)) = lcm_int (zeta p) (zeta q)
  6.1908 +  | zeta T = (1 : IntInf.int)
  6.1909 +  | zeta F = (1 : IntInf.int)
  6.1910 +  | zeta (Lt (C bo)) = (1 : IntInf.int)
  6.1911 +  | zeta (Lt (Bound bp)) = (1 : IntInf.int)
  6.1912 +  | zeta (Lt (Neg bt)) = (1 : IntInf.int)
  6.1913 +  | zeta (Lt (Add (bu, bv))) = (1 : IntInf.int)
  6.1914 +  | zeta (Lt (Sub (bw, bx))) = (1 : IntInf.int)
  6.1915 +  | zeta (Lt (Mul (by, bz))) = (1 : IntInf.int)
  6.1916 +  | zeta (Le (C co)) = (1 : IntInf.int)
  6.1917 +  | zeta (Le (Bound cp)) = (1 : IntInf.int)
  6.1918 +  | zeta (Le (Neg ct)) = (1 : IntInf.int)
  6.1919 +  | zeta (Le (Add (cu, cv))) = (1 : IntInf.int)
  6.1920 +  | zeta (Le (Sub (cw, cx))) = (1 : IntInf.int)
  6.1921 +  | zeta (Le (Mul (cy, cz))) = (1 : IntInf.int)
  6.1922 +  | zeta (Gt (C doa)) = (1 : IntInf.int)
  6.1923 +  | zeta (Gt (Bound dp)) = (1 : IntInf.int)
  6.1924 +  | zeta (Gt (Neg dt)) = (1 : IntInf.int)
  6.1925 +  | zeta (Gt (Add (du, dv))) = (1 : IntInf.int)
  6.1926 +  | zeta (Gt (Sub (dw, dx))) = (1 : IntInf.int)
  6.1927 +  | zeta (Gt (Mul (dy, dz))) = (1 : IntInf.int)
  6.1928 +  | zeta (Ge (C eo)) = (1 : IntInf.int)
  6.1929 +  | zeta (Ge (Bound ep)) = (1 : IntInf.int)
  6.1930 +  | zeta (Ge (Neg et)) = (1 : IntInf.int)
  6.1931 +  | zeta (Ge (Add (eu, ev))) = (1 : IntInf.int)
  6.1932 +  | zeta (Ge (Sub (ew, ex))) = (1 : IntInf.int)
  6.1933 +  | zeta (Ge (Mul (ey, ez))) = (1 : IntInf.int)
  6.1934 +  | zeta (Eq (C fo)) = (1 : IntInf.int)
  6.1935 +  | zeta (Eq (Bound fp)) = (1 : IntInf.int)
  6.1936 +  | zeta (Eq (Neg ft)) = (1 : IntInf.int)
  6.1937 +  | zeta (Eq (Add (fu, fv))) = (1 : IntInf.int)
  6.1938 +  | zeta (Eq (Sub (fw, fx))) = (1 : IntInf.int)
  6.1939 +  | zeta (Eq (Mul (fy, fz))) = (1 : IntInf.int)
  6.1940 +  | zeta (NEq (C go)) = (1 : IntInf.int)
  6.1941 +  | zeta (NEq (Bound gp)) = (1 : IntInf.int)
  6.1942 +  | zeta (NEq (Neg gt)) = (1 : IntInf.int)
  6.1943 +  | zeta (NEq (Add (gu, gv))) = (1 : IntInf.int)
  6.1944 +  | zeta (NEq (Sub (gw, gx))) = (1 : IntInf.int)
  6.1945 +  | zeta (NEq (Mul (gy, gz))) = (1 : IntInf.int)
  6.1946 +  | zeta (Dvd (aa, C ho)) = (1 : IntInf.int)
  6.1947 +  | zeta (Dvd (aa, Bound hp)) = (1 : IntInf.int)
  6.1948 +  | zeta (Dvd (aa, Neg ht)) = (1 : IntInf.int)
  6.1949 +  | zeta (Dvd (aa, Add (hu, hv))) = (1 : IntInf.int)
  6.1950 +  | zeta (Dvd (aa, Sub (hw, hx))) = (1 : IntInf.int)
  6.1951 +  | zeta (Dvd (aa, Mul (hy, hz))) = (1 : IntInf.int)
  6.1952 +  | zeta (NDvd (ac, C io)) = (1 : IntInf.int)
  6.1953 +  | zeta (NDvd (ac, Bound ip)) = (1 : IntInf.int)
  6.1954 +  | zeta (NDvd (ac, Neg it)) = (1 : IntInf.int)
  6.1955 +  | zeta (NDvd (ac, Add (iu, iv))) = (1 : IntInf.int)
  6.1956 +  | zeta (NDvd (ac, Sub (iw, ix))) = (1 : IntInf.int)
  6.1957 +  | zeta (NDvd (ac, Mul (iy, iz))) = (1 : IntInf.int)
  6.1958 +  | zeta (Not ae) = (1 : IntInf.int)
  6.1959 +  | zeta (Imp (aj, ak)) = (1 : IntInf.int)
  6.1960 +  | zeta (Iff (al, am)) = (1 : IntInf.int)
  6.1961 +  | zeta (E an) = (1 : IntInf.int)
  6.1962 +  | zeta (A ao) = (1 : IntInf.int)
  6.1963 +  | zeta (Closed ap) = (1 : IntInf.int)
  6.1964 +  | zeta (NClosed aq) = (1 : IntInf.int)
  6.1965 +  | zeta (Lt (Cn (cm, c, e))) =
  6.1966 +    (if ((cm : IntInf.int) = (0 : IntInf.int)) then c else (1 : IntInf.int))
  6.1967 +  | zeta (Le (Cn (dm, c, e))) =
  6.1968 +    (if ((dm : IntInf.int) = (0 : IntInf.int)) then c else (1 : IntInf.int))
  6.1969 +  | zeta (Gt (Cn (em, c, e))) =
  6.1970 +    (if ((em : IntInf.int) = (0 : IntInf.int)) then c else (1 : IntInf.int))
  6.1971 +  | zeta (Ge (Cn (fm, c, e))) =
  6.1972 +    (if ((fm : IntInf.int) = (0 : IntInf.int)) then c else (1 : IntInf.int))
  6.1973 +  | zeta (Eq (Cn (gm, c, e))) =
  6.1974 +    (if ((gm : IntInf.int) = (0 : IntInf.int)) then c else (1 : IntInf.int))
  6.1975 +  | zeta (NEq (Cn (hm, c, e))) =
  6.1976 +    (if ((hm : IntInf.int) = (0 : IntInf.int)) then c else (1 : IntInf.int))
  6.1977 +  | zeta (Dvd (i, Cn (im, c, e))) =
  6.1978 +    (if ((im : IntInf.int) = (0 : IntInf.int)) then c else (1 : IntInf.int))
  6.1979 +  | zeta (NDvd (i, Cn (jm, c, e))) =
  6.1980 +    (if ((jm : IntInf.int) = (0 : IntInf.int)) then c else (1 : IntInf.int));
  6.1981 +
  6.1982 +fun zsplit0 (C c) = ((0 : IntInf.int), C c)
  6.1983 +  | zsplit0 (Bound n) =
  6.1984 +    (if ((n : IntInf.int) = (0 : IntInf.int))
  6.1985 +      then ((1 : IntInf.int), C (0 : IntInf.int))
  6.1986 +      else ((0 : IntInf.int), Bound n))
  6.1987 +  | zsplit0 (Cn (n, i, a)) =
  6.1988 +    let
  6.1989 +      val (ia, aa) = zsplit0 a;
  6.1990 +    in
  6.1991 +      (if ((n : IntInf.int) = (0 : IntInf.int)) then (IntInf.+ (i, ia), aa)
  6.1992 +        else (ia, Cn (n, i, aa)))
  6.1993 +    end
  6.1994 +  | zsplit0 (Neg a) =
  6.1995 +    let
  6.1996 +      val (i, aa) = zsplit0 a;
  6.1997 +    in
  6.1998 +      (IntInf.~ i, Neg aa)
  6.1999 +    end
  6.2000 +  | zsplit0 (Add (a, b)) =
  6.2001 +    let
  6.2002 +      val (ia, aa) = zsplit0 a;
  6.2003 +      val (ib, ba) = zsplit0 b;
  6.2004 +    in
  6.2005 +      (IntInf.+ (ia, ib), Add (aa, ba))
  6.2006 +    end
  6.2007 +  | zsplit0 (Sub (a, b)) =
  6.2008 +    let
  6.2009 +      val (ia, aa) = zsplit0 a;
  6.2010 +      val (ib, ba) = zsplit0 b;
  6.2011 +    in
  6.2012 +      (IntInf.- (ia, ib), Sub (aa, ba))
  6.2013 +    end
  6.2014 +  | zsplit0 (Mul (i, a)) =
  6.2015 +    let
  6.2016 +      val (ia, aa) = zsplit0 a;
  6.2017 +    in
  6.2018 +      (IntInf.* (i, ia), Mul (i, aa))
  6.2019 +    end;
  6.2020 +
  6.2021 +fun zlfm (And (p, q)) = And (zlfm p, zlfm q)
  6.2022 +  | zlfm (Or (p, q)) = Or (zlfm p, zlfm q)
  6.2023 +  | zlfm (Imp (p, q)) = Or (zlfm (Not p), zlfm q)
  6.2024 +  | zlfm (Iff (p, q)) =
  6.2025 +    Or (And (zlfm p, zlfm q), And (zlfm (Not p), zlfm (Not q)))
  6.2026 +  | zlfm (Lt a) =
  6.2027 +    let
  6.2028 +      val (c, r) = zsplit0 a;
  6.2029 +    in
  6.2030 +      (if ((c : IntInf.int) = (0 : IntInf.int)) then Lt r
  6.2031 +        else (if IntInf.< ((0 : IntInf.int), c)
  6.2032 +               then Lt (Cn ((0 : IntInf.int), c, r))
  6.2033 +               else Gt (Cn ((0 : IntInf.int), IntInf.~ c, Neg r))))
  6.2034 +    end
  6.2035 +  | zlfm (Le a) =
  6.2036 +    let
  6.2037 +      val (c, r) = zsplit0 a;
  6.2038 +    in
  6.2039 +      (if ((c : IntInf.int) = (0 : IntInf.int)) then Le r
  6.2040 +        else (if IntInf.< ((0 : IntInf.int), c)
  6.2041 +               then Le (Cn ((0 : IntInf.int), c, r))
  6.2042 +               else Ge (Cn ((0 : IntInf.int), IntInf.~ c, Neg r))))
  6.2043 +    end
  6.2044 +  | zlfm (Gt a) =
  6.2045 +    let
  6.2046 +      val (c, r) = zsplit0 a;
  6.2047 +    in
  6.2048 +      (if ((c : IntInf.int) = (0 : IntInf.int)) then Gt r
  6.2049 +        else (if IntInf.< ((0 : IntInf.int), c)
  6.2050 +               then Gt (Cn ((0 : IntInf.int), c, r))
  6.2051 +               else Lt (Cn ((0 : IntInf.int), IntInf.~ c, Neg r))))
  6.2052 +    end
  6.2053 +  | zlfm (Ge a) =
  6.2054 +    let
  6.2055 +      val (c, r) = zsplit0 a;
  6.2056 +    in
  6.2057 +      (if ((c : IntInf.int) = (0 : IntInf.int)) then Ge r
  6.2058 +        else (if IntInf.< ((0 : IntInf.int), c)
  6.2059 +               then Ge (Cn ((0 : IntInf.int), c, r))
  6.2060 +               else Le (Cn ((0 : IntInf.int), IntInf.~ c, Neg r))))
  6.2061 +    end
  6.2062 +  | zlfm (Eq a) =
  6.2063 +    let
  6.2064 +      val (c, r) = zsplit0 a;
  6.2065 +    in
  6.2066 +      (if ((c : IntInf.int) = (0 : IntInf.int)) then Eq r
  6.2067 +        else (if IntInf.< ((0 : IntInf.int), c)
  6.2068 +               then Eq (Cn ((0 : IntInf.int), c, r))
  6.2069 +               else Eq (Cn ((0 : IntInf.int), IntInf.~ c, Neg r))))
  6.2070 +    end
  6.2071 +  | zlfm (NEq a) =
  6.2072 +    let
  6.2073 +      val (c, r) = zsplit0 a;
  6.2074 +    in
  6.2075 +      (if ((c : IntInf.int) = (0 : IntInf.int)) then NEq r
  6.2076 +        else (if IntInf.< ((0 : IntInf.int), c)
  6.2077 +               then NEq (Cn ((0 : IntInf.int), c, r))
  6.2078 +               else NEq (Cn ((0 : IntInf.int), IntInf.~ c, Neg r))))
  6.2079 +    end
  6.2080 +  | zlfm (Dvd (i, a)) =
  6.2081 +    (if ((i : IntInf.int) = (0 : IntInf.int)) then zlfm (Eq a)
  6.2082 +      else let
  6.2083 +             val (c, r) = zsplit0 a;
  6.2084 +           in
  6.2085 +             (if ((c : IntInf.int) = (0 : IntInf.int)) then Dvd (abs_int i, r)
  6.2086 +               else (if IntInf.< ((0 : IntInf.int), c)
  6.2087 +                      then Dvd (abs_int i, Cn ((0 : IntInf.int), c, r))
  6.2088 +                      else Dvd (abs_int i,
  6.2089 +                                 Cn ((0 : IntInf.int), IntInf.~ c, Neg r))))
  6.2090 +           end)
  6.2091 +  | zlfm (NDvd (i, a)) =
  6.2092 +    (if ((i : IntInf.int) = (0 : IntInf.int)) then zlfm (NEq a)
  6.2093 +      else let
  6.2094 +             val (c, r) = zsplit0 a;
  6.2095 +           in
  6.2096 +             (if ((c : IntInf.int) = (0 : IntInf.int)) then NDvd (abs_int i, r)
  6.2097 +               else (if IntInf.< ((0 : IntInf.int), c)
  6.2098 +                      then NDvd (abs_int i, Cn ((0 : IntInf.int), c, r))
  6.2099 +                      else NDvd (abs_int i,
  6.2100 +                                  Cn ((0 : IntInf.int), IntInf.~ c, Neg r))))
  6.2101 +           end)
  6.2102 +  | zlfm (Not (And (p, q))) = Or (zlfm (Not p), zlfm (Not q))
  6.2103 +  | zlfm (Not (Or (p, q))) = And (zlfm (Not p), zlfm (Not q))
  6.2104 +  | zlfm (Not (Imp (p, q))) = And (zlfm p, zlfm (Not q))
  6.2105 +  | zlfm (Not (Iff (p, q))) =
  6.2106 +    Or (And (zlfm p, zlfm (Not q)), And (zlfm (Not p), zlfm q))
  6.2107 +  | zlfm (Not (Not p)) = zlfm p
  6.2108 +  | zlfm (Not T) = F
  6.2109 +  | zlfm (Not F) = T
  6.2110 +  | zlfm (Not (Lt a)) = zlfm (Ge a)
  6.2111 +  | zlfm (Not (Le a)) = zlfm (Gt a)
  6.2112 +  | zlfm (Not (Gt a)) = zlfm (Le a)
  6.2113 +  | zlfm (Not (Ge a)) = zlfm (Lt a)
  6.2114 +  | zlfm (Not (Eq a)) = zlfm (NEq a)
  6.2115 +  | zlfm (Not (NEq a)) = zlfm (Eq a)
  6.2116 +  | zlfm (Not (Dvd (i, a))) = zlfm (NDvd (i, a))
  6.2117 +  | zlfm (Not (NDvd (i, a))) = zlfm (Dvd (i, a))
  6.2118 +  | zlfm (Not (Closed p)) = NClosed p
  6.2119 +  | zlfm (Not (NClosed p)) = Closed p
  6.2120 +  | zlfm T = T
  6.2121 +  | zlfm F = F
  6.2122 +  | zlfm (Not (E ci)) = Not (E ci)
  6.2123 +  | zlfm (Not (A cj)) = Not (A cj)
  6.2124 +  | zlfm (E ao) = E ao
  6.2125 +  | zlfm (A ap) = A ap
  6.2126 +  | zlfm (Closed aq) = Closed aq
  6.2127 +  | zlfm (NClosed ar) = NClosed ar;
  6.2128 +
  6.2129 +fun unita p =
  6.2130 +  let
  6.2131 +    val pa = zlfm p;
  6.2132 +    val l = zeta pa;
  6.2133 +    val q =
  6.2134 +      And (Dvd (l, Cn ((0 : IntInf.int), (1 : IntInf.int), C (0 : IntInf.int))),
  6.2135 +            a_beta pa l);
  6.2136 +    val d = delta q;
  6.2137 +    val b = remdups eq_numa (map simpnum (beta q));
  6.2138 +    val a = remdups eq_numa (map simpnum (alpha q));
  6.2139 +  in
  6.2140 +    (if IntInf.<= (size_list b, size_list a) then (q, (b, d))
  6.2141 +      else (mirror q, (a, d)))
  6.2142 +  end;
  6.2143 +
  6.2144 +fun cooper p =
  6.2145 +  let
  6.2146 +    val (q, (b, d)) = unita p;
  6.2147 +    val js = iupt (1 : IntInf.int) d;
  6.2148 +    val mq = simpfm (minusinf q);
  6.2149 +    val md = evaldjf (fn j => simpfm (subst0 (C j) mq)) js;
  6.2150 +  in
  6.2151 +    (if eq_fm md T then T
  6.2152 +      else let
  6.2153 +             val qd =
  6.2154 +               evaldjf (fn (ba, j) => simpfm (subst0 (Add (ba, C j)) q))
  6.2155 +                 (concat_map (fn ba => map (fn a => (ba, a)) js) b);
  6.2156 +           in
  6.2157 +             decr (disj md qd)
  6.2158 +           end)
  6.2159 +  end;
  6.2160 +
  6.2161 +fun prep (E T) = T
  6.2162 +  | prep (E F) = F
  6.2163 +  | prep (E (Or (p, q))) = Or (prep (E p), prep (E q))
  6.2164 +  | prep (E (Imp (p, q))) = Or (prep (E (Not p)), prep (E q))
  6.2165 +  | prep (E (Iff (p, q))) =
  6.2166 +    Or (prep (E (And (p, q))), prep (E (And (Not p, Not q))))
  6.2167 +  | prep (E (Not (And (p, q)))) = Or (prep (E (Not p)), prep (E (Not q)))
  6.2168 +  | prep (E (Not (Imp (p, q)))) = prep (E (And (p, Not q)))
  6.2169 +  | prep (E (Not (Iff (p, q)))) =
  6.2170 +    Or (prep (E (And (p, Not q))), prep (E (And (Not p, q))))
  6.2171 +  | prep (E (Lt ef)) = E (prep (Lt ef))
  6.2172 +  | prep (E (Le eg)) = E (prep (Le eg))
  6.2173 +  | prep (E (Gt eh)) = E (prep (Gt eh))
  6.2174 +  | prep (E (Ge ei)) = E (prep (Ge ei))
  6.2175 +  | prep (E (Eq ej)) = E (prep (Eq ej))
  6.2176 +  | prep (E (NEq ek)) = E (prep (NEq ek))
  6.2177 +  | prep (E (Dvd (el, em))) = E (prep (Dvd (el, em)))
  6.2178 +  | prep (E (NDvd (en, eo))) = E (prep (NDvd (en, eo)))
  6.2179 +  | prep (E (Not T)) = E (prep (Not T))
  6.2180 +  | prep (E (Not F)) = E (prep (Not F))
  6.2181 +  | prep (E (Not (Lt gw))) = E (prep (Not (Lt gw)))
  6.2182 +  | prep (E (Not (Le gx))) = E (prep (Not (Le gx)))
  6.2183 +  | prep (E (Not (Gt gy))) = E (prep (Not (Gt gy)))
  6.2184 +  | prep (E (Not (Ge gz))) = E (prep (Not (Ge gz)))
  6.2185 +  | prep (E (Not (Eq ha))) = E (prep (Not (Eq ha)))
  6.2186 +  | prep (E (Not (NEq hb))) = E (prep (Not (NEq hb)))
  6.2187 +  | prep (E (Not (Dvd (hc, hd)))) = E (prep (Not (Dvd (hc, hd))))
  6.2188 +  | prep (E (Not (NDvd (he, hf)))) = E (prep (Not (NDvd (he, hf))))
  6.2189 +  | prep (E (Not (Not hg))) = E (prep (Not (Not hg)))
  6.2190 +  | prep (E (Not (Or (hj, hk)))) = E (prep (Not (Or (hj, hk))))
  6.2191 +  | prep (E (Not (E hp))) = E (prep (Not (E hp)))
  6.2192 +  | prep (E (Not (A hq))) = E (prep (Not (A hq)))
  6.2193 +  | prep (E (Not (Closed hr))) = E (prep (Not (Closed hr)))
  6.2194 +  | prep (E (Not (NClosed hs))) = E (prep (Not (NClosed hs)))
  6.2195 +  | prep (E (And (eq, er))) = E (prep (And (eq, er)))
  6.2196 +  | prep (E (E ey)) = E (prep (E ey))
  6.2197 +  | prep (E (A ez)) = E (prep (A ez))
  6.2198 +  | prep (E (Closed fa)) = E (prep (Closed fa))
  6.2199 +  | prep (E (NClosed fb)) = E (prep (NClosed fb))
  6.2200 +  | prep (A (And (p, q))) = And (prep (A p), prep (A q))
  6.2201 +  | prep (A T) = prep (Not (E (Not T)))
  6.2202 +  | prep (A F) = prep (Not (E (Not F)))
  6.2203 +  | prep (A (Lt jn)) = prep (Not (E (Not (Lt jn))))
  6.2204 +  | prep (A (Le jo)) = prep (Not (E (Not (Le jo))))
  6.2205 +  | prep (A (Gt jp)) = prep (Not (E (Not (Gt jp))))
  6.2206 +  | prep (A (Ge jq)) = prep (Not (E (Not (Ge jq))))
  6.2207 +  | prep (A (Eq jr)) = prep (Not (E (Not (Eq jr))))
  6.2208 +  | prep (A (NEq js)) = prep (Not (E (Not (NEq js))))
  6.2209 +  | prep (A (Dvd (jt, ju))) = prep (Not (E (Not (Dvd (jt, ju)))))
  6.2210 +  | prep (A (NDvd (jv, jw))) = prep (Not (E (Not (NDvd (jv, jw)))))
  6.2211 +  | prep (A (Not jx)) = prep (Not (E (Not (Not jx))))
  6.2212 +  | prep (A (Or (ka, kb))) = prep (Not (E (Not (Or (ka, kb)))))
  6.2213 +  | prep (A (Imp (kc, kd))) = prep (Not (E (Not (Imp (kc, kd)))))
  6.2214 +  | prep (A (Iff (ke, kf))) = prep (Not (E (Not (Iff (ke, kf)))))
  6.2215 +  | prep (A (E kg)) = prep (Not (E (Not (E kg))))
  6.2216 +  | prep (A (A kh)) = prep (Not (E (Not (A kh))))
  6.2217 +  | prep (A (Closed ki)) = prep (Not (E (Not (Closed ki))))
  6.2218 +  | prep (A (NClosed kj)) = prep (Not (E (Not (NClosed kj))))
  6.2219 +  | prep (Not (Not p)) = prep p
  6.2220 +  | prep (Not (And (p, q))) = Or (prep (Not p), prep (Not q))
  6.2221 +  | prep (Not (A p)) = prep (E (Not p))
  6.2222 +  | prep (Not (Or (p, q))) = And (prep (Not p), prep (Not q))
  6.2223 +  | prep (Not (Imp (p, q))) = And (prep p, prep (Not q))
  6.2224 +  | prep (Not (Iff (p, q))) = Or (prep (And (p, Not q)), prep (And (Not p, q)))
  6.2225 +  | prep (Not T) = Not (prep T)
  6.2226 +  | prep (Not F) = Not (prep F)
  6.2227 +  | prep (Not (Lt bo)) = Not (prep (Lt bo))
  6.2228 +  | prep (Not (Le bp)) = Not (prep (Le bp))
  6.2229 +  | prep (Not (Gt bq)) = Not (prep (Gt bq))
  6.2230 +  | prep (Not (Ge br)) = Not (prep (Ge br))
  6.2231 +  | prep (Not (Eq bs)) = Not (prep (Eq bs))
  6.2232 +  | prep (Not (NEq bt)) = Not (prep (NEq bt))
  6.2233 +  | prep (Not (Dvd (bu, bv))) = Not (prep (Dvd (bu, bv)))
  6.2234 +  | prep (Not (NDvd (bw, bx))) = Not (prep (NDvd (bw, bx)))
  6.2235 +  | prep (Not (E ch)) = Not (prep (E ch))
  6.2236 +  | prep (Not (Closed cj)) = Not (prep (Closed cj))
  6.2237 +  | prep (Not (NClosed ck)) = Not (prep (NClosed ck))
  6.2238 +  | prep (Or (p, q)) = Or (prep p, prep q)
  6.2239 +  | prep (And (p, q)) = And (prep p, prep q)
  6.2240 +  | prep (Imp (p, q)) = prep (Or (Not p, q))
  6.2241 +  | prep (Iff (p, q)) = Or (prep (And (p, q)), prep (And (Not p, Not q)))
  6.2242 +  | prep T = T
  6.2243 +  | prep F = F
  6.2244 +  | prep (Lt u) = Lt u
  6.2245 +  | prep (Le v) = Le v
  6.2246 +  | prep (Gt w) = Gt w
  6.2247 +  | prep (Ge x) = Ge x
  6.2248 +  | prep (Eq y) = Eq y
  6.2249 +  | prep (NEq z) = NEq z
  6.2250 +  | prep (Dvd (aa, ab)) = Dvd (aa, ab)
  6.2251 +  | prep (NDvd (ac, ad)) = NDvd (ac, ad)
  6.2252 +  | prep (Closed ap) = Closed ap
  6.2253 +  | prep (NClosed aq) = NClosed aq;
  6.2254 +
  6.2255 +fun qelim (E p) = (fn qe => dj qe (qelim p qe))
  6.2256 +  | qelim (A p) = (fn qe => nota (qe (qelim (Not p) qe)))
  6.2257 +  | qelim (Not p) = (fn qe => nota (qelim p qe))
  6.2258 +  | qelim (And (p, q)) = (fn qe => conj (qelim p qe) (qelim q qe))
  6.2259 +  | qelim (Or (p, q)) = (fn qe => disj (qelim p qe) (qelim q qe))
  6.2260 +  | qelim (Imp (p, q)) = (fn qe => impa (qelim p qe) (qelim q qe))
  6.2261 +  | qelim (Iff (p, q)) = (fn qe => iffa (qelim p qe) (qelim q qe))
  6.2262 +  | qelim T = (fn _ => simpfm T)
  6.2263 +  | qelim F = (fn _ => simpfm F)
  6.2264 +  | qelim (Lt u) = (fn _ => simpfm (Lt u))
  6.2265 +  | qelim (Le v) = (fn _ => simpfm (Le v))
  6.2266 +  | qelim (Gt w) = (fn _ => simpfm (Gt w))
  6.2267 +  | qelim (Ge x) = (fn _ => simpfm (Ge x))
  6.2268 +  | qelim (Eq y) = (fn _ => simpfm (Eq y))
  6.2269 +  | qelim (NEq z) = (fn _ => simpfm (NEq z))
  6.2270 +  | qelim (Dvd (aa, ab)) = (fn _ => simpfm (Dvd (aa, ab)))
  6.2271 +  | qelim (NDvd (ac, ad)) = (fn _ => simpfm (NDvd (ac, ad)))
  6.2272 +  | qelim (Closed ap) = (fn _ => simpfm (Closed ap))
  6.2273 +  | qelim (NClosed aq) = (fn _ => simpfm (NClosed aq));
  6.2274 +
  6.2275 +fun pa p = qelim (prep p) cooper;
  6.2276 +
  6.2277 +end; (*struct Cooper_Procedure*)
     7.1 --- a/src/HOL/Tools/Qelim/generated_cooper.ML	Mon May 10 12:25:49 2010 +0200
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,2274 +0,0 @@
     7.4 -(* Generated from Cooper.thy; DO NOT EDIT! *)
     7.5 -
     7.6 -structure Generated_Cooper : sig
     7.7 -  type 'a eq
     7.8 -  val eq : 'a eq -> 'a -> 'a -> bool
     7.9 -  val eqa : 'a eq -> 'a -> 'a -> bool
    7.10 -  val leta : 'a -> ('a -> 'b) -> 'b
    7.11 -  val suc : IntInf.int -> IntInf.int
    7.12 -  datatype num = C of IntInf.int | Bound of IntInf.int |
    7.13 -    Cn of IntInf.int * IntInf.int * num | Neg of num | Add of num * num |
    7.14 -    Sub of num * num | Mul of IntInf.int * num
    7.15 -  datatype fm = T | F | Lt of num | Le of num | Gt of num | Ge of num |
    7.16 -    Eq of num | NEq of num | Dvd of IntInf.int * num | NDvd of IntInf.int * num
    7.17 -    | Not of fm | And of fm * fm | Or of fm * fm | Imp of fm * fm |
    7.18 -    Iff of fm * fm | E of fm | A of fm | Closed of IntInf.int |
    7.19 -    NClosed of IntInf.int
    7.20 -  val map : ('a -> 'b) -> 'a list -> 'b list
    7.21 -  val append : 'a list -> 'a list -> 'a list
    7.22 -  val disjuncts : fm -> fm list
    7.23 -  val fm_case :
    7.24 -    'a -> 'a -> (num -> 'a) ->
    7.25 -                  (num -> 'a) ->
    7.26 -                    (num -> 'a) ->
    7.27 -                      (num -> 'a) ->
    7.28 -                        (num -> 'a) ->
    7.29 -                          (num -> 'a) ->
    7.30 -                            (IntInf.int -> num -> 'a) ->
    7.31 -                              (IntInf.int -> num -> 'a) ->
    7.32 -                                (fm -> 'a) ->
    7.33 -                                  (fm -> fm -> 'a) ->
    7.34 -                                    (fm -> fm -> 'a) ->
    7.35 -                                      (fm -> fm -> 'a) ->
    7.36 -(fm -> fm -> 'a) ->
    7.37 -  (fm -> 'a) ->
    7.38 -    (fm -> 'a) -> (IntInf.int -> 'a) -> (IntInf.int -> 'a) -> fm -> 'a
    7.39 -  val eq_num : num -> num -> bool
    7.40 -  val eq_fm : fm -> fm -> bool
    7.41 -  val djf : ('a -> fm) -> 'a -> fm -> fm
    7.42 -  val foldr : ('a -> 'b -> 'b) -> 'a list -> 'b -> 'b
    7.43 -  val evaldjf : ('a -> fm) -> 'a list -> fm
    7.44 -  val dj : (fm -> fm) -> fm -> fm
    7.45 -  val disj : fm -> fm -> fm
    7.46 -  val minus_nat : IntInf.int -> IntInf.int -> IntInf.int
    7.47 -  val decrnum : num -> num
    7.48 -  val decr : fm -> fm
    7.49 -  val concat_map : ('a -> 'b list) -> 'a list -> 'b list
    7.50 -  val numsubst0 : num -> num -> num
    7.51 -  val subst0 : num -> fm -> fm
    7.52 -  val minusinf : fm -> fm
    7.53 -  val eq_int : IntInf.int eq
    7.54 -  val zero_int : IntInf.int
    7.55 -  type 'a zero
    7.56 -  val zero : 'a zero -> 'a
    7.57 -  val zero_inta : IntInf.int zero
    7.58 -  type 'a times
    7.59 -  val times : 'a times -> 'a -> 'a -> 'a
    7.60 -  type 'a no_zero_divisors
    7.61 -  val times_no_zero_divisors : 'a no_zero_divisors -> 'a times
    7.62 -  val zero_no_zero_divisors : 'a no_zero_divisors -> 'a zero
    7.63 -  val times_int : IntInf.int times
    7.64 -  val no_zero_divisors_int : IntInf.int no_zero_divisors
    7.65 -  type 'a one
    7.66 -  val one : 'a one -> 'a
    7.67 -  type 'a zero_neq_one
    7.68 -  val one_zero_neq_one : 'a zero_neq_one -> 'a one
    7.69 -  val zero_zero_neq_one : 'a zero_neq_one -> 'a zero
    7.70 -  type 'a semigroup_mult
    7.71 -  val times_semigroup_mult : 'a semigroup_mult -> 'a times
    7.72 -  type 'a plus
    7.73 -  val plus : 'a plus -> 'a -> 'a -> 'a
    7.74 -  type 'a semigroup_add
    7.75 -  val plus_semigroup_add : 'a semigroup_add -> 'a plus
    7.76 -  type 'a ab_semigroup_add
    7.77 -  val semigroup_add_ab_semigroup_add : 'a ab_semigroup_add -> 'a semigroup_add
    7.78 -  type 'a semiring
    7.79 -  val ab_semigroup_add_semiring : 'a semiring -> 'a ab_semigroup_add
    7.80 -  val semigroup_mult_semiring : 'a semiring -> 'a semigroup_mult
    7.81 -  type 'a mult_zero
    7.82 -  val times_mult_zero : 'a mult_zero -> 'a times
    7.83 -  val zero_mult_zero : 'a mult_zero -> 'a zero
    7.84 -  type 'a monoid_add
    7.85 -  val semigroup_add_monoid_add : 'a monoid_add -> 'a semigroup_add
    7.86 -  val zero_monoid_add : 'a monoid_add -> 'a zero
    7.87 -  type 'a comm_monoid_add
    7.88 -  val ab_semigroup_add_comm_monoid_add :
    7.89 -    'a comm_monoid_add -> 'a ab_semigroup_add
    7.90 -  val monoid_add_comm_monoid_add : 'a comm_monoid_add -> 'a monoid_add
    7.91 -  type 'a semiring_0
    7.92 -  val comm_monoid_add_semiring_0 : 'a semiring_0 -> 'a comm_monoid_add
    7.93 -  val mult_zero_semiring_0 : 'a semiring_0 -> 'a mult_zero
    7.94 -  val semiring_semiring_0 : 'a semiring_0 -> 'a semiring
    7.95 -  type 'a power
    7.96 -  val one_power : 'a power -> 'a one
    7.97 -  val times_power : 'a power -> 'a times
    7.98 -  type 'a monoid_mult
    7.99 -  val semigroup_mult_monoid_mult : 'a monoid_mult -> 'a semigroup_mult
   7.100 -  val power_monoid_mult : 'a monoid_mult -> 'a power
   7.101 -  type 'a semiring_1
   7.102 -  val monoid_mult_semiring_1 : 'a semiring_1 -> 'a monoid_mult
   7.103 -  val semiring_0_semiring_1 : 'a semiring_1 -> 'a semiring_0
   7.104 -  val zero_neq_one_semiring_1 : 'a semiring_1 -> 'a zero_neq_one
   7.105 -  type 'a cancel_semigroup_add
   7.106 -  val semigroup_add_cancel_semigroup_add :
   7.107 -    'a cancel_semigroup_add -> 'a semigroup_add
   7.108 -  type 'a cancel_ab_semigroup_add
   7.109 -  val ab_semigroup_add_cancel_ab_semigroup_add :
   7.110 -    'a cancel_ab_semigroup_add -> 'a ab_semigroup_add
   7.111 -  val cancel_semigroup_add_cancel_ab_semigroup_add :
   7.112 -    'a cancel_ab_semigroup_add -> 'a cancel_semigroup_add
   7.113 -  type 'a cancel_comm_monoid_add
   7.114 -  val cancel_ab_semigroup_add_cancel_comm_monoid_add :
   7.115 -    'a cancel_comm_monoid_add -> 'a cancel_ab_semigroup_add
   7.116 -  val comm_monoid_add_cancel_comm_monoid_add :
   7.117 -    'a cancel_comm_monoid_add -> 'a comm_monoid_add
   7.118 -  type 'a semiring_0_cancel
   7.119 -  val cancel_comm_monoid_add_semiring_0_cancel :
   7.120 -    'a semiring_0_cancel -> 'a cancel_comm_monoid_add
   7.121 -  val semiring_0_semiring_0_cancel : 'a semiring_0_cancel -> 'a semiring_0
   7.122 -  type 'a semiring_1_cancel
   7.123 -  val semiring_0_cancel_semiring_1_cancel :
   7.124 -    'a semiring_1_cancel -> 'a semiring_0_cancel
   7.125 -  val semiring_1_semiring_1_cancel : 'a semiring_1_cancel -> 'a semiring_1
   7.126 -  type 'a dvd
   7.127 -  val times_dvd : 'a dvd -> 'a times
   7.128 -  type 'a ab_semigroup_mult
   7.129 -  val semigroup_mult_ab_semigroup_mult :
   7.130 -    'a ab_semigroup_mult -> 'a semigroup_mult
   7.131 -  type 'a comm_semiring
   7.132 -  val ab_semigroup_mult_comm_semiring : 'a comm_semiring -> 'a ab_semigroup_mult
   7.133 -  val semiring_comm_semiring : 'a comm_semiring -> 'a semiring
   7.134 -  type 'a comm_semiring_0
   7.135 -  val comm_semiring_comm_semiring_0 : 'a comm_semiring_0 -> 'a comm_semiring
   7.136 -  val semiring_0_comm_semiring_0 : 'a comm_semiring_0 -> 'a semiring_0
   7.137 -  type 'a comm_monoid_mult
   7.138 -  val ab_semigroup_mult_comm_monoid_mult :
   7.139 -    'a comm_monoid_mult -> 'a ab_semigroup_mult
   7.140 -  val monoid_mult_comm_monoid_mult : 'a comm_monoid_mult -> 'a monoid_mult
   7.141 -  type 'a comm_semiring_1
   7.142 -  val comm_monoid_mult_comm_semiring_1 :
   7.143 -    'a comm_semiring_1 -> 'a comm_monoid_mult
   7.144 -  val comm_semiring_0_comm_semiring_1 : 'a comm_semiring_1 -> 'a comm_semiring_0
   7.145 -  val dvd_comm_semiring_1 : 'a comm_semiring_1 -> 'a dvd
   7.146 -  val semiring_1_comm_semiring_1 : 'a comm_semiring_1 -> 'a semiring_1
   7.147 -  type 'a comm_semiring_0_cancel
   7.148 -  val comm_semiring_0_comm_semiring_0_cancel :
   7.149 -    'a comm_semiring_0_cancel -> 'a comm_semiring_0
   7.150 -  val semiring_0_cancel_comm_semiring_0_cancel :
   7.151 -    'a comm_semiring_0_cancel -> 'a semiring_0_cancel
   7.152 -  type 'a comm_semiring_1_cancel
   7.153 -  val comm_semiring_0_cancel_comm_semiring_1_cancel :
   7.154 -    'a comm_semiring_1_cancel -> 'a comm_semiring_0_cancel
   7.155 -  val comm_semiring_1_comm_semiring_1_cancel :
   7.156 -    'a comm_semiring_1_cancel -> 'a comm_semiring_1
   7.157 -  val semiring_1_cancel_comm_semiring_1_cancel :
   7.158 -    'a comm_semiring_1_cancel -> 'a semiring_1_cancel
   7.159 -  type 'a diva
   7.160 -  val dvd_div : 'a diva -> 'a dvd
   7.161 -  val diva : 'a diva -> 'a -> 'a -> 'a
   7.162 -  val moda : 'a diva -> 'a -> 'a -> 'a
   7.163 -  type 'a semiring_div
   7.164 -  val div_semiring_div : 'a semiring_div -> 'a diva
   7.165 -  val comm_semiring_1_cancel_semiring_div :
   7.166 -    'a semiring_div -> 'a comm_semiring_1_cancel
   7.167 -  val no_zero_divisors_semiring_div : 'a semiring_div -> 'a no_zero_divisors
   7.168 -  val one_int : IntInf.int
   7.169 -  val one_inta : IntInf.int one
   7.170 -  val zero_neq_one_int : IntInf.int zero_neq_one
   7.171 -  val semigroup_mult_int : IntInf.int semigroup_mult
   7.172 -  val plus_int : IntInf.int plus
   7.173 -  val semigroup_add_int : IntInf.int semigroup_add
   7.174 -  val ab_semigroup_add_int : IntInf.int ab_semigroup_add
   7.175 -  val semiring_int : IntInf.int semiring
   7.176 -  val mult_zero_int : IntInf.int mult_zero
   7.177 -  val monoid_add_int : IntInf.int monoid_add
   7.178 -  val comm_monoid_add_int : IntInf.int comm_monoid_add
   7.179 -  val semiring_0_int : IntInf.int semiring_0
   7.180 -  val power_int : IntInf.int power
   7.181 -  val monoid_mult_int : IntInf.int monoid_mult
   7.182 -  val semiring_1_int : IntInf.int semiring_1
   7.183 -  val cancel_semigroup_add_int : IntInf.int cancel_semigroup_add
   7.184 -  val cancel_ab_semigroup_add_int : IntInf.int cancel_ab_semigroup_add
   7.185 -  val cancel_comm_monoid_add_int : IntInf.int cancel_comm_monoid_add
   7.186 -  val semiring_0_cancel_int : IntInf.int semiring_0_cancel
   7.187 -  val semiring_1_cancel_int : IntInf.int semiring_1_cancel
   7.188 -  val dvd_int : IntInf.int dvd
   7.189 -  val ab_semigroup_mult_int : IntInf.int ab_semigroup_mult
   7.190 -  val comm_semiring_int : IntInf.int comm_semiring
   7.191 -  val comm_semiring_0_int : IntInf.int comm_semiring_0
   7.192 -  val comm_monoid_mult_int : IntInf.int comm_monoid_mult
   7.193 -  val comm_semiring_1_int : IntInf.int comm_semiring_1
   7.194 -  val comm_semiring_0_cancel_int : IntInf.int comm_semiring_0_cancel
   7.195 -  val comm_semiring_1_cancel_int : IntInf.int comm_semiring_1_cancel
   7.196 -  val abs_int : IntInf.int -> IntInf.int
   7.197 -  val split : ('a -> 'b -> 'c) -> 'a * 'b -> 'c
   7.198 -  val sgn_int : IntInf.int -> IntInf.int
   7.199 -  val apsnd : ('a -> 'b) -> 'c * 'a -> 'c * 'b
   7.200 -  val divmod_int : IntInf.int -> IntInf.int -> IntInf.int * IntInf.int
   7.201 -  val snd : 'a * 'b -> 'b
   7.202 -  val mod_int : IntInf.int -> IntInf.int -> IntInf.int
   7.203 -  val fst : 'a * 'b -> 'a
   7.204 -  val div_int : IntInf.int -> IntInf.int -> IntInf.int
   7.205 -  val div_inta : IntInf.int diva
   7.206 -  val semiring_div_int : IntInf.int semiring_div
   7.207 -  val dvd : 'a semiring_div * 'a eq -> 'a -> 'a -> bool
   7.208 -  val num_case :
   7.209 -    (IntInf.int -> 'a) ->
   7.210 -      (IntInf.int -> 'a) ->
   7.211 -        (IntInf.int -> IntInf.int -> num -> 'a) ->
   7.212 -          (num -> 'a) ->
   7.213 -            (num -> num -> 'a) ->
   7.214 -              (num -> num -> 'a) -> (IntInf.int -> num -> 'a) -> num -> 'a
   7.215 -  val nummul : IntInf.int -> num -> num
   7.216 -  val numneg : num -> num
   7.217 -  val numadd : num * num -> num
   7.218 -  val numsub : num -> num -> num
   7.219 -  val simpnum : num -> num
   7.220 -  val nota : fm -> fm
   7.221 -  val iffa : fm -> fm -> fm
   7.222 -  val impa : fm -> fm -> fm
   7.223 -  val conj : fm -> fm -> fm
   7.224 -  val simpfm : fm -> fm
   7.225 -  val iupt : IntInf.int -> IntInf.int -> IntInf.int list
   7.226 -  val mirror : fm -> fm
   7.227 -  val size_list : 'a list -> IntInf.int
   7.228 -  val alpha : fm -> num list
   7.229 -  val beta : fm -> num list
   7.230 -  val eq_numa : num eq
   7.231 -  val member : 'a eq -> 'a -> 'a list -> bool
   7.232 -  val remdups : 'a eq -> 'a list -> 'a list
   7.233 -  val gcd_int : IntInf.int -> IntInf.int -> IntInf.int
   7.234 -  val lcm_int : IntInf.int -> IntInf.int -> IntInf.int
   7.235 -  val delta : fm -> IntInf.int
   7.236 -  val a_beta : fm -> IntInf.int -> fm
   7.237 -  val zeta : fm -> IntInf.int
   7.238 -  val zsplit0 : num -> IntInf.int * num
   7.239 -  val zlfm : fm -> fm
   7.240 -  val unita : fm -> fm * (num list * IntInf.int)
   7.241 -  val cooper : fm -> fm
   7.242 -  val prep : fm -> fm
   7.243 -  val qelim : fm -> (fm -> fm) -> fm
   7.244 -  val pa : fm -> fm
   7.245 -end = struct
   7.246 -
   7.247 -type 'a eq = {eq : 'a -> 'a -> bool};
   7.248 -val eq = #eq : 'a eq -> 'a -> 'a -> bool;
   7.249 -
   7.250 -fun eqa A_ a b = eq A_ a b;
   7.251 -
   7.252 -fun leta s f = f s;
   7.253 -
   7.254 -fun suc n = IntInf.+ (n, (1 : IntInf.int));
   7.255 -
   7.256 -datatype num = C of IntInf.int | Bound of IntInf.int |
   7.257 -  Cn of IntInf.int * IntInf.int * num | Neg of num | Add of num * num |
   7.258 -  Sub of num * num | Mul of IntInf.int * num;
   7.259 -
   7.260 -datatype fm = T | F | Lt of num | Le of num | Gt of num | Ge of num | Eq of num
   7.261 -  | NEq of num | Dvd of IntInf.int * num | NDvd of IntInf.int * num | Not of fm
   7.262 -  | And of fm * fm | Or of fm * fm | Imp of fm * fm | Iff of fm * fm | E of fm |
   7.263 -  A of fm | Closed of IntInf.int | NClosed of IntInf.int;
   7.264 -
   7.265 -fun map f [] = []
   7.266 -  | map f (x :: xs) = f x :: map f xs;
   7.267 -
   7.268 -fun append [] ys = ys
   7.269 -  | append (x :: xs) ys = x :: append xs ys;
   7.270 -
   7.271 -fun disjuncts (Or (p, q)) = append (disjuncts p) (disjuncts q)
   7.272 -  | disjuncts F = []
   7.273 -  | disjuncts T = [T]
   7.274 -  | disjuncts (Lt u) = [Lt u]
   7.275 -  | disjuncts (Le v) = [Le v]
   7.276 -  | disjuncts (Gt w) = [Gt w]
   7.277 -  | disjuncts (Ge x) = [Ge x]
   7.278 -  | disjuncts (Eq y) = [Eq y]
   7.279 -  | disjuncts (NEq z) = [NEq z]
   7.280 -  | disjuncts (Dvd (aa, ab)) = [Dvd (aa, ab)]
   7.281 -  | disjuncts (NDvd (ac, ad)) = [NDvd (ac, ad)]
   7.282 -  | disjuncts (Not ae) = [Not ae]
   7.283 -  | disjuncts (And (af, ag)) = [And (af, ag)]
   7.284 -  | disjuncts (Imp (aj, ak)) = [Imp (aj, ak)]
   7.285 -  | disjuncts (Iff (al, am)) = [Iff (al, am)]
   7.286 -  | disjuncts (E an) = [E an]
   7.287 -  | disjuncts (A ao) = [A ao]
   7.288 -  | disjuncts (Closed ap) = [Closed ap]
   7.289 -  | disjuncts (NClosed aq) = [NClosed aq];
   7.290 -
   7.291 -fun fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
   7.292 -  (NClosed nat) = f19 nat
   7.293 -  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
   7.294 -    (Closed nat) = f18 nat
   7.295 -  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
   7.296 -    (A fm) = f17 fm
   7.297 -  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
   7.298 -    (E fm) = f16 fm
   7.299 -  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
   7.300 -    (Iff (fm1, fm2)) = f15 fm1 fm2
   7.301 -  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
   7.302 -    (Imp (fm1, fm2)) = f14 fm1 fm2
   7.303 -  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
   7.304 -    (Or (fm1, fm2)) = f13 fm1 fm2
   7.305 -  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
   7.306 -    (And (fm1, fm2)) = f12 fm1 fm2
   7.307 -  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
   7.308 -    (Not fm) = f11 fm
   7.309 -  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
   7.310 -    (NDvd (inta, num)) = f10 inta num
   7.311 -  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
   7.312 -    (Dvd (inta, num)) = f9 inta num
   7.313 -  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
   7.314 -    (NEq num) = f8 num
   7.315 -  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
   7.316 -    (Eq num) = f7 num
   7.317 -  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
   7.318 -    (Ge num) = f6 num
   7.319 -  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
   7.320 -    (Gt num) = f5 num
   7.321 -  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
   7.322 -    (Le num) = f4 num
   7.323 -  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
   7.324 -    (Lt num) = f3 num
   7.325 -  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19 F
   7.326 -    = f2
   7.327 -  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19 T
   7.328 -    = f1;
   7.329 -
   7.330 -fun eq_num (C intaa) (C inta) = ((intaa : IntInf.int) = inta)
   7.331 -  | eq_num (Bound nata) (Bound nat) = ((nata : IntInf.int) = nat)
   7.332 -  | eq_num (Cn (nata, intaa, numa)) (Cn (nat, inta, num)) =
   7.333 -    ((nata : IntInf.int) = nat) andalso
   7.334 -      (((intaa : IntInf.int) = inta) andalso eq_num numa num)
   7.335 -  | eq_num (Neg numa) (Neg num) = eq_num numa num
   7.336 -  | eq_num (Add (num1a, num2a)) (Add (num1, num2)) =
   7.337 -    eq_num num1a num1 andalso eq_num num2a num2
   7.338 -  | eq_num (Sub (num1a, num2a)) (Sub (num1, num2)) =
   7.339 -    eq_num num1a num1 andalso eq_num num2a num2
   7.340 -  | eq_num (Mul (intaa, numa)) (Mul (inta, num)) =
   7.341 -    ((intaa : IntInf.int) = inta) andalso eq_num numa num
   7.342 -  | eq_num (C inta) (Bound nat) = false
   7.343 -  | eq_num (Bound nat) (C inta) = false
   7.344 -  | eq_num (C intaa) (Cn (nat, inta, num)) = false
   7.345 -  | eq_num (Cn (nat, intaa, num)) (C inta) = false
   7.346 -  | eq_num (C inta) (Neg num) = false
   7.347 -  | eq_num (Neg num) (C inta) = false
   7.348 -  | eq_num (C inta) (Add (num1, num2)) = false
   7.349 -  | eq_num (Add (num1, num2)) (C inta) = false
   7.350 -  | eq_num (C inta) (Sub (num1, num2)) = false
   7.351 -  | eq_num (Sub (num1, num2)) (C inta) = false
   7.352 -  | eq_num (C intaa) (Mul (inta, num)) = false
   7.353 -  | eq_num (Mul (intaa, num)) (C inta) = false
   7.354 -  | eq_num (Bound nata) (Cn (nat, inta, num)) = false
   7.355 -  | eq_num (Cn (nata, inta, num)) (Bound nat) = false
   7.356 -  | eq_num (Bound nat) (Neg num) = false
   7.357 -  | eq_num (Neg num) (Bound nat) = false
   7.358 -  | eq_num (Bound nat) (Add (num1, num2)) = false
   7.359 -  | eq_num (Add (num1, num2)) (Bound nat) = false
   7.360 -  | eq_num (Bound nat) (Sub (num1, num2)) = false
   7.361 -  | eq_num (Sub (num1, num2)) (Bound nat) = false
   7.362 -  | eq_num (Bound nat) (Mul (inta, num)) = false
   7.363 -  | eq_num (Mul (inta, num)) (Bound nat) = false
   7.364 -  | eq_num (Cn (nat, inta, numa)) (Neg num) = false
   7.365 -  | eq_num (Neg numa) (Cn (nat, inta, num)) = false
   7.366 -  | eq_num (Cn (nat, inta, num)) (Add (num1, num2)) = false
   7.367 -  | eq_num (Add (num1, num2)) (Cn (nat, inta, num)) = false
   7.368 -  | eq_num (Cn (nat, inta, num)) (Sub (num1, num2)) = false
   7.369 -  | eq_num (Sub (num1, num2)) (Cn (nat, inta, num)) = false
   7.370 -  | eq_num (Cn (nat, intaa, numa)) (Mul (inta, num)) = false
   7.371 -  | eq_num (Mul (intaa, numa)) (Cn (nat, inta, num)) = false
   7.372 -  | eq_num (Neg num) (Add (num1, num2)) = false
   7.373 -  | eq_num (Add (num1, num2)) (Neg num) = false
   7.374 -  | eq_num (Neg num) (Sub (num1, num2)) = false
   7.375 -  | eq_num (Sub (num1, num2)) (Neg num) = false
   7.376 -  | eq_num (Neg numa) (Mul (inta, num)) = false
   7.377 -  | eq_num (Mul (inta, numa)) (Neg num) = false
   7.378 -  | eq_num (Add (num1a, num2a)) (Sub (num1, num2)) = false
   7.379 -  | eq_num (Sub (num1a, num2a)) (Add (num1, num2)) = false
   7.380 -  | eq_num (Add (num1, num2)) (Mul (inta, num)) = false
   7.381 -  | eq_num (Mul (inta, num)) (Add (num1, num2)) = false
   7.382 -  | eq_num (Sub (num1, num2)) (Mul (inta, num)) = false
   7.383 -  | eq_num (Mul (inta, num)) (Sub (num1, num2)) = false;
   7.384 -
   7.385 -fun eq_fm T T = true
   7.386 -  | eq_fm F F = true
   7.387 -  | eq_fm (Lt numa) (Lt num) = eq_num numa num
   7.388 -  | eq_fm (Le numa) (Le num) = eq_num numa num
   7.389 -  | eq_fm (Gt numa) (Gt num) = eq_num numa num
   7.390 -  | eq_fm (Ge numa) (Ge num) = eq_num numa num
   7.391 -  | eq_fm (Eq numa) (Eq num) = eq_num numa num
   7.392 -  | eq_fm (NEq numa) (NEq num) = eq_num numa num
   7.393 -  | eq_fm (Dvd (intaa, numa)) (Dvd (inta, num)) =
   7.394 -    ((intaa : IntInf.int) = inta) andalso eq_num numa num
   7.395 -  | eq_fm (NDvd (intaa, numa)) (NDvd (inta, num)) =
   7.396 -    ((intaa : IntInf.int) = inta) andalso eq_num numa num
   7.397 -  | eq_fm (Not fma) (Not fm) = eq_fm fma fm
   7.398 -  | eq_fm (And (fm1a, fm2a)) (And (fm1, fm2)) =
   7.399 -    eq_fm fm1a fm1 andalso eq_fm fm2a fm2
   7.400 -  | eq_fm (Or (fm1a, fm2a)) (Or (fm1, fm2)) =
   7.401 -    eq_fm fm1a fm1 andalso eq_fm fm2a fm2
   7.402 -  | eq_fm (Imp (fm1a, fm2a)) (Imp (fm1, fm2)) =
   7.403 -    eq_fm fm1a fm1 andalso eq_fm fm2a fm2
   7.404 -  | eq_fm (Iff (fm1a, fm2a)) (Iff (fm1, fm2)) =
   7.405 -    eq_fm fm1a fm1 andalso eq_fm fm2a fm2
   7.406 -  | eq_fm (E fma) (E fm) = eq_fm fma fm
   7.407 -  | eq_fm (A fma) (A fm) = eq_fm fma fm
   7.408 -  | eq_fm (Closed nata) (Closed nat) = ((nata : IntInf.int) = nat)
   7.409 -  | eq_fm (NClosed nata) (NClosed nat) = ((nata : IntInf.int) = nat)
   7.410 -  | eq_fm T F = false
   7.411 -  | eq_fm F T = false
   7.412 -  | eq_fm T (Lt num) = false
   7.413 -  | eq_fm (Lt num) T = false
   7.414 -  | eq_fm T (Le num) = false
   7.415 -  | eq_fm (Le num) T = false
   7.416 -  | eq_fm T (Gt num) = false
   7.417 -  | eq_fm (Gt num) T = false
   7.418 -  | eq_fm T (Ge num) = false
   7.419 -  | eq_fm (Ge num) T = false
   7.420 -  | eq_fm T (Eq num) = false
   7.421 -  | eq_fm (Eq num) T = false
   7.422 -  | eq_fm T (NEq num) = false
   7.423 -  | eq_fm (NEq num) T = false
   7.424 -  | eq_fm T (Dvd (inta, num)) = false
   7.425 -  | eq_fm (Dvd (inta, num)) T = false
   7.426 -  | eq_fm T (NDvd (inta, num)) = false
   7.427 -  | eq_fm (NDvd (inta, num)) T = false
   7.428 -  | eq_fm T (Not fm) = false
   7.429 -  | eq_fm (Not fm) T = false
   7.430 -  | eq_fm T (And (fm1, fm2)) = false
   7.431 -  | eq_fm (And (fm1, fm2)) T = false
   7.432 -  | eq_fm T (Or (fm1, fm2)) = false
   7.433 -  | eq_fm (Or (fm1, fm2)) T = false
   7.434 -  | eq_fm T (Imp (fm1, fm2)) = false
   7.435 -  | eq_fm (Imp (fm1, fm2)) T = false
   7.436 -  | eq_fm T (Iff (fm1, fm2)) = false
   7.437 -  | eq_fm (Iff (fm1, fm2)) T = false
   7.438 -  | eq_fm T (E fm) = false
   7.439 -  | eq_fm (E fm) T = false
   7.440 -  | eq_fm T (A fm) = false
   7.441 -  | eq_fm (A fm) T = false
   7.442 -  | eq_fm T (Closed nat) = false
   7.443 -  | eq_fm (Closed nat) T = false
   7.444 -  | eq_fm T (NClosed nat) = false
   7.445 -  | eq_fm (NClosed nat) T = false
   7.446 -  | eq_fm F (Lt num) = false
   7.447 -  | eq_fm (Lt num) F = false
   7.448 -  | eq_fm F (Le num) = false
   7.449 -  | eq_fm (Le num) F = false
   7.450 -  | eq_fm F (Gt num) = false
   7.451 -  | eq_fm (Gt num) F = false
   7.452 -  | eq_fm F (Ge num) = false
   7.453 -  | eq_fm (Ge num) F = false
   7.454 -  | eq_fm F (Eq num) = false
   7.455 -  | eq_fm (Eq num) F = false
   7.456 -  | eq_fm F (NEq num) = false
   7.457 -  | eq_fm (NEq num) F = false
   7.458 -  | eq_fm F (Dvd (inta, num)) = false
   7.459 -  | eq_fm (Dvd (inta, num)) F = false
   7.460 -  | eq_fm F (NDvd (inta, num)) = false
   7.461 -  | eq_fm (NDvd (inta, num)) F = false
   7.462 -  | eq_fm F (Not fm) = false
   7.463 -  | eq_fm (Not fm) F = false
   7.464 -  | eq_fm F (And (fm1, fm2)) = false
   7.465 -  | eq_fm (And (fm1, fm2)) F = false
   7.466 -  | eq_fm F (Or (fm1, fm2)) = false
   7.467 -  | eq_fm (Or (fm1, fm2)) F = false
   7.468 -  | eq_fm F (Imp (fm1, fm2)) = false
   7.469 -  | eq_fm (Imp (fm1, fm2)) F = false
   7.470 -  | eq_fm F (Iff (fm1, fm2)) = false
   7.471 -  | eq_fm (Iff (fm1, fm2)) F = false
   7.472 -  | eq_fm F (E fm) = false
   7.473 -  | eq_fm (E fm) F = false
   7.474 -  | eq_fm F (A fm) = false
   7.475 -  | eq_fm (A fm) F = false
   7.476 -  | eq_fm F (Closed nat) = false
   7.477 -  | eq_fm (Closed nat) F = false
   7.478 -  | eq_fm F (NClosed nat) = false
   7.479 -  | eq_fm (NClosed nat) F = false
   7.480 -  | eq_fm (Lt numa) (Le num) = false
   7.481 -  | eq_fm (Le numa) (Lt num) = false
   7.482 -  | eq_fm (Lt numa) (Gt num) = false
   7.483 -  | eq_fm (Gt numa) (Lt num) = false
   7.484 -  | eq_fm (Lt numa) (Ge num) = false
   7.485 -  | eq_fm (Ge numa) (Lt num) = false
   7.486 -  | eq_fm (Lt numa) (Eq num) = false
   7.487 -  | eq_fm (Eq numa) (Lt num) = false
   7.488 -  | eq_fm (Lt numa) (NEq num) = false
   7.489 -  | eq_fm (NEq numa) (Lt num) = false
   7.490 -  | eq_fm (Lt numa) (Dvd (inta, num)) = false
   7.491 -  | eq_fm (Dvd (inta, numa)) (Lt num) = false
   7.492 -  | eq_fm (Lt numa) (NDvd (inta, num)) = false
   7.493 -  | eq_fm (NDvd (inta, numa)) (Lt num) = false
   7.494 -  | eq_fm (Lt num) (Not fm) = false
   7.495 -  | eq_fm (Not fm) (Lt num) = false
   7.496 -  | eq_fm (Lt num) (And (fm1, fm2)) = false
   7.497 -  | eq_fm (And (fm1, fm2)) (Lt num) = false
   7.498 -  | eq_fm (Lt num) (Or (fm1, fm2)) = false
   7.499 -  | eq_fm (Or (fm1, fm2)) (Lt num) = false
   7.500 -  | eq_fm (Lt num) (Imp (fm1, fm2)) = false
   7.501 -  | eq_fm (Imp (fm1, fm2)) (Lt num) = false
   7.502 -  | eq_fm (Lt num) (Iff (fm1, fm2)) = false
   7.503 -  | eq_fm (Iff (fm1, fm2)) (Lt num) = false
   7.504 -  | eq_fm (Lt num) (E fm) = false
   7.505 -  | eq_fm (E fm) (Lt num) = false
   7.506 -  | eq_fm (Lt num) (A fm) = false
   7.507 -  | eq_fm (A fm) (Lt num) = false
   7.508 -  | eq_fm (Lt num) (Closed nat) = false
   7.509 -  | eq_fm (Closed nat) (Lt num) = false
   7.510 -  | eq_fm (Lt num) (NClosed nat) = false
   7.511 -  | eq_fm (NClosed nat) (Lt num) = false
   7.512 -  | eq_fm (Le numa) (Gt num) = false
   7.513 -  | eq_fm (Gt numa) (Le num) = false
   7.514 -  | eq_fm (Le numa) (Ge num) = false
   7.515 -  | eq_fm (Ge numa) (Le num) = false
   7.516 -  | eq_fm (Le numa) (Eq num) = false
   7.517 -  | eq_fm (Eq numa) (Le num) = false
   7.518 -  | eq_fm (Le numa) (NEq num) = false
   7.519 -  | eq_fm (NEq numa) (Le num) = false
   7.520 -  | eq_fm (Le numa) (Dvd (inta, num)) = false
   7.521 -  | eq_fm (Dvd (inta, numa)) (Le num) = false
   7.522 -  | eq_fm (Le numa) (NDvd (inta, num)) = false
   7.523 -  | eq_fm (NDvd (inta, numa)) (Le num) = false
   7.524 -  | eq_fm (Le num) (Not fm) = false
   7.525 -  | eq_fm (Not fm) (Le num) = false
   7.526 -  | eq_fm (Le num) (And (fm1, fm2)) = false
   7.527 -  | eq_fm (And (fm1, fm2)) (Le num) = false
   7.528 -  | eq_fm (Le num) (Or (fm1, fm2)) = false
   7.529 -  | eq_fm (Or (fm1, fm2)) (Le num) = false
   7.530 -  | eq_fm (Le num) (Imp (fm1, fm2)) = false
   7.531 -  | eq_fm (Imp (fm1, fm2)) (Le num) = false
   7.532 -  | eq_fm (Le num) (Iff (fm1, fm2)) = false
   7.533 -  | eq_fm (Iff (fm1, fm2)) (Le num) = false
   7.534 -  | eq_fm (Le num) (E fm) = false
   7.535 -  | eq_fm (E fm) (Le num) = false
   7.536 -  | eq_fm (Le num) (A fm) = false
   7.537 -  | eq_fm (A fm) (Le num) = false
   7.538 -  | eq_fm (Le num) (Closed nat) = false
   7.539 -  | eq_fm (Closed nat) (Le num) = false
   7.540 -  | eq_fm (Le num) (NClosed nat) = false
   7.541 -  | eq_fm (NClosed nat) (Le num) = false
   7.542 -  | eq_fm (Gt numa) (Ge num) = false
   7.543 -  | eq_fm (Ge numa) (Gt num) = false
   7.544 -  | eq_fm (Gt numa) (Eq num) = false
   7.545 -  | eq_fm (Eq numa) (Gt num) = false
   7.546 -  | eq_fm (Gt numa) (NEq num) = false
   7.547 -  | eq_fm (NEq numa) (Gt num) = false
   7.548 -  | eq_fm (Gt numa) (Dvd (inta, num)) = false
   7.549 -  | eq_fm (Dvd (inta, numa)) (Gt num) = false
   7.550 -  | eq_fm (Gt numa) (NDvd (inta, num)) = false
   7.551 -  | eq_fm (NDvd (inta, numa)) (Gt num) = false
   7.552 -  | eq_fm (Gt num) (Not fm) = false
   7.553 -  | eq_fm (Not fm) (Gt num) = false
   7.554 -  | eq_fm (Gt num) (And (fm1, fm2)) = false
   7.555 -  | eq_fm (And (fm1, fm2)) (Gt num) = false
   7.556 -  | eq_fm (Gt num) (Or (fm1, fm2)) = false
   7.557 -  | eq_fm (Or (fm1, fm2)) (Gt num) = false
   7.558 -  | eq_fm (Gt num) (Imp (fm1, fm2)) = false
   7.559 -  | eq_fm (Imp (fm1, fm2)) (Gt num) = false
   7.560 -  | eq_fm (Gt num) (Iff (fm1, fm2)) = false
   7.561 -  | eq_fm (Iff (fm1, fm2)) (Gt num) = false
   7.562 -  | eq_fm (Gt num) (E fm) = false
   7.563 -  | eq_fm (E fm) (Gt num) = false
   7.564 -  | eq_fm (Gt num) (A fm) = false
   7.565 -  | eq_fm (A fm) (Gt num) = false
   7.566 -  | eq_fm (Gt num) (Closed nat) = false
   7.567 -  | eq_fm (Closed nat) (Gt num) = false
   7.568 -  | eq_fm (Gt num) (NClosed nat) = false
   7.569 -  | eq_fm (NClosed nat) (Gt num) = false
   7.570 -  | eq_fm (Ge numa) (Eq num) = false
   7.571 -  | eq_fm (Eq numa) (Ge num) = false
   7.572 -  | eq_fm (Ge numa) (NEq num) = false
   7.573 -  | eq_fm (NEq numa) (Ge num) = false
   7.574 -  | eq_fm (Ge numa) (Dvd (inta, num)) = false
   7.575 -  | eq_fm (Dvd (inta, numa)) (Ge num) = false
   7.576 -  | eq_fm (Ge numa) (NDvd (inta, num)) = false
   7.577 -  | eq_fm (NDvd (inta, numa)) (Ge num) = false
   7.578 -  | eq_fm (Ge num) (Not fm) = false
   7.579 -  | eq_fm (Not fm) (Ge num) = false
   7.580 -  | eq_fm (Ge num) (And (fm1, fm2)) = false
   7.581 -  | eq_fm (And (fm1, fm2)) (Ge num) = false
   7.582 -  | eq_fm (Ge num) (Or (fm1, fm2)) = false
   7.583 -  | eq_fm (Or (fm1, fm2)) (Ge num) = false
   7.584 -  | eq_fm (Ge num) (Imp (fm1, fm2)) = false
   7.585 -  | eq_fm (Imp (fm1, fm2)) (Ge num) = false
   7.586 -  | eq_fm (Ge num) (Iff (fm1, fm2)) = false
   7.587 -  | eq_fm (Iff (fm1, fm2)) (Ge num) = false
   7.588 -  | eq_fm (Ge num) (E fm) = false
   7.589 -  | eq_fm (E fm) (Ge num) = false
   7.590 -  | eq_fm (Ge num) (A fm) = false
   7.591 -  | eq_fm (A fm) (Ge num) = false
   7.592 -  | eq_fm (Ge num) (Closed nat) = false
   7.593 -  | eq_fm (Closed nat) (Ge num) = false
   7.594 -  | eq_fm (Ge num) (NClosed nat) = false
   7.595 -  | eq_fm (NClosed nat) (Ge num) = false
   7.596 -  | eq_fm (Eq numa) (NEq num) = false
   7.597 -  | eq_fm (NEq numa) (Eq num) = false
   7.598 -  | eq_fm (Eq numa) (Dvd (inta, num)) = false
   7.599 -  | eq_fm (Dvd (inta, numa)) (Eq num) = false
   7.600 -  | eq_fm (Eq numa) (NDvd (inta, num)) = false
   7.601 -  | eq_fm (NDvd (inta, numa)) (Eq num) = false
   7.602 -  | eq_fm (Eq num) (Not fm) = false
   7.603 -  | eq_fm (Not fm) (Eq num) = false
   7.604 -  | eq_fm (Eq num) (And (fm1, fm2)) = false
   7.605 -  | eq_fm (And (fm1, fm2)) (Eq num) = false
   7.606 -  | eq_fm (Eq num) (Or (fm1, fm2)) = false
   7.607 -  | eq_fm (Or (fm1, fm2)) (Eq num) = false
   7.608 -  | eq_fm (Eq num) (Imp (fm1, fm2)) = false
   7.609 -  | eq_fm (Imp (fm1, fm2)) (Eq num) = false
   7.610 -  | eq_fm (Eq num) (Iff (fm1, fm2)) = false
   7.611 -  | eq_fm (Iff (fm1, fm2)) (Eq num) = false
   7.612 -  | eq_fm (Eq num) (E fm) = false
   7.613 -  | eq_fm (E fm) (Eq num) = false
   7.614 -  | eq_fm (Eq num) (A fm) = false
   7.615 -  | eq_fm (A fm) (Eq num) = false
   7.616 -  | eq_fm (Eq num) (Closed nat) = false
   7.617 -  | eq_fm (Closed nat) (Eq num) = false
   7.618 -  | eq_fm (Eq num) (NClosed nat) = false
   7.619 -  | eq_fm (NClosed nat) (Eq num) = false
   7.620 -  | eq_fm (NEq numa) (Dvd (inta, num)) = false
   7.621 -  | eq_fm (Dvd (inta, numa)) (NEq num) = false
   7.622 -  | eq_fm (NEq numa) (NDvd (inta, num)) = false
   7.623 -  | eq_fm (NDvd (inta, numa)) (NEq num) = false
   7.624 -  | eq_fm (NEq num) (Not fm) = false
   7.625 -  | eq_fm (Not fm) (NEq num) = false
   7.626 -  | eq_fm (NEq num) (And (fm1, fm2)) = false
   7.627 -  | eq_fm (And (fm1, fm2)) (NEq num) = false
   7.628 -  | eq_fm (NEq num) (Or (fm1, fm2)) = false
   7.629 -  | eq_fm (Or (fm1, fm2)) (NEq num) = false
   7.630 -  | eq_fm (NEq num) (Imp (fm1, fm2)) = false
   7.631 -  | eq_fm (Imp (fm1, fm2)) (NEq num) = false
   7.632 -  | eq_fm (NEq num) (Iff (fm1, fm2)) = false
   7.633 -  | eq_fm (Iff (fm1, fm2)) (NEq num) = false
   7.634 -  | eq_fm (NEq num) (E fm) = false
   7.635 -  | eq_fm (E fm) (NEq num) = false
   7.636 -  | eq_fm (NEq num) (A fm) = false
   7.637 -  | eq_fm (A fm) (NEq num) = false
   7.638 -  | eq_fm (NEq num) (Closed nat) = false
   7.639 -  | eq_fm (Closed nat) (NEq num) = false
   7.640 -  | eq_fm (NEq num) (NClosed nat) = false
   7.641 -  | eq_fm (NClosed nat) (NEq num) = false
   7.642 -  | eq_fm (Dvd (intaa, numa)) (NDvd (inta, num)) = false
   7.643 -  | eq_fm (NDvd (intaa, numa)) (Dvd (inta, num)) = false
   7.644 -  | eq_fm (Dvd (inta, num)) (Not fm) = false
   7.645 -  | eq_fm (Not fm) (Dvd (inta, num)) = false
   7.646 -  | eq_fm (Dvd (inta, num)) (And (fm1, fm2)) = false
   7.647 -  | eq_fm (And (fm1, fm2)) (Dvd (inta, num)) = false
   7.648 -  | eq_fm (Dvd (inta, num)) (Or (fm1, fm2)) = false
   7.649 -  | eq_fm (Or (fm1, fm2)) (Dvd (inta, num)) = false
   7.650 -  | eq_fm (Dvd (inta, num)) (Imp (fm1, fm2)) = false
   7.651 -  | eq_fm (Imp (fm1, fm2)) (Dvd (inta, num)) = false
   7.652 -  | eq_fm (Dvd (inta, num)) (Iff (fm1, fm2)) = false
   7.653 -  | eq_fm (Iff (fm1, fm2)) (Dvd (inta, num)) = false
   7.654 -  | eq_fm (Dvd (inta, num)) (E fm) = false
   7.655 -  | eq_fm (E fm) (Dvd (inta, num)) = false
   7.656 -  | eq_fm (Dvd (inta, num)) (A fm) = false
   7.657 -  | eq_fm (A fm) (Dvd (inta, num)) = false
   7.658 -  | eq_fm (Dvd (inta, num)) (Closed nat) = false
   7.659 -  | eq_fm (Closed nat) (Dvd (inta, num)) = false
   7.660 -  | eq_fm (Dvd (inta, num)) (NClosed nat) = false
   7.661 -  | eq_fm (NClosed nat) (Dvd (inta, num)) = false
   7.662 -  | eq_fm (NDvd (inta, num)) (Not fm) = false
   7.663 -  | eq_fm (Not fm) (NDvd (inta, num)) = false
   7.664 -  | eq_fm (NDvd (inta, num)) (And (fm1, fm2)) = false
   7.665 -  | eq_fm (And (fm1, fm2)) (NDvd (inta, num)) = false
   7.666 -  | eq_fm (NDvd (inta, num)) (Or (fm1, fm2)) = false
   7.667 -  | eq_fm (Or (fm1, fm2)) (NDvd (inta, num)) = false
   7.668 -  | eq_fm (NDvd (inta, num)) (Imp (fm1, fm2)) = false
   7.669 -  | eq_fm (Imp (fm1, fm2)) (NDvd (inta, num)) = false
   7.670 -  | eq_fm (NDvd (inta, num)) (Iff (fm1, fm2)) = false
   7.671 -  | eq_fm (Iff (fm1, fm2)) (NDvd (inta, num)) = false
   7.672 -  | eq_fm (NDvd (inta, num)) (E fm) = false
   7.673 -  | eq_fm (E fm) (NDvd (inta, num)) = false
   7.674 -  | eq_fm (NDvd (inta, num)) (A fm) = false
   7.675 -  | eq_fm (A fm) (NDvd (inta, num)) = false
   7.676 -  | eq_fm (NDvd (inta, num)) (Closed nat) = false
   7.677 -  | eq_fm (Closed nat) (NDvd (inta, num)) = false
   7.678 -  | eq_fm (NDvd (inta, num)) (NClosed nat) = false
   7.679 -  | eq_fm (NClosed nat) (NDvd (inta, num)) = false
   7.680 -  | eq_fm (Not fm) (And (fm1, fm2)) = false
   7.681 -  | eq_fm (And (fm1, fm2)) (Not fm) = false
   7.682 -  | eq_fm (Not fm) (Or (fm1, fm2)) = false
   7.683 -  | eq_fm (Or (fm1, fm2)) (Not fm) = false
   7.684 -  | eq_fm (Not fm) (Imp (fm1, fm2)) = false
   7.685 -  | eq_fm (Imp (fm1, fm2)) (Not fm) = false
   7.686 -  | eq_fm (Not fm) (Iff (fm1, fm2)) = false
   7.687 -  | eq_fm (Iff (fm1, fm2)) (Not fm) = false
   7.688 -  | eq_fm (Not fma) (E fm) = false
   7.689 -  | eq_fm (E fma) (Not fm) = false
   7.690 -  | eq_fm (Not fma) (A fm) = false
   7.691 -  | eq_fm (A fma) (Not fm) = false
   7.692 -  | eq_fm (Not fm) (Closed nat) = false
   7.693 -  | eq_fm (Closed nat) (Not fm) = false
   7.694 -  | eq_fm (Not fm) (NClosed nat) = false
   7.695 -  | eq_fm (NClosed nat) (Not fm) = false
   7.696 -  | eq_fm (And (fm1a, fm2a)) (Or (fm1, fm2)) = false
   7.697 -  | eq_fm (Or (fm1a, fm2a)) (And (fm1, fm2)) = false
   7.698 -  | eq_fm (And (fm1a, fm2a)) (Imp (fm1, fm2)) = false
   7.699 -  | eq_fm (Imp (fm1a, fm2a)) (And (fm1, fm2)) = false
   7.700 -  | eq_fm (And (fm1a, fm2a)) (Iff (fm1, fm2)) = false
   7.701 -  | eq_fm (Iff (fm1a, fm2a)) (And (fm1, fm2)) = false
   7.702 -  | eq_fm (And (fm1, fm2)) (E fm) = false
   7.703 -  | eq_fm (E fm) (And (fm1, fm2)) = false
   7.704 -  | eq_fm (And (fm1, fm2)) (A fm) = false
   7.705 -  | eq_fm (A fm) (And (fm1, fm2)) = false
   7.706 -  | eq_fm (And (fm1, fm2)) (Closed nat) = false
   7.707 -  | eq_fm (Closed nat) (And (fm1, fm2)) = false
   7.708 -  | eq_fm (And (fm1, fm2)) (NClosed nat) = false
   7.709 -  | eq_fm (NClosed nat) (And (fm1, fm2)) = false
   7.710 -  | eq_fm (Or (fm1a, fm2a)) (Imp (fm1, fm2)) = false
   7.711 -  | eq_fm (Imp (fm1a, fm2a)) (Or (fm1, fm2)) = false
   7.712 -  | eq_fm (Or (fm1a, fm2a)) (Iff (fm1, fm2)) = false
   7.713 -  | eq_fm (Iff (fm1a, fm2a)) (Or (fm1, fm2)) = false
   7.714 -  | eq_fm (Or (fm1, fm2)) (E fm) = false
   7.715 -  | eq_fm (E fm) (Or (fm1, fm2)) = false
   7.716 -  | eq_fm (Or (fm1, fm2)) (A fm) = false
   7.717 -  | eq_fm (A fm) (Or (fm1, fm2)) = false
   7.718 -  | eq_fm (Or (fm1, fm2)) (Closed nat) = false
   7.719 -  | eq_fm (Closed nat) (Or (fm1, fm2)) = false
   7.720 -  | eq_fm (Or (fm1, fm2)) (NClosed nat) = false
   7.721 -  | eq_fm (NClosed nat) (Or (fm1, fm2)) = false
   7.722 -  | eq_fm (Imp (fm1a, fm2a)) (Iff (fm1, fm2)) = false
   7.723 -  | eq_fm (Iff (fm1a, fm2a)) (Imp (fm1, fm2)) = false
   7.724 -  | eq_fm (Imp (fm1, fm2)) (E fm) = false
   7.725 -  | eq_fm (E fm) (Imp (fm1, fm2)) = false
   7.726 -  | eq_fm (Imp (fm1, fm2)) (A fm) = false
   7.727 -  | eq_fm (A fm) (Imp (fm1, fm2)) = false
   7.728 -  | eq_fm (Imp (fm1, fm2)) (Closed nat) = false
   7.729 -  | eq_fm (Closed nat) (Imp (fm1, fm2)) = false
   7.730 -  | eq_fm (Imp (fm1, fm2)) (NClosed nat) = false
   7.731 -  | eq_fm (NClosed nat) (Imp (fm1, fm2)) = false
   7.732 -  | eq_fm (Iff (fm1, fm2)) (E fm) = false
   7.733 -  | eq_fm (E fm) (Iff (fm1, fm2)) = false
   7.734 -  | eq_fm (Iff (fm1, fm2)) (A fm) = false
   7.735 -  | eq_fm (A fm) (Iff (fm1, fm2)) = false
   7.736 -  | eq_fm (Iff (fm1, fm2)) (Closed nat) = false
   7.737 -  | eq_fm (Closed nat) (Iff (fm1, fm2)) = false
   7.738 -  | eq_fm (Iff (fm1, fm2)) (NClosed nat) = false
   7.739 -  | eq_fm (NClosed nat) (Iff (fm1, fm2)) = false
   7.740 -  | eq_fm (E fma) (A fm) = false
   7.741 -  | eq_fm (A fma) (E fm) = false
   7.742 -  | eq_fm (E fm) (Closed nat) = false
   7.743 -  | eq_fm (Closed nat) (E fm) = false
   7.744 -  | eq_fm (E fm) (NClosed nat) = false
   7.745 -  | eq_fm (NClosed nat) (E fm) = false
   7.746 -  | eq_fm (A fm) (Closed nat) = false
   7.747 -  | eq_fm (Closed nat) (A fm) = false
   7.748 -  | eq_fm (A fm) (NClosed nat) = false
   7.749 -  | eq_fm (NClosed nat) (A fm) = false
   7.750 -  | eq_fm (Closed nata) (NClosed nat) = false
   7.751 -  | eq_fm (NClosed nata) (Closed nat) = false;
   7.752 -
   7.753 -fun djf f p q =
   7.754 -  (if eq_fm q T then T
   7.755 -    else (if eq_fm q F then f p
   7.756 -           else (case f p of T => T | F => q | Lt _ => Or (f p, q)
   7.757 -                  | Le _ => Or (f p, q) | Gt _ => Or (f p, q)
   7.758 -                  | Ge _ => Or (f p, q) | Eq _ => Or (f p, q)
   7.759 -                  | NEq _ => Or (f p, q) | Dvd (_, _) => Or (f p, q)
   7.760 -                  | NDvd (_, _) => Or (f p, q) | Not _ => Or (f p, q)
   7.761 -                  | And (_, _) => Or (f p, q) | Or (_, _) => Or (f p, q)
   7.762 -                  | Imp (_, _) => Or (f p, q) | Iff (_, _) => Or (f p, q)
   7.763 -                  | E _ => Or (f p, q) | A _ => Or (f p, q)
   7.764 -                  | Closed _ => Or (f p, q) | NClosed _ => Or (f p, q))));
   7.765 -
   7.766 -fun foldr f [] a = a
   7.767 -  | foldr f (x :: xs) a = f x (foldr f xs a);
   7.768 -
   7.769 -fun evaldjf f ps = foldr (djf f) ps F;
   7.770 -
   7.771 -fun dj f p = evaldjf f (disjuncts p);
   7.772 -
   7.773 -fun disj p q =
   7.774 -  (if eq_fm p T orelse eq_fm q T then T
   7.775 -    else (if eq_fm p F then q else (if eq_fm q F then p else Or (p, q))));
   7.776 -
   7.777 -fun minus_nat n m = IntInf.max (0, (IntInf.- (n, m)));
   7.778 -
   7.779 -fun decrnum (Bound n) = Bound (minus_nat n (1 : IntInf.int))
   7.780 -  | decrnum (Neg a) = Neg (decrnum a)
   7.781 -  | decrnum (Add (a, b)) = Add (decrnum a, decrnum b)
   7.782 -  | decrnum (Sub (a, b)) = Sub (decrnum a, decrnum b)
   7.783 -  | decrnum (Mul (c, a)) = Mul (c, decrnum a)
   7.784 -  | decrnum (Cn (n, i, a)) = Cn (minus_nat n (1 : IntInf.int), i, decrnum a)
   7.785 -  | decrnum (C u) = C u;
   7.786 -
   7.787 -fun decr (Lt a) = Lt (decrnum a)
   7.788 -  | decr (Le a) = Le (decrnum a)
   7.789 -  | decr (Gt a) = Gt (decrnum a)
   7.790 -  | decr (Ge a) = Ge (decrnum a)
   7.791 -  | decr (Eq a) = Eq (decrnum a)
   7.792 -  | decr (NEq a) = NEq (decrnum a)
   7.793 -  | decr (Dvd (i, a)) = Dvd (i, decrnum a)
   7.794 -  | decr (NDvd (i, a)) = NDvd (i, decrnum a)
   7.795 -  | decr (Not p) = Not (decr p)
   7.796 -  | decr (And (p, q)) = And (decr p, decr q)
   7.797 -  | decr (Or (p, q)) = Or (decr p, decr q)
   7.798 -  | decr (Imp (p, q)) = Imp (decr p, decr q)
   7.799 -  | decr (Iff (p, q)) = Iff (decr p, decr q)
   7.800 -  | decr T = T
   7.801 -  | decr F = F
   7.802 -  | decr (E ao) = E ao
   7.803 -  | decr (A ap) = A ap
   7.804 -  | decr (Closed aq) = Closed aq
   7.805 -  | decr (NClosed ar) = NClosed ar;
   7.806 -
   7.807 -fun concat_map f [] = []
   7.808 -  | concat_map f (x :: xs) = append (f x) (concat_map f xs);
   7.809 -
   7.810 -fun numsubst0 t (C c) = C c
   7.811 -  | numsubst0 t (Bound n) =
   7.812 -    (if ((n : IntInf.int) = (0 : IntInf.int)) then t else Bound n)
   7.813 -  | numsubst0 t (Neg a) = Neg (numsubst0 t a)
   7.814 -  | numsubst0 t (Add (a, b)) = Add (numsubst0 t a, numsubst0 t b)
   7.815 -  | numsubst0 t (Sub (a, b)) = Sub (numsubst0 t a, numsubst0 t b)
   7.816 -  | numsubst0 t (Mul (i, a)) = Mul (i, numsubst0 t a)
   7.817 -  | numsubst0 t (Cn (v, i, a)) =
   7.818 -    (if ((v : IntInf.int) = (0 : IntInf.int))
   7.819 -      then Add (Mul (i, t), numsubst0 t a)
   7.820 -      else Cn (suc (minus_nat v (1 : IntInf.int)), i, numsubst0 t a));
   7.821 -
   7.822 -fun subst0 t T = T
   7.823 -  | subst0 t F = F
   7.824 -  | subst0 t (Lt a) = Lt (numsubst0 t a)
   7.825 -  | subst0 t (Le a) = Le (numsubst0 t a)
   7.826 -  | subst0 t (Gt a) = Gt (numsubst0 t a)
   7.827 -  | subst0 t (Ge a) = Ge (numsubst0 t a)
   7.828 -  | subst0 t (Eq a) = Eq (numsubst0 t a)
   7.829 -  | subst0 t (NEq a) = NEq (numsubst0 t a)
   7.830 -  | subst0 t (Dvd (i, a)) = Dvd (i, numsubst0 t a)
   7.831 -  | subst0 t (NDvd (i, a)) = NDvd (i, numsubst0 t a)
   7.832 -  | subst0 t (Not p) = Not (subst0 t p)
   7.833 -  | subst0 t (And (p, q)) = And (subst0 t p, subst0 t q)
   7.834 -  | subst0 t (Or (p, q)) = Or (subst0 t p, subst0 t q)
   7.835 -  | subst0 t (Imp (p, q)) = Imp (subst0 t p, subst0 t q)
   7.836 -  | subst0 t (Iff (p, q)) = Iff (subst0 t p, subst0 t q)
   7.837 -  | subst0 t (Closed p) = Closed p
   7.838 -  | subst0 t (NClosed p) = NClosed p;
   7.839 -
   7.840 -fun minusinf (And (p, q)) = And (minusinf p, minusinf q)
   7.841 -  | minusinf (Or (p, q)) = Or (minusinf p, minusinf q)
   7.842 -  | minusinf T = T
   7.843 -  | minusinf F = F
   7.844 -  | minusinf (Lt (C bo)) = Lt (C bo)
   7.845 -  | minusinf (Lt (Bound bp)) = Lt (Bound bp)
   7.846 -  | minusinf (Lt (Neg bt)) = Lt (Neg bt)
   7.847 -  | minusinf (Lt (Add (bu, bv))) = Lt (Add (bu, bv))
   7.848 -  | minusinf (Lt (Sub (bw, bx))) = Lt (Sub (bw, bx))
   7.849 -  | minusinf (Lt (Mul (by, bz))) = Lt (Mul (by, bz))
   7.850 -  | minusinf (Le (C co)) = Le (C co)
   7.851 -  | minusinf (Le (Bound cp)) = Le (Bound cp)
   7.852 -  | minusinf (Le (Neg ct)) = Le (Neg ct)
   7.853 -  | minusinf (Le (Add (cu, cv))) = Le (Add (cu, cv))
   7.854 -  | minusinf (Le (Sub (cw, cx))) = Le (Sub (cw, cx))
   7.855 -  | minusinf (Le (Mul (cy, cz))) = Le (Mul (cy, cz))
   7.856 -  | minusinf (Gt (C doa)) = Gt (C doa)
   7.857 -  | minusinf (Gt (Bound dp)) = Gt (Bound dp)
   7.858 -  | minusinf (Gt (Neg dt)) = Gt (Neg dt)
   7.859 -  | minusinf (Gt (Add (du, dv))) = Gt (Add (du, dv))
   7.860 -  | minusinf (Gt (Sub (dw, dx))) = Gt (Sub (dw, dx))
   7.861 -  | minusinf (Gt (Mul (dy, dz))) = Gt (Mul (dy, dz))
   7.862 -  | minusinf (Ge (C eo)) = Ge (C eo)
   7.863 -  | minusinf (Ge (Bound ep)) = Ge (Bound ep)
   7.864 -  | minusinf (Ge (Neg et)) = Ge (Neg et)
   7.865 -  | minusinf (Ge (Add (eu, ev))) = Ge (Add (eu, ev))
   7.866 -  | minusinf (Ge (Sub (ew, ex))) = Ge (Sub (ew, ex))
   7.867 -  | minusinf (Ge (Mul (ey, ez))) = Ge (Mul (ey, ez))
   7.868 -  | minusinf (Eq (C fo)) = Eq (C fo)
   7.869 -  | minusinf (Eq (Bound fp)) = Eq (Bound fp)
   7.870 -  | minusinf (Eq (Neg ft)) = Eq (Neg ft)
   7.871 -  | minusinf (Eq (Add (fu, fv))) = Eq (Add (fu, fv))
   7.872 -  | minusinf (Eq (Sub (fw, fx))) = Eq (Sub (fw, fx))
   7.873 -  | minusinf (Eq (Mul (fy, fz))) = Eq (Mul (fy, fz))
   7.874 -  | minusinf (NEq (C go)) = NEq (C go)
   7.875 -  | minusinf (NEq (Bound gp)) = NEq (Bound gp)
   7.876 -  | minusinf (NEq (Neg gt)) = NEq (Neg gt)
   7.877 -  | minusinf (NEq (Add (gu, gv))) = NEq (Add (gu, gv))
   7.878 -  | minusinf (NEq (Sub (gw, gx))) = NEq (Sub (gw, gx))
   7.879 -  | minusinf (NEq (Mul (gy, gz))) = NEq (Mul (gy, gz))
   7.880 -  | minusinf (Dvd (aa, ab)) = Dvd (aa, ab)
   7.881 -  | minusinf (NDvd (ac, ad)) = NDvd (ac, ad)
   7.882 -  | minusinf (Not ae) = Not ae
   7.883 -  | minusinf (Imp (aj, ak)) = Imp (aj, ak)
   7.884 -  | minusinf (Iff (al, am)) = Iff (al, am)
   7.885 -  | minusinf (E an) = E an
   7.886 -  | minusinf (A ao) = A ao
   7.887 -  | minusinf (Closed ap) = Closed ap
   7.888 -  | minusinf (NClosed aq) = NClosed aq
   7.889 -  | minusinf (Lt (Cn (cm, c, e))) =
   7.890 -    (if ((cm : IntInf.int) = (0 : IntInf.int)) then T
   7.891 -      else Lt (Cn (suc (minus_nat cm (1 : IntInf.int)), c, e)))
   7.892 -  | minusinf (Le (Cn (dm, c, e))) =
   7.893 -    (if ((dm : IntInf.int) = (0 : IntInf.int)) then T
   7.894 -      else Le (Cn (suc (minus_nat dm (1 : IntInf.int)), c, e)))
   7.895 -  | minusinf (Gt (Cn (em, c, e))) =
   7.896 -    (if ((em : IntInf.int) = (0 : IntInf.int)) then F
   7.897 -      else Gt (Cn (suc (minus_nat em (1 : IntInf.int)), c, e)))
   7.898 -  | minusinf (Ge (Cn (fm, c, e))) =
   7.899 -    (if ((fm : IntInf.int) = (0 : IntInf.int)) then F
   7.900 -      else Ge (Cn (suc (minus_nat fm (1 : IntInf.int)), c, e)))
   7.901 -  | minusinf (Eq (Cn (gm, c, e))) =
   7.902 -    (if ((gm : IntInf.int) = (0 : IntInf.int)) then F
   7.903 -      else Eq (Cn (suc (minus_nat gm (1 : IntInf.int)), c, e)))
   7.904 -  | minusinf (NEq (Cn (hm, c, e))) =
   7.905 -    (if ((hm : IntInf.int) = (0 : IntInf.int)) then T
   7.906 -      else NEq (Cn (suc (minus_nat hm (1 : IntInf.int)), c, e)));
   7.907 -
   7.908 -val eq_int = {eq = (fn a => fn b => ((a : IntInf.int) = b))} : IntInf.int eq;
   7.909 -
   7.910 -val zero_int : IntInf.int = (0 : IntInf.int);
   7.911 -
   7.912 -type 'a zero = {zero : 'a};
   7.913 -val zero = #zero : 'a zero -> 'a;
   7.914 -
   7.915 -val zero_inta = {zero = zero_int} : IntInf.int zero;
   7.916 -
   7.917 -type 'a times = {times : 'a -> 'a -> 'a};
   7.918 -val times = #times : 'a times -> 'a -> 'a -> 'a;
   7.919 -
   7.920 -type 'a no_zero_divisors =
   7.921 -  {times_no_zero_divisors : 'a times, zero_no_zero_divisors : 'a zero};
   7.922 -val times_no_zero_divisors = #times_no_zero_divisors :
   7.923 -  'a no_zero_divisors -> 'a times;
   7.924 -val zero_no_zero_divisors = #zero_no_zero_divisors :
   7.925 -  'a no_zero_divisors -> 'a zero;
   7.926 -
   7.927 -val times_int = {times = (fn a => fn b => IntInf.* (a, b))} : IntInf.int times;
   7.928 -
   7.929 -val no_zero_divisors_int =
   7.930 -  {times_no_zero_divisors = times_int, zero_no_zero_divisors = zero_inta} :
   7.931 -  IntInf.int no_zero_divisors;
   7.932 -
   7.933 -type 'a one = {one : 'a};
   7.934 -val one = #one : 'a one -> 'a;
   7.935 -
   7.936 -type 'a zero_neq_one = {one_zero_neq_one : 'a one, zero_zero_neq_one : 'a zero};
   7.937 -val one_zero_neq_one = #one_zero_neq_one : 'a zero_neq_one -> 'a one;
   7.938 -val zero_zero_neq_one = #zero_zero_neq_one : 'a zero_neq_one -> 'a zero;
   7.939 -
   7.940 -type 'a semigroup_mult = {times_semigroup_mult : 'a times};
   7.941 -val times_semigroup_mult = #times_semigroup_mult :
   7.942 -  'a semigroup_mult -> 'a times;
   7.943 -
   7.944 -type 'a plus = {plus : 'a -> 'a -> 'a};
   7.945 -val plus = #plus : 'a plus -> 'a -> 'a -> 'a;
   7.946 -
   7.947 -type 'a semigroup_add = {plus_semigroup_add : 'a plus};
   7.948 -val plus_semigroup_add = #plus_semigroup_add : 'a semigroup_add -> 'a plus;
   7.949 -
   7.950 -type 'a ab_semigroup_add = {semigroup_add_ab_semigroup_add : 'a semigroup_add};
   7.951 -val semigroup_add_ab_semigroup_add = #semigroup_add_ab_semigroup_add :
   7.952 -  'a ab_semigroup_add -> 'a semigroup_add;
   7.953 -
   7.954 -type 'a semiring =
   7.955 -  {ab_semigroup_add_semiring : 'a ab_semigroup_add,
   7.956 -    semigroup_mult_semiring : 'a semigroup_mult};
   7.957 -val ab_semigroup_add_semiring = #ab_semigroup_add_semiring :
   7.958 -  'a semiring -> 'a ab_semigroup_add;
   7.959 -val semigroup_mult_semiring = #semigroup_mult_semiring :
   7.960 -  'a semiring -> 'a semigroup_mult;
   7.961 -
   7.962 -type 'a mult_zero = {times_mult_zero : 'a times, zero_mult_zero : 'a zero};
   7.963 -val times_mult_zero = #times_mult_zero : 'a mult_zero -> 'a times;
   7.964 -val zero_mult_zero = #zero_mult_zero : 'a mult_zero -> 'a zero;
   7.965 -
   7.966 -type 'a monoid_add =
   7.967 -  {semigroup_add_monoid_add : 'a semigroup_add, zero_monoid_add : 'a zero};
   7.968 -val semigroup_add_monoid_add = #semigroup_add_monoid_add :
   7.969 -  'a monoid_add -> 'a semigroup_add;
   7.970 -val zero_monoid_add = #zero_monoid_add : 'a monoid_add -> 'a zero;
   7.971 -
   7.972 -type 'a comm_monoid_add =
   7.973 -  {ab_semigroup_add_comm_monoid_add : 'a ab_semigroup_add,
   7.974 -    monoid_add_comm_monoid_add : 'a monoid_add};
   7.975 -val ab_semigroup_add_comm_monoid_add = #ab_semigroup_add_comm_monoid_add :
   7.976 -  'a comm_monoid_add -> 'a ab_semigroup_add;
   7.977 -val monoid_add_comm_monoid_add = #monoid_add_comm_monoid_add :
   7.978 -  'a comm_monoid_add -> 'a monoid_add;
   7.979 -
   7.980 -type 'a semiring_0 =
   7.981 -  {comm_monoid_add_semiring_0 : 'a comm_monoid_add,
   7.982 -    mult_zero_semiring_0 : 'a mult_zero, semiring_semiring_0 : 'a semiring};
   7.983 -val comm_monoid_add_semiring_0 = #comm_monoid_add_semiring_0 :
   7.984 -  'a semiring_0 -> 'a comm_monoid_add;
   7.985 -val mult_zero_semiring_0 = #mult_zero_semiring_0 :
   7.986 -  'a semiring_0 -> 'a mult_zero;
   7.987 -val semiring_semiring_0 = #semiring_semiring_0 : 'a semiring_0 -> 'a semiring;
   7.988 -
   7.989 -type 'a power = {one_power : 'a one, times_power : 'a times};
   7.990 -val one_power = #one_power : 'a power -> 'a one;
   7.991 -val times_power = #times_power : 'a power -> 'a times;
   7.992 -
   7.993 -type 'a monoid_mult =
   7.994 -  {semigroup_mult_monoid_mult : 'a semigroup_mult,
   7.995 -    power_monoid_mult : 'a power};
   7.996 -val semigroup_mult_monoid_mult = #semigroup_mult_monoid_mult :
   7.997 -  'a monoid_mult -> 'a semigroup_mult;
   7.998 -val power_monoid_mult = #power_monoid_mult : 'a monoid_mult -> 'a power;
   7.999 -
  7.1000 -type 'a semiring_1 =
  7.1001 -  {monoid_mult_semiring_1 : 'a monoid_mult,
  7.1002 -    semiring_0_semiring_1 : 'a semiring_0,
  7.1003 -    zero_neq_one_semiring_1 : 'a zero_neq_one};
  7.1004 -val monoid_mult_semiring_1 = #monoid_mult_semiring_1 :
  7.1005 -  'a semiring_1 -> 'a monoid_mult;
  7.1006 -val semiring_0_semiring_1 = #semiring_0_semiring_1 :
  7.1007 -  'a semiring_1 -> 'a semiring_0;
  7.1008 -val zero_neq_one_semiring_1 = #zero_neq_one_semiring_1 :
  7.1009 -  'a semiring_1 -> 'a zero_neq_one;
  7.1010 -
  7.1011 -type 'a cancel_semigroup_add =
  7.1012 -  {semigroup_add_cancel_semigroup_add : 'a semigroup_add};
  7.1013 -val semigroup_add_cancel_semigroup_add = #semigroup_add_cancel_semigroup_add :
  7.1014 -  'a cancel_semigroup_add -> 'a semigroup_add;
  7.1015 -
  7.1016 -type 'a cancel_ab_semigroup_add =
  7.1017 -  {ab_semigroup_add_cancel_ab_semigroup_add : 'a ab_semigroup_add,
  7.1018 -    cancel_semigroup_add_cancel_ab_semigroup_add : 'a cancel_semigroup_add};
  7.1019 -val ab_semigroup_add_cancel_ab_semigroup_add =
  7.1020 -  #ab_semigroup_add_cancel_ab_semigroup_add :
  7.1021 -  'a cancel_ab_semigroup_add -> 'a ab_semigroup_add;
  7.1022 -val cancel_semigroup_add_cancel_ab_semigroup_add =
  7.1023 -  #cancel_semigroup_add_cancel_ab_semigroup_add :
  7.1024 -  'a cancel_ab_semigroup_add -> 'a cancel_semigroup_add;
  7.1025 -
  7.1026 -type 'a cancel_comm_monoid_add =
  7.1027 -  {cancel_ab_semigroup_add_cancel_comm_monoid_add : 'a cancel_ab_semigroup_add,
  7.1028 -    comm_monoid_add_cancel_comm_monoid_add : 'a comm_monoid_add};
  7.1029 -val cancel_ab_semigroup_add_cancel_comm_monoid_add =
  7.1030 -  #cancel_ab_semigroup_add_cancel_comm_monoid_add :
  7.1031 -  'a cancel_comm_monoid_add -> 'a cancel_ab_semigroup_add;
  7.1032 -val comm_monoid_add_cancel_comm_monoid_add =
  7.1033 -  #comm_monoid_add_cancel_comm_monoid_add :
  7.1034 -  'a cancel_comm_monoid_add -> 'a comm_monoid_add;
  7.1035 -
  7.1036 -type 'a semiring_0_cancel =
  7.1037 -  {cancel_comm_monoid_add_semiring_0_cancel : 'a cancel_comm_monoid_add,
  7.1038 -    semiring_0_semiring_0_cancel : 'a semiring_0};
  7.1039 -val cancel_comm_monoid_add_semiring_0_cancel =
  7.1040 -  #cancel_comm_monoid_add_semiring_0_cancel :
  7.1041 -  'a semiring_0_cancel -> 'a cancel_comm_monoid_add;
  7.1042 -val semiring_0_semiring_0_cancel = #semiring_0_semiring_0_cancel :
  7.1043 -  'a semiring_0_cancel -> 'a semiring_0;
  7.1044 -
  7.1045 -type 'a semiring_1_cancel =
  7.1046 -  {semiring_0_cancel_semiring_1_cancel : 'a semiring_0_cancel,
  7.1047 -    semiring_1_semiring_1_cancel : 'a semiring_1};
  7.1048 -val semiring_0_cancel_semiring_1_cancel = #semiring_0_cancel_semiring_1_cancel :
  7.1049 -  'a semiring_1_cancel -> 'a semiring_0_cancel;
  7.1050 -val semiring_1_semiring_1_cancel = #semiring_1_semiring_1_cancel :
  7.1051 -  'a semiring_1_cancel -> 'a semiring_1;
  7.1052 -
  7.1053 -type 'a dvd = {times_dvd : 'a times};
  7.1054 -val times_dvd = #times_dvd : 'a dvd -> 'a times;
  7.1055 -
  7.1056 -type 'a ab_semigroup_mult =
  7.1057 -  {semigroup_mult_ab_semigroup_mult : 'a semigroup_mult};
  7.1058 -val semigroup_mult_ab_semigroup_mult = #semigroup_mult_ab_semigroup_mult :
  7.1059 -  'a ab_semigroup_mult -> 'a semigroup_mult;
  7.1060 -
  7.1061 -type 'a comm_semiring =
  7.1062 -  {ab_semigroup_mult_comm_semiring : 'a ab_semigroup_mult,
  7.1063 -    semiring_comm_semiring : 'a semiring};
  7.1064 -val ab_semigroup_mult_comm_semiring = #ab_semigroup_mult_comm_semiring :
  7.1065 -  'a comm_semiring -> 'a ab_semigroup_mult;
  7.1066 -val semiring_comm_semiring = #semiring_comm_semiring :
  7.1067 -  'a comm_semiring -> 'a semiring;
  7.1068 -
  7.1069 -type 'a comm_semiring_0 =
  7.1070 -  {comm_semiring_comm_semiring_0 : 'a comm_semiring,
  7.1071 -    semiring_0_comm_semiring_0 : 'a semiring_0};
  7.1072 -val comm_semiring_comm_semiring_0 = #comm_semiring_comm_semiring_0 :
  7.1073 -  'a comm_semiring_0 -> 'a comm_semiring;
  7.1074 -val semiring_0_comm_semiring_0 = #semiring_0_comm_semiring_0 :
  7.1075 -  'a comm_semiring_0 -> 'a semiring_0;
  7.1076 -
  7.1077 -type 'a comm_monoid_mult =
  7.1078 -  {ab_semigroup_mult_comm_monoid_mult : 'a ab_semigroup_mult,
  7.1079 -    monoid_mult_comm_monoid_mult : 'a monoid_mult};
  7.1080 -val ab_semigroup_mult_comm_monoid_mult = #ab_semigroup_mult_comm_monoid_mult :
  7.1081 -  'a comm_monoid_mult -> 'a ab_semigroup_mult;
  7.1082 -val monoid_mult_comm_monoid_mult = #monoid_mult_comm_monoid_mult :
  7.1083 -  'a comm_monoid_mult -> 'a monoid_mult;
  7.1084 -
  7.1085 -type 'a comm_semiring_1 =
  7.1086 -  {comm_monoid_mult_comm_semiring_1 : 'a comm_monoid_mult,
  7.1087 -    comm_semiring_0_comm_semiring_1 : 'a comm_semiring_0,
  7.1088 -    dvd_comm_semiring_1 : 'a dvd, semiring_1_comm_semiring_1 : 'a semiring_1};
  7.1089 -val comm_monoid_mult_comm_semiring_1 = #comm_monoid_mult_comm_semiring_1 :
  7.1090 -  'a comm_semiring_1 -> 'a comm_monoid_mult;
  7.1091 -val comm_semiring_0_comm_semiring_1 = #comm_semiring_0_comm_semiring_1 :
  7.1092 -  'a comm_semiring_1 -> 'a comm_semiring_0;
  7.1093 -val dvd_comm_semiring_1 = #dvd_comm_semiring_1 : 'a comm_semiring_1 -> 'a dvd;
  7.1094 -val semiring_1_comm_semiring_1 = #semiring_1_comm_semiring_1 :
  7.1095 -  'a comm_semiring_1 -> 'a semiring_1;
  7.1096 -
  7.1097 -type 'a comm_semiring_0_cancel =
  7.1098 -  {comm_semiring_0_comm_semiring_0_cancel : 'a comm_semiring_0,
  7.1099 -    semiring_0_cancel_comm_semiring_0_cancel : 'a semiring_0_cancel};
  7.1100 -val comm_semiring_0_comm_semiring_0_cancel =
  7.1101 -  #comm_semiring_0_comm_semiring_0_cancel :
  7.1102 -  'a comm_semiring_0_cancel -> 'a comm_semiring_0;
  7.1103 -val semiring_0_cancel_comm_semiring_0_cancel =
  7.1104 -  #semiring_0_cancel_comm_semiring_0_cancel :
  7.1105 -  'a comm_semiring_0_cancel -> 'a semiring_0_cancel;
  7.1106 -
  7.1107 -type 'a comm_semiring_1_cancel =
  7.1108 -  {comm_semiring_0_cancel_comm_semiring_1_cancel : 'a comm_semiring_0_cancel,
  7.1109 -    comm_semiring_1_comm_semiring_1_cancel : 'a comm_semiring_1,
  7.1110 -    semiring_1_cancel_comm_semiring_1_cancel : 'a semiring_1_cancel};
  7.1111 -val comm_semiring_0_cancel_comm_semiring_1_cancel =
  7.1112 -  #comm_semiring_0_cancel_comm_semiring_1_cancel :
  7.1113 -  'a comm_semiring_1_cancel -> 'a comm_semiring_0_cancel;
  7.1114 -val comm_semiring_1_comm_semiring_1_cancel =
  7.1115 -  #comm_semiring_1_comm_semiring_1_cancel :
  7.1116 -  'a comm_semiring_1_cancel -> 'a comm_semiring_1;
  7.1117 -val semiring_1_cancel_comm_semiring_1_cancel =
  7.1118 -  #semiring_1_cancel_comm_semiring_1_cancel :
  7.1119 -  'a comm_semiring_1_cancel -> 'a semiring_1_cancel;
  7.1120 -
  7.1121 -type 'a diva = {dvd_div : 'a dvd, diva : 'a -> 'a -> 'a, moda : 'a -> 'a -> 'a};
  7.1122 -val dvd_div = #dvd_div : 'a diva -> 'a dvd;
  7.1123 -val diva = #diva : 'a diva -> 'a -> 'a -> 'a;
  7.1124 -val moda = #moda : 'a diva -> 'a -> 'a -> 'a;
  7.1125 -
  7.1126 -type 'a semiring_div =
  7.1127 -  {div_semiring_div : 'a diva,
  7.1128 -    comm_semiring_1_cancel_semiring_div : 'a comm_semiring_1_cancel,
  7.1129 -    no_zero_divisors_semiring_div : 'a no_zero_divisors};
  7.1130 -val div_semiring_div = #div_semiring_div : 'a semiring_div -> 'a diva;
  7.1131 -val comm_semiring_1_cancel_semiring_div = #comm_semiring_1_cancel_semiring_div :
  7.1132 -  'a semiring_div -> 'a comm_semiring_1_cancel;
  7.1133 -val no_zero_divisors_semiring_div = #no_zero_divisors_semiring_div :
  7.1134 -  'a semiring_div -> 'a no_zero_divisors;
  7.1135 -
  7.1136 -val one_int : IntInf.int = (1 : IntInf.int);
  7.1137 -
  7.1138 -val one_inta = {one = one_int} : IntInf.int one;
  7.1139 -
  7.1140 -val zero_neq_one_int =
  7.1141 -  {one_zero_neq_one = one_inta, zero_zero_neq_one = zero_inta} :
  7.1142 -  IntInf.int zero_neq_one;
  7.1143 -
  7.1144 -val semigroup_mult_int = {times_semigroup_mult = times_int} :
  7.1145 -  IntInf.int semigroup_mult;
  7.1146 -
  7.1147 -val plus_int = {plus = (fn a => fn b => IntInf.+ (a, b))} : IntInf.int plus;
  7.1148 -
  7.1149 -val semigroup_add_int = {plus_semigroup_add = plus_int} :
  7.1150 -  IntInf.int semigroup_add;
  7.1151 -
  7.1152 -val ab_semigroup_add_int = {semigroup_add_ab_semigroup_add = semigroup_add_int}
  7.1153 -  : IntInf.int ab_semigroup_add;
  7.1154 -
  7.1155 -val semiring_int =
  7.1156 -  {ab_semigroup_add_semiring = ab_semigroup_add_int,
  7.1157 -    semigroup_mult_semiring = semigroup_mult_int}
  7.1158 -  : IntInf.int semiring;
  7.1159 -
  7.1160 -val mult_zero_int = {times_mult_zero = times_int, zero_mult_zero = zero_inta} :
  7.1161 -  IntInf.int mult_zero;
  7.1162 -
  7.1163 -val monoid_add_int =
  7.1164 -  {semigroup_add_monoid_add = semigroup_add_int, zero_monoid_add = zero_inta} :
  7.1165 -  IntInf.int monoid_add;
  7.1166 -
  7.1167 -val comm_monoid_add_int =
  7.1168 -  {ab_semigroup_add_comm_monoid_add = ab_semigroup_add_int,
  7.1169 -    monoid_add_comm_monoid_add = monoid_add_int}
  7.1170 -  : IntInf.int comm_monoid_add;
  7.1171 -
  7.1172 -val semiring_0_int =
  7.1173 -  {comm_monoid_add_semiring_0 = comm_monoid_add_int,
  7.1174 -    mult_zero_semiring_0 = mult_zero_int, semiring_semiring_0 = semiring_int}
  7.1175 -  : IntInf.int semiring_0;
  7.1176 -
  7.1177 -val power_int = {one_power = one_inta, times_power = times_int} :
  7.1178 -  IntInf.int power;
  7.1179 -
  7.1180 -val monoid_mult_int =
  7.1181 -  {semigroup_mult_monoid_mult = semigroup_mult_int,
  7.1182 -    power_monoid_mult = power_int}
  7.1183 -  : IntInf.int monoid_mult;
  7.1184 -
  7.1185 -val semiring_1_int =
  7.1186 -  {monoid_mult_semiring_1 = monoid_mult_int,
  7.1187 -    semiring_0_semiring_1 = semiring_0_int,
  7.1188 -    zero_neq_one_semiring_1 = zero_neq_one_int}
  7.1189 -  : IntInf.int semiring_1;
  7.1190 -
  7.1191 -val cancel_semigroup_add_int =
  7.1192 -  {semigroup_add_cancel_semigroup_add = semigroup_add_int} :
  7.1193 -  IntInf.int cancel_semigroup_add;
  7.1194 -
  7.1195 -val cancel_ab_semigroup_add_int =
  7.1196 -  {ab_semigroup_add_cancel_ab_semigroup_add = ab_semigroup_add_int,
  7.1197 -    cancel_semigroup_add_cancel_ab_semigroup_add = cancel_semigroup_add_int}
  7.1198 -  : IntInf.int cancel_ab_semigroup_add;
  7.1199 -
  7.1200 -val cancel_comm_monoid_add_int =
  7.1201 -  {cancel_ab_semigroup_add_cancel_comm_monoid_add = cancel_ab_semigroup_add_int,
  7.1202 -    comm_monoid_add_cancel_comm_monoid_add = comm_monoid_add_int}
  7.1203 -  : IntInf.int cancel_comm_monoid_add;
  7.1204 -
  7.1205 -val semiring_0_cancel_int =
  7.1206 -  {cancel_comm_monoid_add_semiring_0_cancel = cancel_comm_monoid_add_int,
  7.1207 -    semiring_0_semiring_0_cancel = semiring_0_int}
  7.1208 -  : IntInf.int semiring_0_cancel;
  7.1209 -
  7.1210 -val semiring_1_cancel_int =
  7.1211 -  {semiring_0_cancel_semiring_1_cancel = semiring_0_cancel_int,
  7.1212 -    semiring_1_semiring_1_cancel = semiring_1_int}
  7.1213 -  : IntInf.int semiring_1_cancel;
  7.1214 -
  7.1215 -val dvd_int = {times_dvd = times_int} : IntInf.int dvd;
  7.1216 -
  7.1217 -val ab_semigroup_mult_int =
  7.1218 -  {semigroup_mult_ab_semigroup_mult = semigroup_mult_int} :
  7.1219 -  IntInf.int ab_semigroup_mult;
  7.1220 -
  7.1221 -val comm_semiring_int =
  7.1222 -  {ab_semigroup_mult_comm_semiring = ab_semigroup_mult_int,
  7.1223 -    semiring_comm_semiring = semiring_int}
  7.1224 -  : IntInf.int comm_semiring;
  7.1225 -
  7.1226 -val comm_semiring_0_int =
  7.1227 -  {comm_semiring_comm_semiring_0 = comm_semiring_int,
  7.1228 -    semiring_0_comm_semiring_0 = semiring_0_int}
  7.1229 -  : IntInf.int comm_semiring_0;
  7.1230 -
  7.1231 -val comm_monoid_mult_int =
  7.1232 -  {ab_semigroup_mult_comm_monoid_mult = ab_semigroup_mult_int,
  7.1233 -    monoid_mult_comm_monoid_mult = monoid_mult_int}
  7.1234 -  : IntInf.int comm_monoid_mult;
  7.1235 -
  7.1236 -val comm_semiring_1_int =
  7.1237 -  {comm_monoid_mult_comm_semiring_1 = comm_monoid_mult_int,
  7.1238 -    comm_semiring_0_comm_semiring_1 = comm_semiring_0_int,
  7.1239 -    dvd_comm_semiring_1 = dvd_int, semiring_1_comm_semiring_1 = semiring_1_int}
  7.1240 -  : IntInf.int comm_semiring_1;
  7.1241 -
  7.1242 -val comm_semiring_0_cancel_int =
  7.1243 -  {comm_semiring_0_comm_semiring_0_cancel = comm_semiring_0_int,
  7.1244 -    semiring_0_cancel_comm_semiring_0_cancel = semiring_0_cancel_int}
  7.1245 -  : IntInf.int comm_semiring_0_cancel;
  7.1246 -
  7.1247 -val comm_semiring_1_cancel_int =
  7.1248 -  {comm_semiring_0_cancel_comm_semiring_1_cancel = comm_semiring_0_cancel_int,
  7.1249 -    comm_semiring_1_comm_semiring_1_cancel = comm_semiring_1_int,
  7.1250 -    semiring_1_cancel_comm_semiring_1_cancel = semiring_1_cancel_int}
  7.1251 -  : IntInf.int comm_semiring_1_cancel;
  7.1252 -
  7.1253 -fun abs_int i = (if IntInf.< (i, (0 : IntInf.int)) then IntInf.~ i else i);
  7.1254 -
  7.1255 -fun split f (a, b) = f a b;
  7.1256 -
  7.1257 -fun sgn_int i =
  7.1258 -  (if ((i : IntInf.int) = (0 : IntInf.int)) then (0 : IntInf.int)
  7.1259 -    else (if IntInf.< ((0 : IntInf.int), i) then (1 : IntInf.int)
  7.1260 -           else IntInf.~ (1 : IntInf.int)));
  7.1261 -
  7.1262 -fun apsnd f (x, y) = (x, f y);
  7.1263 -
  7.1264 -fun divmod_int k l =
  7.1265 -  (if ((k : IntInf.int) = (0 : IntInf.int))
  7.1266 -    then ((0 : IntInf.int), (0 : IntInf.int))
  7.1267 -    else (if ((l : IntInf.int) = (0 : IntInf.int)) then ((0 : IntInf.int), k)
  7.1268 -           else apsnd (fn a => IntInf.* (sgn_int l, a))
  7.1269 -                  (if (((sgn_int k) : IntInf.int) = (sgn_int l))
  7.1270 -                    then IntInf.divMod (IntInf.abs k, IntInf.abs l)
  7.1271 -                    else let
  7.1272 -                           val (r, s) =
  7.1273 -                             IntInf.divMod (IntInf.abs k, IntInf.abs l);
  7.1274 -                         in
  7.1275 -                           (if ((s : IntInf.int) = (0 : IntInf.int))
  7.1276 -                             then (IntInf.~ r, (0 : IntInf.int))
  7.1277 -                             else (IntInf.- (IntInf.~ r, (1 : IntInf.int)),
  7.1278 -                                    IntInf.- (abs_int l, s)))
  7.1279 -                         end)));
  7.1280 -
  7.1281 -fun snd (a, b) = b;
  7.1282 -
  7.1283 -fun mod_int a b = snd (divmod_int a b);
  7.1284 -
  7.1285 -fun fst (a, b) = a;
  7.1286 -
  7.1287 -fun div_int a b = fst (divmod_int a b);
  7.1288 -
  7.1289 -val div_inta = {dvd_div = dvd_int, diva = div_int, moda = mod_int} :
  7.1290 -  IntInf.int diva;
  7.1291 -
  7.1292 -val semiring_div_int =
  7.1293 -  {div_semiring_div = div_inta,
  7.1294 -    comm_semiring_1_cancel_semiring_div = comm_semiring_1_cancel_int,
  7.1295 -    no_zero_divisors_semiring_div = no_zero_divisors_int}
  7.1296 -  : IntInf.int semiring_div;
  7.1297 -
  7.1298 -fun dvd (A1_, A2_) a b =
  7.1299 -  eqa A2_ (moda (div_semiring_div A1_) b a)
  7.1300 -    (zero ((zero_no_zero_divisors o no_zero_divisors_semiring_div) A1_));
  7.1301 -
  7.1302 -fun num_case f1 f2 f3 f4 f5 f6 f7 (Mul (inta, num)) = f7 inta num
  7.1303 -  | num_case f1 f2 f3 f4 f5 f6 f7 (Sub (num1, num2)) = f6 num1 num2
  7.1304 -  | num_case f1 f2 f3 f4 f5 f6 f7 (Add (num1, num2)) = f5 num1 num2
  7.1305 -  | num_case f1 f2 f3 f4 f5 f6 f7 (Neg num) = f4 num
  7.1306 -  | num_case f1 f2 f3 f4 f5 f6 f7 (Cn (nat, inta, num)) = f3 nat inta num
  7.1307 -  | num_case f1 f2 f3 f4 f5 f6 f7 (Bound nat) = f2 nat
  7.1308 -  | num_case f1 f2 f3 f4 f5 f6 f7 (C inta) = f1 inta;
  7.1309 -
  7.1310 -fun nummul i (C j) = C (IntInf.* (i, j))
  7.1311 -  | nummul i (Cn (n, c, t)) = Cn (n, IntInf.* (c, i), nummul i t)
  7.1312 -  | nummul i (Bound v) = Mul (i, Bound v)
  7.1313 -  | nummul i (Neg v) = Mul (i, Neg v)
  7.1314 -  | nummul i (Add (v, va)) = Mul (i, Add (v, va))
  7.1315 -  | nummul i (Sub (v, va)) = Mul (i, Sub (v, va))
  7.1316 -  | nummul i (Mul (v, va)) = Mul (i, Mul (v, va));
  7.1317 -
  7.1318 -fun numneg t = nummul (IntInf.~ (1 : IntInf.int)) t;
  7.1319 -
  7.1320 -fun numadd (Cn (n1, c1, r1), Cn (n2, c2, r2)) =
  7.1321 -  (if ((n1 : IntInf.int) = n2)
  7.1322 -    then let
  7.1323 -           val c = IntInf.+ (c1, c2);
  7.1324 -         in
  7.1325 -           (if ((c : IntInf.int) = (0 : IntInf.int)) then numadd (r1, r2)
  7.1326 -             else Cn (n1, c, numadd (r1, r2)))
  7.1327 -         end
  7.1328 -    else (if IntInf.<= (n1, n2)
  7.1329 -           then Cn (n1, c1, numadd (r1, Add (Mul (c2, Bound n2), r2)))
  7.1330 -           else Cn (n2, c2, numadd (Add (Mul (c1, Bound n1), r1), r2))))
  7.1331 -  | numadd (Cn (n1, c1, r1), C dd) = Cn (n1, c1, numadd (r1, C dd))
  7.1332 -  | numadd (Cn (n1, c1, r1), Bound de) = Cn (n1, c1, numadd (r1, Bound de))
  7.1333 -  | numadd (Cn (n1, c1, r1), Neg di) = Cn (n1, c1, numadd (r1, Neg di))
  7.1334 -  | numadd (Cn (n1, c1, r1), Add (dj, dk)) =
  7.1335 -    Cn (n1, c1, numadd (r1, Add (dj, dk)))
  7.1336 -  | numadd (Cn (n1, c1, r1), Sub (dl, dm)) =
  7.1337 -    Cn (n1, c1, numadd (r1, Sub (dl, dm)))
  7.1338 -  | numadd (Cn (n1, c1, r1), Mul (dn, doa)) =
  7.1339 -    Cn (n1, c1, numadd (r1, Mul (dn, doa)))
  7.1340 -  | numadd (C w, Cn (n2, c2, r2)) = Cn (n2, c2, numadd (C w, r2))
  7.1341 -  | numadd (Bound x, Cn (n2, c2, r2)) = Cn (n2, c2, numadd (Bound x, r2))
  7.1342 -  | numadd (Neg ac, Cn (n2, c2, r2)) = Cn (n2, c2, numadd (Neg ac, r2))
  7.1343 -  | numadd (Add (ad, ae), Cn (n2, c2, r2)) =
  7.1344 -    Cn (n2, c2, numadd (Add (ad, ae), r2))
  7.1345 -  | numadd (Sub (af, ag), Cn (n2, c2, r2)) =
  7.1346 -    Cn (n2, c2, numadd (Sub (af, ag), r2))
  7.1347 -  | numadd (Mul (ah, ai), Cn (n2, c2, r2)) =
  7.1348 -    Cn (n2, c2, numadd (Mul (ah, ai), r2))
  7.1349 -  | numadd (C b1, C b2) = C (IntInf.+ (b1, b2))
  7.1350 -  | numadd (C aj, Bound bi) = Add (C aj, Bound bi)
  7.1351 -  | numadd (C aj, Neg bm) = Add (C aj, Neg bm)
  7.1352 -  | numadd (C aj, Add (bn, bo)) = Add (C aj, Add (bn, bo))
  7.1353 -  | numadd (C aj, Sub (bp, bq)) = Add (C aj, Sub (bp, bq))
  7.1354 -  | numadd (C aj, Mul (br, bs)) = Add (C aj, Mul (br, bs))
  7.1355 -  | numadd (Bound ak, C cf) = Add (Bound ak, C cf)
  7.1356 -  | numadd (Bound ak, Bound cg) = Add (Bound ak, Bound cg)
  7.1357 -  | numadd (Bound ak, Neg ck) = Add (Bound ak, Neg ck)
  7.1358 -  | numadd (Bound ak, Add (cl, cm)) = Add (Bound ak, Add (cl, cm))
  7.1359 -  | numadd (Bound ak, Sub (cn, co)) = Add (Bound ak, Sub (cn, co))
  7.1360 -  | numadd (Bound ak, Mul (cp, cq)) = Add (Bound ak, Mul (cp, cq))
  7.1361 -  | numadd (Neg ao, C en) = Add (Neg ao, C en)
  7.1362 -  | numadd (Neg ao, Bound eo) = Add (Neg ao, Bound eo)
  7.1363 -  | numadd (Neg ao, Neg es) = Add (Neg ao, Neg es)
  7.1364 -  | numadd (Neg ao, Add (et, eu)) = Add (Neg ao, Add (et, eu))
  7.1365 -  | numadd (Neg ao, Sub (ev, ew)) = Add (Neg ao, Sub (ev, ew))
  7.1366 -  | numadd (Neg ao, Mul (ex, ey)) = Add (Neg ao, Mul (ex, ey))
  7.1367 -  | numadd (Add (ap, aq), C fl) = Add (Add (ap, aq), C fl)
  7.1368 -  | numadd (Add (ap, aq), Bound fm) = Add (Add (ap, aq), Bound fm)
  7.1369 -  | numadd (Add (ap, aq), Neg fq) = Add (Add (ap, aq), Neg fq)
  7.1370 -  | numadd (Add (ap, aq), Add (fr, fs)) = Add (Add (ap, aq), Add (fr, fs))
  7.1371 -  | numadd (Add (ap, aq), Sub (ft, fu)) = Add (Add (ap, aq), Sub (ft, fu))
  7.1372 -  | numadd (Add (ap, aq), Mul (fv, fw)) = Add (Add (ap, aq), Mul (fv, fw))
  7.1373 -  | numadd (Sub (ar, asa), C gj) = Add (Sub (ar, asa), C gj)
  7.1374 -  | numadd (Sub (ar, asa), Bound gk) = Add (Sub (ar, asa), Bound gk)
  7.1375 -  | numadd (Sub (ar, asa), Neg go) = Add (Sub (ar, asa), Neg go)
  7.1376 -  | numadd (Sub (ar, asa), Add (gp, gq)) = Add (Sub (ar, asa), Add (gp, gq))
  7.1377 -  | numadd (Sub (ar, asa), Sub (gr, gs)) = Add (Sub (ar, asa), Sub (gr, gs))
  7.1378 -  | numadd (Sub (ar, asa), Mul (gt, gu)) = Add (Sub (ar, asa), Mul (gt, gu))
  7.1379 -  | numadd (Mul (at, au), C hh) = Add (Mul (at, au), C hh)
  7.1380 -  | numadd (Mul (at, au), Bound hi) = Add (Mul (at, au), Bound hi)
  7.1381 -  | numadd (Mul (at, au), Neg hm) = Add (Mul (at, au), Neg hm)
  7.1382 -  | numadd (Mul (at, au), Add (hn, ho)) = Add (Mul (at, au), Add (hn, ho))
  7.1383 -  | numadd (Mul (at, au), Sub (hp, hq)) = Add (Mul (at, au), Sub (hp, hq))
  7.1384 -  | numadd (Mul (at, au), Mul (hr, hs)) = Add (Mul (at, au), Mul (hr, hs));
  7.1385 -
  7.1386 -fun numsub s t =
  7.1387 -  (if eq_num s t then C (0 : IntInf.int) else numadd (s, numneg t));
  7.1388 -
  7.1389 -fun simpnum (C j) = C j
  7.1390 -  | simpnum (Bound n) = Cn (n, (1 : IntInf.int), C (0 : IntInf.int))
  7.1391 -  | simpnum (Neg t) = numneg (simpnum t)
  7.1392 -  | simpnum (Add (t, s)) = numadd (simpnum t, simpnum s)
  7.1393 -  | simpnum (Sub (t, s)) = numsub (simpnum t) (simpnum s)
  7.1394 -  | simpnum (Mul (i, t)) =
  7.1395 -    (if ((i : IntInf.int) = (0 : IntInf.int)) then C (0 : IntInf.int)
  7.1396 -      else nummul i (simpnum t))
  7.1397 -  | simpnum (Cn (v, va, vb)) = Cn (v, va, vb);
  7.1398 -
  7.1399 -fun nota (Not p) = p
  7.1400 -  | nota T = F
  7.1401 -  | nota F = T
  7.1402 -  | nota (Lt v) = Not (Lt v)
  7.1403 -  | nota (Le v) = Not (Le v)
  7.1404 -  | nota (Gt v) = Not (Gt v)
  7.1405 -  | nota (Ge v) = Not (Ge v)
  7.1406 -  | nota (Eq v) = Not (Eq v)
  7.1407 -  | nota (NEq v) = Not (NEq v)
  7.1408 -  | nota (Dvd (v, va)) = Not (Dvd (v, va))
  7.1409 -  | nota (NDvd (v, va)) = Not (NDvd (v, va))
  7.1410 -  | nota (And (v, va)) = Not (And (v, va))
  7.1411 -  | nota (Or (v, va)) = Not (Or (v, va))
  7.1412 -  | nota (Imp (v, va)) = Not (Imp (v, va))
  7.1413 -  | nota (Iff (v, va)) = Not (Iff (v, va))
  7.1414 -  | nota (E v) = Not (E v)
  7.1415 -  | nota (A v) = Not (A v)
  7.1416 -  | nota (Closed v) = Not (Closed v)
  7.1417 -  | nota (NClosed v) = Not (NClosed v);
  7.1418 -
  7.1419 -fun iffa p q =
  7.1420 -  (if eq_fm p q then T
  7.1421 -    else (if eq_fm p (nota q) orelse eq_fm (nota p) q then F
  7.1422 -           else (if eq_fm p F then nota q
  7.1423 -                  else (if eq_fm q F then nota p
  7.1424 -                         else (if eq_fm p T then q
  7.1425 -                                else (if eq_fm q T then p else Iff (p, q)))))));
  7.1426 -
  7.1427 -fun impa p q =
  7.1428 -  (if eq_fm p F orelse eq_fm q T then T
  7.1429 -    else (if eq_fm p T then q else (if eq_fm q F then nota p else Imp (p, q))));
  7.1430 -
  7.1431 -fun conj p q =
  7.1432 -  (if eq_fm p F orelse eq_fm q F then F
  7.1433 -    else (if eq_fm p T then q else (if eq_fm q T then p else And (p, q))));
  7.1434 -
  7.1435 -fun simpfm (And (p, q)) = conj (simpfm p) (simpfm q)
  7.1436 -  | simpfm (Or (p, q)) = disj (simpfm p) (simpfm q)
  7.1437 -  | simpfm (Imp (p, q)) = impa (simpfm p) (simpfm q)
  7.1438 -  | simpfm (Iff (p, q)) = iffa (simpfm p) (simpfm q)
  7.1439 -  | simpfm (Not p) = nota (simpfm p)
  7.1440 -  | simpfm (Lt a) =
  7.1441 -    let
  7.1442 -      val aa = simpnum a;
  7.1443 -    in
  7.1444 -      (case aa of C v => (if IntInf.< (v, (0 : IntInf.int)) then T else F)
  7.1445 -        | Bound _ => Lt aa | Cn (_, _, _) => Lt aa | Neg _ => Lt aa
  7.1446 -        | Add (_, _) => Lt aa | Sub (_, _) => Lt aa | Mul (_, _) => Lt aa)
  7.1447 -    end
  7.1448 -  | simpfm (Le a) =
  7.1449 -    let
  7.1450 -      val aa = simpnum a;
  7.1451 -    in
  7.1452 -      (case aa of C v => (if IntInf.<= (v, (0 : IntInf.int)) then T else F)
  7.1453 -        | Bound _ => Le aa | Cn (_, _, _) => Le aa | Neg _ => Le aa
  7.1454 -        | Add (_, _) => Le aa | Sub (_, _) => Le aa | Mul (_, _) => Le aa)
  7.1455 -    end
  7.1456 -  | simpfm (Gt a) =
  7.1457 -    let
  7.1458 -      val aa = simpnum a;
  7.1459 -    in
  7.1460 -      (case aa of C v => (if IntInf.< ((0 : IntInf.int), v) then T else F)
  7.1461 -        | Bound _ => Gt aa | Cn (_, _, _) => Gt aa | Neg _ => Gt aa
  7.1462 -        | Add (_, _) => Gt aa | Sub (_, _) => Gt aa | Mul (_, _) => Gt aa)
  7.1463 -    end
  7.1464 -  | simpfm (Ge a) =
  7.1465 -    let
  7.1466 -      val aa = simpnum a;
  7.1467 -    in
  7.1468 -      (case aa of C v => (if IntInf.<= ((0 : IntInf.int), v) then T else F)
  7.1469 -        | Bound _ => Ge aa | Cn (_, _, _) => Ge aa | Neg _ => Ge aa
  7.1470 -        | Add (_, _) => Ge aa | Sub (_, _) => Ge aa | Mul (_, _) => Ge aa)
  7.1471 -    end
  7.1472 -  | simpfm (Eq a) =
  7.1473 -    let
  7.1474 -      val aa = simpnum a;
  7.1475 -    in
  7.1476 -      (case aa
  7.1477 -        of C v => (if ((v : IntInf.int) = (0 : IntInf.int)) then T else F)
  7.1478 -        | Bound _ => Eq aa | Cn (_, _, _) => Eq aa | Neg _ => Eq aa
  7.1479 -        | Add (_, _) => Eq aa | Sub (_, _) => Eq aa | Mul (_, _) => Eq aa)
  7.1480 -    end
  7.1481 -  | simpfm (NEq a) =
  7.1482 -    let
  7.1483 -      val aa = simpnum a;
  7.1484 -    in
  7.1485 -      (case aa
  7.1486 -        of C v => (if not ((v : IntInf.int) = (0 : IntInf.int)) then T else F)
  7.1487 -        | Bound _ => NEq aa | Cn (_, _, _) => NEq aa | Neg _ => NEq aa
  7.1488 -        | Add (_, _) => NEq aa | Sub (_, _) => NEq aa | Mul (_, _) => NEq aa)
  7.1489 -    end
  7.1490 -  | simpfm (Dvd (i, a)) =
  7.1491 -    (if ((i : IntInf.int) = (0 : IntInf.int)) then simpfm (Eq a)
  7.1492 -      else (if (((abs_int i) : IntInf.int) = (1 : IntInf.int)) then T
  7.1493 -             else let
  7.1494 -                    val aa = simpnum a;
  7.1495 -                  in
  7.1496 -                    (case aa
  7.1497 -                      of C v =>
  7.1498 -                        (if dvd (semiring_div_int, eq_int) i v then T else F)
  7.1499 -                      | Bound _ => Dvd (i, aa) | Cn (_, _, _) => Dvd (i, aa)
  7.1500 -                      | Neg _ => Dvd (i, aa) | Add (_, _) => Dvd (i, aa)
  7.1501 -                      | Sub (_, _) => Dvd (i, aa) | Mul (_, _) => Dvd (i, aa))
  7.1502 -                  end))
  7.1503 -  | simpfm (NDvd (i, a)) =
  7.1504 -    (if ((i : IntInf.int) = (0 : IntInf.int)) then simpfm (NEq a)
  7.1505 -      else (if (((abs_int i) : IntInf.int) = (1 : IntInf.int)) then F
  7.1506 -             else let
  7.1507 -                    val aa = simpnum a;
  7.1508 -                  in
  7.1509 -                    (case aa
  7.1510 -                      of C v =>
  7.1511 -                        (if not (dvd (semiring_div_int, eq_int) i v) then T
  7.1512 -                          else F)
  7.1513 -                      | Bound _ => NDvd (i, aa) | Cn (_, _, _) => NDvd (i, aa)
  7.1514 -                      | Neg _ => NDvd (i, aa) | Add (_, _) => NDvd (i, aa)
  7.1515 -                      | Sub (_, _) => NDvd (i, aa) | Mul (_, _) => NDvd (i, aa))
  7.1516 -                  end))
  7.1517 -  | simpfm T = T
  7.1518 -  | simpfm F = F
  7.1519 -  | simpfm (E v) = E v
  7.1520 -  | simpfm (A v) = A v
  7.1521 -  | simpfm (Closed v) = Closed v
  7.1522 -  | simpfm (NClosed v) = NClosed v;
  7.1523 -
  7.1524 -fun iupt i j =
  7.1525 -  (if IntInf.< (j, i) then []
  7.1526 -    else i :: iupt (IntInf.+ (i, (1 : IntInf.int))) j);
  7.1527 -
  7.1528 -fun mirror (And (p, q)) = And (mirror p, mirror q)
  7.1529 -  | mirror (Or (p, q)) = Or (mirror p, mirror q)
  7.1530 -  | mirror T = T
  7.1531 -  | mirror F = F
  7.1532 -  | mirror (Lt (C bo)) = Lt (C bo)
  7.1533 -  | mirror (Lt (Bound bp)) = Lt (Bound bp)
  7.1534 -  | mirror (Lt (Neg bt)) = Lt (Neg bt)
  7.1535 -  | mirror (Lt (Add (bu, bv))) = Lt (Add (bu, bv))
  7.1536 -  | mirror (Lt (Sub (bw, bx))) = Lt (Sub (bw, bx))
  7.1537 -  | mirror (Lt (Mul (by, bz))) = Lt (Mul (by, bz))
  7.1538 -  | mirror (Le (C co)) = Le (C co)
  7.1539 -  | mirror (Le (Bound cp)) = Le (Bound cp)
  7.1540 -  | mirror (Le (Neg ct)) = Le (Neg ct)
  7.1541 -  | mirror (Le (Add (cu, cv))) = Le (Add (cu, cv))
  7.1542 -  | mirror (Le (Sub (cw, cx))) = Le (Sub (cw, cx))
  7.1543 -  | mirror (Le (Mul (cy, cz))) = Le (Mul (cy, cz))
  7.1544 -  | mirror (Gt (C doa)) = Gt (C doa)
  7.1545 -  | mirror (Gt (Bound dp)) = Gt (Bound dp)
  7.1546 -  | mirror (Gt (Neg dt)) = Gt (Neg dt)
  7.1547 -  | mirror (Gt (Add (du, dv))) = Gt (Add (du, dv))
  7.1548 -  | mirror (Gt (Sub (dw, dx))) = Gt (Sub (dw, dx))
  7.1549 -  | mirror (Gt (Mul (dy, dz))) = Gt (Mul (dy, dz))
  7.1550 -  | mirror (Ge (C eo)) = Ge (C eo)
  7.1551 -  | mirror (Ge (Bound ep)) = Ge (Bound ep)
  7.1552 -  | mirror (Ge (Neg et)) = Ge (Neg et)
  7.1553 -  | mirror (Ge (Add (eu, ev))) = Ge (Add (eu, ev))
  7.1554 -  | mirror (Ge (Sub (ew, ex))) = Ge (Sub (ew, ex))
  7.1555 -  | mirror (Ge (Mul (ey, ez))) = Ge (Mul (ey, ez))
  7.1556 -  | mirror (Eq (C fo)) = Eq (C fo)
  7.1557 -  | mirror (Eq (Bound fp)) = Eq (Bound fp)
  7.1558 -  | mirror (Eq (Neg ft)) = Eq (Neg ft)
  7.1559 -  | mirror (Eq (Add (fu, fv))) = Eq (Add (fu, fv))
  7.1560 -  | mirror (Eq (Sub (fw, fx))) = Eq (Sub (fw, fx))
  7.1561 -  | mirror (Eq (Mul (fy, fz))) = Eq (Mul (fy, fz))
  7.1562 -  | mirror (NEq (C go)) = NEq (C go)
  7.1563 -  | mirror (NEq (Bound gp)) = NEq (Bound gp)
  7.1564 -  | mirror (NEq (Neg gt)) = NEq (Neg gt)
  7.1565 -  | mirror (NEq (Add (gu, gv))) = NEq (Add (gu, gv))
  7.1566 -  | mirror (NEq (Sub (gw, gx))) = NEq (Sub (gw, gx))
  7.1567 -  | mirror (NEq (Mul (gy, gz))) = NEq (Mul (gy, gz))
  7.1568 -  | mirror (Dvd (aa, C ho)) = Dvd (aa, C ho)
  7.1569 -  | mirror (Dvd (aa, Bound hp)) = Dvd (aa, Bound hp)
  7.1570 -  | mirror (Dvd (aa, Neg ht)) = Dvd (aa, Neg ht)
  7.1571 -  | mirror (Dvd (aa, Add (hu, hv))) = Dvd (aa, Add (hu, hv))
  7.1572 -  | mirror (Dvd (aa, Sub (hw, hx))) = Dvd (aa, Sub (hw, hx))
  7.1573 -  | mirror (Dvd (aa, Mul (hy, hz))) = Dvd (aa, Mul (hy, hz))
  7.1574 -  | mirror (NDvd (ac, C io)) = NDvd (ac, C io)
  7.1575 -  | mirror (NDvd (ac, Bound ip)) = NDvd (ac, Bound ip)
  7.1576 -  | mirror (NDvd (ac, Neg it)) = NDvd (ac, Neg it)
  7.1577 -  | mirror (NDvd (ac, Add (iu, iv))) = NDvd (ac, Add (iu, iv))
  7.1578 -  | mirror (NDvd (ac, Sub (iw, ix))) = NDvd (ac, Sub (iw, ix))
  7.1579 -  | mirror (NDvd (ac, Mul (iy, iz))) = NDvd (ac, Mul (iy, iz))
  7.1580 -  | mirror (Not ae) = Not ae
  7.1581 -  | mirror (Imp (aj, ak)) = Imp (aj, ak)
  7.1582 -  | mirror (Iff (al, am)) = Iff (al, am)
  7.1583 -  | mirror (E an) = E an
  7.1584 -  | mirror (A ao) = A ao
  7.1585 -  | mirror (Closed ap) = Closed ap
  7.1586 -  | mirror (NClosed aq) = NClosed aq
  7.1587 -  | mirror (Lt (Cn (cm, c, e))) =
  7.1588 -    (if ((cm : IntInf.int) = (0 : IntInf.int))
  7.1589 -      then Gt (Cn ((0 : IntInf.int), c, Neg e))
  7.1590 -      else Lt (Cn (suc (minus_nat cm (1 : IntInf.int)), c, e)))
  7.1591 -  | mirror (Le (Cn (dm, c, e))) =
  7.1592 -    (if ((dm : IntInf.int) = (0 : IntInf.int))
  7.1593 -      then Ge (Cn ((0 : IntInf.int), c, Neg e))
  7.1594 -      else Le (Cn (suc (minus_nat dm (1 : IntInf.int)), c, e)))
  7.1595 -  | mirror (Gt (Cn (em, c, e))) =
  7.1596 -    (if ((em : IntInf.int) = (0 : IntInf.int))
  7.1597 -      then Lt (Cn ((0 : IntInf.int), c, Neg e))
  7.1598 -      else Gt (Cn (suc (minus_nat em (1 : IntInf.int)), c, e)))
  7.1599 -  | mirror (Ge (Cn (fm, c, e))) =
  7.1600 -    (if ((fm : IntInf.int) = (0 : IntInf.int))
  7.1601 -      then Le (Cn ((0 : IntInf.int), c, Neg e))
  7.1602 -      else Ge (Cn (suc (minus_nat fm (1 : IntInf.int)), c, e)))
  7.1603 -  | mirror (Eq (Cn (gm, c, e))) =
  7.1604 -    (if ((gm : IntInf.int) = (0 : IntInf.int))
  7.1605 -      then Eq (Cn ((0 : IntInf.int), c, Neg e))
  7.1606 -      else Eq (Cn (suc (minus_nat gm (1 : IntInf.int)), c, e)))
  7.1607 -  | mirror (NEq (Cn (hm, c, e))) =
  7.1608 -    (if ((hm : IntInf.int) = (0 : IntInf.int))
  7.1609 -      then NEq (Cn ((0 : IntInf.int), c, Neg e))
  7.1610 -      else NEq (Cn (suc (minus_nat hm (1 : IntInf.int)), c, e)))
  7.1611 -  | mirror (Dvd (i, Cn (im, c, e))) =
  7.1612 -    (if ((im : IntInf.int) = (0 : IntInf.int))
  7.1613 -      then Dvd (i, Cn ((0 : IntInf.int), c, Neg e))
  7.1614 -      else Dvd (i, Cn (suc (minus_nat im (1 : IntInf.int)), c, e)))
  7.1615 -  | mirror (NDvd (i, Cn (jm, c, e))) =
  7.1616 -    (if ((jm : IntInf.int) = (0 : IntInf.int))
  7.1617 -      then NDvd (i, Cn ((0 : IntInf.int), c, Neg e))
  7.1618 -      else NDvd (i, Cn (suc (minus_nat jm (1 : IntInf.int)), c, e)));
  7.1619 -
  7.1620 -fun size_list [] = (0 : IntInf.int)
  7.1621 -  | size_list (a :: lista) = IntInf.+ (size_list lista, suc (0 : IntInf.int));
  7.1622 -
  7.1623 -fun alpha (And (p, q)) = append (alpha p) (alpha q)
  7.1624 -  | alpha (Or (p, q)) = append (alpha p) (alpha q)
  7.1625 -  | alpha T = []
  7.1626 -  | alpha F = []
  7.1627 -  | alpha (Lt (C bo)) = []
  7.1628 -  | alpha (Lt (Bound bp)) = []
  7.1629 -  | alpha (Lt (Neg bt)) = []
  7.1630 -  | alpha (Lt (Add (bu, bv))) = []
  7.1631 -  | alpha (Lt (Sub (bw, bx))) = []
  7.1632 -  | alpha (Lt (Mul (by, bz))) = []
  7.1633 -  | alpha (Le (C co)) = []
  7.1634 -  | alpha (Le (Bound cp)) = []
  7.1635 -  | alpha (Le (Neg ct)) = []
  7.1636 -  | alpha (Le (Add (cu, cv))) = []
  7.1637 -  | alpha (Le (Sub (cw, cx))) = []
  7.1638 -  | alpha (Le (Mul (cy, cz))) = []
  7.1639 -  | alpha (Gt (C doa)) = []
  7.1640 -  | alpha (Gt (Bound dp)) = []
  7.1641 -  | alpha (Gt (Neg dt)) = []
  7.1642 -  | alpha (Gt (Add (du, dv))) = []
  7.1643 -  | alpha (Gt (Sub (dw, dx))) = []
  7.1644 -  | alpha (Gt (Mul (dy, dz))) = []
  7.1645 -  | alpha (Ge (C eo)) = []
  7.1646 -  | alpha (Ge (Bound ep)) = []
  7.1647 -  | alpha (Ge (Neg et)) = []
  7.1648 -  | alpha (Ge (Add (eu, ev))) = []
  7.1649 -  | alpha (Ge (Sub (ew, ex))) = []
  7.1650 -  | alpha (Ge (Mul (ey, ez))) = []
  7.1651 -  | alpha (Eq (C fo)) = []
  7.1652 -  | alpha (Eq (Bound fp)) = []
  7.1653 -  | alpha (Eq (Neg ft)) = []
  7.1654 -  | alpha (Eq (Add (fu, fv))) = []
  7.1655 -  | alpha (Eq (Sub (fw, fx))) = []
  7.1656 -  | alpha (Eq (Mul (fy, fz))) = []
  7.1657 -  | alpha (NEq (C go)) = []
  7.1658 -  | alpha (NEq (Bound gp)) = []
  7.1659 -  | alpha (NEq (Neg gt)) = []
  7.1660 -  | alpha (NEq (Add (gu, gv))) = []
  7.1661 -  | alpha (NEq (Sub (gw, gx))) = []
  7.1662 -  | alpha (NEq (Mul (gy, gz))) = []
  7.1663 -  | alpha (Dvd (aa, ab)) = []
  7.1664 -  | alpha (NDvd (ac, ad)) = []
  7.1665 -  | alpha (Not ae) = []
  7.1666 -  | alpha (Imp (aj, ak)) = []
  7.1667 -  | alpha (Iff (al, am)) = []
  7.1668 -  | alpha (E an) = []
  7.1669 -  | alpha (A ao) = []
  7.1670 -  | alpha (Closed ap) = []
  7.1671 -  | alpha (NClosed aq) = []
  7.1672 -  | alpha (Lt (Cn (cm, c, e))) =
  7.1673 -    (if ((cm : IntInf.int) = (0 : IntInf.int)) then [e] else [])
  7.1674 -  | alpha (Le (Cn (dm, c, e))) =
  7.1675 -    (if ((dm : IntInf.int) = (0 : IntInf.int))
  7.1676 -      then [Add (C (~1 : IntInf.int), e)] else [])
  7.1677 -  | alpha (Gt (Cn (em, c, e))) =
  7.1678 -    (if ((em : IntInf.int) = (0 : IntInf.int)) then [] else [])
  7.1679 -  | alpha (Ge (Cn (fm, c, e))) =
  7.1680 -    (if ((fm : IntInf.int) = (0 : IntInf.int)) then [] else [])
  7.1681 -  | alpha (Eq (Cn (gm, c, e))) =
  7.1682 -    (if ((gm : IntInf.int) = (0 : IntInf.int))
  7.1683 -      then [Add (C (~1 : IntInf.int), e)] else [])
  7.1684 -  | alpha (NEq (Cn (hm, c, e))) =
  7.1685 -    (if ((hm : IntInf.int) = (0 : IntInf.int)) then [e] else []);
  7.1686 -
  7.1687 -fun beta (And (p, q)) = append (beta p) (beta q)
  7.1688 -  | beta (Or (p, q)) = append (beta p) (beta q)
  7.1689 -  | beta T = []
  7.1690 -  | beta F = []
  7.1691 -  | beta (Lt (C bo)) = []
  7.1692 -  | beta (Lt (Bound bp)) = []
  7.1693 -  | beta (Lt (Neg bt)) = []
  7.1694 -  | beta (Lt (Add (bu, bv))) = []
  7.1695 -  | beta (Lt (Sub (bw, bx))) = []
  7.1696 -  | beta (Lt (Mul (by, bz))) = []
  7.1697 -  | beta (Le (C co)) = []
  7.1698 -  | beta (Le (Bound cp)) = []
  7.1699 -  | beta (Le (Neg ct)) = []
  7.1700 -  | beta (Le (Add (cu, cv))) = []
  7.1701 -  | beta (Le (Sub (cw, cx))) = []
  7.1702 -  | beta (Le (Mul (cy, cz))) = []
  7.1703 -  | beta (Gt (C doa)) = []
  7.1704 -  | beta (Gt (Bound dp)) = []
  7.1705 -  | beta (Gt (Neg dt)) = []
  7.1706 -  | beta (Gt (Add (du, dv))) = []
  7.1707 -  | beta (Gt (Sub (dw, dx))) = []
  7.1708 -  | beta (Gt (Mul (dy, dz))) = []
  7.1709 -  | beta (Ge (C eo)) = []
  7.1710 -  | beta (Ge (Bound ep)) = []
  7.1711 -  | beta (Ge (Neg et)) = []
  7.1712 -  | beta (Ge (Add (eu, ev))) = []
  7.1713 -  | beta (Ge (Sub (ew, ex))) = []
  7.1714 -  | beta (Ge (Mul (ey, ez))) = []
  7.1715 -  | beta (Eq (C fo)) = []
  7.1716 -  | beta (Eq (Bound fp)) = []
  7.1717 -  | beta (Eq (Neg ft)) = []
  7.1718 -  | beta (Eq (Add (fu, fv))) = []
  7.1719 -  | beta (Eq (Sub (fw, fx))) = []
  7.1720 -  | beta (Eq (Mul (fy, fz))) = []
  7.1721 -  | beta (NEq (C go)) = []
  7.1722 -  | beta (NEq (Bound gp)) = []
  7.1723 -  | beta (NEq (Neg gt)) = []
  7.1724 -  | beta (NEq (Add (gu, gv))) = []
  7.1725 -  | beta (NEq (Sub (gw, gx))) = []
  7.1726 -  | beta (NEq (Mul (gy, gz))) = []
  7.1727 -  | beta (Dvd (aa, ab)) = []
  7.1728 -  | beta (NDvd (ac, ad)) = []
  7.1729 -  | beta (Not ae) = []
  7.1730 -  | beta (Imp (aj, ak)) = []
  7.1731 -  | beta (Iff (al, am)) = []
  7.1732 -  | beta (E an) = []
  7.1733 -  | beta (A ao) = []
  7.1734 -  | beta (Closed ap) = []
  7.1735 -  | beta (NClosed aq) = []
  7.1736 -  | beta (Lt (Cn (cm, c, e))) =
  7.1737 -    (if ((cm : IntInf.int) = (0 : IntInf.int)) then [] else [])
  7.1738 -  | beta (Le (Cn (dm, c, e))) =
  7.1739 -    (if ((dm : IntInf.int) = (0 : IntInf.int)) then [] else [])
  7.1740 -  | beta (Gt (Cn (em, c, e))) =
  7.1741 -    (if ((em : IntInf.int) = (0 : IntInf.int)) then [Neg e] else [])
  7.1742 -  | beta (Ge (Cn (fm, c, e))) =
  7.1743 -    (if ((fm : IntInf.int) = (0 : IntInf.int))
  7.1744 -      then [Sub (C (~1 : IntInf.int), e)] else [])
  7.1745 -  | beta (Eq (Cn (gm, c, e))) =
  7.1746 -    (if ((gm : IntInf.int) = (0 : IntInf.int))
  7.1747 -      then [Sub (C (~1 : IntInf.int), e)] else [])
  7.1748 -  | beta (NEq (Cn (hm, c, e))) =
  7.1749 -    (if ((hm : IntInf.int) = (0 : IntInf.int)) then [Neg e] else []);
  7.1750 -
  7.1751 -val eq_numa = {eq = eq_num} : num eq;
  7.1752 -
  7.1753 -fun member A_ x [] = false
  7.1754 -  | member A_ x (y :: ys) = eqa A_ x y orelse member A_ x ys;
  7.1755 -
  7.1756 -fun remdups A_ [] = []
  7.1757 -  | remdups A_ (x :: xs) =
  7.1758 -    (if member A_ x xs then remdups A_ xs else x :: remdups A_ xs);
  7.1759 -
  7.1760 -fun gcd_int k l =
  7.1761 -  abs_int
  7.1762 -    (if ((l : IntInf.int) = (0 : IntInf.int)) then k
  7.1763 -      else gcd_int l (mod_int (abs_int k) (abs_int l)));
  7.1764 -
  7.1765 -fun lcm_int a b = div_int (IntInf.* (abs_int a, abs_int b)) (gcd_int a b);
  7.1766 -
  7.1767 -fun delta (And (p, q)) = lcm_int (delta p) (delta q)
  7.1768 -  | delta (Or (p, q)) = lcm_int (delta p) (delta q)
  7.1769 -  | delta T = (1 : IntInf.int)
  7.1770 -  | delta F = (1 : IntInf.int)
  7.1771 -  | delta (Lt u) = (1 : IntInf.int)
  7.1772 -  | delta (Le v) = (1 : IntInf.int)
  7.1773 -  | delta (Gt w) = (1 : IntInf.int)
  7.1774 -  | delta (Ge x) = (1 : IntInf.int)
  7.1775 -  | delta (Eq y) = (1 : IntInf.int)
  7.1776 -  | delta (NEq z) = (1 : IntInf.int)
  7.1777 -  | delta (Dvd (aa, C bo)) = (1 : IntInf.int)
  7.1778 -  | delta (Dvd (aa, Bound bp)) = (1 : IntInf.int)
  7.1779 -  | delta (Dvd (aa, Neg bt)) = (1 : IntInf.int)
  7.1780 -  | delta (Dvd (aa, Add (bu, bv))) = (1 : IntInf.int)
  7.1781 -  | delta (Dvd (aa, Sub (bw, bx))) = (1 : IntInf.int)
  7.1782 -  | delta (Dvd (aa, Mul (by, bz))) = (1 : IntInf.int)
  7.1783 -  | delta (NDvd (ac, C co)) = (1 : IntInf.int)
  7.1784 -  | delta (NDvd (ac, Bound cp)) = (1 : IntInf.int)
  7.1785 -  | delta (NDvd (ac, Neg ct)) = (1 : IntInf.int)
  7.1786 -  | delta (NDvd (ac, Add (cu, cv))) = (1 : IntInf.int)
  7.1787 -  | delta (NDvd (ac, Sub (cw, cx))) = (1 : IntInf.int)
  7.1788 -  | delta (NDvd (ac, Mul (cy, cz))) = (1 : IntInf.int)
  7.1789 -  | delta (Not ae) = (1 : IntInf.int)
  7.1790 -  | delta (Imp (aj, ak)) = (1 : IntInf.int)
  7.1791 -  | delta (Iff (al, am)) = (1 : IntInf.int)
  7.1792 -  | delta (E an) = (1 : IntInf.int)
  7.1793 -  | delta (A ao) = (1 : IntInf.int)
  7.1794 -  | delta (Closed ap) = (1 : IntInf.int)
  7.1795 -  | delta (NClosed aq) = (1 : IntInf.int)
  7.1796 -  | delta (Dvd (i, Cn (cm, c, e))) =
  7.1797 -    (if ((cm : IntInf.int) = (0 : IntInf.int)) then i else (1 : IntInf.int))
  7.1798 -  | delta (NDvd (i, Cn (dm, c, e))) =
  7.1799 -    (if ((dm : IntInf.int) = (0 : IntInf.int)) then i else (1 : IntInf.int));
  7.1800 -
  7.1801 -fun a_beta (And (p, q)) = (fn k => And (a_beta p k, a_beta q k))
  7.1802 -  | a_beta (Or (p, q)) = (fn k => Or (a_beta p k, a_beta q k))
  7.1803 -  | a_beta T = (fn _ => T)
  7.1804 -  | a_beta F = (fn _ => F)
  7.1805 -  | a_beta (Lt (C bo)) = (fn _ => Lt (C bo))
  7.1806 -  | a_beta (Lt (Bound bp)) = (fn _ => Lt (Bound bp))
  7.1807 -  | a_beta (Lt (Neg bt)) = (fn _ => Lt (Neg bt))
  7.1808 -  | a_beta (Lt (Add (bu, bv))) = (fn _ => Lt (Add (bu, bv)))
  7.1809 -  | a_beta (Lt (Sub (bw, bx))) = (fn _ => Lt (Sub (bw, bx)))
  7.1810 -  | a_beta (Lt (Mul (by, bz))) = (fn _ => Lt (Mul (by, bz)))
  7.1811 -  | a_beta (Le (C co)) = (fn _ => Le (C co))
  7.1812 -  | a_beta (Le (Bound cp)) = (fn _ => Le (Bound cp))
  7.1813 -  | a_beta (Le (Neg ct)) = (fn _ => Le (Neg ct))
  7.1814 -  | a_beta (Le (Add (cu, cv))) = (fn _ => Le (Add (cu, cv)))
  7.1815 -  | a_beta (Le (Sub (cw, cx))) = (fn _ => Le (Sub (cw, cx)))
  7.1816 -  | a_beta (Le (Mul (cy, cz))) = (fn _ => Le (Mul (cy, cz)))
  7.1817 -  | a_beta (Gt (C doa)) = (fn _ => Gt (C doa))
  7.1818 -  | a_beta (Gt (Bound dp)) = (fn _ => Gt (Bound dp))
  7.1819 -  | a_beta (Gt (Neg dt)) = (fn _ => Gt (Neg dt))
  7.1820 -  | a_beta (Gt (Add (du, dv))) = (fn _ => Gt (Add (du, dv)))
  7.1821 -  | a_beta (Gt (Sub (dw, dx))) = (fn _ => Gt (Sub (dw, dx)))
  7.1822 -  | a_beta (Gt (Mul (dy, dz))) = (fn _ => Gt (Mul (dy, dz)))
  7.1823 -  | a_beta (Ge (C eo)) = (fn _ => Ge (C eo))
  7.1824 -  | a_beta (Ge (Bound ep)) = (fn _ => Ge (Bound ep))
  7.1825 -  | a_beta (Ge (Neg et)) = (fn _ => Ge (Neg et))
  7.1826 -  | a_beta (Ge (Add (eu, ev))) = (fn _ => Ge (Add (eu, ev)))
  7.1827 -  | a_beta (Ge (Sub (ew, ex))) = (fn _ => Ge (Sub (ew, ex)))
  7.1828 -  | a_beta (Ge (Mul (ey, ez))) = (fn _ => Ge (Mul (ey, ez)))
  7.1829 -  | a_beta (Eq (C fo)) = (fn _ => Eq (C fo))
  7.1830 -  | a_beta (Eq (Bound fp)) = (fn _ => Eq (Bound fp))
  7.1831 -  | a_beta (Eq (Neg ft)) = (fn _ => Eq (Neg ft))
  7.1832 -  | a_beta (Eq (Add (fu, fv))) = (fn _ => Eq (Add (fu, fv)))
  7.1833 -  | a_beta (Eq (Sub (fw, fx))) = (fn _ => Eq (Sub (fw, fx)))
  7.1834 -  | a_beta (Eq (Mul (fy, fz))) = (fn _ => Eq (Mul (fy, fz)))
  7.1835 -  | a_beta (NEq (C go)) = (fn _ => NEq (C go))
  7.1836 -  | a_beta (NEq (Bound gp)) = (fn _ => NEq (Bound gp))
  7.1837 -  | a_beta (NEq (Neg gt)) = (fn _ => NEq (Neg gt))
  7.1838 -  | a_beta (NEq (Add (gu, gv))) = (fn _ => NEq (Add (gu, gv)))
  7.1839 -  | a_beta (NEq (Sub (gw, gx))) = (fn _ => NEq (Sub (gw, gx)))
  7.1840 -  | a_beta (NEq (Mul (gy, gz))) = (fn _ => NEq (Mul (gy, gz)))
  7.1841 -  | a_beta (Dvd (aa, C ho)) = (fn _ => Dvd (aa, C ho))
  7.1842 -  | a_beta (Dvd (aa, Bound hp)) = (fn _ => Dvd (aa, Bound hp))
  7.1843 -  | a_beta (Dvd (aa, Neg ht)) = (fn _ => Dvd (aa, Neg ht))
  7.1844 -  | a_beta (Dvd (aa, Add (hu, hv))) = (fn _ => Dvd (aa, Add (hu, hv)))
  7.1845 -  | a_beta (Dvd (aa, Sub (hw, hx))) = (fn _ => Dvd (aa, Sub (hw, hx)))
  7.1846 -  | a_beta (Dvd (aa, Mul (hy, hz))) = (fn _ => Dvd (aa, Mul (hy, hz)))
  7.1847 -  | a_beta (NDvd (ac, C io)) = (fn _ => NDvd (ac, C io))
  7.1848 -  | a_beta (NDvd (ac, Bound ip)) = (fn _ => NDvd (ac, Bound ip))
  7.1849 -  | a_beta (NDvd (ac, Neg it)) = (fn _ => NDvd (ac, Neg it))
  7.1850 -  | a_beta (NDvd (ac, Add (iu, iv))) = (fn _ => NDvd (ac, Add (iu, iv)))
  7.1851 -  | a_beta (NDvd (ac, Sub (iw, ix))) = (fn _ => NDvd (ac, Sub (iw, ix)))
  7.1852 -  | a_beta (NDvd (ac, Mul (iy, iz))) = (fn _ => NDvd (ac, Mul (iy, iz)))
  7.1853 -  | a_beta (Not ae) = (fn _ => Not ae)
  7.1854 -  | a_beta (Imp (aj, ak)) = (fn _ => Imp (aj, ak))
  7.1855 -  | a_beta (Iff (al, am)) = (fn _ => Iff (al, am))
  7.1856 -  | a_beta (E an) = (fn _ => E an)
  7.1857 -  | a_beta (A ao) = (fn _ => A ao)
  7.1858 -  | a_beta (Closed ap) = (fn _ => Closed ap)
  7.1859 -  | a_beta (NClosed aq) = (fn _ => NClosed aq)
  7.1860 -  | a_beta (Lt (Cn (cm, c, e))) =
  7.1861 -    (if ((cm : IntInf.int) = (0 : IntInf.int))
  7.1862 -      then (fn k =>
  7.1863 -             Lt (Cn ((0 : IntInf.int), (1 : IntInf.int), Mul (div_int k c, e))))
  7.1864 -      else (fn _ => Lt (Cn (suc (minus_nat cm (1 : IntInf.int)), c, e))))
  7.1865 -  | a_beta (Le (Cn (dm, c, e))) =
  7.1866 -    (if ((dm : IntInf.int) = (0 : IntInf.int))
  7.1867 -      then (fn k =>
  7.1868 -             Le (Cn ((0 : IntInf.int), (1 : IntInf.int), Mul (div_int k c, e))))
  7.1869 -      else (fn _ => Le (Cn (suc (minus_nat dm (1 : IntInf.int)), c, e))))
  7.1870 -  | a_beta (Gt (Cn (em, c, e))) =
  7.1871 -    (if ((em : IntInf.int) = (0 : IntInf.int))
  7.1872 -      then (fn k =>
  7.1873 -             Gt (Cn ((0 : IntInf.int), (1 : IntInf.int), Mul (div_int k c, e))))
  7.1874 -      else (fn _ => Gt (Cn (suc (minus_nat em (1 : IntInf.int)), c, e))))
  7.1875 -  | a_beta (Ge (Cn (fm, c, e))) =
  7.1876 -    (if ((fm : IntInf.int) = (0 : IntInf.int))
  7.1877 -      then (fn k =>
  7.1878 -             Ge (Cn ((0 : IntInf.int), (1 : IntInf.int), Mul (div_int k c, e))))
  7.1879 -      else (fn _ => Ge (Cn (suc (minus_nat fm (1 : IntInf.int)), c, e))))
  7.1880 -  | a_beta (Eq (Cn (gm, c, e))) =
  7.1881 -    (if ((gm : IntInf.int) = (0 : IntInf.int))
  7.1882 -      then (fn k =>
  7.1883 -             Eq (Cn ((0 : IntInf.int), (1 : IntInf.int), Mul (div_int k c, e))))
  7.1884 -      else (fn _ => Eq (Cn (suc (minus_nat gm (1 : IntInf.int)), c, e))))
  7.1885 -  | a_beta (NEq (Cn (hm, c, e))) =
  7.1886 -    (if ((hm : IntInf.int) = (0 : IntInf.int))
  7.1887 -      then (fn k =>
  7.1888 -             NEq (Cn ((0 : IntInf.int), (1 : IntInf.int),
  7.1889 -                       Mul (div_int k c, e))))
  7.1890 -      else (fn _ => NEq (Cn (suc (minus_nat hm (1 : IntInf.int)), c, e))))
  7.1891 -  | a_beta (Dvd (i, Cn (im, c, e))) =
  7.1892 -    (if ((im : IntInf.int) = (0 : IntInf.int))
  7.1893 -      then (fn k =>
  7.1894 -             Dvd (IntInf.* (div_int k c, i),
  7.1895 -                   Cn ((0 : IntInf.int), (1 : IntInf.int),
  7.1896 -                        Mul (div_int k c, e))))
  7.1897 -      else (fn _ => Dvd (i, Cn (suc (minus_nat im (1 : IntInf.int)), c, e))))
  7.1898 -  | a_beta (NDvd (i, Cn (jm, c, e))) =
  7.1899 -    (if ((jm : IntInf.int) = (0 : IntInf.int))
  7.1900 -      then (fn k =>
  7.1901 -             NDvd (IntInf.* (div_int k c, i),
  7.1902 -                    Cn ((0 : IntInf.int), (1 : IntInf.int),
  7.1903 -                         Mul (div_int k c, e))))
  7.1904 -      else (fn _ => NDvd (i, Cn (suc (minus_nat jm (1 : IntInf.int)), c, e))));
  7.1905 -
  7.1906 -fun zeta (And (p, q)) = lcm_int (zeta p) (zeta q)
  7.1907 -  | zeta (Or (p, q)) = lcm_int (zeta p) (zeta q)
  7.1908 -  | zeta T = (1 : IntInf.int)
  7.1909 -  | zeta F = (1 : IntInf.int)
  7.1910 -  | zeta (Lt (C bo)) = (1 : IntInf.int)
  7.1911 -  | zeta (Lt (Bound bp)) = (1 : IntInf.int)
  7.1912 -  | zeta (Lt (Neg bt)) = (1 : IntInf.int)
  7.1913 -  | zeta (Lt (Add (bu, bv))) = (1 : IntInf.int)
  7.1914 -  | zeta (Lt (Sub (bw, bx))) = (1 : IntInf.int)
  7.1915 -  | zeta (Lt (Mul (by, bz))) = (1 : IntInf.int)
  7.1916 -  | zeta (Le (C co)) = (1 : IntInf.int)
  7.1917 -  | zeta (Le (Bound cp)) = (1 : IntInf.int)
  7.1918 -  | zeta (Le (Neg ct)) = (1 : IntInf.int)
  7.1919 -  | zeta (Le (Add (cu, cv))) = (1 : IntInf.int)
  7.1920 -  | zeta (Le (Sub (cw, cx))) = (1 : IntInf.int)
  7.1921 -  | zeta (Le (Mul (cy, cz))) = (1 : IntInf.int)
  7.1922 -  | zeta (Gt (C doa)) = (1 : IntInf.int)
  7.1923 -  | zeta (Gt (Bound dp)) = (1 : IntInf.int)
  7.1924 -  | zeta (Gt (Neg dt)) = (1 : IntInf.int)
  7.1925 -  | zeta (Gt (Add (du, dv))) = (1 : IntInf.int)
  7.1926 -  | zeta (Gt (Sub (dw, dx))) = (1 : IntInf.int)
  7.1927 -  | zeta (Gt (Mul (dy, dz))) = (1 : IntInf.int)
  7.1928 -  | zeta (Ge (C eo)) = (1 : IntInf.int)
  7.1929 -  | zeta (Ge (Bound ep)) = (1 : IntInf.int)
  7.1930 -  | zeta (Ge (Neg et)) = (1 : IntInf.int)
  7.1931 -  | zeta (Ge (Add (eu, ev))) = (1 : IntInf.int)
  7.1932 -  | zeta (Ge (Sub (ew, ex))) = (1 : IntInf.int)
  7.1933 -  | zeta (Ge (Mul (ey, ez))) = (1 : IntInf.int)
  7.1934 -  | zeta (Eq (C fo)) = (1 : IntInf.int)
  7.1935 -  | zeta (Eq (Bound fp)) = (1 : IntInf.int)
  7.1936 -  | zeta (Eq (Neg ft)) = (1 : IntInf.int)
  7.1937 -  | zeta (Eq (Add (fu, fv))) = (1 : IntInf.int)
  7.1938 -  | zeta (Eq (Sub (fw, fx))) = (1 : IntInf.int)
  7.1939 -  | zeta (Eq (Mul (fy, fz))) = (1 : IntInf.int)
  7.1940 -  | zeta (NEq (C go)) = (1 : IntInf.int)
  7.1941 -  | zeta (NEq (Bound gp)) = (1 : IntInf.int)
  7.1942 -  | zeta (NEq (Neg gt)) = (1 : IntInf.int)
  7.1943 -  | zeta (NEq (Add (gu, gv))) = (1 : IntInf.int)
  7.1944 -  | zeta (NEq (Sub (gw, gx))) = (1 : IntInf.int)
  7.1945 -  | zeta (NEq (Mul (gy, gz))) = (1 : IntInf.int)
  7.1946 -  | zeta (Dvd (aa, C ho)) = (1 : IntInf.int)
  7.1947 -  | zeta (Dvd (aa, Bound hp)) = (1 : IntInf.int)
  7.1948 -  | zeta (Dvd (aa, Neg ht)) = (1 : IntInf.int)
  7.1949 -  | zeta (Dvd (aa, Add (hu, hv))) = (1 : IntInf.int)
  7.1950 -  | zeta (Dvd (aa, Sub (hw, hx))) = (1 : IntInf.int)
  7.1951 -  | zeta (Dvd (aa, Mul (hy, hz))) = (1 : IntInf.int)
  7.1952 -  | zeta (NDvd (ac, C io)) = (1 : IntInf.int)
  7.1953 -  | zeta (NDvd (ac, Bound ip)) = (1 : IntInf.int)
  7.1954 -  | zeta (NDvd (ac, Neg it)) = (1 : IntInf.int)
  7.1955 -  | zeta (NDvd (ac, Add (iu, iv))) = (1 : IntInf.int)
  7.1956 -  | zeta (NDvd (ac, Sub (iw, ix))) = (1 : IntInf.int)
  7.1957 -  | zeta (NDvd (ac, Mul (iy, iz))) = (1 : IntInf.int)
  7.1958 -  | zeta (Not ae) = (1 : IntInf.int)
  7.1959 -  | zeta (Imp (aj, ak)) = (1 : IntInf.int)
  7.1960 -  | zeta (Iff (al, am)) = (1 : IntInf.int)
  7.1961 -  | zeta (E an) = (1 : IntInf.int)
  7.1962 -  | zeta (A ao) = (1 : IntInf.int)
  7.1963 -  | zeta (Closed ap) = (1 : IntInf.int)
  7.1964 -  | zeta (NClosed aq) = (1 : IntInf.int)
  7.1965 -  | zeta (Lt (Cn (cm, c, e))) =
  7.1966 -    (if ((cm : IntInf.int) = (0 : IntInf.int)) then c else (1 : IntInf.int))
  7.1967 -  | zeta (Le (Cn (dm, c, e))) =
  7.1968 -    (if ((dm : IntInf.int) = (0 : IntInf.int)) then c else (1 : IntInf.int))
  7.1969 -  | zeta (Gt (Cn (em, c, e))) =
  7.1970 -    (if ((em : IntInf.int) = (0 : IntInf.int)) then c else (1 : IntInf.int))
  7.1971 -  | zeta (Ge (Cn (fm, c, e))) =
  7.1972 -    (if ((fm : IntInf.int) = (0 : IntInf.int)) then c else (1 : IntInf.int))
  7.1973 -  | zeta (Eq (Cn (gm, c, e))) =
  7.1974 -    (if ((gm : IntInf.int) = (0 : IntInf.int)) then c else (1 : IntInf.int))
  7.1975 -  | zeta (NEq (Cn (hm, c, e))) =
  7.1976 -    (if ((hm : IntInf.int) = (0 : IntInf.int)) then c else (1 : IntInf.int))
  7.1977 -  | zeta (Dvd (i, Cn (im, c, e))) =
  7.1978 -    (if ((im : IntInf.int) = (0 : IntInf.int)) then c else (1 : IntInf.int))
  7.1979 -  | zeta (NDvd (i, Cn (jm, c, e))) =
  7.1980 -    (if ((jm : IntInf.int) = (0 : IntInf.int)) then c else (1 : IntInf.int));
  7.1981 -
  7.1982 -fun zsplit0 (C c) = ((0 : IntInf.int), C c)
  7.1983 -  | zsplit0 (Bound n) =
  7.1984 -    (if ((n : IntInf.int) = (0 : IntInf.int))
  7.1985 -      then ((1 : IntInf.int), C (0 : IntInf.int))
  7.1986 -      else ((0 : IntInf.int), Bound n))
  7.1987 -  | zsplit0 (Cn (n, i, a)) =
  7.1988 -    let
  7.1989 -      val (ia, aa) = zsplit0 a;
  7.1990 -    in
  7.1991 -      (if ((n : IntInf.int) = (0 : IntInf.int)) then (IntInf.+ (i, ia), aa)
  7.1992 -        else (ia, Cn (n, i, aa)))
  7.1993 -    end
  7.1994 -  | zsplit0 (Neg a) =
  7.1995 -    let
  7.1996 -      val (i, aa) = zsplit0 a;
  7.1997 -    in
  7.1998 -      (IntInf.~ i, Neg aa)
  7.1999 -    end
  7.2000 -  | zsplit0 (Add (a, b)) =
  7.2001 -    let
  7.2002 -      val (ia, aa) = zsplit0 a;
  7.2003 -      val (ib, ba) = zsplit0 b;
  7.2004 -    in
  7.2005 -      (IntInf.+ (ia, ib), Add (aa, ba))
  7.2006 -    end
  7.2007 -  | zsplit0 (Sub (a, b)) =
  7.2008 -    let
  7.2009 -      val (ia, aa) = zsplit0 a;
  7.2010 -      val (ib, ba) = zsplit0 b;
  7.2011 -    in
  7.2012 -      (IntInf.- (ia, ib), Sub (aa, ba))
  7.2013 -    end
  7.2014 -  | zsplit0 (Mul (i, a)) =
  7.2015 -    let
  7.2016 -      val (ia, aa) = zsplit0 a;
  7.2017 -    in
  7.2018 -      (IntInf.* (i, ia), Mul (i, aa))
  7.2019 -    end;
  7.2020 -
  7.2021 -fun zlfm (And (p, q)) = And (zlfm p, zlfm q)
  7.2022 -  | zlfm (Or (p, q)) = Or (zlfm p, zlfm q)
  7.2023 -  | zlfm (Imp (p, q)) = Or (zlfm (Not p), zlfm q)
  7.2024 -  | zlfm (Iff (p, q)) =
  7.2025 -    Or (And (zlfm p, zlfm q), And (zlfm (Not p), zlfm (Not q)))
  7.2026 -  | zlfm (Lt a) =
  7.2027 -    let
  7.2028 -      val (c, r) = zsplit0 a;
  7.2029 -    in
  7.2030 -      (if ((c : IntInf.int) = (0 : IntInf.int)) then Lt r
  7.2031 -        else (if IntInf.< ((0 : IntInf.int), c)
  7.2032 -               then Lt (Cn ((0 : IntInf.int), c, r))
  7.2033 -               else Gt (Cn ((0 : IntInf.int), IntInf.~ c, Neg r))))
  7.2034 -    end
  7.2035 -  | zlfm (Le a) =
  7.2036 -    let
  7.2037 -      val (c, r) = zsplit0 a;
  7.2038 -    in
  7.2039 -      (if ((c : IntInf.int) = (0 : IntInf.int)) then Le r
  7.2040 -        else (if IntInf.< ((0 : IntInf.int), c)
  7.2041 -               then Le (Cn ((0 : IntInf.int), c, r))
  7.2042 -               else Ge (Cn ((0 : IntInf.int), IntInf.~ c, Neg r))))
  7.2043 -    end
  7.2044 -  | zlfm (Gt a) =
  7.2045 -    let
  7.2046 -      val (c, r) = zsplit0 a;
  7.2047 -    in
  7.2048 -      (if ((c : IntInf.int) = (0 : IntInf.int)) then Gt r
  7.2049 -        else (if IntInf.< ((0 : IntInf.int), c)
  7.2050 -               then Gt (Cn ((0 : IntInf.int), c, r))
  7.2051 -               else Lt (Cn ((0 : IntInf.int), IntInf.~ c, Neg r))))
  7.2052 -    end
  7.2053 -  | zlfm (Ge a) =
  7.2054 -    let
  7.2055 -      val (c, r) = zsplit0 a;
  7.2056 -    in
  7.2057 -      (if ((c : IntInf.int) = (0 : IntInf.int)) then Ge r
  7.2058 -        else (if IntInf.< ((0 : IntInf.int), c)
  7.2059 -               then Ge (Cn ((0 : IntInf.int), c, r))
  7.2060 -               else Le (Cn ((0 : IntInf.int), IntInf.~ c, Neg r))))
  7.2061 -    end
  7.2062 -  | zlfm (Eq a) =
  7.2063 -    let
  7.2064 -      val (c, r) = zsplit0 a;
  7.2065 -    in
  7.2066 -      (if ((c : IntInf.int) = (0 : IntInf.int)) then Eq r
  7.2067 -        else (if IntInf.< ((0 : IntInf.int), c)
  7.2068 -               then Eq (Cn ((0 : IntInf.int), c, r))
  7.2069 -               else Eq (Cn ((0 : IntInf.int), IntInf.~ c, Neg r))))
  7.2070 -    end
  7.2071 -  | zlfm (NEq a) =
  7.2072 -    let
  7.2073 -      val (c, r) = zsplit0 a;
  7.2074 -    in
  7.2075 -      (if ((c : IntInf.int) = (0 : IntInf.int)) then NEq r
  7.2076 -        else (if IntInf.< ((0 : IntInf.int), c)
  7.2077 -               then NEq (Cn ((0 : IntInf.int), c, r))
  7.2078 -               else NEq (Cn ((0 : IntInf.int), IntInf.~ c, Neg r))))
  7.2079 -    end
  7.2080 -  | zlfm (Dvd (i, a)) =
  7.2081 -    (if ((i : IntInf.int) = (0 : IntInf.int)) then zlfm (Eq a)
  7.2082 -      else let
  7.2083 -             val (c, r) = zsplit0 a;
  7.2084 -           in
  7.2085 -             (if ((c : IntInf.int) = (0 : IntInf.int)) then Dvd (abs_int i, r)
  7.2086 -               else (if IntInf.< ((0 : IntInf.int), c)
  7.2087 -                      then Dvd (abs_int i, Cn ((0 : IntInf.int), c, r))
  7.2088 -                      else Dvd (abs_int i,
  7.2089 -                                 Cn ((0 : IntInf.int), IntInf.~ c, Neg r))))
  7.2090 -           end)
  7.2091 -  | zlfm (NDvd (i, a)) =
  7.2092 -    (if ((i : IntInf.int) = (0 : IntInf.int)) then zlfm (NEq a)
  7.2093 -      else let
  7.2094 -             val (c, r) = zsplit0 a;
  7.2095 -           in
  7.2096 -             (if ((c : IntInf.int) = (0 : IntInf.int)) then NDvd (abs_int i, r)
  7.2097 -               else (if IntInf.< ((0 : IntInf.int), c)
  7.2098 -                      then NDvd (abs_int i, Cn ((0 : IntInf.int), c, r))
  7.2099 -                      else NDvd (abs_int i,
  7.2100 -                                  Cn ((0 : IntInf.int), IntInf.~ c, Neg r))))
  7.2101 -           end)
  7.2102 -  | zlfm (Not (And (p, q))) = Or (zlfm (Not p), zlfm (Not q))
  7.2103 -  | zlfm (Not (Or (p, q))) = And (zlfm (Not p), zlfm (Not q))
  7.2104 -  | zlfm (Not (Imp (p, q))) = And (zlfm p, zlfm (Not q))
  7.2105 -  | zlfm (Not (Iff (p, q))) =
  7.2106 -    Or (And (zlfm p, zlfm (Not q)), And (zlfm (Not p), zlfm q))
  7.2107 -  | zlfm (Not (Not p)) = zlfm p
  7.2108 -  | zlfm (Not T) = F
  7.2109 -  | zlfm (Not F) = T
  7.2110 -  | zlfm (Not (Lt a)) = zlfm (Ge a)
  7.2111 -  | zlfm (Not (Le a)) = zlfm (Gt a)
  7.2112 -  | zlfm (Not (Gt a)) = zlfm (Le a)
  7.2113 -  | zlfm (Not (Ge a)) = zlfm (Lt a)
  7.2114 -  | zlfm (Not (Eq a)) = zlfm (NEq a)
  7.2115 -  | zlfm (Not (NEq a)) = zlfm (Eq a)
  7.2116 -  | zlfm (Not (Dvd (i, a))) = zlfm (NDvd (i, a))
  7.2117 -  | zlfm (Not (NDvd (i, a))) = zlfm (Dvd (i, a))
  7.2118 -  | zlfm (Not (Closed p)) = NClosed p
  7.2119 -  | zlfm (Not (NClosed p)) = Closed p
  7.2120 -  | zlfm T = T
  7.2121 -  | zlfm F = F
  7.2122 -  | zlfm (Not (E ci)) = Not (E ci)
  7.2123 -  | zlfm (Not (A cj)) = Not (A cj)
  7.2124 -  | zlfm (E ao) = E ao
  7.2125 -  | zlfm (A ap) = A ap
  7.2126 -  | zlfm (Closed aq) = Closed aq
  7.2127 -  | zlfm (NClosed ar) = NClosed ar;
  7.2128 -
  7.2129 -fun unita p =
  7.2130 -  let
  7.2131 -    val pa = zlfm p;
  7.2132 -    val l = zeta pa;
  7.2133 -    val q =
  7.2134 -      And (Dvd (l, Cn ((0 : IntInf.int), (1 : IntInf.int), C (0 : IntInf.int))),
  7.2135 -            a_beta pa l);
  7.2136 -    val d = delta q;
  7.2137 -    val b = remdups eq_numa (map simpnum (beta q));
  7.2138 -    val a = remdups eq_numa (map simpnum (alpha q));
  7.2139 -  in
  7.2140 -    (if IntInf.<= (size_list b, size_list a) then (q, (b, d))
  7.2141 -      else (mirror q, (a, d)))
  7.2142 -  end;
  7.2143 -
  7.2144 -fun cooper p =
  7.2145 -  let
  7.2146 -    val (q, (b, d)) = unita p;
  7.2147 -    val js = iupt (1 : IntInf.int) d;
  7.2148 -    val mq = simpfm (minusinf q);
  7.2149 -    val md = evaldjf (fn j => simpfm (subst0 (C j) mq)) js;
  7.2150 -  in
  7.2151 -    (if eq_fm md T then T
  7.2152 -      else let
  7.2153 -             val qd =
  7.2154 -               evaldjf (fn (ba, j) => simpfm (subst0 (Add (ba, C j)) q))
  7.2155 -                 (concat_map (fn ba => map (fn a => (ba, a)) js) b);
  7.2156 -           in
  7.2157 -             decr (disj md qd)
  7.2158 -           end)
  7.2159 -  end;
  7.2160 -
  7.2161 -fun prep (E T) = T
  7.2162 -  | prep (E F) = F
  7.2163 -  | prep (E (Or (p, q))) = Or (prep (E p), prep (E q))
  7.2164 -  | prep (E (Imp (p, q))) = Or (prep (E (Not p)), prep (E q))
  7.2165 -  | prep (E (Iff (p, q))) =
  7.2166 -    Or (prep (E (And (p, q))), prep (E (And (Not p, Not q))))
  7.2167 -  | prep (E (Not (And (p, q)))) = Or (prep (E (Not p)), prep (E (Not q)))
  7.2168 -  | prep (E (Not (Imp (p, q)))) = prep (E (And (p, Not q)))
  7.2169 -  | prep (E (Not (Iff (p, q)))) =
  7.2170 -    Or (prep (E (And (p, Not q))), prep (E (And (Not p, q))))
  7.2171 -  | prep (E (Lt ef)) = E (prep (Lt ef))
  7.2172 -  | prep (E (Le eg)) = E (prep (Le eg))
  7.2173 -  | prep (E (Gt eh)) = E (prep (Gt eh))
  7.2174 -  | prep (E (Ge ei)) = E (prep (Ge ei))
  7.2175 -  | prep (E (Eq ej)) = E (prep (Eq ej))
  7.2176 -  | prep (E (NEq ek)) = E (prep (NEq ek))
  7.2177 -  | prep (E (Dvd (el, em))) = E (prep (Dvd (el, em)))
  7.2178 -  | prep (E (NDvd (en, eo))) = E (prep (NDvd (en, eo)))
  7.2179 -  | prep (E (Not T)) = E (prep (Not T))
  7.2180 -  | prep (E (Not F)) = E (prep (Not F))
  7.2181 -  | prep (E (Not (Lt gw))) = E (prep (Not (Lt gw)))
  7.2182 -  | prep (E (Not (Le gx))) = E (prep (Not (Le gx)))
  7.2183 -  | prep (E (Not (Gt gy))) = E (prep (Not (Gt gy)))
  7.2184 -  | prep (E (Not (Ge gz))) = E (prep (Not (Ge gz)))
  7.2185 -  | prep (E (Not (Eq ha))) = E (prep (Not (Eq ha)))
  7.2186 -  | prep (E (Not (NEq hb))) = E (prep (Not (NEq hb)))
  7.2187 -  | prep (E (Not (Dvd (hc, hd)))) = E (prep (Not (Dvd (hc, hd))))
  7.2188 -  | prep (E (Not (NDvd (he, hf)))) = E (prep (Not (NDvd (he, hf))))
  7.2189 -  | prep (E (Not (Not hg))) = E (prep (Not (Not hg)))
  7.2190 -  | prep (E (Not (Or (hj, hk)))) = E (prep (Not (Or (hj, hk))))
  7.2191 -  | prep (E (Not (E hp))) = E (prep (Not (E hp)))
  7.2192 -  | prep (E (Not (A hq))) = E (prep (Not (A hq)))
  7.2193 -  | prep (E (Not (Closed hr))) = E (prep (Not (Closed hr)))
  7.2194 -  | prep (E (Not (NClosed hs))) = E (prep (Not (NClosed hs)))
  7.2195 -  | prep (E (And (eq, er))) = E (prep (And (eq, er)))
  7.2196 -  | prep (E (E ey)) = E (prep (E ey))
  7.2197 -  | prep (E (A ez)) = E (prep (A ez))
  7.2198 -  | prep (E (Closed fa)) = E (prep (Closed fa))
  7.2199 -  | prep (E (NClosed fb)) = E (prep (NClosed fb))
  7.2200 -  | prep (A (And (p, q))) = And (prep (A p), prep (A q))
  7.2201 -  | prep (A T) = prep (Not (E (Not T)))
  7.2202 -  | prep (A F) = prep (Not (E (Not F)))
  7.2203 -  | prep (A (Lt jn)) = prep (Not (E (Not (Lt jn))))
  7.2204 -  | prep (A (Le jo)) = prep (Not (E (Not (Le jo))))
  7.2205 -  | prep (A (Gt jp)) = prep (Not (E (Not (Gt jp))))
  7.2206 -  | prep (A (Ge jq)) = prep (Not (E (Not (Ge jq))))
  7.2207 -  | prep (A (Eq jr)) = prep (Not (E (Not (Eq jr))))
  7.2208 -  | prep (A (NEq js)) = prep (Not (E (Not (NEq js))))
  7.2209 -  | prep (A (Dvd (jt, ju))) = prep (Not (E (Not (Dvd (jt, ju)))))
  7.2210 -  | prep (A (NDvd (jv, jw))) = prep (Not (E (Not (NDvd (jv, jw)))))
  7.2211 -  | prep (A (Not jx)) = prep (Not (E (Not (Not jx))))
  7.2212 -  | prep (A (Or (ka, kb))) = prep (Not (E (Not (Or (ka, kb)))))
  7.2213 -  | prep (A (Imp (kc, kd))) = prep (Not (E (Not (Imp (kc, kd)))))
  7.2214 -  | prep (A (Iff (ke, kf))) = prep (Not (E (Not (Iff (ke, kf)))))
  7.2215 -  | prep (A (E kg)) = prep (Not (E (Not (E kg))))
  7.2216 -  | prep (A (A kh)) = prep (Not (E (Not (A kh))))
  7.2217 -  | prep (A (Closed ki)) = prep (Not (E (Not (Closed ki))))
  7.2218 -  | prep (A (NClosed kj)) = prep (Not (E (Not (NClosed kj))))
  7.2219 -  | prep (Not (Not p)) = prep p
  7.2220 -  | prep (Not (And (p, q))) = Or (prep (Not p), prep (Not q))
  7.2221 -  | prep (Not (A p)) = prep (E (Not p))
  7.2222 -  | prep (Not (Or (p, q))) = And (prep (Not p), prep (Not q))
  7.2223 -  | prep (Not (Imp (p, q))) = And (prep p, prep (Not q))
  7.2224 -  | prep (Not (Iff (p, q))) = Or (prep (And (p, Not q)), prep (And (Not p, q)))
  7.2225 -  | prep (Not T) = Not (prep T)
  7.2226 -  | prep (Not F) = Not (prep F)
  7.2227 -  | prep (Not (Lt bo)) = Not (prep (Lt bo))
  7.2228 -  | prep (Not (Le bp)) = Not (prep (Le bp))
  7.2229 -  | prep (Not (Gt bq)) = Not (prep (Gt bq))
  7.2230 -  | prep (Not (Ge br)) = Not (prep (Ge br))
  7.2231 -  | prep (Not (Eq bs)) = Not (prep (Eq bs))
  7.2232 -  | prep (Not (NEq bt)) = Not (prep (NEq bt))
  7.2233 -  | prep (Not (Dvd (bu, bv))) = Not (prep (Dvd (bu, bv)))
  7.2234 -  | prep (Not (NDvd (bw, bx))) = Not (prep (NDvd (bw, bx)))
  7.2235 -  | prep (Not (E ch)) = Not (prep (E ch))
  7.2236 -  | prep (Not (Closed cj)) = Not (prep (Closed cj))
  7.2237 -  | prep (Not (NClosed ck)) = Not (prep (NClosed ck))
  7.2238 -  | prep (Or (p, q)) = Or (prep p, prep q)
  7.2239 -  | prep (And (p, q)) = And (prep p, prep q)
  7.2240 -  | prep (Imp (p, q)) = prep (Or (Not p, q))
  7.2241 -  | prep (Iff (p, q)) = Or (prep (And (p, q)), prep (And (Not p, Not q)))
  7.2242 -  | prep T = T
  7.2243 -  | prep F = F
  7.2244 -  | prep (Lt u) = Lt u
  7.2245 -  | prep (Le v) = Le v
  7.2246 -  | prep (Gt w) = Gt w
  7.2247 -  | prep (Ge x) = Ge x
  7.2248 -  | prep (Eq y) = Eq y
  7.2249 -  | prep (NEq z) = NEq z
  7.2250 -  | prep (Dvd (aa, ab)) = Dvd (aa, ab)
  7.2251 -  | prep (NDvd (ac, ad)) = NDvd (ac, ad)
  7.2252 -  | prep (Closed ap) = Closed ap
  7.2253 -  | prep (NClosed aq) = NClosed aq;
  7.2254 -
  7.2255 -fun qelim (E p) = (fn qe => dj qe (qelim p qe))
  7.2256 -  | qelim (A p) = (fn qe => nota (qe (qelim (Not p) qe)))
  7.2257 -  | qelim (Not p) = (fn qe => nota (qelim p qe))
  7.2258 -  | qelim (And (p, q)) = (fn qe => conj (qelim p qe) (qelim q qe))
  7.2259 -  | qelim (Or (p, q)) = (fn qe => disj (qelim p qe) (qelim q qe))
  7.2260 -  | qelim (Imp (p, q)) = (fn qe => impa (qelim p qe) (qelim q qe))
  7.2261 -  | qelim (Iff (p, q)) = (fn qe => iffa (qelim p qe) (qelim q qe))
  7.2262 -  | qelim T = (fn _ => simpfm T)
  7.2263 -  | qelim F = (fn _ => simpfm F)
  7.2264 -  | qelim (Lt u) = (fn _ => simpfm (Lt u))
  7.2265 -  | qelim (Le v) = (fn _ => simpfm (Le v))
  7.2266 -  | qelim (Gt w) = (fn _ => simpfm (Gt w))
  7.2267 -  | qelim (Ge x) = (fn _ => simpfm (Ge x))
  7.2268 -  | qelim (Eq y) = (fn _ => simpfm (Eq y))
  7.2269 -  | qelim (NEq z) = (fn _ => simpfm (NEq z))
  7.2270 -  | qelim (Dvd (aa, ab)) = (fn _ => simpfm (Dvd (aa, ab)))
  7.2271 -  | qelim (NDvd (ac, ad)) = (fn _ => simpfm (NDvd (ac, ad)))
  7.2272 -  | qelim (Closed ap) = (fn _ => simpfm (Closed ap))
  7.2273 -  | qelim (NClosed aq) = (fn _ => simpfm (NClosed aq));
  7.2274 -
  7.2275 -fun pa p = qelim (prep p) cooper;
  7.2276 -
  7.2277 -end; (*struct Generated_Cooper*)