--- a/NEWS Tue May 11 09:10:31 2010 -0700
+++ b/NEWS Tue May 11 11:02:56 2010 -0700
@@ -140,6 +140,9 @@
*** HOL ***
+* Theorem Int.int_induct renamed to Int.int_of_nat_induct and is
+no longer shadowed. INCOMPATIBILITY.
+
* Dropped theorem duplicate comp_arith; use semiring_norm instead. INCOMPATIBILITY.
* Theory 'Finite_Set': various folding_* locales facilitate the application
--- a/src/HOL/Decision_Procs/Cooper.thy Tue May 11 09:10:31 2010 -0700
+++ b/src/HOL/Decision_Procs/Cooper.thy Tue May 11 11:02:56 2010 -0700
@@ -1910,7 +1910,7 @@
ML {* @{code cooper_test} () *}
(*
-code_reflect Generated_Cooper
+code_reflect Cooper_Procedure
functions pa
file "~~/src/HOL/Tools/Qelim/generated_cooper.ML"
*)
--- a/src/HOL/Int.thy Tue May 11 09:10:31 2010 -0700
+++ b/src/HOL/Int.thy Tue May 11 11:02:56 2010 -0700
@@ -559,7 +559,7 @@
apply (blast dest: nat_0_le [THEN sym])
done
-theorem int_induct [induct type: int, case_names nonneg neg]:
+theorem int_of_nat_induct [induct type: int, case_names nonneg neg]:
"[|!! n. P (of_nat n \<Colon> int); !!n. P (- (of_nat (Suc n))) |] ==> P z"
by (cases z rule: int_cases) auto
@@ -1784,6 +1784,23 @@
apply (rule step, simp+)
done
+theorem int_induct [case_names base step1 step2]:
+ fixes k :: int
+ assumes base: "P k"
+ and step1: "\<And>i. k \<le> i \<Longrightarrow> P i \<Longrightarrow> P (i + 1)"
+ and step2: "\<And>i. k \<ge> i \<Longrightarrow> P i \<Longrightarrow> P (i - 1)"
+ shows "P i"
+proof -
+ have "i \<le> k \<or> i \<ge> k" by arith
+ then show ?thesis proof
+ assume "i \<ge> k" then show ?thesis using base
+ by (rule int_ge_induct) (fact step1)
+ next
+ assume "i \<le> k" then show ?thesis using base
+ by (rule int_le_induct) (fact step2)
+ qed
+qed
+
subsection{*Intermediate value theorems*}
lemma int_val_lemma:
--- a/src/HOL/IsaMakefile Tue May 11 09:10:31 2010 -0700
+++ b/src/HOL/IsaMakefile Tue May 11 11:02:56 2010 -0700
@@ -302,10 +302,8 @@
Tools/Predicate_Compile/predicate_compile_specialisation.ML \
Tools/Predicate_Compile/predicate_compile_pred.ML \
Tools/quickcheck_generators.ML \
- Tools/Qelim/cooper_data.ML \
Tools/Qelim/cooper.ML \
- Tools/Qelim/generated_cooper.ML \
- Tools/Qelim/presburger.ML \
+ Tools/Qelim/cooper_procedure.ML \
Tools/Qelim/qelim.ML \
Tools/Quotient/quotient_def.ML \
Tools/Quotient/quotient_info.ML \
--- a/src/HOL/Library/Formal_Power_Series.thy Tue May 11 09:10:31 2010 -0700
+++ b/src/HOL/Library/Formal_Power_Series.thy Tue May 11 11:02:56 2010 -0700
@@ -402,7 +402,7 @@
lemma number_of_fps_const: "(number_of k::('a::comm_ring_1) fps) = fps_const (of_int k)"
-proof(induct k rule: int_induct[where k=0])
+proof(induct k rule: int_induct [where k=0])
case base thus ?case unfolding number_of_fps_def of_int_0 by simp
next
case (step1 i) thus ?case unfolding number_of_fps_def
@@ -3214,7 +3214,7 @@
lemma fps_number_of_fps_const: "number_of i = fps_const (number_of i :: 'a:: {comm_ring_1, number_ring})"
apply (subst (2) number_of_eq)
-apply(rule int_induct[of _ 0])
+apply(rule int_induct [of _ 0])
apply (simp_all add: number_of_fps_def)
by (simp_all add: fps_const_add[symmetric] fps_const_minus[symmetric])
--- a/src/HOL/Library/Quotient_List.thy Tue May 11 09:10:31 2010 -0700
+++ b/src/HOL/Library/Quotient_List.thy Tue May 11 11:02:56 2010 -0700
@@ -52,12 +52,17 @@
lemma list_rel_transp:
assumes a: "equivp R"
shows "list_rel R xs1 xs2 \<Longrightarrow> list_rel R xs2 xs3 \<Longrightarrow> list_rel R xs1 xs3"
- apply(induct xs1 xs2 arbitrary: xs3 rule: list_induct2')
- apply(simp_all)
+ using a
+ apply(induct R xs1 xs2 arbitrary: xs3 rule: list_rel.induct)
+ apply(simp)
+ apply(simp)
+ apply(simp)
apply(case_tac xs3)
- apply(simp_all)
- apply(rule equivp_transp[OF a])
- apply(auto)
+ apply(clarify)
+ apply(simp (no_asm_use))
+ apply(clarify)
+ apply(simp (no_asm_use))
+ apply(auto intro: equivp_transp)
done
lemma list_equivp[quot_equiv]:
--- a/src/HOL/Mirabelle/Tools/mirabelle.ML Tue May 11 09:10:31 2010 -0700
+++ b/src/HOL/Mirabelle/Tools/mirabelle.ML Tue May 11 11:02:56 2010 -0700
@@ -92,7 +92,7 @@
fun log thy s =
let fun append_to n = if n = "" then K () else File.append (Path.explode n)
- in append_to (Config.get_thy thy logfile) (s ^ "\n") end
+ in append_to (Config.get_global thy logfile) (s ^ "\n") end
(* FIXME: with multithreading and parallel proofs enabled, we might need to
encapsulate this inside a critical section *)
@@ -108,7 +108,7 @@
| in_range l r (SOME i) = (l <= i andalso (r < 0 orelse i <= r))
fun only_within_range thy pos f x =
- let val l = Config.get_thy thy start_line and r = Config.get_thy thy end_line
+ let val l = Config.get_global thy start_line and r = Config.get_global thy end_line
in if in_range l r (Position.line_of pos) then f x else () end
in
@@ -118,7 +118,7 @@
val thy = Proof.theory_of pre
val pos = Toplevel.pos_of tr
val name = Toplevel.name_of tr
- val st = (pre, post, Time.fromSeconds (Config.get_thy thy timeout))
+ val st = (pre, post, Time.fromSeconds (Config.get_global thy timeout))
val str0 = string_of_int o the_default 0
val loc = str0 (Position.line_of pos) ^ ":" ^ str0 (Position.column_of pos)
--- a/src/HOL/Presburger.thy Tue May 11 09:10:31 2010 -0700
+++ b/src/HOL/Presburger.thy Tue May 11 11:02:56 2010 -0700
@@ -8,17 +8,12 @@
imports Groebner_Basis SetInterval
uses
"Tools/Qelim/qelim.ML"
- "Tools/Qelim/cooper_data.ML"
- "Tools/Qelim/generated_cooper.ML"
+ "Tools/Qelim/cooper_procedure.ML"
("Tools/Qelim/cooper.ML")
- ("Tools/Qelim/presburger.ML")
begin
-setup CooperData.setup
-
subsection{* The @{text "-\<infinity>"} and @{text "+\<infinity>"} Properties *}
-
lemma minf:
"\<lbrakk>\<exists>(z ::'a::linorder).\<forall>x<z. P x = P' x; \<exists>z.\<forall>x<z. Q x = Q' x\<rbrakk>
\<Longrightarrow> \<exists>z.\<forall>x<z. (P x \<and> Q x) = (P' x \<and> Q' x)"
@@ -222,16 +217,6 @@
lemma incr_lemma: "0 < (d::int) \<Longrightarrow> z < x + (abs(x-z)+1) * d"
by(induct rule: int_gr_induct, simp_all add:int_distrib)
-theorem int_induct[case_names base step1 step2]:
- assumes
- base: "P(k::int)" and step1: "\<And>i. \<lbrakk>k \<le> i; P i\<rbrakk> \<Longrightarrow> P(i+1)" and
- step2: "\<And>i. \<lbrakk>k \<ge> i; P i\<rbrakk> \<Longrightarrow> P(i - 1)"
- shows "P i"
-proof -
- have "i \<le> k \<or> i\<ge> k" by arith
- thus ?thesis using prems int_ge_induct[where P="P" and k="k" and i="i"] int_le_induct[where P="P" and k="k" and i="i"] by blast
-qed
-
lemma decr_mult_lemma:
assumes dpos: "(0::int) < d" and minus: "\<forall>x. P x \<longrightarrow> P(x - d)" and knneg: "0 <= k"
shows "ALL x. P x \<longrightarrow> P(x - k*d)"
@@ -387,10 +372,11 @@
lemma zdiff_int_split: "P (int (x - y)) =
((y \<le> x \<longrightarrow> P (int x - int y)) \<and> (x < y \<longrightarrow> P 0))"
- by (case_tac "y \<le> x", simp_all add: zdiff_int)
+ by (cases "y \<le> x") (simp_all add: zdiff_int)
lemma number_of1: "(0::int) <= number_of n \<Longrightarrow> (0::int) <= number_of (Int.Bit0 n) \<and> (0::int) <= number_of (Int.Bit1 n)"
by simp
+
lemma number_of2: "(0::int) <= Numeral0" by simp
text {*
@@ -401,9 +387,12 @@
theorem conj_le_cong: "(0 <= x \<Longrightarrow> P = P') \<Longrightarrow> (0 <= (x::int) \<and> P) = (0 <= x \<and> P')"
by (simp cong: conj_cong)
-lemma int_eq_number_of_eq:
- "(((number_of v)::int) = (number_of w)) = iszero ((number_of (v + (uminus w)))::int)"
- by (rule eq_number_of_eq)
+
+use "Tools/Qelim/cooper.ML"
+
+setup Cooper.setup
+
+method_setup presburger = "Cooper.method" "Cooper's algorithm for Presburger arithmetic"
declare dvd_eq_mod_eq_0[symmetric, presburger]
declare mod_1[presburger]
@@ -426,31 +415,6 @@
lemma [presburger]: "(a::int) div 0 = 0" and [presburger]: "a mod 0 = a"
by simp_all
-use "Tools/Qelim/cooper.ML"
-oracle linzqe_oracle = Coopereif.cooper_oracle
-
-use "Tools/Qelim/presburger.ML"
-
-setup {* Arith_Data.add_tactic "Presburger arithmetic" (K (Presburger.cooper_tac true [] [])) *}
-
-method_setup presburger = {*
-let
- fun keyword k = Scan.lift (Args.$$$ k -- Args.colon) >> K ()
- fun simple_keyword k = Scan.lift (Args.$$$ k) >> K ()
- val addN = "add"
- val delN = "del"
- val elimN = "elim"
- val any_keyword = keyword addN || keyword delN || simple_keyword elimN
- val thms = Scan.repeat (Scan.unless any_keyword Attrib.multi_thm) >> flat;
-in
- Scan.optional (simple_keyword elimN >> K false) true --
- Scan.optional (keyword addN |-- thms) [] --
- Scan.optional (keyword delN |-- thms) [] >>
- (fn ((elim, add_ths), del_ths) => fn ctxt =>
- SIMPLE_METHOD' (Presburger.cooper_tac elim add_ths del_ths ctxt))
-end
-*} "Cooper's algorithm for Presburger arithmetic"
-
lemma [presburger, algebra]: "m mod 2 = (1::nat) \<longleftrightarrow> \<not> 2 dvd m " by presburger
lemma [presburger, algebra]: "m mod 2 = Suc 0 \<longleftrightarrow> \<not> 2 dvd m " by presburger
lemma [presburger, algebra]: "m mod (Suc (Suc 0)) = (1::nat) \<longleftrightarrow> \<not> 2 dvd m " by presburger
--- a/src/HOL/Tools/Qelim/cooper.ML Tue May 11 09:10:31 2010 -0700
+++ b/src/HOL/Tools/Qelim/cooper.ML Tue May 11 11:02:56 2010 -0700
@@ -1,19 +1,70 @@
(* Title: HOL/Tools/Qelim/cooper.ML
Author: Amine Chaieb, TU Muenchen
+
+Presburger arithmetic by Cooper's algorithm.
*)
signature COOPER =
sig
- val cooper_conv : Proof.context -> conv
- exception COOPER of string * exn
+ type entry
+ val get: Proof.context -> entry
+ val del: term list -> attribute
+ val add: term list -> attribute
+ val conv: Proof.context -> conv
+ val tac: bool -> thm list -> thm list -> Proof.context -> int -> tactic
+ val method: (Proof.context -> Method.method) context_parser
+ val setup: theory -> theory
end;
structure Cooper: COOPER =
struct
-open Conv;
+type entry = simpset * term list;
-exception COOPER of string * exn;
+val allowed_consts =
+ [@{term "op + :: int => _"}, @{term "op + :: nat => _"},
+ @{term "op - :: int => _"}, @{term "op - :: nat => _"},
+ @{term "op * :: int => _"}, @{term "op * :: nat => _"},
+ @{term "op div :: int => _"}, @{term "op div :: nat => _"},
+ @{term "op mod :: int => _"}, @{term "op mod :: nat => _"},
+ @{term "op &"}, @{term "op |"}, @{term "op -->"},
+ @{term "op = :: int => _"}, @{term "op = :: nat => _"}, @{term "op = :: bool => _"},
+ @{term "op < :: int => _"}, @{term "op < :: nat => _"},
+ @{term "op <= :: int => _"}, @{term "op <= :: nat => _"},
+ @{term "op dvd :: int => _"}, @{term "op dvd :: nat => _"},
+ @{term "abs :: int => _"},
+ @{term "max :: int => _"}, @{term "max :: nat => _"},
+ @{term "min :: int => _"}, @{term "min :: nat => _"},
+ @{term "uminus :: int => _"}, (*@ {term "uminus :: nat => _"},*)
+ @{term "Not"}, @{term "Suc"},
+ @{term "Ex :: (int => _) => _"}, @{term "Ex :: (nat => _) => _"},
+ @{term "All :: (int => _) => _"}, @{term "All :: (nat => _) => _"},
+ @{term "nat"}, @{term "int"},
+ @{term "Int.Bit0"}, @{term "Int.Bit1"},
+ @{term "Int.Pls"}, @{term "Int.Min"},
+ @{term "Int.number_of :: int => int"}, @{term "Int.number_of :: int => nat"},
+ @{term "0::int"}, @{term "1::int"}, @{term "0::nat"}, @{term "1::nat"},
+ @{term "True"}, @{term "False"}];
+
+structure Data = Generic_Data
+(
+ type T = simpset * term list;
+ val empty = (HOL_ss, allowed_consts);
+ val extend = I;
+ fun merge ((ss1, ts1), (ss2, ts2)) =
+ (merge_ss (ss1, ss2), Library.merge (op aconv) (ts1, ts2));
+);
+
+val get = Data.get o Context.Proof;
+
+fun add ts = Thm.declaration_attribute (fn th => fn context =>
+ context |> Data.map (fn (ss,ts') =>
+ (ss addsimps [th], merge (op aconv) (ts',ts) )))
+
+fun del ts = Thm.declaration_attribute (fn th => fn context =>
+ context |> Data.map (fn (ss,ts') =>
+ (ss delsimps [th], subtract (op aconv) ts' ts )))
+
fun simp_thms_conv ctxt =
Simplifier.rewrite (Simplifier.context ctxt HOL_basic_ss addsimps @{thms simp_thms});
val FWD = Drule.implies_elim_list;
@@ -46,8 +97,7 @@
[bsetconj, bsetdisj, bseteq, bsetneq, bsetlt, bsetle,
bsetgt, bsetge, bsetdvd, bsetndvd,bsetP]] = [@{thms "aset"}, @{thms "bset"}];
-val [miex, cpmi, piex, cppi] = [@{thm "minusinfinity"}, @{thm "cpmi"},
- @{thm "plusinfinity"}, @{thm "cppi"}];
+val [cpmi, cppi] = [@{thm "cpmi"}, @{thm "cppi"}];
val unity_coeff_ex = instantiate' [SOME @{ctyp "int"}] [] @{thm "unity_coeff_ex"};
@@ -69,7 +119,7 @@
( case (term_of ct) of
Const("op &",_)$_$_ => And (Thm.dest_binop ct)
| Const ("op |",_)$_$_ => Or (Thm.dest_binop ct)
-| Const ("op =",ty)$y$_ => if term_of x aconv y then Eq (Thm.dest_arg ct) else Nox
+| Const ("op =",_)$y$_ => if term_of x aconv y then Eq (Thm.dest_arg ct) else Nox
| Const (@{const_name Not},_) $ (Const ("op =",_)$y$_) =>
if term_of x aconv y then NEq (funpow 2 Thm.dest_arg ct) else Nox
| Const (@{const_name Orderings.less}, _) $ y$ z =>
@@ -118,8 +168,7 @@
val cmulC = @{cterm "op * :: int => _"}
val cminus = @{cterm "op - :: int => _"}
val cone = @{cterm "1 :: int"}
-val cneg = @{cterm "uminus :: int => _"}
-val [addC, mulC, subC, negC] = map term_of [cadd, cmulC, cminus, cneg]
+val [addC, mulC, subC] = map term_of [cadd, cmulC, cminus]
val [zero, one] = [@{term "0 :: int"}, @{term "1 :: int"}];
val is_numeral = can dest_numeral;
@@ -202,6 +251,7 @@
fun linear_neg tm = linear_cmul ~1 tm;
fun linear_sub vars tm1 tm2 = linear_add vars tm1 (linear_neg tm2);
+exception COOPER of string;
fun lint vars tm = if is_numeral tm then tm else case tm of
Const (@{const_name Groups.uminus}, _) $ t => linear_neg (lint vars t)
@@ -212,7 +262,7 @@
val t' = lint vars t
in if is_numeral s' then (linear_cmul (dest_numeral s') t')
else if is_numeral t' then (linear_cmul (dest_numeral t') s')
- else raise COOPER ("Cooper Failed", TERM ("lint: not linear",[tm]))
+ else raise COOPER "lint: not linear"
end
| _ => addC $ (mulC $ one $ tm) $ zero;
@@ -254,16 +304,16 @@
fun linearize_conv ctxt vs ct = case term_of ct of
Const(@{const_name Rings.dvd},_)$d$t =>
let
- val th = binop_conv (lint_conv ctxt vs) ct
+ val th = Conv.binop_conv (lint_conv ctxt vs) ct
val (d',t') = Thm.dest_binop (Thm.rhs_of th)
val (dt',tt') = (term_of d', term_of t')
in if is_numeral dt' andalso is_numeral tt'
- then Conv.fconv_rule (arg_conv (Simplifier.rewrite presburger_ss)) th
+ then Conv.fconv_rule (Conv.arg_conv (Simplifier.rewrite presburger_ss)) th
else
let
val dth =
((if dest_numeral (term_of d') < 0 then
- Conv.fconv_rule (arg_conv (arg1_conv (lint_conv ctxt vs)))
+ Conv.fconv_rule (Conv.arg_conv (Conv.arg1_conv (lint_conv ctxt vs)))
(Thm.transitive th (inst' [d',t'] dvd_uminus))
else th) handle TERM _ => th)
val d'' = Thm.rhs_of dth |> Thm.dest_arg1
@@ -271,13 +321,13 @@
case tt' of
Const(@{const_name Groups.plus},_)$(Const(@{const_name Groups.times},_)$c$_)$_ =>
let val x = dest_numeral c
- in if x < 0 then Conv.fconv_rule (arg_conv (arg_conv (lint_conv ctxt vs)))
+ in if x < 0 then Conv.fconv_rule (Conv.arg_conv (Conv.arg_conv (lint_conv ctxt vs)))
(Thm.transitive dth (inst' [d'',t'] dvd_uminus'))
else dth end
| _ => dth
end
end
-| Const (@{const_name Not},_)$(Const(@{const_name Rings.dvd},_)$_$_) => arg_conv (linearize_conv ctxt vs) ct
+| Const (@{const_name Not},_)$(Const(@{const_name Rings.dvd},_)$_$_) => Conv.arg_conv (linearize_conv ctxt vs) ct
| t => if is_intrel t
then (provelin ctxt ((HOLogic.eq_const bT)$t$(lin vs t) |> HOLogic.mk_Trueprop))
RS eq_reflection
@@ -331,9 +381,9 @@
end
fun unit_conv t =
case (term_of t) of
- Const("op &",_)$_$_ => binop_conv unit_conv t
- | Const("op |",_)$_$_ => binop_conv unit_conv t
- | Const (@{const_name Not},_)$_ => arg_conv unit_conv t
+ Const("op &",_)$_$_ => Conv.binop_conv unit_conv t
+ | Const("op |",_)$_$_ => Conv.binop_conv unit_conv t
+ | Const (@{const_name Not},_)$_ => Conv.arg_conv unit_conv t
| Const(s,_)$(Const(@{const_name Groups.times},_)$c$y)$ _ =>
if x=y andalso member (op =)
["op =", @{const_name Orderings.less}, @{const_name Orderings.less_eq}] s
@@ -371,9 +421,7 @@
val emptyIS = @{cterm "{}::int set"};
val insert_tm = @{cterm "insert :: int => _"};
-val mem_tm = Const("op :",[iT , HOLogic.mk_setT iT] ---> bT);
fun mkISet cts = fold_rev (Thm.capply insert_tm #> Thm.capply) cts emptyIS;
-val cTrp = @{cterm "Trueprop"};
val eqelem_imp_imp = (thm"eqelem_imp_iff") RS iffD1;
val [A_tm,B_tm] = map (fn th => cprop_of th |> funpow 2 Thm.dest_arg |> Thm.dest_abs NONE |> snd |> Thm.dest_arg1 |> Thm.dest_arg
|> Thm.dest_abs NONE |> snd |> Thm.dest_fun |> Thm.dest_arg)
@@ -399,13 +447,12 @@
| Le t => (bacc, ins (plus1 t) aacc,dacc)
| Gt t => (ins t bacc, aacc,dacc)
| Ge t => (ins (minus1 t) bacc, aacc,dacc)
- | Dvd (d,s) => (bacc,aacc,insert (op =) (term_of d |> dest_numeral) dacc)
- | NDvd (d,s) => (bacc,aacc,insert (op =) (term_of d|> dest_numeral) dacc)
+ | Dvd (d,_) => (bacc,aacc,insert (op =) (term_of d |> dest_numeral) dacc)
+ | NDvd (d,_) => (bacc,aacc,insert (op =) (term_of d|> dest_numeral) dacc)
| _ => (bacc, aacc, dacc)
val (b0,a0,ds) = h p ([],[],[])
val d = Integer.lcms ds
val cd = Numeral.mk_cnumber @{ctyp "int"} d
- val dt = term_of cd
fun divprop x =
let
val th =
@@ -474,10 +521,6 @@
val eqelem_th = instantiate' [SOME @{ctyp "int"}] [NONE,NONE, SOME S] eqelem_imp_imp
val inS =
let
- fun transmem th0 th1 =
- Thm.equal_elim
- (Drule.arg_cong_rule cTrp (Drule.fun_cong_rule (Drule.arg_cong_rule
- ((Thm.dest_fun o Thm.dest_fun o Thm.dest_arg o cprop_of) th1) th0) S)) th1
val tab = fold Termtab.update
(map (fn eq =>
let val (s,t) = cprop_of eq |> Thm.dest_arg |> Thm.dest_binop
@@ -503,8 +546,8 @@
fun literals_conv bops uops env cv =
let fun h t =
case (term_of t) of
- b$_$_ => if member (op aconv) bops b then binop_conv h t else cv env t
- | u$_ => if member (op aconv) uops u then arg_conv h t else cv env t
+ b$_$_ => if member (op aconv) bops b then Conv.binop_conv h t else cv env t
+ | u$_ => if member (op aconv) uops u then Conv.arg_conv h t else cv env t
| _ => cv env t
in h end;
@@ -523,131 +566,325 @@
(OldTerm.term_frees (term_of p)) (linearize_conv ctxt) (integer_nnf_conv ctxt)
(cooperex_conv ctxt) p
end
- handle CTERM s => raise COOPER ("Cooper Failed", CTERM s)
- | THM s => raise COOPER ("Cooper Failed", THM s)
- | TYPE s => raise COOPER ("Cooper Failed", TYPE s)
-in val cooper_conv = conv
-end;
+ handle CTERM s => raise COOPER "bad cterm"
+ | THM s => raise COOPER "bad thm"
+ | TYPE s => raise COOPER "bad type"
+in val conv = conv
end;
-
-
-structure Coopereif =
-struct
+fun term_bools acc t =
+ let
+ val ops = [@{term "op &"}, @{term "op |"}, @{term "op -->"}, @{term "op = :: bool => _"},
+ @{term "op = :: int => _"}, @{term "op < :: int => _"},
+ @{term "op <= :: int => _"}, @{term "Not"}, @{term "All:: (int => _) => _"},
+ @{term "Ex:: (int => _) => _"}, @{term "True"}, @{term "False"}]
+ fun ty t = not (fastype_of t = HOLogic.boolT)
+ in case t of
+ (l as f $ a) $ b => if ty t orelse member (op =) ops f then term_bools (term_bools acc l)b
+ else insert (op aconv) t acc
+ | f $ a => if ty t orelse member (op =) ops f then term_bools (term_bools acc f) a
+ else insert (op aconv) t acc
+ | Abs p => term_bools acc (snd (variant_abs p))
+ | _ => if ty t orelse member (op =) ops t then acc else insert (op aconv) t acc
+ end;
-open Generated_Cooper;
-
-fun member eq = Library.member eq;
-
-fun cooper s = raise Cooper.COOPER ("Cooper oracle failed", ERROR s);
fun i_of_term vs t = case t
of Free (xn, xT) => (case AList.lookup (op aconv) vs t
- of NONE => cooper "Variable not found in the list!"
- | SOME n => Bound n)
- | @{term "0::int"} => C 0
- | @{term "1::int"} => C 1
- | Term.Bound i => Bound i
- | Const(@{const_name Groups.uminus},_)$t' => Neg (i_of_term vs t')
- | Const(@{const_name Groups.plus},_)$t1$t2 => Add (i_of_term vs t1,i_of_term vs t2)
- | Const(@{const_name Groups.minus},_)$t1$t2 => Sub (i_of_term vs t1,i_of_term vs t2)
+ of NONE => raise COOPER "reification: variable not found in list"
+ | SOME n => Cooper_Procedure.Bound n)
+ | @{term "0::int"} => Cooper_Procedure.C 0
+ | @{term "1::int"} => Cooper_Procedure.C 1
+ | Term.Bound i => Cooper_Procedure.Bound i
+ | Const(@{const_name Groups.uminus},_)$t' => Cooper_Procedure.Neg (i_of_term vs t')
+ | Const(@{const_name Groups.plus},_)$t1$t2 => Cooper_Procedure.Add (i_of_term vs t1,i_of_term vs t2)
+ | Const(@{const_name Groups.minus},_)$t1$t2 => Cooper_Procedure.Sub (i_of_term vs t1,i_of_term vs t2)
| Const(@{const_name Groups.times},_)$t1$t2 =>
- (Mul (HOLogic.dest_number t1 |> snd, i_of_term vs t2)
+ (Cooper_Procedure.Mul (HOLogic.dest_number t1 |> snd, i_of_term vs t2)
handle TERM _ =>
- (Mul (HOLogic.dest_number t2 |> snd, i_of_term vs t1)
- handle TERM _ => cooper "Reification: Unsupported kind of multiplication"))
- | _ => (C (HOLogic.dest_number t |> snd)
- handle TERM _ => cooper "Reification: unknown term");
+ (Cooper_Procedure.Mul (HOLogic.dest_number t2 |> snd, i_of_term vs t1)
+ handle TERM _ => raise COOPER "reification: unsupported kind of multiplication"))
+ | _ => (Cooper_Procedure.C (HOLogic.dest_number t |> snd)
+ handle TERM _ => raise COOPER "reification: unknown term");
fun qf_of_term ps vs t = case t
- of Const("True",_) => T
- | Const("False",_) => F
- | Const(@{const_name Orderings.less},_)$t1$t2 => Lt (Sub (i_of_term vs t1,i_of_term vs t2))
- | Const(@{const_name Orderings.less_eq},_)$t1$t2 => Le (Sub(i_of_term vs t1,i_of_term vs t2))
+ of Const("True",_) => Cooper_Procedure.T
+ | Const("False",_) => Cooper_Procedure.F
+ | Const(@{const_name Orderings.less},_)$t1$t2 => Cooper_Procedure.Lt (Cooper_Procedure.Sub (i_of_term vs t1,i_of_term vs t2))
+ | Const(@{const_name Orderings.less_eq},_)$t1$t2 => Cooper_Procedure.Le (Cooper_Procedure.Sub(i_of_term vs t1,i_of_term vs t2))
| Const(@{const_name Rings.dvd},_)$t1$t2 =>
- (Dvd(HOLogic.dest_number t1 |> snd, i_of_term vs t2) handle _ => cooper "Reification: unsupported dvd") (* FIXME avoid handle _ *)
- | @{term "op = :: int => _"}$t1$t2 => Eq (Sub (i_of_term vs t1,i_of_term vs t2))
- | @{term "op = :: bool => _ "}$t1$t2 => Iff(qf_of_term ps vs t1,qf_of_term ps vs t2)
- | Const("op &",_)$t1$t2 => And(qf_of_term ps vs t1,qf_of_term ps vs t2)
- | Const("op |",_)$t1$t2 => Or(qf_of_term ps vs t1,qf_of_term ps vs t2)
- | Const("op -->",_)$t1$t2 => Imp(qf_of_term ps vs t1,qf_of_term ps vs t2)
- | Const (@{const_name Not},_)$t' => Not(qf_of_term ps vs t')
+ (Cooper_Procedure.Dvd (HOLogic.dest_number t1 |> snd, i_of_term vs t2)
+ handle TERM _ => raise COOPER "reification: unsupported dvd")
+ | @{term "op = :: int => _"}$t1$t2 => Cooper_Procedure.Eq (Cooper_Procedure.Sub (i_of_term vs t1,i_of_term vs t2))
+ | @{term "op = :: bool => _ "}$t1$t2 => Cooper_Procedure.Iff(qf_of_term ps vs t1,qf_of_term ps vs t2)
+ | Const("op &",_)$t1$t2 => Cooper_Procedure.And(qf_of_term ps vs t1,qf_of_term ps vs t2)
+ | Const("op |",_)$t1$t2 => Cooper_Procedure.Or(qf_of_term ps vs t1,qf_of_term ps vs t2)
+ | Const("op -->",_)$t1$t2 => Cooper_Procedure.Imp(qf_of_term ps vs t1,qf_of_term ps vs t2)
+ | Const (@{const_name Not},_)$t' => Cooper_Procedure.Not(qf_of_term ps vs t')
| Const("Ex",_)$Abs(xn,xT,p) =>
let val (xn',p') = variant_abs (xn,xT,p)
val vs' = (Free (xn',xT), 0) :: (map (fn(v,n) => (v,1+ n)) vs)
- in E (qf_of_term ps vs' p')
+ in Cooper_Procedure.E (qf_of_term ps vs' p')
end
| Const("All",_)$Abs(xn,xT,p) =>
let val (xn',p') = variant_abs (xn,xT,p)
val vs' = (Free (xn',xT), 0) :: (map (fn(v,n) => (v,1+ n)) vs)
- in A (qf_of_term ps vs' p')
+ in Cooper_Procedure.A (qf_of_term ps vs' p')
end
| _ =>(case AList.lookup (op aconv) ps t of
- NONE => cooper "Reification: unknown term!"
- | SOME n => Closed n);
-
-local
- val ops = [@{term "op &"}, @{term "op |"}, @{term "op -->"}, @{term "op = :: bool => _"},
- @{term "op = :: int => _"}, @{term "op < :: int => _"},
- @{term "op <= :: int => _"}, @{term "Not"}, @{term "All:: (int => _) => _"},
- @{term "Ex:: (int => _) => _"}, @{term "True"}, @{term "False"}]
-fun ty t = Bool.not (fastype_of t = HOLogic.boolT)
-in
-fun term_bools acc t =
-case t of
- (l as f $ a) $ b => if ty t orelse member (op =) ops f then term_bools (term_bools acc l)b
- else insert (op aconv) t acc
- | f $ a => if ty t orelse member (op =) ops f then term_bools (term_bools acc f) a
- else insert (op aconv) t acc
- | Abs p => term_bools acc (snd (variant_abs p))
- | _ => if ty t orelse member (op =) ops t then acc else insert (op aconv) t acc
-end;
-
-fun myassoc2 l v =
- case l of
- [] => NONE
- | (x,v')::xs => if v = v' then SOME x
- else myassoc2 xs v;
+ NONE => raise COOPER "reification: unknown term"
+ | SOME n => Cooper_Procedure.Closed n);
fun term_of_i vs t = case t
- of C i => HOLogic.mk_number HOLogic.intT i
- | Bound n => the (myassoc2 vs n)
- | Neg t' => @{term "uminus :: int => _"} $ term_of_i vs t'
- | Add (t1, t2) => @{term "op + :: int => _"} $ term_of_i vs t1 $ term_of_i vs t2
- | Sub (t1, t2) => @{term "op - :: int => _"} $ term_of_i vs t1 $ term_of_i vs t2
- | Mul (i, t2) => @{term "op * :: int => _"} $
+ of Cooper_Procedure.C i => HOLogic.mk_number HOLogic.intT i
+ | Cooper_Procedure.Bound n => the (AList.lookup (op =) vs n)
+ | Cooper_Procedure.Neg t' => @{term "uminus :: int => _"} $ term_of_i vs t'
+ | Cooper_Procedure.Add (t1, t2) => @{term "op + :: int => _"} $ term_of_i vs t1 $ term_of_i vs t2
+ | Cooper_Procedure.Sub (t1, t2) => @{term "op - :: int => _"} $ term_of_i vs t1 $ term_of_i vs t2
+ | Cooper_Procedure.Mul (i, t2) => @{term "op * :: int => _"} $
HOLogic.mk_number HOLogic.intT i $ term_of_i vs t2
- | Cn (n, i, t') => term_of_i vs (Add (Mul (i, Bound n), t'));
+ | Cooper_Procedure.Cn (n, i, t') => term_of_i vs (Cooper_Procedure.Add (Cooper_Procedure.Mul (i, Cooper_Procedure.Bound n), t'));
fun term_of_qf ps vs t =
case t of
- T => HOLogic.true_const
- | F => HOLogic.false_const
- | Lt t' => @{term "op < :: int => _ "}$ term_of_i vs t'$ @{term "0::int"}
- | Le t' => @{term "op <= :: int => _ "}$ term_of_i vs t' $ @{term "0::int"}
- | Gt t' => @{term "op < :: int => _ "}$ @{term "0::int"}$ term_of_i vs t'
- | Ge t' => @{term "op <= :: int => _ "}$ @{term "0::int"}$ term_of_i vs t'
- | Eq t' => @{term "op = :: int => _ "}$ term_of_i vs t'$ @{term "0::int"}
- | NEq t' => term_of_qf ps vs (Not (Eq t'))
- | Dvd(i,t') => @{term "op dvd :: int => _ "} $
+ Cooper_Procedure.T => HOLogic.true_const
+ | Cooper_Procedure.F => HOLogic.false_const
+ | Cooper_Procedure.Lt t' => @{term "op < :: int => _ "}$ term_of_i vs t'$ @{term "0::int"}
+ | Cooper_Procedure.Le t' => @{term "op <= :: int => _ "}$ term_of_i vs t' $ @{term "0::int"}
+ | Cooper_Procedure.Gt t' => @{term "op < :: int => _ "}$ @{term "0::int"}$ term_of_i vs t'
+ | Cooper_Procedure.Ge t' => @{term "op <= :: int => _ "}$ @{term "0::int"}$ term_of_i vs t'
+ | Cooper_Procedure.Eq t' => @{term "op = :: int => _ "}$ term_of_i vs t'$ @{term "0::int"}
+ | Cooper_Procedure.NEq t' => term_of_qf ps vs (Cooper_Procedure.Not (Cooper_Procedure.Eq t'))
+ | Cooper_Procedure.Dvd(i,t') => @{term "op dvd :: int => _ "} $
HOLogic.mk_number HOLogic.intT i $ term_of_i vs t'
- | NDvd(i,t')=> term_of_qf ps vs (Not(Dvd(i,t')))
- | Not t' => HOLogic.Not$(term_of_qf ps vs t')
- | And(t1,t2) => HOLogic.conj$(term_of_qf ps vs t1)$(term_of_qf ps vs t2)
- | Or(t1,t2) => HOLogic.disj$(term_of_qf ps vs t1)$(term_of_qf ps vs t2)
- | Imp(t1,t2) => HOLogic.imp$(term_of_qf ps vs t1)$(term_of_qf ps vs t2)
- | Iff(t1,t2) => @{term "op = :: bool => _"} $ term_of_qf ps vs t1 $ term_of_qf ps vs t2
- | Closed n => the (myassoc2 ps n)
- | NClosed n => term_of_qf ps vs (Not (Closed n))
- | _ => cooper "If this is raised, Isabelle/HOL or code generator is inconsistent!";
+ | Cooper_Procedure.NDvd(i,t')=> term_of_qf ps vs (Cooper_Procedure.Not(Cooper_Procedure.Dvd(i,t')))
+ | Cooper_Procedure.Not t' => HOLogic.Not$(term_of_qf ps vs t')
+ | Cooper_Procedure.And(t1,t2) => HOLogic.conj$(term_of_qf ps vs t1)$(term_of_qf ps vs t2)
+ | Cooper_Procedure.Or(t1,t2) => HOLogic.disj$(term_of_qf ps vs t1)$(term_of_qf ps vs t2)
+ | Cooper_Procedure.Imp(t1,t2) => HOLogic.imp$(term_of_qf ps vs t1)$(term_of_qf ps vs t2)
+ | Cooper_Procedure.Iff(t1,t2) => @{term "op = :: bool => _"} $ term_of_qf ps vs t1 $ term_of_qf ps vs t2
+ | Cooper_Procedure.Closed n => the (AList.lookup (op =) ps n)
+ | Cooper_Procedure.NClosed n => term_of_qf ps vs (Cooper_Procedure.Not (Cooper_Procedure.Closed n));
-fun cooper_oracle ct =
+fun invoke t =
let
- val thy = Thm.theory_of_cterm ct;
- val t = Thm.term_of ct;
val (vs, ps) = pairself (map_index swap) (OldTerm.term_frees t, term_bools [] t);
in
- Thm.cterm_of thy (Logic.mk_equals (HOLogic.mk_Trueprop t,
- HOLogic.mk_Trueprop (term_of_qf ps vs (pa (qf_of_term ps vs t)))))
+ Logic.mk_equals (HOLogic.mk_Trueprop t,
+ HOLogic.mk_Trueprop (term_of_qf (map swap ps) (map swap vs) (Cooper_Procedure.pa (qf_of_term ps vs t))))
end;
+val (_, oracle) = Context.>>> (Context.map_theory_result
+ (Thm.add_oracle (Binding.name "cooper",
+ (fn (ctxt, t) => Thm.cterm_of (ProofContext.theory_of ctxt) (invoke t)))));
+
+val comp_ss = HOL_ss addsimps @{thms semiring_norm};
+
+fun strip_objimp ct =
+ (case Thm.term_of ct of
+ Const ("op -->", _) $ _ $ _ =>
+ let val (A, B) = Thm.dest_binop ct
+ in A :: strip_objimp B end
+ | _ => [ct]);
+
+fun strip_objall ct =
+ case term_of ct of
+ Const ("All", _) $ Abs (xn,xT,p) =>
+ let val (a,(v,t')) = (apsnd (Thm.dest_abs (SOME xn)) o Thm.dest_comb) ct
+ in apfst (cons (a,v)) (strip_objall t')
+ end
+| _ => ([],ct);
+
+local
+ val all_maxscope_ss =
+ HOL_basic_ss addsimps map (fn th => th RS sym) @{thms "all_simps"}
+in
+fun thin_prems_tac P = simp_tac all_maxscope_ss THEN'
+ CSUBGOAL (fn (p', i) =>
+ let
+ val (qvs, p) = strip_objall (Thm.dest_arg p')
+ val (ps, c) = split_last (strip_objimp p)
+ val qs = filter P ps
+ val q = if P c then c else @{cterm "False"}
+ val ng = fold_rev (fn (a,v) => fn t => Thm.capply a (Thm.cabs v t)) qvs
+ (fold_rev (fn p => fn q => Thm.capply (Thm.capply @{cterm "op -->"} p) q) qs q)
+ val g = Thm.capply (Thm.capply @{cterm "op ==>"} (Thm.capply @{cterm "Trueprop"} ng)) p'
+ val ntac = (case qs of [] => q aconvc @{cterm "False"}
+ | _ => false)
+ in
+ if ntac then no_tac
+ else rtac (Goal.prove_internal [] g (K (blast_tac HOL_cs 1))) i
+ end)
end;
+
+local
+ fun isnum t = case t of
+ Const(@{const_name Groups.zero},_) => true
+ | Const(@{const_name Groups.one},_) => true
+ | @{term "Suc"}$s => isnum s
+ | @{term "nat"}$s => isnum s
+ | @{term "int"}$s => isnum s
+ | Const(@{const_name Groups.uminus},_)$s => isnum s
+ | Const(@{const_name Groups.plus},_)$l$r => isnum l andalso isnum r
+ | Const(@{const_name Groups.times},_)$l$r => isnum l andalso isnum r
+ | Const(@{const_name Groups.minus},_)$l$r => isnum l andalso isnum r
+ | Const(@{const_name Power.power},_)$l$r => isnum l andalso isnum r
+ | Const(@{const_name Divides.mod},_)$l$r => isnum l andalso isnum r
+ | Const(@{const_name Divides.div},_)$l$r => isnum l andalso isnum r
+ | _ => can HOLogic.dest_number t orelse can HOLogic.dest_nat t
+
+ fun ty cts t =
+ if not (member (op =) [HOLogic.intT, HOLogic.natT, HOLogic.boolT] (typ_of (ctyp_of_term t))) then false
+ else case term_of t of
+ c$l$r => if member (op =) [@{term"op *::int => _"}, @{term"op *::nat => _"}] c
+ then not (isnum l orelse isnum r)
+ else not (member (op aconv) cts c)
+ | c$_ => not (member (op aconv) cts c)
+ | c => not (member (op aconv) cts c)
+
+ val term_constants =
+ let fun h acc t = case t of
+ Const _ => insert (op aconv) t acc
+ | a$b => h (h acc a) b
+ | Abs (_,_,t) => h acc t
+ | _ => acc
+ in h [] end;
+in
+fun is_relevant ctxt ct =
+ subset (op aconv) (term_constants (term_of ct) , snd (get ctxt))
+ andalso forall (fn Free (_,T) => member (op =) [@{typ int}, @{typ nat}] T) (OldTerm.term_frees (term_of ct))
+ andalso forall (fn Var (_,T) => member (op =) [@{typ int}, @{typ nat}] T) (OldTerm.term_vars (term_of ct));
+
+fun int_nat_terms ctxt ct =
+ let
+ val cts = snd (get ctxt)
+ fun h acc t = if ty cts t then insert (op aconvc) t acc else
+ case (term_of t) of
+ _$_ => h (h acc (Thm.dest_arg t)) (Thm.dest_fun t)
+ | Abs(_,_,_) => Thm.dest_abs NONE t ||> h acc |> uncurry (remove (op aconvc))
+ | _ => acc
+ in h [] ct end
+end;
+
+fun generalize_tac f = CSUBGOAL (fn (p, i) => PRIMITIVE (fn st =>
+ let
+ fun all T = Drule.cterm_rule (instantiate' [SOME T] []) @{cpat "all"}
+ fun gen x t = Thm.capply (all (ctyp_of_term x)) (Thm.cabs x t)
+ val ts = sort (fn (a,b) => Term_Ord.fast_term_ord (term_of a, term_of b)) (f p)
+ val p' = fold_rev gen ts p
+ in implies_intr p' (implies_elim st (fold forall_elim ts (assume p'))) end));
+
+local
+val ss1 = comp_ss
+ addsimps @{thms simp_thms} @ [@{thm "nat_number_of_def"}, @{thm "zdvd_int"}]
+ @ map (fn r => r RS sym)
+ [@{thm "int_int_eq"}, @{thm "zle_int"}, @{thm "zless_int"}, @{thm "zadd_int"},
+ @{thm "zmult_int"}]
+ addsplits [@{thm "zdiff_int_split"}]
+
+val ss2 = HOL_basic_ss
+ addsimps [@{thm "nat_0_le"}, @{thm "int_nat_number_of"},
+ @{thm "all_nat"}, @{thm "ex_nat"}, @{thm "number_of1"},
+ @{thm "number_of2"}, @{thm "int_0"}, @{thm "int_1"}, @{thm "Suc_eq_plus1"}]
+ addcongs [@{thm "conj_le_cong"}, @{thm "imp_le_cong"}]
+val div_mod_ss = HOL_basic_ss addsimps @{thms simp_thms}
+ @ map (symmetric o mk_meta_eq)
+ [@{thm "dvd_eq_mod_eq_0"},
+ @{thm "mod_add_left_eq"}, @{thm "mod_add_right_eq"},
+ @{thm "mod_add_eq"}, @{thm "div_add1_eq"}, @{thm "zdiv_zadd1_eq"}]
+ @ [@{thm "mod_self"}, @{thm "zmod_self"}, @{thm "mod_by_0"},
+ @{thm "div_by_0"}, @{thm "DIVISION_BY_ZERO"} RS conjunct1,
+ @{thm "DIVISION_BY_ZERO"} RS conjunct2, @{thm "zdiv_zero"}, @{thm "zmod_zero"},
+ @{thm "div_0"}, @{thm "mod_0"}, @{thm "div_by_1"}, @{thm "mod_by_1"}, @{thm "div_1"},
+ @{thm "mod_1"}, @{thm "Suc_eq_plus1"}]
+ @ @{thms add_ac}
+ addsimprocs [cancel_div_mod_nat_proc, cancel_div_mod_int_proc]
+ val splits_ss = comp_ss addsimps [@{thm "mod_div_equality'"}] addsplits
+ [@{thm "split_zdiv"}, @{thm "split_zmod"}, @{thm "split_div'"},
+ @{thm "split_min"}, @{thm "split_max"}, @{thm "abs_split"}]
+in
+fun nat_to_int_tac ctxt =
+ simp_tac (Simplifier.context ctxt ss1) THEN_ALL_NEW
+ simp_tac (Simplifier.context ctxt ss2) THEN_ALL_NEW
+ simp_tac (Simplifier.context ctxt comp_ss);
+
+fun div_mod_tac ctxt i = simp_tac (Simplifier.context ctxt div_mod_ss) i;
+fun splits_tac ctxt i = simp_tac (Simplifier.context ctxt splits_ss) i;
+end;
+
+fun core_tac ctxt = CSUBGOAL (fn (p, i) =>
+ let
+ val cpth =
+ if !quick_and_dirty
+ then oracle (ctxt, Envir.beta_norm (Pattern.eta_long [] (term_of (Thm.dest_arg p))))
+ else Conv.arg_conv (conv ctxt) p
+ val p' = Thm.rhs_of cpth
+ val th = implies_intr p' (equal_elim (symmetric cpth) (assume p'))
+ in rtac th i end
+ handle COOPER _ => no_tac);
+
+fun finish_tac q = SUBGOAL (fn (_, i) =>
+ (if q then I else TRY) (rtac TrueI i));
+
+fun tac elim add_ths del_ths ctxt =
+let val ss = Simplifier.context ctxt (fst (get ctxt)) delsimps del_ths addsimps add_ths
+ val aprems = Arith_Data.get_arith_facts ctxt
+in
+ Method.insert_tac aprems
+ THEN_ALL_NEW Object_Logic.full_atomize_tac
+ THEN_ALL_NEW CONVERSION Thm.eta_long_conversion
+ THEN_ALL_NEW simp_tac ss
+ THEN_ALL_NEW (TRY o generalize_tac (int_nat_terms ctxt))
+ THEN_ALL_NEW Object_Logic.full_atomize_tac
+ THEN_ALL_NEW (thin_prems_tac (is_relevant ctxt))
+ THEN_ALL_NEW Object_Logic.full_atomize_tac
+ THEN_ALL_NEW div_mod_tac ctxt
+ THEN_ALL_NEW splits_tac ctxt
+ THEN_ALL_NEW simp_tac ss
+ THEN_ALL_NEW CONVERSION Thm.eta_long_conversion
+ THEN_ALL_NEW nat_to_int_tac ctxt
+ THEN_ALL_NEW (core_tac ctxt)
+ THEN_ALL_NEW finish_tac elim
+end;
+
+val method =
+ let
+ fun keyword k = Scan.lift (Args.$$$ k -- Args.colon) >> K ()
+ fun simple_keyword k = Scan.lift (Args.$$$ k) >> K ()
+ val addN = "add"
+ val delN = "del"
+ val elimN = "elim"
+ val any_keyword = keyword addN || keyword delN || simple_keyword elimN
+ val thms = Scan.repeat (Scan.unless any_keyword Attrib.multi_thm) >> flat;
+ in
+ Scan.optional (simple_keyword elimN >> K false) true --
+ Scan.optional (keyword addN |-- thms) [] --
+ Scan.optional (keyword delN |-- thms) [] >>
+ (fn ((elim, add_ths), del_ths) => fn ctxt =>
+ SIMPLE_METHOD' (tac elim add_ths del_ths ctxt))
+ end;
+
+
+(* theory setup *)
+
+local
+
+fun keyword k = Scan.lift (Args.$$$ k -- Args.colon) >> K ();
+
+val constsN = "consts";
+val any_keyword = keyword constsN
+val thms = Scan.repeat (Scan.unless any_keyword Attrib.multi_thm) >> flat;
+val terms = thms >> map (term_of o Drule.dest_term);
+
+fun optional scan = Scan.optional scan [];
+
+in
+
+val setup =
+ Attrib.setup @{binding presburger}
+ ((Scan.lift (Args.$$$ "del") |-- optional (keyword constsN |-- terms)) >> del ||
+ optional (keyword constsN |-- terms) >> add) "data for Cooper's algorithm"
+ #> Arith_Data.add_tactic "Presburger arithmetic" (K (tac true [] []));
+
+end;
+
+end;
--- a/src/HOL/Tools/Qelim/cooper_data.ML Tue May 11 09:10:31 2010 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-(* Title: HOL/Tools/Qelim/cooper_data.ML
- Author: Amine Chaieb, TU Muenchen
-*)
-
-signature COOPER_DATA =
-sig
- type entry
- val get: Proof.context -> entry
- val del: term list -> attribute
- val add: term list -> attribute
- val setup: theory -> theory
-end;
-
-structure CooperData : COOPER_DATA =
-struct
-
-type entry = simpset * (term list);
-
-val allowed_consts =
- [@{term "op + :: int => _"}, @{term "op + :: nat => _"},
- @{term "op - :: int => _"}, @{term "op - :: nat => _"},
- @{term "op * :: int => _"}, @{term "op * :: nat => _"},
- @{term "op div :: int => _"}, @{term "op div :: nat => _"},
- @{term "op mod :: int => _"}, @{term "op mod :: nat => _"},
- @{term "Int.Bit0"}, @{term "Int.Bit1"},
- @{term "op &"}, @{term "op |"}, @{term "op -->"},
- @{term "op = :: int => _"}, @{term "op = :: nat => _"}, @{term "op = :: bool => _"},
- @{term "op < :: int => _"}, @{term "op < :: nat => _"},
- @{term "op <= :: int => _"}, @{term "op <= :: nat => _"},
- @{term "op dvd :: int => _"}, @{term "op dvd :: nat => _"},
- @{term "abs :: int => _"},
- @{term "max :: int => _"}, @{term "max :: nat => _"},
- @{term "min :: int => _"}, @{term "min :: nat => _"},
- @{term "uminus :: int => _"}, (*@ {term "uminus :: nat => _"},*)
- @{term "Not"}, @{term "Suc"},
- @{term "Ex :: (int => _) => _"}, @{term "Ex :: (nat => _) => _"},
- @{term "All :: (int => _) => _"}, @{term "All :: (nat => _) => _"},
- @{term "nat"}, @{term "int"},
- @{term "Int.Bit0"}, @{term "Int.Bit1"},
- @{term "Int.Pls"}, @{term "Int.Min"},
- @{term "Int.number_of :: int => int"}, @{term "Int.number_of :: int => nat"},
- @{term "0::int"}, @{term "1::int"}, @{term "0::nat"}, @{term "1::nat"},
- @{term "True"}, @{term "False"}];
-
-structure Data = Generic_Data
-(
- type T = simpset * term list;
- val empty = (HOL_ss, allowed_consts);
- val extend = I;
- fun merge ((ss1, ts1), (ss2, ts2)) =
- (merge_ss (ss1, ss2), Library.merge (op aconv) (ts1, ts2));
-);
-
-val get = Data.get o Context.Proof;
-
-fun add ts = Thm.declaration_attribute (fn th => fn context =>
- context |> Data.map (fn (ss,ts') =>
- (ss addsimps [th], merge (op aconv) (ts',ts) )))
-
-fun del ts = Thm.declaration_attribute (fn th => fn context =>
- context |> Data.map (fn (ss,ts') =>
- (ss delsimps [th], subtract (op aconv) ts' ts )))
-
-
-(* theory setup *)
-
-local
-
-fun keyword k = Scan.lift (Args.$$$ k -- Args.colon) >> K ();
-
-val constsN = "consts";
-val any_keyword = keyword constsN
-val thms = Scan.repeat (Scan.unless any_keyword Attrib.multi_thm) >> flat;
-val terms = thms >> map (term_of o Drule.dest_term);
-
-fun optional scan = Scan.optional scan [];
-
-in
-
-val setup =
- Attrib.setup @{binding presburger}
- ((Scan.lift (Args.$$$ "del") |-- optional (keyword constsN |-- terms)) >> del ||
- optional (keyword constsN |-- terms) >> add) "Cooper data";
-
-end;
-
-end;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/HOL/Tools/Qelim/cooper_procedure.ML Tue May 11 11:02:56 2010 -0700
@@ -0,0 +1,2274 @@
+(* Generated from Cooper.thy; DO NOT EDIT! *)
+
+structure Cooper_Procedure : sig
+ type 'a eq
+ val eq : 'a eq -> 'a -> 'a -> bool
+ val eqa : 'a eq -> 'a -> 'a -> bool
+ val leta : 'a -> ('a -> 'b) -> 'b
+ val suc : IntInf.int -> IntInf.int
+ datatype num = C of IntInf.int | Bound of IntInf.int |
+ Cn of IntInf.int * IntInf.int * num | Neg of num | Add of num * num |
+ Sub of num * num | Mul of IntInf.int * num
+ datatype fm = T | F | Lt of num | Le of num | Gt of num | Ge of num |
+ Eq of num | NEq of num | Dvd of IntInf.int * num | NDvd of IntInf.int * num
+ | Not of fm | And of fm * fm | Or of fm * fm | Imp of fm * fm |
+ Iff of fm * fm | E of fm | A of fm | Closed of IntInf.int |
+ NClosed of IntInf.int
+ val map : ('a -> 'b) -> 'a list -> 'b list
+ val append : 'a list -> 'a list -> 'a list
+ val disjuncts : fm -> fm list
+ val fm_case :
+ 'a -> 'a -> (num -> 'a) ->
+ (num -> 'a) ->
+ (num -> 'a) ->
+ (num -> 'a) ->
+ (num -> 'a) ->
+ (num -> 'a) ->
+ (IntInf.int -> num -> 'a) ->
+ (IntInf.int -> num -> 'a) ->
+ (fm -> 'a) ->
+ (fm -> fm -> 'a) ->
+ (fm -> fm -> 'a) ->
+ (fm -> fm -> 'a) ->
+(fm -> fm -> 'a) ->
+ (fm -> 'a) ->
+ (fm -> 'a) -> (IntInf.int -> 'a) -> (IntInf.int -> 'a) -> fm -> 'a
+ val eq_num : num -> num -> bool
+ val eq_fm : fm -> fm -> bool
+ val djf : ('a -> fm) -> 'a -> fm -> fm
+ val foldr : ('a -> 'b -> 'b) -> 'a list -> 'b -> 'b
+ val evaldjf : ('a -> fm) -> 'a list -> fm
+ val dj : (fm -> fm) -> fm -> fm
+ val disj : fm -> fm -> fm
+ val minus_nat : IntInf.int -> IntInf.int -> IntInf.int
+ val decrnum : num -> num
+ val decr : fm -> fm
+ val concat_map : ('a -> 'b list) -> 'a list -> 'b list
+ val numsubst0 : num -> num -> num
+ val subst0 : num -> fm -> fm
+ val minusinf : fm -> fm
+ val eq_int : IntInf.int eq
+ val zero_int : IntInf.int
+ type 'a zero
+ val zero : 'a zero -> 'a
+ val zero_inta : IntInf.int zero
+ type 'a times
+ val times : 'a times -> 'a -> 'a -> 'a
+ type 'a no_zero_divisors
+ val times_no_zero_divisors : 'a no_zero_divisors -> 'a times
+ val zero_no_zero_divisors : 'a no_zero_divisors -> 'a zero
+ val times_int : IntInf.int times
+ val no_zero_divisors_int : IntInf.int no_zero_divisors
+ type 'a one
+ val one : 'a one -> 'a
+ type 'a zero_neq_one
+ val one_zero_neq_one : 'a zero_neq_one -> 'a one
+ val zero_zero_neq_one : 'a zero_neq_one -> 'a zero
+ type 'a semigroup_mult
+ val times_semigroup_mult : 'a semigroup_mult -> 'a times
+ type 'a plus
+ val plus : 'a plus -> 'a -> 'a -> 'a
+ type 'a semigroup_add
+ val plus_semigroup_add : 'a semigroup_add -> 'a plus
+ type 'a ab_semigroup_add
+ val semigroup_add_ab_semigroup_add : 'a ab_semigroup_add -> 'a semigroup_add
+ type 'a semiring
+ val ab_semigroup_add_semiring : 'a semiring -> 'a ab_semigroup_add
+ val semigroup_mult_semiring : 'a semiring -> 'a semigroup_mult
+ type 'a mult_zero
+ val times_mult_zero : 'a mult_zero -> 'a times
+ val zero_mult_zero : 'a mult_zero -> 'a zero
+ type 'a monoid_add
+ val semigroup_add_monoid_add : 'a monoid_add -> 'a semigroup_add
+ val zero_monoid_add : 'a monoid_add -> 'a zero
+ type 'a comm_monoid_add
+ val ab_semigroup_add_comm_monoid_add :
+ 'a comm_monoid_add -> 'a ab_semigroup_add
+ val monoid_add_comm_monoid_add : 'a comm_monoid_add -> 'a monoid_add
+ type 'a semiring_0
+ val comm_monoid_add_semiring_0 : 'a semiring_0 -> 'a comm_monoid_add
+ val mult_zero_semiring_0 : 'a semiring_0 -> 'a mult_zero
+ val semiring_semiring_0 : 'a semiring_0 -> 'a semiring
+ type 'a power
+ val one_power : 'a power -> 'a one
+ val times_power : 'a power -> 'a times
+ type 'a monoid_mult
+ val semigroup_mult_monoid_mult : 'a monoid_mult -> 'a semigroup_mult
+ val power_monoid_mult : 'a monoid_mult -> 'a power
+ type 'a semiring_1
+ val monoid_mult_semiring_1 : 'a semiring_1 -> 'a monoid_mult
+ val semiring_0_semiring_1 : 'a semiring_1 -> 'a semiring_0
+ val zero_neq_one_semiring_1 : 'a semiring_1 -> 'a zero_neq_one
+ type 'a cancel_semigroup_add
+ val semigroup_add_cancel_semigroup_add :
+ 'a cancel_semigroup_add -> 'a semigroup_add
+ type 'a cancel_ab_semigroup_add
+ val ab_semigroup_add_cancel_ab_semigroup_add :
+ 'a cancel_ab_semigroup_add -> 'a ab_semigroup_add
+ val cancel_semigroup_add_cancel_ab_semigroup_add :
+ 'a cancel_ab_semigroup_add -> 'a cancel_semigroup_add
+ type 'a cancel_comm_monoid_add
+ val cancel_ab_semigroup_add_cancel_comm_monoid_add :
+ 'a cancel_comm_monoid_add -> 'a cancel_ab_semigroup_add
+ val comm_monoid_add_cancel_comm_monoid_add :
+ 'a cancel_comm_monoid_add -> 'a comm_monoid_add
+ type 'a semiring_0_cancel
+ val cancel_comm_monoid_add_semiring_0_cancel :
+ 'a semiring_0_cancel -> 'a cancel_comm_monoid_add
+ val semiring_0_semiring_0_cancel : 'a semiring_0_cancel -> 'a semiring_0
+ type 'a semiring_1_cancel
+ val semiring_0_cancel_semiring_1_cancel :
+ 'a semiring_1_cancel -> 'a semiring_0_cancel
+ val semiring_1_semiring_1_cancel : 'a semiring_1_cancel -> 'a semiring_1
+ type 'a dvd
+ val times_dvd : 'a dvd -> 'a times
+ type 'a ab_semigroup_mult
+ val semigroup_mult_ab_semigroup_mult :
+ 'a ab_semigroup_mult -> 'a semigroup_mult
+ type 'a comm_semiring
+ val ab_semigroup_mult_comm_semiring : 'a comm_semiring -> 'a ab_semigroup_mult
+ val semiring_comm_semiring : 'a comm_semiring -> 'a semiring
+ type 'a comm_semiring_0
+ val comm_semiring_comm_semiring_0 : 'a comm_semiring_0 -> 'a comm_semiring
+ val semiring_0_comm_semiring_0 : 'a comm_semiring_0 -> 'a semiring_0
+ type 'a comm_monoid_mult
+ val ab_semigroup_mult_comm_monoid_mult :
+ 'a comm_monoid_mult -> 'a ab_semigroup_mult
+ val monoid_mult_comm_monoid_mult : 'a comm_monoid_mult -> 'a monoid_mult
+ type 'a comm_semiring_1
+ val comm_monoid_mult_comm_semiring_1 :
+ 'a comm_semiring_1 -> 'a comm_monoid_mult
+ val comm_semiring_0_comm_semiring_1 : 'a comm_semiring_1 -> 'a comm_semiring_0
+ val dvd_comm_semiring_1 : 'a comm_semiring_1 -> 'a dvd
+ val semiring_1_comm_semiring_1 : 'a comm_semiring_1 -> 'a semiring_1
+ type 'a comm_semiring_0_cancel
+ val comm_semiring_0_comm_semiring_0_cancel :
+ 'a comm_semiring_0_cancel -> 'a comm_semiring_0
+ val semiring_0_cancel_comm_semiring_0_cancel :
+ 'a comm_semiring_0_cancel -> 'a semiring_0_cancel
+ type 'a comm_semiring_1_cancel
+ val comm_semiring_0_cancel_comm_semiring_1_cancel :
+ 'a comm_semiring_1_cancel -> 'a comm_semiring_0_cancel
+ val comm_semiring_1_comm_semiring_1_cancel :
+ 'a comm_semiring_1_cancel -> 'a comm_semiring_1
+ val semiring_1_cancel_comm_semiring_1_cancel :
+ 'a comm_semiring_1_cancel -> 'a semiring_1_cancel
+ type 'a diva
+ val dvd_div : 'a diva -> 'a dvd
+ val diva : 'a diva -> 'a -> 'a -> 'a
+ val moda : 'a diva -> 'a -> 'a -> 'a
+ type 'a semiring_div
+ val div_semiring_div : 'a semiring_div -> 'a diva
+ val comm_semiring_1_cancel_semiring_div :
+ 'a semiring_div -> 'a comm_semiring_1_cancel
+ val no_zero_divisors_semiring_div : 'a semiring_div -> 'a no_zero_divisors
+ val one_int : IntInf.int
+ val one_inta : IntInf.int one
+ val zero_neq_one_int : IntInf.int zero_neq_one
+ val semigroup_mult_int : IntInf.int semigroup_mult
+ val plus_int : IntInf.int plus
+ val semigroup_add_int : IntInf.int semigroup_add
+ val ab_semigroup_add_int : IntInf.int ab_semigroup_add
+ val semiring_int : IntInf.int semiring
+ val mult_zero_int : IntInf.int mult_zero
+ val monoid_add_int : IntInf.int monoid_add
+ val comm_monoid_add_int : IntInf.int comm_monoid_add
+ val semiring_0_int : IntInf.int semiring_0
+ val power_int : IntInf.int power
+ val monoid_mult_int : IntInf.int monoid_mult
+ val semiring_1_int : IntInf.int semiring_1
+ val cancel_semigroup_add_int : IntInf.int cancel_semigroup_add
+ val cancel_ab_semigroup_add_int : IntInf.int cancel_ab_semigroup_add
+ val cancel_comm_monoid_add_int : IntInf.int cancel_comm_monoid_add
+ val semiring_0_cancel_int : IntInf.int semiring_0_cancel
+ val semiring_1_cancel_int : IntInf.int semiring_1_cancel
+ val dvd_int : IntInf.int dvd
+ val ab_semigroup_mult_int : IntInf.int ab_semigroup_mult
+ val comm_semiring_int : IntInf.int comm_semiring
+ val comm_semiring_0_int : IntInf.int comm_semiring_0
+ val comm_monoid_mult_int : IntInf.int comm_monoid_mult
+ val comm_semiring_1_int : IntInf.int comm_semiring_1
+ val comm_semiring_0_cancel_int : IntInf.int comm_semiring_0_cancel
+ val comm_semiring_1_cancel_int : IntInf.int comm_semiring_1_cancel
+ val abs_int : IntInf.int -> IntInf.int
+ val split : ('a -> 'b -> 'c) -> 'a * 'b -> 'c
+ val sgn_int : IntInf.int -> IntInf.int
+ val apsnd : ('a -> 'b) -> 'c * 'a -> 'c * 'b
+ val divmod_int : IntInf.int -> IntInf.int -> IntInf.int * IntInf.int
+ val snd : 'a * 'b -> 'b
+ val mod_int : IntInf.int -> IntInf.int -> IntInf.int
+ val fst : 'a * 'b -> 'a
+ val div_int : IntInf.int -> IntInf.int -> IntInf.int
+ val div_inta : IntInf.int diva
+ val semiring_div_int : IntInf.int semiring_div
+ val dvd : 'a semiring_div * 'a eq -> 'a -> 'a -> bool
+ val num_case :
+ (IntInf.int -> 'a) ->
+ (IntInf.int -> 'a) ->
+ (IntInf.int -> IntInf.int -> num -> 'a) ->
+ (num -> 'a) ->
+ (num -> num -> 'a) ->
+ (num -> num -> 'a) -> (IntInf.int -> num -> 'a) -> num -> 'a
+ val nummul : IntInf.int -> num -> num
+ val numneg : num -> num
+ val numadd : num * num -> num
+ val numsub : num -> num -> num
+ val simpnum : num -> num
+ val nota : fm -> fm
+ val iffa : fm -> fm -> fm
+ val impa : fm -> fm -> fm
+ val conj : fm -> fm -> fm
+ val simpfm : fm -> fm
+ val iupt : IntInf.int -> IntInf.int -> IntInf.int list
+ val mirror : fm -> fm
+ val size_list : 'a list -> IntInf.int
+ val alpha : fm -> num list
+ val beta : fm -> num list
+ val eq_numa : num eq
+ val member : 'a eq -> 'a -> 'a list -> bool
+ val remdups : 'a eq -> 'a list -> 'a list
+ val gcd_int : IntInf.int -> IntInf.int -> IntInf.int
+ val lcm_int : IntInf.int -> IntInf.int -> IntInf.int
+ val delta : fm -> IntInf.int
+ val a_beta : fm -> IntInf.int -> fm
+ val zeta : fm -> IntInf.int
+ val zsplit0 : num -> IntInf.int * num
+ val zlfm : fm -> fm
+ val unita : fm -> fm * (num list * IntInf.int)
+ val cooper : fm -> fm
+ val prep : fm -> fm
+ val qelim : fm -> (fm -> fm) -> fm
+ val pa : fm -> fm
+end = struct
+
+type 'a eq = {eq : 'a -> 'a -> bool};
+val eq = #eq : 'a eq -> 'a -> 'a -> bool;
+
+fun eqa A_ a b = eq A_ a b;
+
+fun leta s f = f s;
+
+fun suc n = IntInf.+ (n, (1 : IntInf.int));
+
+datatype num = C of IntInf.int | Bound of IntInf.int |
+ Cn of IntInf.int * IntInf.int * num | Neg of num | Add of num * num |
+ Sub of num * num | Mul of IntInf.int * num;
+
+datatype fm = T | F | Lt of num | Le of num | Gt of num | Ge of num | Eq of num
+ | NEq of num | Dvd of IntInf.int * num | NDvd of IntInf.int * num | Not of fm
+ | And of fm * fm | Or of fm * fm | Imp of fm * fm | Iff of fm * fm | E of fm |
+ A of fm | Closed of IntInf.int | NClosed of IntInf.int;
+
+fun map f [] = []
+ | map f (x :: xs) = f x :: map f xs;
+
+fun append [] ys = ys
+ | append (x :: xs) ys = x :: append xs ys;
+
+fun disjuncts (Or (p, q)) = append (disjuncts p) (disjuncts q)
+ | disjuncts F = []
+ | disjuncts T = [T]
+ | disjuncts (Lt u) = [Lt u]
+ | disjuncts (Le v) = [Le v]
+ | disjuncts (Gt w) = [Gt w]
+ | disjuncts (Ge x) = [Ge x]
+ | disjuncts (Eq y) = [Eq y]
+ | disjuncts (NEq z) = [NEq z]
+ | disjuncts (Dvd (aa, ab)) = [Dvd (aa, ab)]
+ | disjuncts (NDvd (ac, ad)) = [NDvd (ac, ad)]
+ | disjuncts (Not ae) = [Not ae]
+ | disjuncts (And (af, ag)) = [And (af, ag)]
+ | disjuncts (Imp (aj, ak)) = [Imp (aj, ak)]
+ | disjuncts (Iff (al, am)) = [Iff (al, am)]
+ | disjuncts (E an) = [E an]
+ | disjuncts (A ao) = [A ao]
+ | disjuncts (Closed ap) = [Closed ap]
+ | disjuncts (NClosed aq) = [NClosed aq];
+
+fun fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
+ (NClosed nat) = f19 nat
+ | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
+ (Closed nat) = f18 nat
+ | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
+ (A fm) = f17 fm
+ | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
+ (E fm) = f16 fm
+ | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
+ (Iff (fm1, fm2)) = f15 fm1 fm2
+ | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
+ (Imp (fm1, fm2)) = f14 fm1 fm2
+ | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
+ (Or (fm1, fm2)) = f13 fm1 fm2
+ | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
+ (And (fm1, fm2)) = f12 fm1 fm2
+ | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
+ (Not fm) = f11 fm
+ | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
+ (NDvd (inta, num)) = f10 inta num
+ | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
+ (Dvd (inta, num)) = f9 inta num
+ | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
+ (NEq num) = f8 num
+ | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
+ (Eq num) = f7 num
+ | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
+ (Ge num) = f6 num
+ | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
+ (Gt num) = f5 num
+ | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
+ (Le num) = f4 num
+ | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
+ (Lt num) = f3 num
+ | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19 F
+ = f2
+ | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19 T
+ = f1;
+
+fun eq_num (C intaa) (C inta) = ((intaa : IntInf.int) = inta)
+ | eq_num (Bound nata) (Bound nat) = ((nata : IntInf.int) = nat)
+ | eq_num (Cn (nata, intaa, numa)) (Cn (nat, inta, num)) =
+ ((nata : IntInf.int) = nat) andalso
+ (((intaa : IntInf.int) = inta) andalso eq_num numa num)
+ | eq_num (Neg numa) (Neg num) = eq_num numa num
+ | eq_num (Add (num1a, num2a)) (Add (num1, num2)) =
+ eq_num num1a num1 andalso eq_num num2a num2
+ | eq_num (Sub (num1a, num2a)) (Sub (num1, num2)) =
+ eq_num num1a num1 andalso eq_num num2a num2
+ | eq_num (Mul (intaa, numa)) (Mul (inta, num)) =
+ ((intaa : IntInf.int) = inta) andalso eq_num numa num
+ | eq_num (C inta) (Bound nat) = false
+ | eq_num (Bound nat) (C inta) = false
+ | eq_num (C intaa) (Cn (nat, inta, num)) = false
+ | eq_num (Cn (nat, intaa, num)) (C inta) = false
+ | eq_num (C inta) (Neg num) = false
+ | eq_num (Neg num) (C inta) = false
+ | eq_num (C inta) (Add (num1, num2)) = false
+ | eq_num (Add (num1, num2)) (C inta) = false
+ | eq_num (C inta) (Sub (num1, num2)) = false
+ | eq_num (Sub (num1, num2)) (C inta) = false
+ | eq_num (C intaa) (Mul (inta, num)) = false
+ | eq_num (Mul (intaa, num)) (C inta) = false
+ | eq_num (Bound nata) (Cn (nat, inta, num)) = false
+ | eq_num (Cn (nata, inta, num)) (Bound nat) = false
+ | eq_num (Bound nat) (Neg num) = false
+ | eq_num (Neg num) (Bound nat) = false
+ | eq_num (Bound nat) (Add (num1, num2)) = false
+ | eq_num (Add (num1, num2)) (Bound nat) = false
+ | eq_num (Bound nat) (Sub (num1, num2)) = false
+ | eq_num (Sub (num1, num2)) (Bound nat) = false
+ | eq_num (Bound nat) (Mul (inta, num)) = false
+ | eq_num (Mul (inta, num)) (Bound nat) = false
+ | eq_num (Cn (nat, inta, numa)) (Neg num) = false
+ | eq_num (Neg numa) (Cn (nat, inta, num)) = false
+ | eq_num (Cn (nat, inta, num)) (Add (num1, num2)) = false
+ | eq_num (Add (num1, num2)) (Cn (nat, inta, num)) = false
+ | eq_num (Cn (nat, inta, num)) (Sub (num1, num2)) = false
+ | eq_num (Sub (num1, num2)) (Cn (nat, inta, num)) = false
+ | eq_num (Cn (nat, intaa, numa)) (Mul (inta, num)) = false
+ | eq_num (Mul (intaa, numa)) (Cn (nat, inta, num)) = false
+ | eq_num (Neg num) (Add (num1, num2)) = false
+ | eq_num (Add (num1, num2)) (Neg num) = false
+ | eq_num (Neg num) (Sub (num1, num2)) = false
+ | eq_num (Sub (num1, num2)) (Neg num) = false
+ | eq_num (Neg numa) (Mul (inta, num)) = false
+ | eq_num (Mul (inta, numa)) (Neg num) = false
+ | eq_num (Add (num1a, num2a)) (Sub (num1, num2)) = false
+ | eq_num (Sub (num1a, num2a)) (Add (num1, num2)) = false
+ | eq_num (Add (num1, num2)) (Mul (inta, num)) = false
+ | eq_num (Mul (inta, num)) (Add (num1, num2)) = false
+ | eq_num (Sub (num1, num2)) (Mul (inta, num)) = false
+ | eq_num (Mul (inta, num)) (Sub (num1, num2)) = false;
+
+fun eq_fm T T = true
+ | eq_fm F F = true
+ | eq_fm (Lt numa) (Lt num) = eq_num numa num
+ | eq_fm (Le numa) (Le num) = eq_num numa num
+ | eq_fm (Gt numa) (Gt num) = eq_num numa num
+ | eq_fm (Ge numa) (Ge num) = eq_num numa num
+ | eq_fm (Eq numa) (Eq num) = eq_num numa num
+ | eq_fm (NEq numa) (NEq num) = eq_num numa num
+ | eq_fm (Dvd (intaa, numa)) (Dvd (inta, num)) =
+ ((intaa : IntInf.int) = inta) andalso eq_num numa num
+ | eq_fm (NDvd (intaa, numa)) (NDvd (inta, num)) =
+ ((intaa : IntInf.int) = inta) andalso eq_num numa num
+ | eq_fm (Not fma) (Not fm) = eq_fm fma fm
+ | eq_fm (And (fm1a, fm2a)) (And (fm1, fm2)) =
+ eq_fm fm1a fm1 andalso eq_fm fm2a fm2
+ | eq_fm (Or (fm1a, fm2a)) (Or (fm1, fm2)) =
+ eq_fm fm1a fm1 andalso eq_fm fm2a fm2
+ | eq_fm (Imp (fm1a, fm2a)) (Imp (fm1, fm2)) =
+ eq_fm fm1a fm1 andalso eq_fm fm2a fm2
+ | eq_fm (Iff (fm1a, fm2a)) (Iff (fm1, fm2)) =
+ eq_fm fm1a fm1 andalso eq_fm fm2a fm2
+ | eq_fm (E fma) (E fm) = eq_fm fma fm
+ | eq_fm (A fma) (A fm) = eq_fm fma fm
+ | eq_fm (Closed nata) (Closed nat) = ((nata : IntInf.int) = nat)
+ | eq_fm (NClosed nata) (NClosed nat) = ((nata : IntInf.int) = nat)
+ | eq_fm T F = false
+ | eq_fm F T = false
+ | eq_fm T (Lt num) = false
+ | eq_fm (Lt num) T = false
+ | eq_fm T (Le num) = false
+ | eq_fm (Le num) T = false
+ | eq_fm T (Gt num) = false
+ | eq_fm (Gt num) T = false
+ | eq_fm T (Ge num) = false
+ | eq_fm (Ge num) T = false
+ | eq_fm T (Eq num) = false
+ | eq_fm (Eq num) T = false
+ | eq_fm T (NEq num) = false
+ | eq_fm (NEq num) T = false
+ | eq_fm T (Dvd (inta, num)) = false
+ | eq_fm (Dvd (inta, num)) T = false
+ | eq_fm T (NDvd (inta, num)) = false
+ | eq_fm (NDvd (inta, num)) T = false
+ | eq_fm T (Not fm) = false
+ | eq_fm (Not fm) T = false
+ | eq_fm T (And (fm1, fm2)) = false
+ | eq_fm (And (fm1, fm2)) T = false
+ | eq_fm T (Or (fm1, fm2)) = false
+ | eq_fm (Or (fm1, fm2)) T = false
+ | eq_fm T (Imp (fm1, fm2)) = false
+ | eq_fm (Imp (fm1, fm2)) T = false
+ | eq_fm T (Iff (fm1, fm2)) = false
+ | eq_fm (Iff (fm1, fm2)) T = false
+ | eq_fm T (E fm) = false
+ | eq_fm (E fm) T = false
+ | eq_fm T (A fm) = false
+ | eq_fm (A fm) T = false
+ | eq_fm T (Closed nat) = false
+ | eq_fm (Closed nat) T = false
+ | eq_fm T (NClosed nat) = false
+ | eq_fm (NClosed nat) T = false
+ | eq_fm F (Lt num) = false
+ | eq_fm (Lt num) F = false
+ | eq_fm F (Le num) = false
+ | eq_fm (Le num) F = false
+ | eq_fm F (Gt num) = false
+ | eq_fm (Gt num) F = false
+ | eq_fm F (Ge num) = false
+ | eq_fm (Ge num) F = false
+ | eq_fm F (Eq num) = false
+ | eq_fm (Eq num) F = false
+ | eq_fm F (NEq num) = false
+ | eq_fm (NEq num) F = false
+ | eq_fm F (Dvd (inta, num)) = false
+ | eq_fm (Dvd (inta, num)) F = false
+ | eq_fm F (NDvd (inta, num)) = false
+ | eq_fm (NDvd (inta, num)) F = false
+ | eq_fm F (Not fm) = false
+ | eq_fm (Not fm) F = false
+ | eq_fm F (And (fm1, fm2)) = false
+ | eq_fm (And (fm1, fm2)) F = false
+ | eq_fm F (Or (fm1, fm2)) = false
+ | eq_fm (Or (fm1, fm2)) F = false
+ | eq_fm F (Imp (fm1, fm2)) = false
+ | eq_fm (Imp (fm1, fm2)) F = false
+ | eq_fm F (Iff (fm1, fm2)) = false
+ | eq_fm (Iff (fm1, fm2)) F = false
+ | eq_fm F (E fm) = false
+ | eq_fm (E fm) F = false
+ | eq_fm F (A fm) = false
+ | eq_fm (A fm) F = false
+ | eq_fm F (Closed nat) = false
+ | eq_fm (Closed nat) F = false
+ | eq_fm F (NClosed nat) = false
+ | eq_fm (NClosed nat) F = false
+ | eq_fm (Lt numa) (Le num) = false
+ | eq_fm (Le numa) (Lt num) = false
+ | eq_fm (Lt numa) (Gt num) = false
+ | eq_fm (Gt numa) (Lt num) = false
+ | eq_fm (Lt numa) (Ge num) = false
+ | eq_fm (Ge numa) (Lt num) = false
+ | eq_fm (Lt numa) (Eq num) = false
+ | eq_fm (Eq numa) (Lt num) = false
+ | eq_fm (Lt numa) (NEq num) = false
+ | eq_fm (NEq numa) (Lt num) = false
+ | eq_fm (Lt numa) (Dvd (inta, num)) = false
+ | eq_fm (Dvd (inta, numa)) (Lt num) = false
+ | eq_fm (Lt numa) (NDvd (inta, num)) = false
+ | eq_fm (NDvd (inta, numa)) (Lt num) = false
+ | eq_fm (Lt num) (Not fm) = false
+ | eq_fm (Not fm) (Lt num) = false
+ | eq_fm (Lt num) (And (fm1, fm2)) = false
+ | eq_fm (And (fm1, fm2)) (Lt num) = false
+ | eq_fm (Lt num) (Or (fm1, fm2)) = false
+ | eq_fm (Or (fm1, fm2)) (Lt num) = false
+ | eq_fm (Lt num) (Imp (fm1, fm2)) = false
+ | eq_fm (Imp (fm1, fm2)) (Lt num) = false
+ | eq_fm (Lt num) (Iff (fm1, fm2)) = false
+ | eq_fm (Iff (fm1, fm2)) (Lt num) = false
+ | eq_fm (Lt num) (E fm) = false
+ | eq_fm (E fm) (Lt num) = false
+ | eq_fm (Lt num) (A fm) = false
+ | eq_fm (A fm) (Lt num) = false
+ | eq_fm (Lt num) (Closed nat) = false
+ | eq_fm (Closed nat) (Lt num) = false
+ | eq_fm (Lt num) (NClosed nat) = false
+ | eq_fm (NClosed nat) (Lt num) = false
+ | eq_fm (Le numa) (Gt num) = false
+ | eq_fm (Gt numa) (Le num) = false
+ | eq_fm (Le numa) (Ge num) = false
+ | eq_fm (Ge numa) (Le num) = false
+ | eq_fm (Le numa) (Eq num) = false
+ | eq_fm (Eq numa) (Le num) = false
+ | eq_fm (Le numa) (NEq num) = false
+ | eq_fm (NEq numa) (Le num) = false
+ | eq_fm (Le numa) (Dvd (inta, num)) = false
+ | eq_fm (Dvd (inta, numa)) (Le num) = false
+ | eq_fm (Le numa) (NDvd (inta, num)) = false
+ | eq_fm (NDvd (inta, numa)) (Le num) = false
+ | eq_fm (Le num) (Not fm) = false
+ | eq_fm (Not fm) (Le num) = false
+ | eq_fm (Le num) (And (fm1, fm2)) = false
+ | eq_fm (And (fm1, fm2)) (Le num) = false
+ | eq_fm (Le num) (Or (fm1, fm2)) = false
+ | eq_fm (Or (fm1, fm2)) (Le num) = false
+ | eq_fm (Le num) (Imp (fm1, fm2)) = false
+ | eq_fm (Imp (fm1, fm2)) (Le num) = false
+ | eq_fm (Le num) (Iff (fm1, fm2)) = false
+ | eq_fm (Iff (fm1, fm2)) (Le num) = false
+ | eq_fm (Le num) (E fm) = false
+ | eq_fm (E fm) (Le num) = false
+ | eq_fm (Le num) (A fm) = false
+ | eq_fm (A fm) (Le num) = false
+ | eq_fm (Le num) (Closed nat) = false
+ | eq_fm (Closed nat) (Le num) = false
+ | eq_fm (Le num) (NClosed nat) = false
+ | eq_fm (NClosed nat) (Le num) = false
+ | eq_fm (Gt numa) (Ge num) = false
+ | eq_fm (Ge numa) (Gt num) = false
+ | eq_fm (Gt numa) (Eq num) = false
+ | eq_fm (Eq numa) (Gt num) = false
+ | eq_fm (Gt numa) (NEq num) = false
+ | eq_fm (NEq numa) (Gt num) = false
+ | eq_fm (Gt numa) (Dvd (inta, num)) = false
+ | eq_fm (Dvd (inta, numa)) (Gt num) = false
+ | eq_fm (Gt numa) (NDvd (inta, num)) = false
+ | eq_fm (NDvd (inta, numa)) (Gt num) = false
+ | eq_fm (Gt num) (Not fm) = false
+ | eq_fm (Not fm) (Gt num) = false
+ | eq_fm (Gt num) (And (fm1, fm2)) = false
+ | eq_fm (And (fm1, fm2)) (Gt num) = false
+ | eq_fm (Gt num) (Or (fm1, fm2)) = false
+ | eq_fm (Or (fm1, fm2)) (Gt num) = false
+ | eq_fm (Gt num) (Imp (fm1, fm2)) = false
+ | eq_fm (Imp (fm1, fm2)) (Gt num) = false
+ | eq_fm (Gt num) (Iff (fm1, fm2)) = false
+ | eq_fm (Iff (fm1, fm2)) (Gt num) = false
+ | eq_fm (Gt num) (E fm) = false
+ | eq_fm (E fm) (Gt num) = false
+ | eq_fm (Gt num) (A fm) = false
+ | eq_fm (A fm) (Gt num) = false
+ | eq_fm (Gt num) (Closed nat) = false
+ | eq_fm (Closed nat) (Gt num) = false
+ | eq_fm (Gt num) (NClosed nat) = false
+ | eq_fm (NClosed nat) (Gt num) = false
+ | eq_fm (Ge numa) (Eq num) = false
+ | eq_fm (Eq numa) (Ge num) = false
+ | eq_fm (Ge numa) (NEq num) = false
+ | eq_fm (NEq numa) (Ge num) = false
+ | eq_fm (Ge numa) (Dvd (inta, num)) = false
+ | eq_fm (Dvd (inta, numa)) (Ge num) = false
+ | eq_fm (Ge numa) (NDvd (inta, num)) = false
+ | eq_fm (NDvd (inta, numa)) (Ge num) = false
+ | eq_fm (Ge num) (Not fm) = false
+ | eq_fm (Not fm) (Ge num) = false
+ | eq_fm (Ge num) (And (fm1, fm2)) = false
+ | eq_fm (And (fm1, fm2)) (Ge num) = false
+ | eq_fm (Ge num) (Or (fm1, fm2)) = false
+ | eq_fm (Or (fm1, fm2)) (Ge num) = false
+ | eq_fm (Ge num) (Imp (fm1, fm2)) = false
+ | eq_fm (Imp (fm1, fm2)) (Ge num) = false
+ | eq_fm (Ge num) (Iff (fm1, fm2)) = false
+ | eq_fm (Iff (fm1, fm2)) (Ge num) = false
+ | eq_fm (Ge num) (E fm) = false
+ | eq_fm (E fm) (Ge num) = false
+ | eq_fm (Ge num) (A fm) = false
+ | eq_fm (A fm) (Ge num) = false
+ | eq_fm (Ge num) (Closed nat) = false
+ | eq_fm (Closed nat) (Ge num) = false
+ | eq_fm (Ge num) (NClosed nat) = false
+ | eq_fm (NClosed nat) (Ge num) = false
+ | eq_fm (Eq numa) (NEq num) = false
+ | eq_fm (NEq numa) (Eq num) = false
+ | eq_fm (Eq numa) (Dvd (inta, num)) = false
+ | eq_fm (Dvd (inta, numa)) (Eq num) = false
+ | eq_fm (Eq numa) (NDvd (inta, num)) = false
+ | eq_fm (NDvd (inta, numa)) (Eq num) = false
+ | eq_fm (Eq num) (Not fm) = false
+ | eq_fm (Not fm) (Eq num) = false
+ | eq_fm (Eq num) (And (fm1, fm2)) = false
+ | eq_fm (And (fm1, fm2)) (Eq num) = false
+ | eq_fm (Eq num) (Or (fm1, fm2)) = false
+ | eq_fm (Or (fm1, fm2)) (Eq num) = false
+ | eq_fm (Eq num) (Imp (fm1, fm2)) = false
+ | eq_fm (Imp (fm1, fm2)) (Eq num) = false
+ | eq_fm (Eq num) (Iff (fm1, fm2)) = false
+ | eq_fm (Iff (fm1, fm2)) (Eq num) = false
+ | eq_fm (Eq num) (E fm) = false
+ | eq_fm (E fm) (Eq num) = false
+ | eq_fm (Eq num) (A fm) = false
+ | eq_fm (A fm) (Eq num) = false
+ | eq_fm (Eq num) (Closed nat) = false
+ | eq_fm (Closed nat) (Eq num) = false
+ | eq_fm (Eq num) (NClosed nat) = false
+ | eq_fm (NClosed nat) (Eq num) = false
+ | eq_fm (NEq numa) (Dvd (inta, num)) = false
+ | eq_fm (Dvd (inta, numa)) (NEq num) = false
+ | eq_fm (NEq numa) (NDvd (inta, num)) = false
+ | eq_fm (NDvd (inta, numa)) (NEq num) = false
+ | eq_fm (NEq num) (Not fm) = false
+ | eq_fm (Not fm) (NEq num) = false
+ | eq_fm (NEq num) (And (fm1, fm2)) = false
+ | eq_fm (And (fm1, fm2)) (NEq num) = false
+ | eq_fm (NEq num) (Or (fm1, fm2)) = false
+ | eq_fm (Or (fm1, fm2)) (NEq num) = false
+ | eq_fm (NEq num) (Imp (fm1, fm2)) = false
+ | eq_fm (Imp (fm1, fm2)) (NEq num) = false
+ | eq_fm (NEq num) (Iff (fm1, fm2)) = false
+ | eq_fm (Iff (fm1, fm2)) (NEq num) = false
+ | eq_fm (NEq num) (E fm) = false
+ | eq_fm (E fm) (NEq num) = false
+ | eq_fm (NEq num) (A fm) = false
+ | eq_fm (A fm) (NEq num) = false
+ | eq_fm (NEq num) (Closed nat) = false
+ | eq_fm (Closed nat) (NEq num) = false
+ | eq_fm (NEq num) (NClosed nat) = false
+ | eq_fm (NClosed nat) (NEq num) = false
+ | eq_fm (Dvd (intaa, numa)) (NDvd (inta, num)) = false
+ | eq_fm (NDvd (intaa, numa)) (Dvd (inta, num)) = false
+ | eq_fm (Dvd (inta, num)) (Not fm) = false
+ | eq_fm (Not fm) (Dvd (inta, num)) = false
+ | eq_fm (Dvd (inta, num)) (And (fm1, fm2)) = false
+ | eq_fm (And (fm1, fm2)) (Dvd (inta, num)) = false
+ | eq_fm (Dvd (inta, num)) (Or (fm1, fm2)) = false
+ | eq_fm (Or (fm1, fm2)) (Dvd (inta, num)) = false
+ | eq_fm (Dvd (inta, num)) (Imp (fm1, fm2)) = false
+ | eq_fm (Imp (fm1, fm2)) (Dvd (inta, num)) = false
+ | eq_fm (Dvd (inta, num)) (Iff (fm1, fm2)) = false
+ | eq_fm (Iff (fm1, fm2)) (Dvd (inta, num)) = false
+ | eq_fm (Dvd (inta, num)) (E fm) = false
+ | eq_fm (E fm) (Dvd (inta, num)) = false
+ | eq_fm (Dvd (inta, num)) (A fm) = false
+ | eq_fm (A fm) (Dvd (inta, num)) = false
+ | eq_fm (Dvd (inta, num)) (Closed nat) = false
+ | eq_fm (Closed nat) (Dvd (inta, num)) = false
+ | eq_fm (Dvd (inta, num)) (NClosed nat) = false
+ | eq_fm (NClosed nat) (Dvd (inta, num)) = false
+ | eq_fm (NDvd (inta, num)) (Not fm) = false
+ | eq_fm (Not fm) (NDvd (inta, num)) = false
+ | eq_fm (NDvd (inta, num)) (And (fm1, fm2)) = false
+ | eq_fm (And (fm1, fm2)) (NDvd (inta, num)) = false
+ | eq_fm (NDvd (inta, num)) (Or (fm1, fm2)) = false
+ | eq_fm (Or (fm1, fm2)) (NDvd (inta, num)) = false
+ | eq_fm (NDvd (inta, num)) (Imp (fm1, fm2)) = false
+ | eq_fm (Imp (fm1, fm2)) (NDvd (inta, num)) = false
+ | eq_fm (NDvd (inta, num)) (Iff (fm1, fm2)) = false
+ | eq_fm (Iff (fm1, fm2)) (NDvd (inta, num)) = false
+ | eq_fm (NDvd (inta, num)) (E fm) = false
+ | eq_fm (E fm) (NDvd (inta, num)) = false
+ | eq_fm (NDvd (inta, num)) (A fm) = false
+ | eq_fm (A fm) (NDvd (inta, num)) = false
+ | eq_fm (NDvd (inta, num)) (Closed nat) = false
+ | eq_fm (Closed nat) (NDvd (inta, num)) = false
+ | eq_fm (NDvd (inta, num)) (NClosed nat) = false
+ | eq_fm (NClosed nat) (NDvd (inta, num)) = false
+ | eq_fm (Not fm) (And (fm1, fm2)) = false
+ | eq_fm (And (fm1, fm2)) (Not fm) = false
+ | eq_fm (Not fm) (Or (fm1, fm2)) = false
+ | eq_fm (Or (fm1, fm2)) (Not fm) = false
+ | eq_fm (Not fm) (Imp (fm1, fm2)) = false
+ | eq_fm (Imp (fm1, fm2)) (Not fm) = false
+ | eq_fm (Not fm) (Iff (fm1, fm2)) = false
+ | eq_fm (Iff (fm1, fm2)) (Not fm) = false
+ | eq_fm (Not fma) (E fm) = false
+ | eq_fm (E fma) (Not fm) = false
+ | eq_fm (Not fma) (A fm) = false
+ | eq_fm (A fma) (Not fm) = false
+ | eq_fm (Not fm) (Closed nat) = false
+ | eq_fm (Closed nat) (Not fm) = false
+ | eq_fm (Not fm) (NClosed nat) = false
+ | eq_fm (NClosed nat) (Not fm) = false
+ | eq_fm (And (fm1a, fm2a)) (Or (fm1, fm2)) = false
+ | eq_fm (Or (fm1a, fm2a)) (And (fm1, fm2)) = false
+ | eq_fm (And (fm1a, fm2a)) (Imp (fm1, fm2)) = false
+ | eq_fm (Imp (fm1a, fm2a)) (And (fm1, fm2)) = false
+ | eq_fm (And (fm1a, fm2a)) (Iff (fm1, fm2)) = false
+ | eq_fm (Iff (fm1a, fm2a)) (And (fm1, fm2)) = false
+ | eq_fm (And (fm1, fm2)) (E fm) = false
+ | eq_fm (E fm) (And (fm1, fm2)) = false
+ | eq_fm (And (fm1, fm2)) (A fm) = false
+ | eq_fm (A fm) (And (fm1, fm2)) = false
+ | eq_fm (And (fm1, fm2)) (Closed nat) = false
+ | eq_fm (Closed nat) (And (fm1, fm2)) = false
+ | eq_fm (And (fm1, fm2)) (NClosed nat) = false
+ | eq_fm (NClosed nat) (And (fm1, fm2)) = false
+ | eq_fm (Or (fm1a, fm2a)) (Imp (fm1, fm2)) = false
+ | eq_fm (Imp (fm1a, fm2a)) (Or (fm1, fm2)) = false
+ | eq_fm (Or (fm1a, fm2a)) (Iff (fm1, fm2)) = false
+ | eq_fm (Iff (fm1a, fm2a)) (Or (fm1, fm2)) = false
+ | eq_fm (Or (fm1, fm2)) (E fm) = false
+ | eq_fm (E fm) (Or (fm1, fm2)) = false
+ | eq_fm (Or (fm1, fm2)) (A fm) = false
+ | eq_fm (A fm) (Or (fm1, fm2)) = false
+ | eq_fm (Or (fm1, fm2)) (Closed nat) = false
+ | eq_fm (Closed nat) (Or (fm1, fm2)) = false
+ | eq_fm (Or (fm1, fm2)) (NClosed nat) = false
+ | eq_fm (NClosed nat) (Or (fm1, fm2)) = false
+ | eq_fm (Imp (fm1a, fm2a)) (Iff (fm1, fm2)) = false
+ | eq_fm (Iff (fm1a, fm2a)) (Imp (fm1, fm2)) = false
+ | eq_fm (Imp (fm1, fm2)) (E fm) = false
+ | eq_fm (E fm) (Imp (fm1, fm2)) = false
+ | eq_fm (Imp (fm1, fm2)) (A fm) = false
+ | eq_fm (A fm) (Imp (fm1, fm2)) = false
+ | eq_fm (Imp (fm1, fm2)) (Closed nat) = false
+ | eq_fm (Closed nat) (Imp (fm1, fm2)) = false
+ | eq_fm (Imp (fm1, fm2)) (NClosed nat) = false
+ | eq_fm (NClosed nat) (Imp (fm1, fm2)) = false
+ | eq_fm (Iff (fm1, fm2)) (E fm) = false
+ | eq_fm (E fm) (Iff (fm1, fm2)) = false
+ | eq_fm (Iff (fm1, fm2)) (A fm) = false
+ | eq_fm (A fm) (Iff (fm1, fm2)) = false
+ | eq_fm (Iff (fm1, fm2)) (Closed nat) = false
+ | eq_fm (Closed nat) (Iff (fm1, fm2)) = false
+ | eq_fm (Iff (fm1, fm2)) (NClosed nat) = false
+ | eq_fm (NClosed nat) (Iff (fm1, fm2)) = false
+ | eq_fm (E fma) (A fm) = false
+ | eq_fm (A fma) (E fm) = false
+ | eq_fm (E fm) (Closed nat) = false
+ | eq_fm (Closed nat) (E fm) = false
+ | eq_fm (E fm) (NClosed nat) = false
+ | eq_fm (NClosed nat) (E fm) = false
+ | eq_fm (A fm) (Closed nat) = false
+ | eq_fm (Closed nat) (A fm) = false
+ | eq_fm (A fm) (NClosed nat) = false
+ | eq_fm (NClosed nat) (A fm) = false
+ | eq_fm (Closed nata) (NClosed nat) = false
+ | eq_fm (NClosed nata) (Closed nat) = false;
+
+fun djf f p q =
+ (if eq_fm q T then T
+ else (if eq_fm q F then f p
+ else (case f p of T => T | F => q | Lt _ => Or (f p, q)
+ | Le _ => Or (f p, q) | Gt _ => Or (f p, q)
+ | Ge _ => Or (f p, q) | Eq _ => Or (f p, q)
+ | NEq _ => Or (f p, q) | Dvd (_, _) => Or (f p, q)
+ | NDvd (_, _) => Or (f p, q) | Not _ => Or (f p, q)
+ | And (_, _) => Or (f p, q) | Or (_, _) => Or (f p, q)
+ | Imp (_, _) => Or (f p, q) | Iff (_, _) => Or (f p, q)
+ | E _ => Or (f p, q) | A _ => Or (f p, q)
+ | Closed _ => Or (f p, q) | NClosed _ => Or (f p, q))));
+
+fun foldr f [] a = a
+ | foldr f (x :: xs) a = f x (foldr f xs a);
+
+fun evaldjf f ps = foldr (djf f) ps F;
+
+fun dj f p = evaldjf f (disjuncts p);
+
+fun disj p q =
+ (if eq_fm p T orelse eq_fm q T then T
+ else (if eq_fm p F then q else (if eq_fm q F then p else Or (p, q))));
+
+fun minus_nat n m = IntInf.max (0, (IntInf.- (n, m)));
+
+fun decrnum (Bound n) = Bound (minus_nat n (1 : IntInf.int))
+ | decrnum (Neg a) = Neg (decrnum a)
+ | decrnum (Add (a, b)) = Add (decrnum a, decrnum b)
+ | decrnum (Sub (a, b)) = Sub (decrnum a, decrnum b)
+ | decrnum (Mul (c, a)) = Mul (c, decrnum a)
+ | decrnum (Cn (n, i, a)) = Cn (minus_nat n (1 : IntInf.int), i, decrnum a)
+ | decrnum (C u) = C u;
+
+fun decr (Lt a) = Lt (decrnum a)
+ | decr (Le a) = Le (decrnum a)
+ | decr (Gt a) = Gt (decrnum a)
+ | decr (Ge a) = Ge (decrnum a)
+ | decr (Eq a) = Eq (decrnum a)
+ | decr (NEq a) = NEq (decrnum a)
+ | decr (Dvd (i, a)) = Dvd (i, decrnum a)
+ | decr (NDvd (i, a)) = NDvd (i, decrnum a)
+ | decr (Not p) = Not (decr p)
+ | decr (And (p, q)) = And (decr p, decr q)
+ | decr (Or (p, q)) = Or (decr p, decr q)
+ | decr (Imp (p, q)) = Imp (decr p, decr q)
+ | decr (Iff (p, q)) = Iff (decr p, decr q)
+ | decr T = T
+ | decr F = F
+ | decr (E ao) = E ao
+ | decr (A ap) = A ap
+ | decr (Closed aq) = Closed aq
+ | decr (NClosed ar) = NClosed ar;
+
+fun concat_map f [] = []
+ | concat_map f (x :: xs) = append (f x) (concat_map f xs);
+
+fun numsubst0 t (C c) = C c
+ | numsubst0 t (Bound n) =
+ (if ((n : IntInf.int) = (0 : IntInf.int)) then t else Bound n)
+ | numsubst0 t (Neg a) = Neg (numsubst0 t a)
+ | numsubst0 t (Add (a, b)) = Add (numsubst0 t a, numsubst0 t b)
+ | numsubst0 t (Sub (a, b)) = Sub (numsubst0 t a, numsubst0 t b)
+ | numsubst0 t (Mul (i, a)) = Mul (i, numsubst0 t a)
+ | numsubst0 t (Cn (v, i, a)) =
+ (if ((v : IntInf.int) = (0 : IntInf.int))
+ then Add (Mul (i, t), numsubst0 t a)
+ else Cn (suc (minus_nat v (1 : IntInf.int)), i, numsubst0 t a));
+
+fun subst0 t T = T
+ | subst0 t F = F
+ | subst0 t (Lt a) = Lt (numsubst0 t a)
+ | subst0 t (Le a) = Le (numsubst0 t a)
+ | subst0 t (Gt a) = Gt (numsubst0 t a)
+ | subst0 t (Ge a) = Ge (numsubst0 t a)
+ | subst0 t (Eq a) = Eq (numsubst0 t a)
+ | subst0 t (NEq a) = NEq (numsubst0 t a)
+ | subst0 t (Dvd (i, a)) = Dvd (i, numsubst0 t a)
+ | subst0 t (NDvd (i, a)) = NDvd (i, numsubst0 t a)
+ | subst0 t (Not p) = Not (subst0 t p)
+ | subst0 t (And (p, q)) = And (subst0 t p, subst0 t q)
+ | subst0 t (Or (p, q)) = Or (subst0 t p, subst0 t q)
+ | subst0 t (Imp (p, q)) = Imp (subst0 t p, subst0 t q)
+ | subst0 t (Iff (p, q)) = Iff (subst0 t p, subst0 t q)
+ | subst0 t (Closed p) = Closed p
+ | subst0 t (NClosed p) = NClosed p;
+
+fun minusinf (And (p, q)) = And (minusinf p, minusinf q)
+ | minusinf (Or (p, q)) = Or (minusinf p, minusinf q)
+ | minusinf T = T
+ | minusinf F = F
+ | minusinf (Lt (C bo)) = Lt (C bo)
+ | minusinf (Lt (Bound bp)) = Lt (Bound bp)
+ | minusinf (Lt (Neg bt)) = Lt (Neg bt)
+ | minusinf (Lt (Add (bu, bv))) = Lt (Add (bu, bv))
+ | minusinf (Lt (Sub (bw, bx))) = Lt (Sub (bw, bx))
+ | minusinf (Lt (Mul (by, bz))) = Lt (Mul (by, bz))
+ | minusinf (Le (C co)) = Le (C co)
+ | minusinf (Le (Bound cp)) = Le (Bound cp)
+ | minusinf (Le (Neg ct)) = Le (Neg ct)
+ | minusinf (Le (Add (cu, cv))) = Le (Add (cu, cv))
+ | minusinf (Le (Sub (cw, cx))) = Le (Sub (cw, cx))
+ | minusinf (Le (Mul (cy, cz))) = Le (Mul (cy, cz))
+ | minusinf (Gt (C doa)) = Gt (C doa)
+ | minusinf (Gt (Bound dp)) = Gt (Bound dp)
+ | minusinf (Gt (Neg dt)) = Gt (Neg dt)
+ | minusinf (Gt (Add (du, dv))) = Gt (Add (du, dv))
+ | minusinf (Gt (Sub (dw, dx))) = Gt (Sub (dw, dx))
+ | minusinf (Gt (Mul (dy, dz))) = Gt (Mul (dy, dz))
+ | minusinf (Ge (C eo)) = Ge (C eo)
+ | minusinf (Ge (Bound ep)) = Ge (Bound ep)
+ | minusinf (Ge (Neg et)) = Ge (Neg et)
+ | minusinf (Ge (Add (eu, ev))) = Ge (Add (eu, ev))
+ | minusinf (Ge (Sub (ew, ex))) = Ge (Sub (ew, ex))
+ | minusinf (Ge (Mul (ey, ez))) = Ge (Mul (ey, ez))
+ | minusinf (Eq (C fo)) = Eq (C fo)
+ | minusinf (Eq (Bound fp)) = Eq (Bound fp)
+ | minusinf (Eq (Neg ft)) = Eq (Neg ft)
+ | minusinf (Eq (Add (fu, fv))) = Eq (Add (fu, fv))
+ | minusinf (Eq (Sub (fw, fx))) = Eq (Sub (fw, fx))
+ | minusinf (Eq (Mul (fy, fz))) = Eq (Mul (fy, fz))
+ | minusinf (NEq (C go)) = NEq (C go)
+ | minusinf (NEq (Bound gp)) = NEq (Bound gp)
+ | minusinf (NEq (Neg gt)) = NEq (Neg gt)
+ | minusinf (NEq (Add (gu, gv))) = NEq (Add (gu, gv))
+ | minusinf (NEq (Sub (gw, gx))) = NEq (Sub (gw, gx))
+ | minusinf (NEq (Mul (gy, gz))) = NEq (Mul (gy, gz))
+ | minusinf (Dvd (aa, ab)) = Dvd (aa, ab)
+ | minusinf (NDvd (ac, ad)) = NDvd (ac, ad)
+ | minusinf (Not ae) = Not ae
+ | minusinf (Imp (aj, ak)) = Imp (aj, ak)
+ | minusinf (Iff (al, am)) = Iff (al, am)
+ | minusinf (E an) = E an
+ | minusinf (A ao) = A ao
+ | minusinf (Closed ap) = Closed ap
+ | minusinf (NClosed aq) = NClosed aq
+ | minusinf (Lt (Cn (cm, c, e))) =
+ (if ((cm : IntInf.int) = (0 : IntInf.int)) then T
+ else Lt (Cn (suc (minus_nat cm (1 : IntInf.int)), c, e)))
+ | minusinf (Le (Cn (dm, c, e))) =
+ (if ((dm : IntInf.int) = (0 : IntInf.int)) then T
+ else Le (Cn (suc (minus_nat dm (1 : IntInf.int)), c, e)))
+ | minusinf (Gt (Cn (em, c, e))) =
+ (if ((em : IntInf.int) = (0 : IntInf.int)) then F
+ else Gt (Cn (suc (minus_nat em (1 : IntInf.int)), c, e)))
+ | minusinf (Ge (Cn (fm, c, e))) =
+ (if ((fm : IntInf.int) = (0 : IntInf.int)) then F
+ else Ge (Cn (suc (minus_nat fm (1 : IntInf.int)), c, e)))
+ | minusinf (Eq (Cn (gm, c, e))) =
+ (if ((gm : IntInf.int) = (0 : IntInf.int)) then F
+ else Eq (Cn (suc (minus_nat gm (1 : IntInf.int)), c, e)))
+ | minusinf (NEq (Cn (hm, c, e))) =
+ (if ((hm : IntInf.int) = (0 : IntInf.int)) then T
+ else NEq (Cn (suc (minus_nat hm (1 : IntInf.int)), c, e)));
+
+val eq_int = {eq = (fn a => fn b => ((a : IntInf.int) = b))} : IntInf.int eq;
+
+val zero_int : IntInf.int = (0 : IntInf.int);
+
+type 'a zero = {zero : 'a};
+val zero = #zero : 'a zero -> 'a;
+
+val zero_inta = {zero = zero_int} : IntInf.int zero;
+
+type 'a times = {times : 'a -> 'a -> 'a};
+val times = #times : 'a times -> 'a -> 'a -> 'a;
+
+type 'a no_zero_divisors =
+ {times_no_zero_divisors : 'a times, zero_no_zero_divisors : 'a zero};
+val times_no_zero_divisors = #times_no_zero_divisors :
+ 'a no_zero_divisors -> 'a times;
+val zero_no_zero_divisors = #zero_no_zero_divisors :
+ 'a no_zero_divisors -> 'a zero;
+
+val times_int = {times = (fn a => fn b => IntInf.* (a, b))} : IntInf.int times;
+
+val no_zero_divisors_int =
+ {times_no_zero_divisors = times_int, zero_no_zero_divisors = zero_inta} :
+ IntInf.int no_zero_divisors;
+
+type 'a one = {one : 'a};
+val one = #one : 'a one -> 'a;
+
+type 'a zero_neq_one = {one_zero_neq_one : 'a one, zero_zero_neq_one : 'a zero};
+val one_zero_neq_one = #one_zero_neq_one : 'a zero_neq_one -> 'a one;
+val zero_zero_neq_one = #zero_zero_neq_one : 'a zero_neq_one -> 'a zero;
+
+type 'a semigroup_mult = {times_semigroup_mult : 'a times};
+val times_semigroup_mult = #times_semigroup_mult :
+ 'a semigroup_mult -> 'a times;
+
+type 'a plus = {plus : 'a -> 'a -> 'a};
+val plus = #plus : 'a plus -> 'a -> 'a -> 'a;
+
+type 'a semigroup_add = {plus_semigroup_add : 'a plus};
+val plus_semigroup_add = #plus_semigroup_add : 'a semigroup_add -> 'a plus;
+
+type 'a ab_semigroup_add = {semigroup_add_ab_semigroup_add : 'a semigroup_add};
+val semigroup_add_ab_semigroup_add = #semigroup_add_ab_semigroup_add :
+ 'a ab_semigroup_add -> 'a semigroup_add;
+
+type 'a semiring =
+ {ab_semigroup_add_semiring : 'a ab_semigroup_add,
+ semigroup_mult_semiring : 'a semigroup_mult};
+val ab_semigroup_add_semiring = #ab_semigroup_add_semiring :
+ 'a semiring -> 'a ab_semigroup_add;
+val semigroup_mult_semiring = #semigroup_mult_semiring :
+ 'a semiring -> 'a semigroup_mult;
+
+type 'a mult_zero = {times_mult_zero : 'a times, zero_mult_zero : 'a zero};
+val times_mult_zero = #times_mult_zero : 'a mult_zero -> 'a times;
+val zero_mult_zero = #zero_mult_zero : 'a mult_zero -> 'a zero;
+
+type 'a monoid_add =
+ {semigroup_add_monoid_add : 'a semigroup_add, zero_monoid_add : 'a zero};
+val semigroup_add_monoid_add = #semigroup_add_monoid_add :
+ 'a monoid_add -> 'a semigroup_add;
+val zero_monoid_add = #zero_monoid_add : 'a monoid_add -> 'a zero;
+
+type 'a comm_monoid_add =
+ {ab_semigroup_add_comm_monoid_add : 'a ab_semigroup_add,
+ monoid_add_comm_monoid_add : 'a monoid_add};
+val ab_semigroup_add_comm_monoid_add = #ab_semigroup_add_comm_monoid_add :
+ 'a comm_monoid_add -> 'a ab_semigroup_add;
+val monoid_add_comm_monoid_add = #monoid_add_comm_monoid_add :
+ 'a comm_monoid_add -> 'a monoid_add;
+
+type 'a semiring_0 =
+ {comm_monoid_add_semiring_0 : 'a comm_monoid_add,
+ mult_zero_semiring_0 : 'a mult_zero, semiring_semiring_0 : 'a semiring};
+val comm_monoid_add_semiring_0 = #comm_monoid_add_semiring_0 :
+ 'a semiring_0 -> 'a comm_monoid_add;
+val mult_zero_semiring_0 = #mult_zero_semiring_0 :
+ 'a semiring_0 -> 'a mult_zero;
+val semiring_semiring_0 = #semiring_semiring_0 : 'a semiring_0 -> 'a semiring;
+
+type 'a power = {one_power : 'a one, times_power : 'a times};
+val one_power = #one_power : 'a power -> 'a one;
+val times_power = #times_power : 'a power -> 'a times;
+
+type 'a monoid_mult =
+ {semigroup_mult_monoid_mult : 'a semigroup_mult,
+ power_monoid_mult : 'a power};
+val semigroup_mult_monoid_mult = #semigroup_mult_monoid_mult :
+ 'a monoid_mult -> 'a semigroup_mult;
+val power_monoid_mult = #power_monoid_mult : 'a monoid_mult -> 'a power;
+
+type 'a semiring_1 =
+ {monoid_mult_semiring_1 : 'a monoid_mult,
+ semiring_0_semiring_1 : 'a semiring_0,
+ zero_neq_one_semiring_1 : 'a zero_neq_one};
+val monoid_mult_semiring_1 = #monoid_mult_semiring_1 :
+ 'a semiring_1 -> 'a monoid_mult;
+val semiring_0_semiring_1 = #semiring_0_semiring_1 :
+ 'a semiring_1 -> 'a semiring_0;
+val zero_neq_one_semiring_1 = #zero_neq_one_semiring_1 :
+ 'a semiring_1 -> 'a zero_neq_one;
+
+type 'a cancel_semigroup_add =
+ {semigroup_add_cancel_semigroup_add : 'a semigroup_add};
+val semigroup_add_cancel_semigroup_add = #semigroup_add_cancel_semigroup_add :
+ 'a cancel_semigroup_add -> 'a semigroup_add;
+
+type 'a cancel_ab_semigroup_add =
+ {ab_semigroup_add_cancel_ab_semigroup_add : 'a ab_semigroup_add,
+ cancel_semigroup_add_cancel_ab_semigroup_add : 'a cancel_semigroup_add};
+val ab_semigroup_add_cancel_ab_semigroup_add =
+ #ab_semigroup_add_cancel_ab_semigroup_add :
+ 'a cancel_ab_semigroup_add -> 'a ab_semigroup_add;
+val cancel_semigroup_add_cancel_ab_semigroup_add =
+ #cancel_semigroup_add_cancel_ab_semigroup_add :
+ 'a cancel_ab_semigroup_add -> 'a cancel_semigroup_add;
+
+type 'a cancel_comm_monoid_add =
+ {cancel_ab_semigroup_add_cancel_comm_monoid_add : 'a cancel_ab_semigroup_add,
+ comm_monoid_add_cancel_comm_monoid_add : 'a comm_monoid_add};
+val cancel_ab_semigroup_add_cancel_comm_monoid_add =
+ #cancel_ab_semigroup_add_cancel_comm_monoid_add :
+ 'a cancel_comm_monoid_add -> 'a cancel_ab_semigroup_add;
+val comm_monoid_add_cancel_comm_monoid_add =
+ #comm_monoid_add_cancel_comm_monoid_add :
+ 'a cancel_comm_monoid_add -> 'a comm_monoid_add;
+
+type 'a semiring_0_cancel =
+ {cancel_comm_monoid_add_semiring_0_cancel : 'a cancel_comm_monoid_add,
+ semiring_0_semiring_0_cancel : 'a semiring_0};
+val cancel_comm_monoid_add_semiring_0_cancel =
+ #cancel_comm_monoid_add_semiring_0_cancel :
+ 'a semiring_0_cancel -> 'a cancel_comm_monoid_add;
+val semiring_0_semiring_0_cancel = #semiring_0_semiring_0_cancel :
+ 'a semiring_0_cancel -> 'a semiring_0;
+
+type 'a semiring_1_cancel =
+ {semiring_0_cancel_semiring_1_cancel : 'a semiring_0_cancel,
+ semiring_1_semiring_1_cancel : 'a semiring_1};
+val semiring_0_cancel_semiring_1_cancel = #semiring_0_cancel_semiring_1_cancel :
+ 'a semiring_1_cancel -> 'a semiring_0_cancel;
+val semiring_1_semiring_1_cancel = #semiring_1_semiring_1_cancel :
+ 'a semiring_1_cancel -> 'a semiring_1;
+
+type 'a dvd = {times_dvd : 'a times};
+val times_dvd = #times_dvd : 'a dvd -> 'a times;
+
+type 'a ab_semigroup_mult =
+ {semigroup_mult_ab_semigroup_mult : 'a semigroup_mult};
+val semigroup_mult_ab_semigroup_mult = #semigroup_mult_ab_semigroup_mult :
+ 'a ab_semigroup_mult -> 'a semigroup_mult;
+
+type 'a comm_semiring =
+ {ab_semigroup_mult_comm_semiring : 'a ab_semigroup_mult,
+ semiring_comm_semiring : 'a semiring};
+val ab_semigroup_mult_comm_semiring = #ab_semigroup_mult_comm_semiring :
+ 'a comm_semiring -> 'a ab_semigroup_mult;
+val semiring_comm_semiring = #semiring_comm_semiring :
+ 'a comm_semiring -> 'a semiring;
+
+type 'a comm_semiring_0 =
+ {comm_semiring_comm_semiring_0 : 'a comm_semiring,
+ semiring_0_comm_semiring_0 : 'a semiring_0};
+val comm_semiring_comm_semiring_0 = #comm_semiring_comm_semiring_0 :
+ 'a comm_semiring_0 -> 'a comm_semiring;
+val semiring_0_comm_semiring_0 = #semiring_0_comm_semiring_0 :
+ 'a comm_semiring_0 -> 'a semiring_0;
+
+type 'a comm_monoid_mult =
+ {ab_semigroup_mult_comm_monoid_mult : 'a ab_semigroup_mult,
+ monoid_mult_comm_monoid_mult : 'a monoid_mult};
+val ab_semigroup_mult_comm_monoid_mult = #ab_semigroup_mult_comm_monoid_mult :
+ 'a comm_monoid_mult -> 'a ab_semigroup_mult;
+val monoid_mult_comm_monoid_mult = #monoid_mult_comm_monoid_mult :
+ 'a comm_monoid_mult -> 'a monoid_mult;
+
+type 'a comm_semiring_1 =
+ {comm_monoid_mult_comm_semiring_1 : 'a comm_monoid_mult,
+ comm_semiring_0_comm_semiring_1 : 'a comm_semiring_0,
+ dvd_comm_semiring_1 : 'a dvd, semiring_1_comm_semiring_1 : 'a semiring_1};
+val comm_monoid_mult_comm_semiring_1 = #comm_monoid_mult_comm_semiring_1 :
+ 'a comm_semiring_1 -> 'a comm_monoid_mult;
+val comm_semiring_0_comm_semiring_1 = #comm_semiring_0_comm_semiring_1 :
+ 'a comm_semiring_1 -> 'a comm_semiring_0;
+val dvd_comm_semiring_1 = #dvd_comm_semiring_1 : 'a comm_semiring_1 -> 'a dvd;
+val semiring_1_comm_semiring_1 = #semiring_1_comm_semiring_1 :
+ 'a comm_semiring_1 -> 'a semiring_1;
+
+type 'a comm_semiring_0_cancel =
+ {comm_semiring_0_comm_semiring_0_cancel : 'a comm_semiring_0,
+ semiring_0_cancel_comm_semiring_0_cancel : 'a semiring_0_cancel};
+val comm_semiring_0_comm_semiring_0_cancel =
+ #comm_semiring_0_comm_semiring_0_cancel :
+ 'a comm_semiring_0_cancel -> 'a comm_semiring_0;
+val semiring_0_cancel_comm_semiring_0_cancel =
+ #semiring_0_cancel_comm_semiring_0_cancel :
+ 'a comm_semiring_0_cancel -> 'a semiring_0_cancel;
+
+type 'a comm_semiring_1_cancel =
+ {comm_semiring_0_cancel_comm_semiring_1_cancel : 'a comm_semiring_0_cancel,
+ comm_semiring_1_comm_semiring_1_cancel : 'a comm_semiring_1,
+ semiring_1_cancel_comm_semiring_1_cancel : 'a semiring_1_cancel};
+val comm_semiring_0_cancel_comm_semiring_1_cancel =
+ #comm_semiring_0_cancel_comm_semiring_1_cancel :
+ 'a comm_semiring_1_cancel -> 'a comm_semiring_0_cancel;
+val comm_semiring_1_comm_semiring_1_cancel =
+ #comm_semiring_1_comm_semiring_1_cancel :
+ 'a comm_semiring_1_cancel -> 'a comm_semiring_1;
+val semiring_1_cancel_comm_semiring_1_cancel =
+ #semiring_1_cancel_comm_semiring_1_cancel :
+ 'a comm_semiring_1_cancel -> 'a semiring_1_cancel;
+
+type 'a diva = {dvd_div : 'a dvd, diva : 'a -> 'a -> 'a, moda : 'a -> 'a -> 'a};
+val dvd_div = #dvd_div : 'a diva -> 'a dvd;
+val diva = #diva : 'a diva -> 'a -> 'a -> 'a;
+val moda = #moda : 'a diva -> 'a -> 'a -> 'a;
+
+type 'a semiring_div =
+ {div_semiring_div : 'a diva,
+ comm_semiring_1_cancel_semiring_div : 'a comm_semiring_1_cancel,
+ no_zero_divisors_semiring_div : 'a no_zero_divisors};
+val div_semiring_div = #div_semiring_div : 'a semiring_div -> 'a diva;
+val comm_semiring_1_cancel_semiring_div = #comm_semiring_1_cancel_semiring_div :
+ 'a semiring_div -> 'a comm_semiring_1_cancel;
+val no_zero_divisors_semiring_div = #no_zero_divisors_semiring_div :
+ 'a semiring_div -> 'a no_zero_divisors;
+
+val one_int : IntInf.int = (1 : IntInf.int);
+
+val one_inta = {one = one_int} : IntInf.int one;
+
+val zero_neq_one_int =
+ {one_zero_neq_one = one_inta, zero_zero_neq_one = zero_inta} :
+ IntInf.int zero_neq_one;
+
+val semigroup_mult_int = {times_semigroup_mult = times_int} :
+ IntInf.int semigroup_mult;
+
+val plus_int = {plus = (fn a => fn b => IntInf.+ (a, b))} : IntInf.int plus;
+
+val semigroup_add_int = {plus_semigroup_add = plus_int} :
+ IntInf.int semigroup_add;
+
+val ab_semigroup_add_int = {semigroup_add_ab_semigroup_add = semigroup_add_int}
+ : IntInf.int ab_semigroup_add;
+
+val semiring_int =
+ {ab_semigroup_add_semiring = ab_semigroup_add_int,
+ semigroup_mult_semiring = semigroup_mult_int}
+ : IntInf.int semiring;
+
+val mult_zero_int = {times_mult_zero = times_int, zero_mult_zero = zero_inta} :
+ IntInf.int mult_zero;
+
+val monoid_add_int =
+ {semigroup_add_monoid_add = semigroup_add_int, zero_monoid_add = zero_inta} :
+ IntInf.int monoid_add;
+
+val comm_monoid_add_int =
+ {ab_semigroup_add_comm_monoid_add = ab_semigroup_add_int,
+ monoid_add_comm_monoid_add = monoid_add_int}
+ : IntInf.int comm_monoid_add;
+
+val semiring_0_int =
+ {comm_monoid_add_semiring_0 = comm_monoid_add_int,
+ mult_zero_semiring_0 = mult_zero_int, semiring_semiring_0 = semiring_int}
+ : IntInf.int semiring_0;
+
+val power_int = {one_power = one_inta, times_power = times_int} :
+ IntInf.int power;
+
+val monoid_mult_int =
+ {semigroup_mult_monoid_mult = semigroup_mult_int,
+ power_monoid_mult = power_int}
+ : IntInf.int monoid_mult;
+
+val semiring_1_int =
+ {monoid_mult_semiring_1 = monoid_mult_int,
+ semiring_0_semiring_1 = semiring_0_int,
+ zero_neq_one_semiring_1 = zero_neq_one_int}
+ : IntInf.int semiring_1;
+
+val cancel_semigroup_add_int =
+ {semigroup_add_cancel_semigroup_add = semigroup_add_int} :
+ IntInf.int cancel_semigroup_add;
+
+val cancel_ab_semigroup_add_int =
+ {ab_semigroup_add_cancel_ab_semigroup_add = ab_semigroup_add_int,
+ cancel_semigroup_add_cancel_ab_semigroup_add = cancel_semigroup_add_int}
+ : IntInf.int cancel_ab_semigroup_add;
+
+val cancel_comm_monoid_add_int =
+ {cancel_ab_semigroup_add_cancel_comm_monoid_add = cancel_ab_semigroup_add_int,
+ comm_monoid_add_cancel_comm_monoid_add = comm_monoid_add_int}
+ : IntInf.int cancel_comm_monoid_add;
+
+val semiring_0_cancel_int =
+ {cancel_comm_monoid_add_semiring_0_cancel = cancel_comm_monoid_add_int,
+ semiring_0_semiring_0_cancel = semiring_0_int}
+ : IntInf.int semiring_0_cancel;
+
+val semiring_1_cancel_int =
+ {semiring_0_cancel_semiring_1_cancel = semiring_0_cancel_int,
+ semiring_1_semiring_1_cancel = semiring_1_int}
+ : IntInf.int semiring_1_cancel;
+
+val dvd_int = {times_dvd = times_int} : IntInf.int dvd;
+
+val ab_semigroup_mult_int =
+ {semigroup_mult_ab_semigroup_mult = semigroup_mult_int} :
+ IntInf.int ab_semigroup_mult;
+
+val comm_semiring_int =
+ {ab_semigroup_mult_comm_semiring = ab_semigroup_mult_int,
+ semiring_comm_semiring = semiring_int}
+ : IntInf.int comm_semiring;
+
+val comm_semiring_0_int =
+ {comm_semiring_comm_semiring_0 = comm_semiring_int,
+ semiring_0_comm_semiring_0 = semiring_0_int}
+ : IntInf.int comm_semiring_0;
+
+val comm_monoid_mult_int =
+ {ab_semigroup_mult_comm_monoid_mult = ab_semigroup_mult_int,
+ monoid_mult_comm_monoid_mult = monoid_mult_int}
+ : IntInf.int comm_monoid_mult;
+
+val comm_semiring_1_int =
+ {comm_monoid_mult_comm_semiring_1 = comm_monoid_mult_int,
+ comm_semiring_0_comm_semiring_1 = comm_semiring_0_int,
+ dvd_comm_semiring_1 = dvd_int, semiring_1_comm_semiring_1 = semiring_1_int}
+ : IntInf.int comm_semiring_1;
+
+val comm_semiring_0_cancel_int =
+ {comm_semiring_0_comm_semiring_0_cancel = comm_semiring_0_int,
+ semiring_0_cancel_comm_semiring_0_cancel = semiring_0_cancel_int}
+ : IntInf.int comm_semiring_0_cancel;
+
+val comm_semiring_1_cancel_int =
+ {comm_semiring_0_cancel_comm_semiring_1_cancel = comm_semiring_0_cancel_int,
+ comm_semiring_1_comm_semiring_1_cancel = comm_semiring_1_int,
+ semiring_1_cancel_comm_semiring_1_cancel = semiring_1_cancel_int}
+ : IntInf.int comm_semiring_1_cancel;
+
+fun abs_int i = (if IntInf.< (i, (0 : IntInf.int)) then IntInf.~ i else i);
+
+fun split f (a, b) = f a b;
+
+fun sgn_int i =
+ (if ((i : IntInf.int) = (0 : IntInf.int)) then (0 : IntInf.int)
+ else (if IntInf.< ((0 : IntInf.int), i) then (1 : IntInf.int)
+ else IntInf.~ (1 : IntInf.int)));
+
+fun apsnd f (x, y) = (x, f y);
+
+fun divmod_int k l =
+ (if ((k : IntInf.int) = (0 : IntInf.int))
+ then ((0 : IntInf.int), (0 : IntInf.int))
+ else (if ((l : IntInf.int) = (0 : IntInf.int)) then ((0 : IntInf.int), k)
+ else apsnd (fn a => IntInf.* (sgn_int l, a))
+ (if (((sgn_int k) : IntInf.int) = (sgn_int l))
+ then IntInf.divMod (IntInf.abs k, IntInf.abs l)
+ else let
+ val (r, s) =
+ IntInf.divMod (IntInf.abs k, IntInf.abs l);
+ in
+ (if ((s : IntInf.int) = (0 : IntInf.int))
+ then (IntInf.~ r, (0 : IntInf.int))
+ else (IntInf.- (IntInf.~ r, (1 : IntInf.int)),
+ IntInf.- (abs_int l, s)))
+ end)));
+
+fun snd (a, b) = b;
+
+fun mod_int a b = snd (divmod_int a b);
+
+fun fst (a, b) = a;
+
+fun div_int a b = fst (divmod_int a b);
+
+val div_inta = {dvd_div = dvd_int, diva = div_int, moda = mod_int} :
+ IntInf.int diva;
+
+val semiring_div_int =
+ {div_semiring_div = div_inta,
+ comm_semiring_1_cancel_semiring_div = comm_semiring_1_cancel_int,
+ no_zero_divisors_semiring_div = no_zero_divisors_int}
+ : IntInf.int semiring_div;
+
+fun dvd (A1_, A2_) a b =
+ eqa A2_ (moda (div_semiring_div A1_) b a)
+ (zero ((zero_no_zero_divisors o no_zero_divisors_semiring_div) A1_));
+
+fun num_case f1 f2 f3 f4 f5 f6 f7 (Mul (inta, num)) = f7 inta num
+ | num_case f1 f2 f3 f4 f5 f6 f7 (Sub (num1, num2)) = f6 num1 num2
+ | num_case f1 f2 f3 f4 f5 f6 f7 (Add (num1, num2)) = f5 num1 num2
+ | num_case f1 f2 f3 f4 f5 f6 f7 (Neg num) = f4 num
+ | num_case f1 f2 f3 f4 f5 f6 f7 (Cn (nat, inta, num)) = f3 nat inta num
+ | num_case f1 f2 f3 f4 f5 f6 f7 (Bound nat) = f2 nat
+ | num_case f1 f2 f3 f4 f5 f6 f7 (C inta) = f1 inta;
+
+fun nummul i (C j) = C (IntInf.* (i, j))
+ | nummul i (Cn (n, c, t)) = Cn (n, IntInf.* (c, i), nummul i t)
+ | nummul i (Bound v) = Mul (i, Bound v)
+ | nummul i (Neg v) = Mul (i, Neg v)
+ | nummul i (Add (v, va)) = Mul (i, Add (v, va))
+ | nummul i (Sub (v, va)) = Mul (i, Sub (v, va))
+ | nummul i (Mul (v, va)) = Mul (i, Mul (v, va));
+
+fun numneg t = nummul (IntInf.~ (1 : IntInf.int)) t;
+
+fun numadd (Cn (n1, c1, r1), Cn (n2, c2, r2)) =
+ (if ((n1 : IntInf.int) = n2)
+ then let
+ val c = IntInf.+ (c1, c2);
+ in
+ (if ((c : IntInf.int) = (0 : IntInf.int)) then numadd (r1, r2)
+ else Cn (n1, c, numadd (r1, r2)))
+ end
+ else (if IntInf.<= (n1, n2)
+ then Cn (n1, c1, numadd (r1, Add (Mul (c2, Bound n2), r2)))
+ else Cn (n2, c2, numadd (Add (Mul (c1, Bound n1), r1), r2))))
+ | numadd (Cn (n1, c1, r1), C dd) = Cn (n1, c1, numadd (r1, C dd))
+ | numadd (Cn (n1, c1, r1), Bound de) = Cn (n1, c1, numadd (r1, Bound de))
+ | numadd (Cn (n1, c1, r1), Neg di) = Cn (n1, c1, numadd (r1, Neg di))
+ | numadd (Cn (n1, c1, r1), Add (dj, dk)) =
+ Cn (n1, c1, numadd (r1, Add (dj, dk)))
+ | numadd (Cn (n1, c1, r1), Sub (dl, dm)) =
+ Cn (n1, c1, numadd (r1, Sub (dl, dm)))
+ | numadd (Cn (n1, c1, r1), Mul (dn, doa)) =
+ Cn (n1, c1, numadd (r1, Mul (dn, doa)))
+ | numadd (C w, Cn (n2, c2, r2)) = Cn (n2, c2, numadd (C w, r2))
+ | numadd (Bound x, Cn (n2, c2, r2)) = Cn (n2, c2, numadd (Bound x, r2))
+ | numadd (Neg ac, Cn (n2, c2, r2)) = Cn (n2, c2, numadd (Neg ac, r2))
+ | numadd (Add (ad, ae), Cn (n2, c2, r2)) =
+ Cn (n2, c2, numadd (Add (ad, ae), r2))
+ | numadd (Sub (af, ag), Cn (n2, c2, r2)) =
+ Cn (n2, c2, numadd (Sub (af, ag), r2))
+ | numadd (Mul (ah, ai), Cn (n2, c2, r2)) =
+ Cn (n2, c2, numadd (Mul (ah, ai), r2))
+ | numadd (C b1, C b2) = C (IntInf.+ (b1, b2))
+ | numadd (C aj, Bound bi) = Add (C aj, Bound bi)
+ | numadd (C aj, Neg bm) = Add (C aj, Neg bm)
+ | numadd (C aj, Add (bn, bo)) = Add (C aj, Add (bn, bo))
+ | numadd (C aj, Sub (bp, bq)) = Add (C aj, Sub (bp, bq))
+ | numadd (C aj, Mul (br, bs)) = Add (C aj, Mul (br, bs))
+ | numadd (Bound ak, C cf) = Add (Bound ak, C cf)
+ | numadd (Bound ak, Bound cg) = Add (Bound ak, Bound cg)
+ | numadd (Bound ak, Neg ck) = Add (Bound ak, Neg ck)
+ | numadd (Bound ak, Add (cl, cm)) = Add (Bound ak, Add (cl, cm))
+ | numadd (Bound ak, Sub (cn, co)) = Add (Bound ak, Sub (cn, co))
+ | numadd (Bound ak, Mul (cp, cq)) = Add (Bound ak, Mul (cp, cq))
+ | numadd (Neg ao, C en) = Add (Neg ao, C en)
+ | numadd (Neg ao, Bound eo) = Add (Neg ao, Bound eo)
+ | numadd (Neg ao, Neg es) = Add (Neg ao, Neg es)
+ | numadd (Neg ao, Add (et, eu)) = Add (Neg ao, Add (et, eu))
+ | numadd (Neg ao, Sub (ev, ew)) = Add (Neg ao, Sub (ev, ew))
+ | numadd (Neg ao, Mul (ex, ey)) = Add (Neg ao, Mul (ex, ey))
+ | numadd (Add (ap, aq), C fl) = Add (Add (ap, aq), C fl)
+ | numadd (Add (ap, aq), Bound fm) = Add (Add (ap, aq), Bound fm)
+ | numadd (Add (ap, aq), Neg fq) = Add (Add (ap, aq), Neg fq)
+ | numadd (Add (ap, aq), Add (fr, fs)) = Add (Add (ap, aq), Add (fr, fs))
+ | numadd (Add (ap, aq), Sub (ft, fu)) = Add (Add (ap, aq), Sub (ft, fu))
+ | numadd (Add (ap, aq), Mul (fv, fw)) = Add (Add (ap, aq), Mul (fv, fw))
+ | numadd (Sub (ar, asa), C gj) = Add (Sub (ar, asa), C gj)
+ | numadd (Sub (ar, asa), Bound gk) = Add (Sub (ar, asa), Bound gk)
+ | numadd (Sub (ar, asa), Neg go) = Add (Sub (ar, asa), Neg go)
+ | numadd (Sub (ar, asa), Add (gp, gq)) = Add (Sub (ar, asa), Add (gp, gq))
+ | numadd (Sub (ar, asa), Sub (gr, gs)) = Add (Sub (ar, asa), Sub (gr, gs))
+ | numadd (Sub (ar, asa), Mul (gt, gu)) = Add (Sub (ar, asa), Mul (gt, gu))
+ | numadd (Mul (at, au), C hh) = Add (Mul (at, au), C hh)
+ | numadd (Mul (at, au), Bound hi) = Add (Mul (at, au), Bound hi)
+ | numadd (Mul (at, au), Neg hm) = Add (Mul (at, au), Neg hm)
+ | numadd (Mul (at, au), Add (hn, ho)) = Add (Mul (at, au), Add (hn, ho))
+ | numadd (Mul (at, au), Sub (hp, hq)) = Add (Mul (at, au), Sub (hp, hq))
+ | numadd (Mul (at, au), Mul (hr, hs)) = Add (Mul (at, au), Mul (hr, hs));
+
+fun numsub s t =
+ (if eq_num s t then C (0 : IntInf.int) else numadd (s, numneg t));
+
+fun simpnum (C j) = C j
+ | simpnum (Bound n) = Cn (n, (1 : IntInf.int), C (0 : IntInf.int))
+ | simpnum (Neg t) = numneg (simpnum t)
+ | simpnum (Add (t, s)) = numadd (simpnum t, simpnum s)
+ | simpnum (Sub (t, s)) = numsub (simpnum t) (simpnum s)
+ | simpnum (Mul (i, t)) =
+ (if ((i : IntInf.int) = (0 : IntInf.int)) then C (0 : IntInf.int)
+ else nummul i (simpnum t))
+ | simpnum (Cn (v, va, vb)) = Cn (v, va, vb);
+
+fun nota (Not p) = p
+ | nota T = F
+ | nota F = T
+ | nota (Lt v) = Not (Lt v)
+ | nota (Le v) = Not (Le v)
+ | nota (Gt v) = Not (Gt v)
+ | nota (Ge v) = Not (Ge v)
+ | nota (Eq v) = Not (Eq v)
+ | nota (NEq v) = Not (NEq v)
+ | nota (Dvd (v, va)) = Not (Dvd (v, va))
+ | nota (NDvd (v, va)) = Not (NDvd (v, va))
+ | nota (And (v, va)) = Not (And (v, va))
+ | nota (Or (v, va)) = Not (Or (v, va))
+ | nota (Imp (v, va)) = Not (Imp (v, va))
+ | nota (Iff (v, va)) = Not (Iff (v, va))
+ | nota (E v) = Not (E v)
+ | nota (A v) = Not (A v)
+ | nota (Closed v) = Not (Closed v)
+ | nota (NClosed v) = Not (NClosed v);
+
+fun iffa p q =
+ (if eq_fm p q then T
+ else (if eq_fm p (nota q) orelse eq_fm (nota p) q then F
+ else (if eq_fm p F then nota q
+ else (if eq_fm q F then nota p
+ else (if eq_fm p T then q
+ else (if eq_fm q T then p else Iff (p, q)))))));
+
+fun impa p q =
+ (if eq_fm p F orelse eq_fm q T then T
+ else (if eq_fm p T then q else (if eq_fm q F then nota p else Imp (p, q))));
+
+fun conj p q =
+ (if eq_fm p F orelse eq_fm q F then F
+ else (if eq_fm p T then q else (if eq_fm q T then p else And (p, q))));
+
+fun simpfm (And (p, q)) = conj (simpfm p) (simpfm q)
+ | simpfm (Or (p, q)) = disj (simpfm p) (simpfm q)
+ | simpfm (Imp (p, q)) = impa (simpfm p) (simpfm q)
+ | simpfm (Iff (p, q)) = iffa (simpfm p) (simpfm q)
+ | simpfm (Not p) = nota (simpfm p)
+ | simpfm (Lt a) =
+ let
+ val aa = simpnum a;
+ in
+ (case aa of C v => (if IntInf.< (v, (0 : IntInf.int)) then T else F)
+ | Bound _ => Lt aa | Cn (_, _, _) => Lt aa | Neg _ => Lt aa
+ | Add (_, _) => Lt aa | Sub (_, _) => Lt aa | Mul (_, _) => Lt aa)
+ end
+ | simpfm (Le a) =
+ let
+ val aa = simpnum a;
+ in
+ (case aa of C v => (if IntInf.<= (v, (0 : IntInf.int)) then T else F)
+ | Bound _ => Le aa | Cn (_, _, _) => Le aa | Neg _ => Le aa
+ | Add (_, _) => Le aa | Sub (_, _) => Le aa | Mul (_, _) => Le aa)
+ end
+ | simpfm (Gt a) =
+ let
+ val aa = simpnum a;
+ in
+ (case aa of C v => (if IntInf.< ((0 : IntInf.int), v) then T else F)
+ | Bound _ => Gt aa | Cn (_, _, _) => Gt aa | Neg _ => Gt aa
+ | Add (_, _) => Gt aa | Sub (_, _) => Gt aa | Mul (_, _) => Gt aa)
+ end
+ | simpfm (Ge a) =
+ let
+ val aa = simpnum a;
+ in
+ (case aa of C v => (if IntInf.<= ((0 : IntInf.int), v) then T else F)
+ | Bound _ => Ge aa | Cn (_, _, _) => Ge aa | Neg _ => Ge aa
+ | Add (_, _) => Ge aa | Sub (_, _) => Ge aa | Mul (_, _) => Ge aa)
+ end
+ | simpfm (Eq a) =
+ let
+ val aa = simpnum a;
+ in
+ (case aa
+ of C v => (if ((v : IntInf.int) = (0 : IntInf.int)) then T else F)
+ | Bound _ => Eq aa | Cn (_, _, _) => Eq aa | Neg _ => Eq aa
+ | Add (_, _) => Eq aa | Sub (_, _) => Eq aa | Mul (_, _) => Eq aa)
+ end
+ | simpfm (NEq a) =
+ let
+ val aa = simpnum a;
+ in
+ (case aa
+ of C v => (if not ((v : IntInf.int) = (0 : IntInf.int)) then T else F)
+ | Bound _ => NEq aa | Cn (_, _, _) => NEq aa | Neg _ => NEq aa
+ | Add (_, _) => NEq aa | Sub (_, _) => NEq aa | Mul (_, _) => NEq aa)
+ end
+ | simpfm (Dvd (i, a)) =
+ (if ((i : IntInf.int) = (0 : IntInf.int)) then simpfm (Eq a)
+ else (if (((abs_int i) : IntInf.int) = (1 : IntInf.int)) then T
+ else let
+ val aa = simpnum a;
+ in
+ (case aa
+ of C v =>
+ (if dvd (semiring_div_int, eq_int) i v then T else F)
+ | Bound _ => Dvd (i, aa) | Cn (_, _, _) => Dvd (i, aa)
+ | Neg _ => Dvd (i, aa) | Add (_, _) => Dvd (i, aa)
+ | Sub (_, _) => Dvd (i, aa) | Mul (_, _) => Dvd (i, aa))
+ end))
+ | simpfm (NDvd (i, a)) =
+ (if ((i : IntInf.int) = (0 : IntInf.int)) then simpfm (NEq a)
+ else (if (((abs_int i) : IntInf.int) = (1 : IntInf.int)) then F
+ else let
+ val aa = simpnum a;
+ in
+ (case aa
+ of C v =>
+ (if not (dvd (semiring_div_int, eq_int) i v) then T
+ else F)
+ | Bound _ => NDvd (i, aa) | Cn (_, _, _) => NDvd (i, aa)
+ | Neg _ => NDvd (i, aa) | Add (_, _) => NDvd (i, aa)
+ | Sub (_, _) => NDvd (i, aa) | Mul (_, _) => NDvd (i, aa))
+ end))
+ | simpfm T = T
+ | simpfm F = F
+ | simpfm (E v) = E v
+ | simpfm (A v) = A v
+ | simpfm (Closed v) = Closed v
+ | simpfm (NClosed v) = NClosed v;
+
+fun iupt i j =
+ (if IntInf.< (j, i) then []
+ else i :: iupt (IntInf.+ (i, (1 : IntInf.int))) j);
+
+fun mirror (And (p, q)) = And (mirror p, mirror q)
+ | mirror (Or (p, q)) = Or (mirror p, mirror q)
+ | mirror T = T
+ | mirror F = F
+ | mirror (Lt (C bo)) = Lt (C bo)
+ | mirror (Lt (Bound bp)) = Lt (Bound bp)
+ | mirror (Lt (Neg bt)) = Lt (Neg bt)
+ | mirror (Lt (Add (bu, bv))) = Lt (Add (bu, bv))
+ | mirror (Lt (Sub (bw, bx))) = Lt (Sub (bw, bx))
+ | mirror (Lt (Mul (by, bz))) = Lt (Mul (by, bz))
+ | mirror (Le (C co)) = Le (C co)
+ | mirror (Le (Bound cp)) = Le (Bound cp)
+ | mirror (Le (Neg ct)) = Le (Neg ct)
+ | mirror (Le (Add (cu, cv))) = Le (Add (cu, cv))
+ | mirror (Le (Sub (cw, cx))) = Le (Sub (cw, cx))
+ | mirror (Le (Mul (cy, cz))) = Le (Mul (cy, cz))
+ | mirror (Gt (C doa)) = Gt (C doa)
+ | mirror (Gt (Bound dp)) = Gt (Bound dp)
+ | mirror (Gt (Neg dt)) = Gt (Neg dt)
+ | mirror (Gt (Add (du, dv))) = Gt (Add (du, dv))
+ | mirror (Gt (Sub (dw, dx))) = Gt (Sub (dw, dx))
+ | mirror (Gt (Mul (dy, dz))) = Gt (Mul (dy, dz))
+ | mirror (Ge (C eo)) = Ge (C eo)
+ | mirror (Ge (Bound ep)) = Ge (Bound ep)
+ | mirror (Ge (Neg et)) = Ge (Neg et)
+ | mirror (Ge (Add (eu, ev))) = Ge (Add (eu, ev))
+ | mirror (Ge (Sub (ew, ex))) = Ge (Sub (ew, ex))
+ | mirror (Ge (Mul (ey, ez))) = Ge (Mul (ey, ez))
+ | mirror (Eq (C fo)) = Eq (C fo)
+ | mirror (Eq (Bound fp)) = Eq (Bound fp)
+ | mirror (Eq (Neg ft)) = Eq (Neg ft)
+ | mirror (Eq (Add (fu, fv))) = Eq (Add (fu, fv))
+ | mirror (Eq (Sub (fw, fx))) = Eq (Sub (fw, fx))
+ | mirror (Eq (Mul (fy, fz))) = Eq (Mul (fy, fz))
+ | mirror (NEq (C go)) = NEq (C go)
+ | mirror (NEq (Bound gp)) = NEq (Bound gp)
+ | mirror (NEq (Neg gt)) = NEq (Neg gt)
+ | mirror (NEq (Add (gu, gv))) = NEq (Add (gu, gv))
+ | mirror (NEq (Sub (gw, gx))) = NEq (Sub (gw, gx))
+ | mirror (NEq (Mul (gy, gz))) = NEq (Mul (gy, gz))
+ | mirror (Dvd (aa, C ho)) = Dvd (aa, C ho)
+ | mirror (Dvd (aa, Bound hp)) = Dvd (aa, Bound hp)
+ | mirror (Dvd (aa, Neg ht)) = Dvd (aa, Neg ht)
+ | mirror (Dvd (aa, Add (hu, hv))) = Dvd (aa, Add (hu, hv))
+ | mirror (Dvd (aa, Sub (hw, hx))) = Dvd (aa, Sub (hw, hx))
+ | mirror (Dvd (aa, Mul (hy, hz))) = Dvd (aa, Mul (hy, hz))
+ | mirror (NDvd (ac, C io)) = NDvd (ac, C io)
+ | mirror (NDvd (ac, Bound ip)) = NDvd (ac, Bound ip)
+ | mirror (NDvd (ac, Neg it)) = NDvd (ac, Neg it)
+ | mirror (NDvd (ac, Add (iu, iv))) = NDvd (ac, Add (iu, iv))
+ | mirror (NDvd (ac, Sub (iw, ix))) = NDvd (ac, Sub (iw, ix))
+ | mirror (NDvd (ac, Mul (iy, iz))) = NDvd (ac, Mul (iy, iz))
+ | mirror (Not ae) = Not ae
+ | mirror (Imp (aj, ak)) = Imp (aj, ak)
+ | mirror (Iff (al, am)) = Iff (al, am)
+ | mirror (E an) = E an
+ | mirror (A ao) = A ao
+ | mirror (Closed ap) = Closed ap
+ | mirror (NClosed aq) = NClosed aq
+ | mirror (Lt (Cn (cm, c, e))) =
+ (if ((cm : IntInf.int) = (0 : IntInf.int))
+ then Gt (Cn ((0 : IntInf.int), c, Neg e))
+ else Lt (Cn (suc (minus_nat cm (1 : IntInf.int)), c, e)))
+ | mirror (Le (Cn (dm, c, e))) =
+ (if ((dm : IntInf.int) = (0 : IntInf.int))
+ then Ge (Cn ((0 : IntInf.int), c, Neg e))
+ else Le (Cn (suc (minus_nat dm (1 : IntInf.int)), c, e)))
+ | mirror (Gt (Cn (em, c, e))) =
+ (if ((em : IntInf.int) = (0 : IntInf.int))
+ then Lt (Cn ((0 : IntInf.int), c, Neg e))
+ else Gt (Cn (suc (minus_nat em (1 : IntInf.int)), c, e)))
+ | mirror (Ge (Cn (fm, c, e))) =
+ (if ((fm : IntInf.int) = (0 : IntInf.int))
+ then Le (Cn ((0 : IntInf.int), c, Neg e))
+ else Ge (Cn (suc (minus_nat fm (1 : IntInf.int)), c, e)))
+ | mirror (Eq (Cn (gm, c, e))) =
+ (if ((gm : IntInf.int) = (0 : IntInf.int))
+ then Eq (Cn ((0 : IntInf.int), c, Neg e))
+ else Eq (Cn (suc (minus_nat gm (1 : IntInf.int)), c, e)))
+ | mirror (NEq (Cn (hm, c, e))) =
+ (if ((hm : IntInf.int) = (0 : IntInf.int))
+ then NEq (Cn ((0 : IntInf.int), c, Neg e))
+ else NEq (Cn (suc (minus_nat hm (1 : IntInf.int)), c, e)))
+ | mirror (Dvd (i, Cn (im, c, e))) =
+ (if ((im : IntInf.int) = (0 : IntInf.int))
+ then Dvd (i, Cn ((0 : IntInf.int), c, Neg e))
+ else Dvd (i, Cn (suc (minus_nat im (1 : IntInf.int)), c, e)))
+ | mirror (NDvd (i, Cn (jm, c, e))) =
+ (if ((jm : IntInf.int) = (0 : IntInf.int))
+ then NDvd (i, Cn ((0 : IntInf.int), c, Neg e))
+ else NDvd (i, Cn (suc (minus_nat jm (1 : IntInf.int)), c, e)));
+
+fun size_list [] = (0 : IntInf.int)
+ | size_list (a :: lista) = IntInf.+ (size_list lista, suc (0 : IntInf.int));
+
+fun alpha (And (p, q)) = append (alpha p) (alpha q)
+ | alpha (Or (p, q)) = append (alpha p) (alpha q)
+ | alpha T = []
+ | alpha F = []
+ | alpha (Lt (C bo)) = []
+ | alpha (Lt (Bound bp)) = []
+ | alpha (Lt (Neg bt)) = []
+ | alpha (Lt (Add (bu, bv))) = []
+ | alpha (Lt (Sub (bw, bx))) = []
+ | alpha (Lt (Mul (by, bz))) = []
+ | alpha (Le (C co)) = []
+ | alpha (Le (Bound cp)) = []
+ | alpha (Le (Neg ct)) = []
+ | alpha (Le (Add (cu, cv))) = []
+ | alpha (Le (Sub (cw, cx))) = []
+ | alpha (Le (Mul (cy, cz))) = []
+ | alpha (Gt (C doa)) = []
+ | alpha (Gt (Bound dp)) = []
+ | alpha (Gt (Neg dt)) = []
+ | alpha (Gt (Add (du, dv))) = []
+ | alpha (Gt (Sub (dw, dx))) = []
+ | alpha (Gt (Mul (dy, dz))) = []
+ | alpha (Ge (C eo)) = []
+ | alpha (Ge (Bound ep)) = []
+ | alpha (Ge (Neg et)) = []
+ | alpha (Ge (Add (eu, ev))) = []
+ | alpha (Ge (Sub (ew, ex))) = []
+ | alpha (Ge (Mul (ey, ez))) = []
+ | alpha (Eq (C fo)) = []
+ | alpha (Eq (Bound fp)) = []
+ | alpha (Eq (Neg ft)) = []
+ | alpha (Eq (Add (fu, fv))) = []
+ | alpha (Eq (Sub (fw, fx))) = []
+ | alpha (Eq (Mul (fy, fz))) = []
+ | alpha (NEq (C go)) = []
+ | alpha (NEq (Bound gp)) = []
+ | alpha (NEq (Neg gt)) = []
+ | alpha (NEq (Add (gu, gv))) = []
+ | alpha (NEq (Sub (gw, gx))) = []
+ | alpha (NEq (Mul (gy, gz))) = []
+ | alpha (Dvd (aa, ab)) = []
+ | alpha (NDvd (ac, ad)) = []
+ | alpha (Not ae) = []
+ | alpha (Imp (aj, ak)) = []
+ | alpha (Iff (al, am)) = []
+ | alpha (E an) = []
+ | alpha (A ao) = []
+ | alpha (Closed ap) = []
+ | alpha (NClosed aq) = []
+ | alpha (Lt (Cn (cm, c, e))) =
+ (if ((cm : IntInf.int) = (0 : IntInf.int)) then [e] else [])
+ | alpha (Le (Cn (dm, c, e))) =
+ (if ((dm : IntInf.int) = (0 : IntInf.int))
+ then [Add (C (~1 : IntInf.int), e)] else [])
+ | alpha (Gt (Cn (em, c, e))) =
+ (if ((em : IntInf.int) = (0 : IntInf.int)) then [] else [])
+ | alpha (Ge (Cn (fm, c, e))) =
+ (if ((fm : IntInf.int) = (0 : IntInf.int)) then [] else [])
+ | alpha (Eq (Cn (gm, c, e))) =
+ (if ((gm : IntInf.int) = (0 : IntInf.int))
+ then [Add (C (~1 : IntInf.int), e)] else [])
+ | alpha (NEq (Cn (hm, c, e))) =
+ (if ((hm : IntInf.int) = (0 : IntInf.int)) then [e] else []);
+
+fun beta (And (p, q)) = append (beta p) (beta q)
+ | beta (Or (p, q)) = append (beta p) (beta q)
+ | beta T = []
+ | beta F = []
+ | beta (Lt (C bo)) = []
+ | beta (Lt (Bound bp)) = []
+ | beta (Lt (Neg bt)) = []
+ | beta (Lt (Add (bu, bv))) = []
+ | beta (Lt (Sub (bw, bx))) = []
+ | beta (Lt (Mul (by, bz))) = []
+ | beta (Le (C co)) = []
+ | beta (Le (Bound cp)) = []
+ | beta (Le (Neg ct)) = []
+ | beta (Le (Add (cu, cv))) = []
+ | beta (Le (Sub (cw, cx))) = []
+ | beta (Le (Mul (cy, cz))) = []
+ | beta (Gt (C doa)) = []
+ | beta (Gt (Bound dp)) = []
+ | beta (Gt (Neg dt)) = []
+ | beta (Gt (Add (du, dv))) = []
+ | beta (Gt (Sub (dw, dx))) = []
+ | beta (Gt (Mul (dy, dz))) = []
+ | beta (Ge (C eo)) = []
+ | beta (Ge (Bound ep)) = []
+ | beta (Ge (Neg et)) = []
+ | beta (Ge (Add (eu, ev))) = []
+ | beta (Ge (Sub (ew, ex))) = []
+ | beta (Ge (Mul (ey, ez))) = []
+ | beta (Eq (C fo)) = []
+ | beta (Eq (Bound fp)) = []
+ | beta (Eq (Neg ft)) = []
+ | beta (Eq (Add (fu, fv))) = []
+ | beta (Eq (Sub (fw, fx))) = []
+ | beta (Eq (Mul (fy, fz))) = []
+ | beta (NEq (C go)) = []
+ | beta (NEq (Bound gp)) = []
+ | beta (NEq (Neg gt)) = []
+ | beta (NEq (Add (gu, gv))) = []
+ | beta (NEq (Sub (gw, gx))) = []
+ | beta (NEq (Mul (gy, gz))) = []
+ | beta (Dvd (aa, ab)) = []
+ | beta (NDvd (ac, ad)) = []
+ | beta (Not ae) = []
+ | beta (Imp (aj, ak)) = []
+ | beta (Iff (al, am)) = []
+ | beta (E an) = []
+ | beta (A ao) = []
+ | beta (Closed ap) = []
+ | beta (NClosed aq) = []
+ | beta (Lt (Cn (cm, c, e))) =
+ (if ((cm : IntInf.int) = (0 : IntInf.int)) then [] else [])
+ | beta (Le (Cn (dm, c, e))) =
+ (if ((dm : IntInf.int) = (0 : IntInf.int)) then [] else [])
+ | beta (Gt (Cn (em, c, e))) =
+ (if ((em : IntInf.int) = (0 : IntInf.int)) then [Neg e] else [])
+ | beta (Ge (Cn (fm, c, e))) =
+ (if ((fm : IntInf.int) = (0 : IntInf.int))
+ then [Sub (C (~1 : IntInf.int), e)] else [])
+ | beta (Eq (Cn (gm, c, e))) =
+ (if ((gm : IntInf.int) = (0 : IntInf.int))
+ then [Sub (C (~1 : IntInf.int), e)] else [])
+ | beta (NEq (Cn (hm, c, e))) =
+ (if ((hm : IntInf.int) = (0 : IntInf.int)) then [Neg e] else []);
+
+val eq_numa = {eq = eq_num} : num eq;
+
+fun member A_ x [] = false
+ | member A_ x (y :: ys) = eqa A_ x y orelse member A_ x ys;
+
+fun remdups A_ [] = []
+ | remdups A_ (x :: xs) =
+ (if member A_ x xs then remdups A_ xs else x :: remdups A_ xs);
+
+fun gcd_int k l =
+ abs_int
+ (if ((l : IntInf.int) = (0 : IntInf.int)) then k
+ else gcd_int l (mod_int (abs_int k) (abs_int l)));
+
+fun lcm_int a b = div_int (IntInf.* (abs_int a, abs_int b)) (gcd_int a b);
+
+fun delta (And (p, q)) = lcm_int (delta p) (delta q)
+ | delta (Or (p, q)) = lcm_int (delta p) (delta q)
+ | delta T = (1 : IntInf.int)
+ | delta F = (1 : IntInf.int)
+ | delta (Lt u) = (1 : IntInf.int)
+ | delta (Le v) = (1 : IntInf.int)
+ | delta (Gt w) = (1 : IntInf.int)
+ | delta (Ge x) = (1 : IntInf.int)
+ | delta (Eq y) = (1 : IntInf.int)
+ | delta (NEq z) = (1 : IntInf.int)
+ | delta (Dvd (aa, C bo)) = (1 : IntInf.int)
+ | delta (Dvd (aa, Bound bp)) = (1 : IntInf.int)
+ | delta (Dvd (aa, Neg bt)) = (1 : IntInf.int)
+ | delta (Dvd (aa, Add (bu, bv))) = (1 : IntInf.int)
+ | delta (Dvd (aa, Sub (bw, bx))) = (1 : IntInf.int)
+ | delta (Dvd (aa, Mul (by, bz))) = (1 : IntInf.int)
+ | delta (NDvd (ac, C co)) = (1 : IntInf.int)
+ | delta (NDvd (ac, Bound cp)) = (1 : IntInf.int)
+ | delta (NDvd (ac, Neg ct)) = (1 : IntInf.int)
+ | delta (NDvd (ac, Add (cu, cv))) = (1 : IntInf.int)
+ | delta (NDvd (ac, Sub (cw, cx))) = (1 : IntInf.int)
+ | delta (NDvd (ac, Mul (cy, cz))) = (1 : IntInf.int)
+ | delta (Not ae) = (1 : IntInf.int)
+ | delta (Imp (aj, ak)) = (1 : IntInf.int)
+ | delta (Iff (al, am)) = (1 : IntInf.int)
+ | delta (E an) = (1 : IntInf.int)
+ | delta (A ao) = (1 : IntInf.int)
+ | delta (Closed ap) = (1 : IntInf.int)
+ | delta (NClosed aq) = (1 : IntInf.int)
+ | delta (Dvd (i, Cn (cm, c, e))) =
+ (if ((cm : IntInf.int) = (0 : IntInf.int)) then i else (1 : IntInf.int))
+ | delta (NDvd (i, Cn (dm, c, e))) =
+ (if ((dm : IntInf.int) = (0 : IntInf.int)) then i else (1 : IntInf.int));
+
+fun a_beta (And (p, q)) = (fn k => And (a_beta p k, a_beta q k))
+ | a_beta (Or (p, q)) = (fn k => Or (a_beta p k, a_beta q k))
+ | a_beta T = (fn _ => T)
+ | a_beta F = (fn _ => F)
+ | a_beta (Lt (C bo)) = (fn _ => Lt (C bo))
+ | a_beta (Lt (Bound bp)) = (fn _ => Lt (Bound bp))
+ | a_beta (Lt (Neg bt)) = (fn _ => Lt (Neg bt))
+ | a_beta (Lt (Add (bu, bv))) = (fn _ => Lt (Add (bu, bv)))
+ | a_beta (Lt (Sub (bw, bx))) = (fn _ => Lt (Sub (bw, bx)))
+ | a_beta (Lt (Mul (by, bz))) = (fn _ => Lt (Mul (by, bz)))
+ | a_beta (Le (C co)) = (fn _ => Le (C co))
+ | a_beta (Le (Bound cp)) = (fn _ => Le (Bound cp))
+ | a_beta (Le (Neg ct)) = (fn _ => Le (Neg ct))
+ | a_beta (Le (Add (cu, cv))) = (fn _ => Le (Add (cu, cv)))
+ | a_beta (Le (Sub (cw, cx))) = (fn _ => Le (Sub (cw, cx)))
+ | a_beta (Le (Mul (cy, cz))) = (fn _ => Le (Mul (cy, cz)))
+ | a_beta (Gt (C doa)) = (fn _ => Gt (C doa))
+ | a_beta (Gt (Bound dp)) = (fn _ => Gt (Bound dp))
+ | a_beta (Gt (Neg dt)) = (fn _ => Gt (Neg dt))
+ | a_beta (Gt (Add (du, dv))) = (fn _ => Gt (Add (du, dv)))
+ | a_beta (Gt (Sub (dw, dx))) = (fn _ => Gt (Sub (dw, dx)))
+ | a_beta (Gt (Mul (dy, dz))) = (fn _ => Gt (Mul (dy, dz)))
+ | a_beta (Ge (C eo)) = (fn _ => Ge (C eo))
+ | a_beta (Ge (Bound ep)) = (fn _ => Ge (Bound ep))
+ | a_beta (Ge (Neg et)) = (fn _ => Ge (Neg et))
+ | a_beta (Ge (Add (eu, ev))) = (fn _ => Ge (Add (eu, ev)))
+ | a_beta (Ge (Sub (ew, ex))) = (fn _ => Ge (Sub (ew, ex)))
+ | a_beta (Ge (Mul (ey, ez))) = (fn _ => Ge (Mul (ey, ez)))
+ | a_beta (Eq (C fo)) = (fn _ => Eq (C fo))
+ | a_beta (Eq (Bound fp)) = (fn _ => Eq (Bound fp))
+ | a_beta (Eq (Neg ft)) = (fn _ => Eq (Neg ft))
+ | a_beta (Eq (Add (fu, fv))) = (fn _ => Eq (Add (fu, fv)))
+ | a_beta (Eq (Sub (fw, fx))) = (fn _ => Eq (Sub (fw, fx)))
+ | a_beta (Eq (Mul (fy, fz))) = (fn _ => Eq (Mul (fy, fz)))
+ | a_beta (NEq (C go)) = (fn _ => NEq (C go))
+ | a_beta (NEq (Bound gp)) = (fn _ => NEq (Bound gp))
+ | a_beta (NEq (Neg gt)) = (fn _ => NEq (Neg gt))
+ | a_beta (NEq (Add (gu, gv))) = (fn _ => NEq (Add (gu, gv)))
+ | a_beta (NEq (Sub (gw, gx))) = (fn _ => NEq (Sub (gw, gx)))
+ | a_beta (NEq (Mul (gy, gz))) = (fn _ => NEq (Mul (gy, gz)))
+ | a_beta (Dvd (aa, C ho)) = (fn _ => Dvd (aa, C ho))
+ | a_beta (Dvd (aa, Bound hp)) = (fn _ => Dvd (aa, Bound hp))
+ | a_beta (Dvd (aa, Neg ht)) = (fn _ => Dvd (aa, Neg ht))
+ | a_beta (Dvd (aa, Add (hu, hv))) = (fn _ => Dvd (aa, Add (hu, hv)))
+ | a_beta (Dvd (aa, Sub (hw, hx))) = (fn _ => Dvd (aa, Sub (hw, hx)))
+ | a_beta (Dvd (aa, Mul (hy, hz))) = (fn _ => Dvd (aa, Mul (hy, hz)))
+ | a_beta (NDvd (ac, C io)) = (fn _ => NDvd (ac, C io))
+ | a_beta (NDvd (ac, Bound ip)) = (fn _ => NDvd (ac, Bound ip))
+ | a_beta (NDvd (ac, Neg it)) = (fn _ => NDvd (ac, Neg it))
+ | a_beta (NDvd (ac, Add (iu, iv))) = (fn _ => NDvd (ac, Add (iu, iv)))
+ | a_beta (NDvd (ac, Sub (iw, ix))) = (fn _ => NDvd (ac, Sub (iw, ix)))
+ | a_beta (NDvd (ac, Mul (iy, iz))) = (fn _ => NDvd (ac, Mul (iy, iz)))
+ | a_beta (Not ae) = (fn _ => Not ae)
+ | a_beta (Imp (aj, ak)) = (fn _ => Imp (aj, ak))
+ | a_beta (Iff (al, am)) = (fn _ => Iff (al, am))
+ | a_beta (E an) = (fn _ => E an)
+ | a_beta (A ao) = (fn _ => A ao)
+ | a_beta (Closed ap) = (fn _ => Closed ap)
+ | a_beta (NClosed aq) = (fn _ => NClosed aq)
+ | a_beta (Lt (Cn (cm, c, e))) =
+ (if ((cm : IntInf.int) = (0 : IntInf.int))
+ then (fn k =>
+ Lt (Cn ((0 : IntInf.int), (1 : IntInf.int), Mul (div_int k c, e))))
+ else (fn _ => Lt (Cn (suc (minus_nat cm (1 : IntInf.int)), c, e))))
+ | a_beta (Le (Cn (dm, c, e))) =
+ (if ((dm : IntInf.int) = (0 : IntInf.int))
+ then (fn k =>
+ Le (Cn ((0 : IntInf.int), (1 : IntInf.int), Mul (div_int k c, e))))
+ else (fn _ => Le (Cn (suc (minus_nat dm (1 : IntInf.int)), c, e))))
+ | a_beta (Gt (Cn (em, c, e))) =
+ (if ((em : IntInf.int) = (0 : IntInf.int))
+ then (fn k =>
+ Gt (Cn ((0 : IntInf.int), (1 : IntInf.int), Mul (div_int k c, e))))
+ else (fn _ => Gt (Cn (suc (minus_nat em (1 : IntInf.int)), c, e))))
+ | a_beta (Ge (Cn (fm, c, e))) =
+ (if ((fm : IntInf.int) = (0 : IntInf.int))
+ then (fn k =>
+ Ge (Cn ((0 : IntInf.int), (1 : IntInf.int), Mul (div_int k c, e))))
+ else (fn _ => Ge (Cn (suc (minus_nat fm (1 : IntInf.int)), c, e))))
+ | a_beta (Eq (Cn (gm, c, e))) =
+ (if ((gm : IntInf.int) = (0 : IntInf.int))
+ then (fn k =>
+ Eq (Cn ((0 : IntInf.int), (1 : IntInf.int), Mul (div_int k c, e))))
+ else (fn _ => Eq (Cn (suc (minus_nat gm (1 : IntInf.int)), c, e))))
+ | a_beta (NEq (Cn (hm, c, e))) =
+ (if ((hm : IntInf.int) = (0 : IntInf.int))
+ then (fn k =>
+ NEq (Cn ((0 : IntInf.int), (1 : IntInf.int),
+ Mul (div_int k c, e))))
+ else (fn _ => NEq (Cn (suc (minus_nat hm (1 : IntInf.int)), c, e))))
+ | a_beta (Dvd (i, Cn (im, c, e))) =
+ (if ((im : IntInf.int) = (0 : IntInf.int))
+ then (fn k =>
+ Dvd (IntInf.* (div_int k c, i),
+ Cn ((0 : IntInf.int), (1 : IntInf.int),
+ Mul (div_int k c, e))))
+ else (fn _ => Dvd (i, Cn (suc (minus_nat im (1 : IntInf.int)), c, e))))
+ | a_beta (NDvd (i, Cn (jm, c, e))) =
+ (if ((jm : IntInf.int) = (0 : IntInf.int))
+ then (fn k =>
+ NDvd (IntInf.* (div_int k c, i),
+ Cn ((0 : IntInf.int), (1 : IntInf.int),
+ Mul (div_int k c, e))))
+ else (fn _ => NDvd (i, Cn (suc (minus_nat jm (1 : IntInf.int)), c, e))));
+
+fun zeta (And (p, q)) = lcm_int (zeta p) (zeta q)
+ | zeta (Or (p, q)) = lcm_int (zeta p) (zeta q)
+ | zeta T = (1 : IntInf.int)
+ | zeta F = (1 : IntInf.int)
+ | zeta (Lt (C bo)) = (1 : IntInf.int)
+ | zeta (Lt (Bound bp)) = (1 : IntInf.int)
+ | zeta (Lt (Neg bt)) = (1 : IntInf.int)
+ | zeta (Lt (Add (bu, bv))) = (1 : IntInf.int)
+ | zeta (Lt (Sub (bw, bx))) = (1 : IntInf.int)
+ | zeta (Lt (Mul (by, bz))) = (1 : IntInf.int)
+ | zeta (Le (C co)) = (1 : IntInf.int)
+ | zeta (Le (Bound cp)) = (1 : IntInf.int)
+ | zeta (Le (Neg ct)) = (1 : IntInf.int)
+ | zeta (Le (Add (cu, cv))) = (1 : IntInf.int)
+ | zeta (Le (Sub (cw, cx))) = (1 : IntInf.int)
+ | zeta (Le (Mul (cy, cz))) = (1 : IntInf.int)
+ | zeta (Gt (C doa)) = (1 : IntInf.int)
+ | zeta (Gt (Bound dp)) = (1 : IntInf.int)
+ | zeta (Gt (Neg dt)) = (1 : IntInf.int)
+ | zeta (Gt (Add (du, dv))) = (1 : IntInf.int)
+ | zeta (Gt (Sub (dw, dx))) = (1 : IntInf.int)
+ | zeta (Gt (Mul (dy, dz))) = (1 : IntInf.int)
+ | zeta (Ge (C eo)) = (1 : IntInf.int)
+ | zeta (Ge (Bound ep)) = (1 : IntInf.int)
+ | zeta (Ge (Neg et)) = (1 : IntInf.int)
+ | zeta (Ge (Add (eu, ev))) = (1 : IntInf.int)
+ | zeta (Ge (Sub (ew, ex))) = (1 : IntInf.int)
+ | zeta (Ge (Mul (ey, ez))) = (1 : IntInf.int)
+ | zeta (Eq (C fo)) = (1 : IntInf.int)
+ | zeta (Eq (Bound fp)) = (1 : IntInf.int)
+ | zeta (Eq (Neg ft)) = (1 : IntInf.int)
+ | zeta (Eq (Add (fu, fv))) = (1 : IntInf.int)
+ | zeta (Eq (Sub (fw, fx))) = (1 : IntInf.int)
+ | zeta (Eq (Mul (fy, fz))) = (1 : IntInf.int)
+ | zeta (NEq (C go)) = (1 : IntInf.int)
+ | zeta (NEq (Bound gp)) = (1 : IntInf.int)
+ | zeta (NEq (Neg gt)) = (1 : IntInf.int)
+ | zeta (NEq (Add (gu, gv))) = (1 : IntInf.int)
+ | zeta (NEq (Sub (gw, gx))) = (1 : IntInf.int)
+ | zeta (NEq (Mul (gy, gz))) = (1 : IntInf.int)
+ | zeta (Dvd (aa, C ho)) = (1 : IntInf.int)
+ | zeta (Dvd (aa, Bound hp)) = (1 : IntInf.int)
+ | zeta (Dvd (aa, Neg ht)) = (1 : IntInf.int)
+ | zeta (Dvd (aa, Add (hu, hv))) = (1 : IntInf.int)
+ | zeta (Dvd (aa, Sub (hw, hx))) = (1 : IntInf.int)
+ | zeta (Dvd (aa, Mul (hy, hz))) = (1 : IntInf.int)
+ | zeta (NDvd (ac, C io)) = (1 : IntInf.int)
+ | zeta (NDvd (ac, Bound ip)) = (1 : IntInf.int)
+ | zeta (NDvd (ac, Neg it)) = (1 : IntInf.int)
+ | zeta (NDvd (ac, Add (iu, iv))) = (1 : IntInf.int)
+ | zeta (NDvd (ac, Sub (iw, ix))) = (1 : IntInf.int)
+ | zeta (NDvd (ac, Mul (iy, iz))) = (1 : IntInf.int)
+ | zeta (Not ae) = (1 : IntInf.int)
+ | zeta (Imp (aj, ak)) = (1 : IntInf.int)
+ | zeta (Iff (al, am)) = (1 : IntInf.int)
+ | zeta (E an) = (1 : IntInf.int)
+ | zeta (A ao) = (1 : IntInf.int)
+ | zeta (Closed ap) = (1 : IntInf.int)
+ | zeta (NClosed aq) = (1 : IntInf.int)
+ | zeta (Lt (Cn (cm, c, e))) =
+ (if ((cm : IntInf.int) = (0 : IntInf.int)) then c else (1 : IntInf.int))
+ | zeta (Le (Cn (dm, c, e))) =
+ (if ((dm : IntInf.int) = (0 : IntInf.int)) then c else (1 : IntInf.int))
+ | zeta (Gt (Cn (em, c, e))) =
+ (if ((em : IntInf.int) = (0 : IntInf.int)) then c else (1 : IntInf.int))
+ | zeta (Ge (Cn (fm, c, e))) =
+ (if ((fm : IntInf.int) = (0 : IntInf.int)) then c else (1 : IntInf.int))
+ | zeta (Eq (Cn (gm, c, e))) =
+ (if ((gm : IntInf.int) = (0 : IntInf.int)) then c else (1 : IntInf.int))
+ | zeta (NEq (Cn (hm, c, e))) =
+ (if ((hm : IntInf.int) = (0 : IntInf.int)) then c else (1 : IntInf.int))
+ | zeta (Dvd (i, Cn (im, c, e))) =
+ (if ((im : IntInf.int) = (0 : IntInf.int)) then c else (1 : IntInf.int))
+ | zeta (NDvd (i, Cn (jm, c, e))) =
+ (if ((jm : IntInf.int) = (0 : IntInf.int)) then c else (1 : IntInf.int));
+
+fun zsplit0 (C c) = ((0 : IntInf.int), C c)
+ | zsplit0 (Bound n) =
+ (if ((n : IntInf.int) = (0 : IntInf.int))
+ then ((1 : IntInf.int), C (0 : IntInf.int))
+ else ((0 : IntInf.int), Bound n))
+ | zsplit0 (Cn (n, i, a)) =
+ let
+ val (ia, aa) = zsplit0 a;
+ in
+ (if ((n : IntInf.int) = (0 : IntInf.int)) then (IntInf.+ (i, ia), aa)
+ else (ia, Cn (n, i, aa)))
+ end
+ | zsplit0 (Neg a) =
+ let
+ val (i, aa) = zsplit0 a;
+ in
+ (IntInf.~ i, Neg aa)
+ end
+ | zsplit0 (Add (a, b)) =
+ let
+ val (ia, aa) = zsplit0 a;
+ val (ib, ba) = zsplit0 b;
+ in
+ (IntInf.+ (ia, ib), Add (aa, ba))
+ end
+ | zsplit0 (Sub (a, b)) =
+ let
+ val (ia, aa) = zsplit0 a;
+ val (ib, ba) = zsplit0 b;
+ in
+ (IntInf.- (ia, ib), Sub (aa, ba))
+ end
+ | zsplit0 (Mul (i, a)) =
+ let
+ val (ia, aa) = zsplit0 a;
+ in
+ (IntInf.* (i, ia), Mul (i, aa))
+ end;
+
+fun zlfm (And (p, q)) = And (zlfm p, zlfm q)
+ | zlfm (Or (p, q)) = Or (zlfm p, zlfm q)
+ | zlfm (Imp (p, q)) = Or (zlfm (Not p), zlfm q)
+ | zlfm (Iff (p, q)) =
+ Or (And (zlfm p, zlfm q), And (zlfm (Not p), zlfm (Not q)))
+ | zlfm (Lt a) =
+ let
+ val (c, r) = zsplit0 a;
+ in
+ (if ((c : IntInf.int) = (0 : IntInf.int)) then Lt r
+ else (if IntInf.< ((0 : IntInf.int), c)
+ then Lt (Cn ((0 : IntInf.int), c, r))
+ else Gt (Cn ((0 : IntInf.int), IntInf.~ c, Neg r))))
+ end
+ | zlfm (Le a) =
+ let
+ val (c, r) = zsplit0 a;
+ in
+ (if ((c : IntInf.int) = (0 : IntInf.int)) then Le r
+ else (if IntInf.< ((0 : IntInf.int), c)
+ then Le (Cn ((0 : IntInf.int), c, r))
+ else Ge (Cn ((0 : IntInf.int), IntInf.~ c, Neg r))))
+ end
+ | zlfm (Gt a) =
+ let
+ val (c, r) = zsplit0 a;
+ in
+ (if ((c : IntInf.int) = (0 : IntInf.int)) then Gt r
+ else (if IntInf.< ((0 : IntInf.int), c)
+ then Gt (Cn ((0 : IntInf.int), c, r))
+ else Lt (Cn ((0 : IntInf.int), IntInf.~ c, Neg r))))
+ end
+ | zlfm (Ge a) =
+ let
+ val (c, r) = zsplit0 a;
+ in
+ (if ((c : IntInf.int) = (0 : IntInf.int)) then Ge r
+ else (if IntInf.< ((0 : IntInf.int), c)
+ then Ge (Cn ((0 : IntInf.int), c, r))
+ else Le (Cn ((0 : IntInf.int), IntInf.~ c, Neg r))))
+ end
+ | zlfm (Eq a) =
+ let
+ val (c, r) = zsplit0 a;
+ in
+ (if ((c : IntInf.int) = (0 : IntInf.int)) then Eq r
+ else (if IntInf.< ((0 : IntInf.int), c)
+ then Eq (Cn ((0 : IntInf.int), c, r))
+ else Eq (Cn ((0 : IntInf.int), IntInf.~ c, Neg r))))
+ end
+ | zlfm (NEq a) =
+ let
+ val (c, r) = zsplit0 a;
+ in
+ (if ((c : IntInf.int) = (0 : IntInf.int)) then NEq r
+ else (if IntInf.< ((0 : IntInf.int), c)
+ then NEq (Cn ((0 : IntInf.int), c, r))
+ else NEq (Cn ((0 : IntInf.int), IntInf.~ c, Neg r))))
+ end
+ | zlfm (Dvd (i, a)) =
+ (if ((i : IntInf.int) = (0 : IntInf.int)) then zlfm (Eq a)
+ else let
+ val (c, r) = zsplit0 a;
+ in
+ (if ((c : IntInf.int) = (0 : IntInf.int)) then Dvd (abs_int i, r)
+ else (if IntInf.< ((0 : IntInf.int), c)
+ then Dvd (abs_int i, Cn ((0 : IntInf.int), c, r))
+ else Dvd (abs_int i,
+ Cn ((0 : IntInf.int), IntInf.~ c, Neg r))))
+ end)
+ | zlfm (NDvd (i, a)) =
+ (if ((i : IntInf.int) = (0 : IntInf.int)) then zlfm (NEq a)
+ else let
+ val (c, r) = zsplit0 a;
+ in
+ (if ((c : IntInf.int) = (0 : IntInf.int)) then NDvd (abs_int i, r)
+ else (if IntInf.< ((0 : IntInf.int), c)
+ then NDvd (abs_int i, Cn ((0 : IntInf.int), c, r))
+ else NDvd (abs_int i,
+ Cn ((0 : IntInf.int), IntInf.~ c, Neg r))))
+ end)
+ | zlfm (Not (And (p, q))) = Or (zlfm (Not p), zlfm (Not q))
+ | zlfm (Not (Or (p, q))) = And (zlfm (Not p), zlfm (Not q))
+ | zlfm (Not (Imp (p, q))) = And (zlfm p, zlfm (Not q))
+ | zlfm (Not (Iff (p, q))) =
+ Or (And (zlfm p, zlfm (Not q)), And (zlfm (Not p), zlfm q))
+ | zlfm (Not (Not p)) = zlfm p
+ | zlfm (Not T) = F
+ | zlfm (Not F) = T
+ | zlfm (Not (Lt a)) = zlfm (Ge a)
+ | zlfm (Not (Le a)) = zlfm (Gt a)
+ | zlfm (Not (Gt a)) = zlfm (Le a)
+ | zlfm (Not (Ge a)) = zlfm (Lt a)
+ | zlfm (Not (Eq a)) = zlfm (NEq a)
+ | zlfm (Not (NEq a)) = zlfm (Eq a)
+ | zlfm (Not (Dvd (i, a))) = zlfm (NDvd (i, a))
+ | zlfm (Not (NDvd (i, a))) = zlfm (Dvd (i, a))
+ | zlfm (Not (Closed p)) = NClosed p
+ | zlfm (Not (NClosed p)) = Closed p
+ | zlfm T = T
+ | zlfm F = F
+ | zlfm (Not (E ci)) = Not (E ci)
+ | zlfm (Not (A cj)) = Not (A cj)
+ | zlfm (E ao) = E ao
+ | zlfm (A ap) = A ap
+ | zlfm (Closed aq) = Closed aq
+ | zlfm (NClosed ar) = NClosed ar;
+
+fun unita p =
+ let
+ val pa = zlfm p;
+ val l = zeta pa;
+ val q =
+ And (Dvd (l, Cn ((0 : IntInf.int), (1 : IntInf.int), C (0 : IntInf.int))),
+ a_beta pa l);
+ val d = delta q;
+ val b = remdups eq_numa (map simpnum (beta q));
+ val a = remdups eq_numa (map simpnum (alpha q));
+ in
+ (if IntInf.<= (size_list b, size_list a) then (q, (b, d))
+ else (mirror q, (a, d)))
+ end;
+
+fun cooper p =
+ let
+ val (q, (b, d)) = unita p;
+ val js = iupt (1 : IntInf.int) d;
+ val mq = simpfm (minusinf q);
+ val md = evaldjf (fn j => simpfm (subst0 (C j) mq)) js;
+ in
+ (if eq_fm md T then T
+ else let
+ val qd =
+ evaldjf (fn (ba, j) => simpfm (subst0 (Add (ba, C j)) q))
+ (concat_map (fn ba => map (fn a => (ba, a)) js) b);
+ in
+ decr (disj md qd)
+ end)
+ end;
+
+fun prep (E T) = T
+ | prep (E F) = F
+ | prep (E (Or (p, q))) = Or (prep (E p), prep (E q))
+ | prep (E (Imp (p, q))) = Or (prep (E (Not p)), prep (E q))
+ | prep (E (Iff (p, q))) =
+ Or (prep (E (And (p, q))), prep (E (And (Not p, Not q))))
+ | prep (E (Not (And (p, q)))) = Or (prep (E (Not p)), prep (E (Not q)))
+ | prep (E (Not (Imp (p, q)))) = prep (E (And (p, Not q)))
+ | prep (E (Not (Iff (p, q)))) =
+ Or (prep (E (And (p, Not q))), prep (E (And (Not p, q))))
+ | prep (E (Lt ef)) = E (prep (Lt ef))
+ | prep (E (Le eg)) = E (prep (Le eg))
+ | prep (E (Gt eh)) = E (prep (Gt eh))
+ | prep (E (Ge ei)) = E (prep (Ge ei))
+ | prep (E (Eq ej)) = E (prep (Eq ej))
+ | prep (E (NEq ek)) = E (prep (NEq ek))
+ | prep (E (Dvd (el, em))) = E (prep (Dvd (el, em)))
+ | prep (E (NDvd (en, eo))) = E (prep (NDvd (en, eo)))
+ | prep (E (Not T)) = E (prep (Not T))
+ | prep (E (Not F)) = E (prep (Not F))
+ | prep (E (Not (Lt gw))) = E (prep (Not (Lt gw)))
+ | prep (E (Not (Le gx))) = E (prep (Not (Le gx)))
+ | prep (E (Not (Gt gy))) = E (prep (Not (Gt gy)))
+ | prep (E (Not (Ge gz))) = E (prep (Not (Ge gz)))
+ | prep (E (Not (Eq ha))) = E (prep (Not (Eq ha)))
+ | prep (E (Not (NEq hb))) = E (prep (Not (NEq hb)))
+ | prep (E (Not (Dvd (hc, hd)))) = E (prep (Not (Dvd (hc, hd))))
+ | prep (E (Not (NDvd (he, hf)))) = E (prep (Not (NDvd (he, hf))))
+ | prep (E (Not (Not hg))) = E (prep (Not (Not hg)))
+ | prep (E (Not (Or (hj, hk)))) = E (prep (Not (Or (hj, hk))))
+ | prep (E (Not (E hp))) = E (prep (Not (E hp)))
+ | prep (E (Not (A hq))) = E (prep (Not (A hq)))
+ | prep (E (Not (Closed hr))) = E (prep (Not (Closed hr)))
+ | prep (E (Not (NClosed hs))) = E (prep (Not (NClosed hs)))
+ | prep (E (And (eq, er))) = E (prep (And (eq, er)))
+ | prep (E (E ey)) = E (prep (E ey))
+ | prep (E (A ez)) = E (prep (A ez))
+ | prep (E (Closed fa)) = E (prep (Closed fa))
+ | prep (E (NClosed fb)) = E (prep (NClosed fb))
+ | prep (A (And (p, q))) = And (prep (A p), prep (A q))
+ | prep (A T) = prep (Not (E (Not T)))
+ | prep (A F) = prep (Not (E (Not F)))
+ | prep (A (Lt jn)) = prep (Not (E (Not (Lt jn))))
+ | prep (A (Le jo)) = prep (Not (E (Not (Le jo))))
+ | prep (A (Gt jp)) = prep (Not (E (Not (Gt jp))))
+ | prep (A (Ge jq)) = prep (Not (E (Not (Ge jq))))
+ | prep (A (Eq jr)) = prep (Not (E (Not (Eq jr))))
+ | prep (A (NEq js)) = prep (Not (E (Not (NEq js))))
+ | prep (A (Dvd (jt, ju))) = prep (Not (E (Not (Dvd (jt, ju)))))
+ | prep (A (NDvd (jv, jw))) = prep (Not (E (Not (NDvd (jv, jw)))))
+ | prep (A (Not jx)) = prep (Not (E (Not (Not jx))))
+ | prep (A (Or (ka, kb))) = prep (Not (E (Not (Or (ka, kb)))))
+ | prep (A (Imp (kc, kd))) = prep (Not (E (Not (Imp (kc, kd)))))
+ | prep (A (Iff (ke, kf))) = prep (Not (E (Not (Iff (ke, kf)))))
+ | prep (A (E kg)) = prep (Not (E (Not (E kg))))
+ | prep (A (A kh)) = prep (Not (E (Not (A kh))))
+ | prep (A (Closed ki)) = prep (Not (E (Not (Closed ki))))
+ | prep (A (NClosed kj)) = prep (Not (E (Not (NClosed kj))))
+ | prep (Not (Not p)) = prep p
+ | prep (Not (And (p, q))) = Or (prep (Not p), prep (Not q))
+ | prep (Not (A p)) = prep (E (Not p))
+ | prep (Not (Or (p, q))) = And (prep (Not p), prep (Not q))
+ | prep (Not (Imp (p, q))) = And (prep p, prep (Not q))
+ | prep (Not (Iff (p, q))) = Or (prep (And (p, Not q)), prep (And (Not p, q)))
+ | prep (Not T) = Not (prep T)
+ | prep (Not F) = Not (prep F)
+ | prep (Not (Lt bo)) = Not (prep (Lt bo))
+ | prep (Not (Le bp)) = Not (prep (Le bp))
+ | prep (Not (Gt bq)) = Not (prep (Gt bq))
+ | prep (Not (Ge br)) = Not (prep (Ge br))
+ | prep (Not (Eq bs)) = Not (prep (Eq bs))
+ | prep (Not (NEq bt)) = Not (prep (NEq bt))
+ | prep (Not (Dvd (bu, bv))) = Not (prep (Dvd (bu, bv)))
+ | prep (Not (NDvd (bw, bx))) = Not (prep (NDvd (bw, bx)))
+ | prep (Not (E ch)) = Not (prep (E ch))
+ | prep (Not (Closed cj)) = Not (prep (Closed cj))
+ | prep (Not (NClosed ck)) = Not (prep (NClosed ck))
+ | prep (Or (p, q)) = Or (prep p, prep q)
+ | prep (And (p, q)) = And (prep p, prep q)
+ | prep (Imp (p, q)) = prep (Or (Not p, q))
+ | prep (Iff (p, q)) = Or (prep (And (p, q)), prep (And (Not p, Not q)))
+ | prep T = T
+ | prep F = F
+ | prep (Lt u) = Lt u
+ | prep (Le v) = Le v
+ | prep (Gt w) = Gt w
+ | prep (Ge x) = Ge x
+ | prep (Eq y) = Eq y
+ | prep (NEq z) = NEq z
+ | prep (Dvd (aa, ab)) = Dvd (aa, ab)
+ | prep (NDvd (ac, ad)) = NDvd (ac, ad)
+ | prep (Closed ap) = Closed ap
+ | prep (NClosed aq) = NClosed aq;
+
+fun qelim (E p) = (fn qe => dj qe (qelim p qe))
+ | qelim (A p) = (fn qe => nota (qe (qelim (Not p) qe)))
+ | qelim (Not p) = (fn qe => nota (qelim p qe))
+ | qelim (And (p, q)) = (fn qe => conj (qelim p qe) (qelim q qe))
+ | qelim (Or (p, q)) = (fn qe => disj (qelim p qe) (qelim q qe))
+ | qelim (Imp (p, q)) = (fn qe => impa (qelim p qe) (qelim q qe))
+ | qelim (Iff (p, q)) = (fn qe => iffa (qelim p qe) (qelim q qe))
+ | qelim T = (fn _ => simpfm T)
+ | qelim F = (fn _ => simpfm F)
+ | qelim (Lt u) = (fn _ => simpfm (Lt u))
+ | qelim (Le v) = (fn _ => simpfm (Le v))
+ | qelim (Gt w) = (fn _ => simpfm (Gt w))
+ | qelim (Ge x) = (fn _ => simpfm (Ge x))
+ | qelim (Eq y) = (fn _ => simpfm (Eq y))
+ | qelim (NEq z) = (fn _ => simpfm (NEq z))
+ | qelim (Dvd (aa, ab)) = (fn _ => simpfm (Dvd (aa, ab)))
+ | qelim (NDvd (ac, ad)) = (fn _ => simpfm (NDvd (ac, ad)))
+ | qelim (Closed ap) = (fn _ => simpfm (Closed ap))
+ | qelim (NClosed aq) = (fn _ => simpfm (NClosed aq));
+
+fun pa p = qelim (prep p) cooper;
+
+end; (*struct Cooper_Procedure*)
--- a/src/HOL/Tools/Qelim/generated_cooper.ML Tue May 11 09:10:31 2010 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2274 +0,0 @@
-(* Generated from Cooper.thy; DO NOT EDIT! *)
-
-structure Generated_Cooper : sig
- type 'a eq
- val eq : 'a eq -> 'a -> 'a -> bool
- val eqa : 'a eq -> 'a -> 'a -> bool
- val leta : 'a -> ('a -> 'b) -> 'b
- val suc : IntInf.int -> IntInf.int
- datatype num = C of IntInf.int | Bound of IntInf.int |
- Cn of IntInf.int * IntInf.int * num | Neg of num | Add of num * num |
- Sub of num * num | Mul of IntInf.int * num
- datatype fm = T | F | Lt of num | Le of num | Gt of num | Ge of num |
- Eq of num | NEq of num | Dvd of IntInf.int * num | NDvd of IntInf.int * num
- | Not of fm | And of fm * fm | Or of fm * fm | Imp of fm * fm |
- Iff of fm * fm | E of fm | A of fm | Closed of IntInf.int |
- NClosed of IntInf.int
- val map : ('a -> 'b) -> 'a list -> 'b list
- val append : 'a list -> 'a list -> 'a list
- val disjuncts : fm -> fm list
- val fm_case :
- 'a -> 'a -> (num -> 'a) ->
- (num -> 'a) ->
- (num -> 'a) ->
- (num -> 'a) ->
- (num -> 'a) ->
- (num -> 'a) ->
- (IntInf.int -> num -> 'a) ->
- (IntInf.int -> num -> 'a) ->
- (fm -> 'a) ->
- (fm -> fm -> 'a) ->
- (fm -> fm -> 'a) ->
- (fm -> fm -> 'a) ->
-(fm -> fm -> 'a) ->
- (fm -> 'a) ->
- (fm -> 'a) -> (IntInf.int -> 'a) -> (IntInf.int -> 'a) -> fm -> 'a
- val eq_num : num -> num -> bool
- val eq_fm : fm -> fm -> bool
- val djf : ('a -> fm) -> 'a -> fm -> fm
- val foldr : ('a -> 'b -> 'b) -> 'a list -> 'b -> 'b
- val evaldjf : ('a -> fm) -> 'a list -> fm
- val dj : (fm -> fm) -> fm -> fm
- val disj : fm -> fm -> fm
- val minus_nat : IntInf.int -> IntInf.int -> IntInf.int
- val decrnum : num -> num
- val decr : fm -> fm
- val concat_map : ('a -> 'b list) -> 'a list -> 'b list
- val numsubst0 : num -> num -> num
- val subst0 : num -> fm -> fm
- val minusinf : fm -> fm
- val eq_int : IntInf.int eq
- val zero_int : IntInf.int
- type 'a zero
- val zero : 'a zero -> 'a
- val zero_inta : IntInf.int zero
- type 'a times
- val times : 'a times -> 'a -> 'a -> 'a
- type 'a no_zero_divisors
- val times_no_zero_divisors : 'a no_zero_divisors -> 'a times
- val zero_no_zero_divisors : 'a no_zero_divisors -> 'a zero
- val times_int : IntInf.int times
- val no_zero_divisors_int : IntInf.int no_zero_divisors
- type 'a one
- val one : 'a one -> 'a
- type 'a zero_neq_one
- val one_zero_neq_one : 'a zero_neq_one -> 'a one
- val zero_zero_neq_one : 'a zero_neq_one -> 'a zero
- type 'a semigroup_mult
- val times_semigroup_mult : 'a semigroup_mult -> 'a times
- type 'a plus
- val plus : 'a plus -> 'a -> 'a -> 'a
- type 'a semigroup_add
- val plus_semigroup_add : 'a semigroup_add -> 'a plus
- type 'a ab_semigroup_add
- val semigroup_add_ab_semigroup_add : 'a ab_semigroup_add -> 'a semigroup_add
- type 'a semiring
- val ab_semigroup_add_semiring : 'a semiring -> 'a ab_semigroup_add
- val semigroup_mult_semiring : 'a semiring -> 'a semigroup_mult
- type 'a mult_zero
- val times_mult_zero : 'a mult_zero -> 'a times
- val zero_mult_zero : 'a mult_zero -> 'a zero
- type 'a monoid_add
- val semigroup_add_monoid_add : 'a monoid_add -> 'a semigroup_add
- val zero_monoid_add : 'a monoid_add -> 'a zero
- type 'a comm_monoid_add
- val ab_semigroup_add_comm_monoid_add :
- 'a comm_monoid_add -> 'a ab_semigroup_add
- val monoid_add_comm_monoid_add : 'a comm_monoid_add -> 'a monoid_add
- type 'a semiring_0
- val comm_monoid_add_semiring_0 : 'a semiring_0 -> 'a comm_monoid_add
- val mult_zero_semiring_0 : 'a semiring_0 -> 'a mult_zero
- val semiring_semiring_0 : 'a semiring_0 -> 'a semiring
- type 'a power
- val one_power : 'a power -> 'a one
- val times_power : 'a power -> 'a times
- type 'a monoid_mult
- val semigroup_mult_monoid_mult : 'a monoid_mult -> 'a semigroup_mult
- val power_monoid_mult : 'a monoid_mult -> 'a power
- type 'a semiring_1
- val monoid_mult_semiring_1 : 'a semiring_1 -> 'a monoid_mult
- val semiring_0_semiring_1 : 'a semiring_1 -> 'a semiring_0
- val zero_neq_one_semiring_1 : 'a semiring_1 -> 'a zero_neq_one
- type 'a cancel_semigroup_add
- val semigroup_add_cancel_semigroup_add :
- 'a cancel_semigroup_add -> 'a semigroup_add
- type 'a cancel_ab_semigroup_add
- val ab_semigroup_add_cancel_ab_semigroup_add :
- 'a cancel_ab_semigroup_add -> 'a ab_semigroup_add
- val cancel_semigroup_add_cancel_ab_semigroup_add :
- 'a cancel_ab_semigroup_add -> 'a cancel_semigroup_add
- type 'a cancel_comm_monoid_add
- val cancel_ab_semigroup_add_cancel_comm_monoid_add :
- 'a cancel_comm_monoid_add -> 'a cancel_ab_semigroup_add
- val comm_monoid_add_cancel_comm_monoid_add :
- 'a cancel_comm_monoid_add -> 'a comm_monoid_add
- type 'a semiring_0_cancel
- val cancel_comm_monoid_add_semiring_0_cancel :
- 'a semiring_0_cancel -> 'a cancel_comm_monoid_add
- val semiring_0_semiring_0_cancel : 'a semiring_0_cancel -> 'a semiring_0
- type 'a semiring_1_cancel
- val semiring_0_cancel_semiring_1_cancel :
- 'a semiring_1_cancel -> 'a semiring_0_cancel
- val semiring_1_semiring_1_cancel : 'a semiring_1_cancel -> 'a semiring_1
- type 'a dvd
- val times_dvd : 'a dvd -> 'a times
- type 'a ab_semigroup_mult
- val semigroup_mult_ab_semigroup_mult :
- 'a ab_semigroup_mult -> 'a semigroup_mult
- type 'a comm_semiring
- val ab_semigroup_mult_comm_semiring : 'a comm_semiring -> 'a ab_semigroup_mult
- val semiring_comm_semiring : 'a comm_semiring -> 'a semiring
- type 'a comm_semiring_0
- val comm_semiring_comm_semiring_0 : 'a comm_semiring_0 -> 'a comm_semiring
- val semiring_0_comm_semiring_0 : 'a comm_semiring_0 -> 'a semiring_0
- type 'a comm_monoid_mult
- val ab_semigroup_mult_comm_monoid_mult :
- 'a comm_monoid_mult -> 'a ab_semigroup_mult
- val monoid_mult_comm_monoid_mult : 'a comm_monoid_mult -> 'a monoid_mult
- type 'a comm_semiring_1
- val comm_monoid_mult_comm_semiring_1 :
- 'a comm_semiring_1 -> 'a comm_monoid_mult
- val comm_semiring_0_comm_semiring_1 : 'a comm_semiring_1 -> 'a comm_semiring_0
- val dvd_comm_semiring_1 : 'a comm_semiring_1 -> 'a dvd
- val semiring_1_comm_semiring_1 : 'a comm_semiring_1 -> 'a semiring_1
- type 'a comm_semiring_0_cancel
- val comm_semiring_0_comm_semiring_0_cancel :
- 'a comm_semiring_0_cancel -> 'a comm_semiring_0
- val semiring_0_cancel_comm_semiring_0_cancel :
- 'a comm_semiring_0_cancel -> 'a semiring_0_cancel
- type 'a comm_semiring_1_cancel
- val comm_semiring_0_cancel_comm_semiring_1_cancel :
- 'a comm_semiring_1_cancel -> 'a comm_semiring_0_cancel
- val comm_semiring_1_comm_semiring_1_cancel :
- 'a comm_semiring_1_cancel -> 'a comm_semiring_1
- val semiring_1_cancel_comm_semiring_1_cancel :
- 'a comm_semiring_1_cancel -> 'a semiring_1_cancel
- type 'a diva
- val dvd_div : 'a diva -> 'a dvd
- val diva : 'a diva -> 'a -> 'a -> 'a
- val moda : 'a diva -> 'a -> 'a -> 'a
- type 'a semiring_div
- val div_semiring_div : 'a semiring_div -> 'a diva
- val comm_semiring_1_cancel_semiring_div :
- 'a semiring_div -> 'a comm_semiring_1_cancel
- val no_zero_divisors_semiring_div : 'a semiring_div -> 'a no_zero_divisors
- val one_int : IntInf.int
- val one_inta : IntInf.int one
- val zero_neq_one_int : IntInf.int zero_neq_one
- val semigroup_mult_int : IntInf.int semigroup_mult
- val plus_int : IntInf.int plus
- val semigroup_add_int : IntInf.int semigroup_add
- val ab_semigroup_add_int : IntInf.int ab_semigroup_add
- val semiring_int : IntInf.int semiring
- val mult_zero_int : IntInf.int mult_zero
- val monoid_add_int : IntInf.int monoid_add
- val comm_monoid_add_int : IntInf.int comm_monoid_add
- val semiring_0_int : IntInf.int semiring_0
- val power_int : IntInf.int power
- val monoid_mult_int : IntInf.int monoid_mult
- val semiring_1_int : IntInf.int semiring_1
- val cancel_semigroup_add_int : IntInf.int cancel_semigroup_add
- val cancel_ab_semigroup_add_int : IntInf.int cancel_ab_semigroup_add
- val cancel_comm_monoid_add_int : IntInf.int cancel_comm_monoid_add
- val semiring_0_cancel_int : IntInf.int semiring_0_cancel
- val semiring_1_cancel_int : IntInf.int semiring_1_cancel
- val dvd_int : IntInf.int dvd
- val ab_semigroup_mult_int : IntInf.int ab_semigroup_mult
- val comm_semiring_int : IntInf.int comm_semiring
- val comm_semiring_0_int : IntInf.int comm_semiring_0
- val comm_monoid_mult_int : IntInf.int comm_monoid_mult
- val comm_semiring_1_int : IntInf.int comm_semiring_1
- val comm_semiring_0_cancel_int : IntInf.int comm_semiring_0_cancel
- val comm_semiring_1_cancel_int : IntInf.int comm_semiring_1_cancel
- val abs_int : IntInf.int -> IntInf.int
- val split : ('a -> 'b -> 'c) -> 'a * 'b -> 'c
- val sgn_int : IntInf.int -> IntInf.int
- val apsnd : ('a -> 'b) -> 'c * 'a -> 'c * 'b
- val divmod_int : IntInf.int -> IntInf.int -> IntInf.int * IntInf.int
- val snd : 'a * 'b -> 'b
- val mod_int : IntInf.int -> IntInf.int -> IntInf.int
- val fst : 'a * 'b -> 'a
- val div_int : IntInf.int -> IntInf.int -> IntInf.int
- val div_inta : IntInf.int diva
- val semiring_div_int : IntInf.int semiring_div
- val dvd : 'a semiring_div * 'a eq -> 'a -> 'a -> bool
- val num_case :
- (IntInf.int -> 'a) ->
- (IntInf.int -> 'a) ->
- (IntInf.int -> IntInf.int -> num -> 'a) ->
- (num -> 'a) ->
- (num -> num -> 'a) ->
- (num -> num -> 'a) -> (IntInf.int -> num -> 'a) -> num -> 'a
- val nummul : IntInf.int -> num -> num
- val numneg : num -> num
- val numadd : num * num -> num
- val numsub : num -> num -> num
- val simpnum : num -> num
- val nota : fm -> fm
- val iffa : fm -> fm -> fm
- val impa : fm -> fm -> fm
- val conj : fm -> fm -> fm
- val simpfm : fm -> fm
- val iupt : IntInf.int -> IntInf.int -> IntInf.int list
- val mirror : fm -> fm
- val size_list : 'a list -> IntInf.int
- val alpha : fm -> num list
- val beta : fm -> num list
- val eq_numa : num eq
- val member : 'a eq -> 'a -> 'a list -> bool
- val remdups : 'a eq -> 'a list -> 'a list
- val gcd_int : IntInf.int -> IntInf.int -> IntInf.int
- val lcm_int : IntInf.int -> IntInf.int -> IntInf.int
- val delta : fm -> IntInf.int
- val a_beta : fm -> IntInf.int -> fm
- val zeta : fm -> IntInf.int
- val zsplit0 : num -> IntInf.int * num
- val zlfm : fm -> fm
- val unita : fm -> fm * (num list * IntInf.int)
- val cooper : fm -> fm
- val prep : fm -> fm
- val qelim : fm -> (fm -> fm) -> fm
- val pa : fm -> fm
-end = struct
-
-type 'a eq = {eq : 'a -> 'a -> bool};
-val eq = #eq : 'a eq -> 'a -> 'a -> bool;
-
-fun eqa A_ a b = eq A_ a b;
-
-fun leta s f = f s;
-
-fun suc n = IntInf.+ (n, (1 : IntInf.int));
-
-datatype num = C of IntInf.int | Bound of IntInf.int |
- Cn of IntInf.int * IntInf.int * num | Neg of num | Add of num * num |
- Sub of num * num | Mul of IntInf.int * num;
-
-datatype fm = T | F | Lt of num | Le of num | Gt of num | Ge of num | Eq of num
- | NEq of num | Dvd of IntInf.int * num | NDvd of IntInf.int * num | Not of fm
- | And of fm * fm | Or of fm * fm | Imp of fm * fm | Iff of fm * fm | E of fm |
- A of fm | Closed of IntInf.int | NClosed of IntInf.int;
-
-fun map f [] = []
- | map f (x :: xs) = f x :: map f xs;
-
-fun append [] ys = ys
- | append (x :: xs) ys = x :: append xs ys;
-
-fun disjuncts (Or (p, q)) = append (disjuncts p) (disjuncts q)
- | disjuncts F = []
- | disjuncts T = [T]
- | disjuncts (Lt u) = [Lt u]
- | disjuncts (Le v) = [Le v]
- | disjuncts (Gt w) = [Gt w]
- | disjuncts (Ge x) = [Ge x]
- | disjuncts (Eq y) = [Eq y]
- | disjuncts (NEq z) = [NEq z]
- | disjuncts (Dvd (aa, ab)) = [Dvd (aa, ab)]
- | disjuncts (NDvd (ac, ad)) = [NDvd (ac, ad)]
- | disjuncts (Not ae) = [Not ae]
- | disjuncts (And (af, ag)) = [And (af, ag)]
- | disjuncts (Imp (aj, ak)) = [Imp (aj, ak)]
- | disjuncts (Iff (al, am)) = [Iff (al, am)]
- | disjuncts (E an) = [E an]
- | disjuncts (A ao) = [A ao]
- | disjuncts (Closed ap) = [Closed ap]
- | disjuncts (NClosed aq) = [NClosed aq];
-
-fun fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
- (NClosed nat) = f19 nat
- | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
- (Closed nat) = f18 nat
- | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
- (A fm) = f17 fm
- | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
- (E fm) = f16 fm
- | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
- (Iff (fm1, fm2)) = f15 fm1 fm2
- | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
- (Imp (fm1, fm2)) = f14 fm1 fm2
- | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
- (Or (fm1, fm2)) = f13 fm1 fm2
- | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
- (And (fm1, fm2)) = f12 fm1 fm2
- | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
- (Not fm) = f11 fm
- | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
- (NDvd (inta, num)) = f10 inta num
- | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
- (Dvd (inta, num)) = f9 inta num
- | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
- (NEq num) = f8 num
- | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
- (Eq num) = f7 num
- | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
- (Ge num) = f6 num
- | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
- (Gt num) = f5 num
- | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
- (Le num) = f4 num
- | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
- (Lt num) = f3 num
- | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19 F
- = f2
- | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19 T
- = f1;
-
-fun eq_num (C intaa) (C inta) = ((intaa : IntInf.int) = inta)
- | eq_num (Bound nata) (Bound nat) = ((nata : IntInf.int) = nat)
- | eq_num (Cn (nata, intaa, numa)) (Cn (nat, inta, num)) =
- ((nata : IntInf.int) = nat) andalso
- (((intaa : IntInf.int) = inta) andalso eq_num numa num)
- | eq_num (Neg numa) (Neg num) = eq_num numa num
- | eq_num (Add (num1a, num2a)) (Add (num1, num2)) =
- eq_num num1a num1 andalso eq_num num2a num2
- | eq_num (Sub (num1a, num2a)) (Sub (num1, num2)) =
- eq_num num1a num1 andalso eq_num num2a num2
- | eq_num (Mul (intaa, numa)) (Mul (inta, num)) =
- ((intaa : IntInf.int) = inta) andalso eq_num numa num
- | eq_num (C inta) (Bound nat) = false
- | eq_num (Bound nat) (C inta) = false
- | eq_num (C intaa) (Cn (nat, inta, num)) = false
- | eq_num (Cn (nat, intaa, num)) (C inta) = false
- | eq_num (C inta) (Neg num) = false
- | eq_num (Neg num) (C inta) = false
- | eq_num (C inta) (Add (num1, num2)) = false
- | eq_num (Add (num1, num2)) (C inta) = false
- | eq_num (C inta) (Sub (num1, num2)) = false
- | eq_num (Sub (num1, num2)) (C inta) = false
- | eq_num (C intaa) (Mul (inta, num)) = false
- | eq_num (Mul (intaa, num)) (C inta) = false
- | eq_num (Bound nata) (Cn (nat, inta, num)) = false
- | eq_num (Cn (nata, inta, num)) (Bound nat) = false
- | eq_num (Bound nat) (Neg num) = false
- | eq_num (Neg num) (Bound nat) = false
- | eq_num (Bound nat) (Add (num1, num2)) = false
- | eq_num (Add (num1, num2)) (Bound nat) = false
- | eq_num (Bound nat) (Sub (num1, num2)) = false
- | eq_num (Sub (num1, num2)) (Bound nat) = false
- | eq_num (Bound nat) (Mul (inta, num)) = false
- | eq_num (Mul (inta, num)) (Bound nat) = false
- | eq_num (Cn (nat, inta, numa)) (Neg num) = false
- | eq_num (Neg numa) (Cn (nat, inta, num)) = false
- | eq_num (Cn (nat, inta, num)) (Add (num1, num2)) = false
- | eq_num (Add (num1, num2)) (Cn (nat, inta, num)) = false
- | eq_num (Cn (nat, inta, num)) (Sub (num1, num2)) = false
- | eq_num (Sub (num1, num2)) (Cn (nat, inta, num)) = false
- | eq_num (Cn (nat, intaa, numa)) (Mul (inta, num)) = false
- | eq_num (Mul (intaa, numa)) (Cn (nat, inta, num)) = false
- | eq_num (Neg num) (Add (num1, num2)) = false
- | eq_num (Add (num1, num2)) (Neg num) = false
- | eq_num (Neg num) (Sub (num1, num2)) = false
- | eq_num (Sub (num1, num2)) (Neg num) = false
- | eq_num (Neg numa) (Mul (inta, num)) = false
- | eq_num (Mul (inta, numa)) (Neg num) = false
- | eq_num (Add (num1a, num2a)) (Sub (num1, num2)) = false
- | eq_num (Sub (num1a, num2a)) (Add (num1, num2)) = false
- | eq_num (Add (num1, num2)) (Mul (inta, num)) = false
- | eq_num (Mul (inta, num)) (Add (num1, num2)) = false
- | eq_num (Sub (num1, num2)) (Mul (inta, num)) = false
- | eq_num (Mul (inta, num)) (Sub (num1, num2)) = false;
-
-fun eq_fm T T = true
- | eq_fm F F = true
- | eq_fm (Lt numa) (Lt num) = eq_num numa num
- | eq_fm (Le numa) (Le num) = eq_num numa num
- | eq_fm (Gt numa) (Gt num) = eq_num numa num
- | eq_fm (Ge numa) (Ge num) = eq_num numa num
- | eq_fm (Eq numa) (Eq num) = eq_num numa num
- | eq_fm (NEq numa) (NEq num) = eq_num numa num
- | eq_fm (Dvd (intaa, numa)) (Dvd (inta, num)) =
- ((intaa : IntInf.int) = inta) andalso eq_num numa num
- | eq_fm (NDvd (intaa, numa)) (NDvd (inta, num)) =
- ((intaa : IntInf.int) = inta) andalso eq_num numa num
- | eq_fm (Not fma) (Not fm) = eq_fm fma fm
- | eq_fm (And (fm1a, fm2a)) (And (fm1, fm2)) =
- eq_fm fm1a fm1 andalso eq_fm fm2a fm2
- | eq_fm (Or (fm1a, fm2a)) (Or (fm1, fm2)) =
- eq_fm fm1a fm1 andalso eq_fm fm2a fm2
- | eq_fm (Imp (fm1a, fm2a)) (Imp (fm1, fm2)) =
- eq_fm fm1a fm1 andalso eq_fm fm2a fm2
- | eq_fm (Iff (fm1a, fm2a)) (Iff (fm1, fm2)) =
- eq_fm fm1a fm1 andalso eq_fm fm2a fm2
- | eq_fm (E fma) (E fm) = eq_fm fma fm
- | eq_fm (A fma) (A fm) = eq_fm fma fm
- | eq_fm (Closed nata) (Closed nat) = ((nata : IntInf.int) = nat)
- | eq_fm (NClosed nata) (NClosed nat) = ((nata : IntInf.int) = nat)
- | eq_fm T F = false
- | eq_fm F T = false
- | eq_fm T (Lt num) = false
- | eq_fm (Lt num) T = false
- | eq_fm T (Le num) = false
- | eq_fm (Le num) T = false
- | eq_fm T (Gt num) = false
- | eq_fm (Gt num) T = false
- | eq_fm T (Ge num) = false
- | eq_fm (Ge num) T = false
- | eq_fm T (Eq num) = false
- | eq_fm (Eq num) T = false
- | eq_fm T (NEq num) = false
- | eq_fm (NEq num) T = false
- | eq_fm T (Dvd (inta, num)) = false
- | eq_fm (Dvd (inta, num)) T = false
- | eq_fm T (NDvd (inta, num)) = false
- | eq_fm (NDvd (inta, num)) T = false
- | eq_fm T (Not fm) = false
- | eq_fm (Not fm) T = false
- | eq_fm T (And (fm1, fm2)) = false
- | eq_fm (And (fm1, fm2)) T = false
- | eq_fm T (Or (fm1, fm2)) = false
- | eq_fm (Or (fm1, fm2)) T = false
- | eq_fm T (Imp (fm1, fm2)) = false
- | eq_fm (Imp (fm1, fm2)) T = false
- | eq_fm T (Iff (fm1, fm2)) = false
- | eq_fm (Iff (fm1, fm2)) T = false
- | eq_fm T (E fm) = false
- | eq_fm (E fm) T = false
- | eq_fm T (A fm) = false
- | eq_fm (A fm) T = false
- | eq_fm T (Closed nat) = false
- | eq_fm (Closed nat) T = false
- | eq_fm T (NClosed nat) = false
- | eq_fm (NClosed nat) T = false
- | eq_fm F (Lt num) = false
- | eq_fm (Lt num) F = false
- | eq_fm F (Le num) = false
- | eq_fm (Le num) F = false
- | eq_fm F (Gt num) = false
- | eq_fm (Gt num) F = false
- | eq_fm F (Ge num) = false
- | eq_fm (Ge num) F = false
- | eq_fm F (Eq num) = false
- | eq_fm (Eq num) F = false
- | eq_fm F (NEq num) = false
- | eq_fm (NEq num) F = false
- | eq_fm F (Dvd (inta, num)) = false
- | eq_fm (Dvd (inta, num)) F = false
- | eq_fm F (NDvd (inta, num)) = false
- | eq_fm (NDvd (inta, num)) F = false
- | eq_fm F (Not fm) = false
- | eq_fm (Not fm) F = false
- | eq_fm F (And (fm1, fm2)) = false
- | eq_fm (And (fm1, fm2)) F = false
- | eq_fm F (Or (fm1, fm2)) = false
- | eq_fm (Or (fm1, fm2)) F = false
- | eq_fm F (Imp (fm1, fm2)) = false
- | eq_fm (Imp (fm1, fm2)) F = false
- | eq_fm F (Iff (fm1, fm2)) = false
- | eq_fm (Iff (fm1, fm2)) F = false
- | eq_fm F (E fm) = false
- | eq_fm (E fm) F = false
- | eq_fm F (A fm) = false
- | eq_fm (A fm) F = false
- | eq_fm F (Closed nat) = false
- | eq_fm (Closed nat) F = false
- | eq_fm F (NClosed nat) = false
- | eq_fm (NClosed nat) F = false
- | eq_fm (Lt numa) (Le num) = false
- | eq_fm (Le numa) (Lt num) = false
- | eq_fm (Lt numa) (Gt num) = false
- | eq_fm (Gt numa) (Lt num) = false
- | eq_fm (Lt numa) (Ge num) = false
- | eq_fm (Ge numa) (Lt num) = false
- | eq_fm (Lt numa) (Eq num) = false
- | eq_fm (Eq numa) (Lt num) = false
- | eq_fm (Lt numa) (NEq num) = false
- | eq_fm (NEq numa) (Lt num) = false
- | eq_fm (Lt numa) (Dvd (inta, num)) = false
- | eq_fm (Dvd (inta, numa)) (Lt num) = false
- | eq_fm (Lt numa) (NDvd (inta, num)) = false
- | eq_fm (NDvd (inta, numa)) (Lt num) = false
- | eq_fm (Lt num) (Not fm) = false
- | eq_fm (Not fm) (Lt num) = false
- | eq_fm (Lt num) (And (fm1, fm2)) = false
- | eq_fm (And (fm1, fm2)) (Lt num) = false
- | eq_fm (Lt num) (Or (fm1, fm2)) = false
- | eq_fm (Or (fm1, fm2)) (Lt num) = false
- | eq_fm (Lt num) (Imp (fm1, fm2)) = false
- | eq_fm (Imp (fm1, fm2)) (Lt num) = false
- | eq_fm (Lt num) (Iff (fm1, fm2)) = false
- | eq_fm (Iff (fm1, fm2)) (Lt num) = false
- | eq_fm (Lt num) (E fm) = false
- | eq_fm (E fm) (Lt num) = false
- | eq_fm (Lt num) (A fm) = false
- | eq_fm (A fm) (Lt num) = false
- | eq_fm (Lt num) (Closed nat) = false
- | eq_fm (Closed nat) (Lt num) = false
- | eq_fm (Lt num) (NClosed nat) = false
- | eq_fm (NClosed nat) (Lt num) = false
- | eq_fm (Le numa) (Gt num) = false
- | eq_fm (Gt numa) (Le num) = false
- | eq_fm (Le numa) (Ge num) = false
- | eq_fm (Ge numa) (Le num) = false
- | eq_fm (Le numa) (Eq num) = false
- | eq_fm (Eq numa) (Le num) = false
- | eq_fm (Le numa) (NEq num) = false
- | eq_fm (NEq numa) (Le num) = false
- | eq_fm (Le numa) (Dvd (inta, num)) = false
- | eq_fm (Dvd (inta, numa)) (Le num) = false
- | eq_fm (Le numa) (NDvd (inta, num)) = false
- | eq_fm (NDvd (inta, numa)) (Le num) = false
- | eq_fm (Le num) (Not fm) = false
- | eq_fm (Not fm) (Le num) = false
- | eq_fm (Le num) (And (fm1, fm2)) = false
- | eq_fm (And (fm1, fm2)) (Le num) = false
- | eq_fm (Le num) (Or (fm1, fm2)) = false
- | eq_fm (Or (fm1, fm2)) (Le num) = false
- | eq_fm (Le num) (Imp (fm1, fm2)) = false
- | eq_fm (Imp (fm1, fm2)) (Le num) = false
- | eq_fm (Le num) (Iff (fm1, fm2)) = false
- | eq_fm (Iff (fm1, fm2)) (Le num) = false
- | eq_fm (Le num) (E fm) = false
- | eq_fm (E fm) (Le num) = false
- | eq_fm (Le num) (A fm) = false
- | eq_fm (A fm) (Le num) = false
- | eq_fm (Le num) (Closed nat) = false
- | eq_fm (Closed nat) (Le num) = false
- | eq_fm (Le num) (NClosed nat) = false
- | eq_fm (NClosed nat) (Le num) = false
- | eq_fm (Gt numa) (Ge num) = false
- | eq_fm (Ge numa) (Gt num) = false
- | eq_fm (Gt numa) (Eq num) = false
- | eq_fm (Eq numa) (Gt num) = false
- | eq_fm (Gt numa) (NEq num) = false
- | eq_fm (NEq numa) (Gt num) = false
- | eq_fm (Gt numa) (Dvd (inta, num)) = false
- | eq_fm (Dvd (inta, numa)) (Gt num) = false
- | eq_fm (Gt numa) (NDvd (inta, num)) = false
- | eq_fm (NDvd (inta, numa)) (Gt num) = false
- | eq_fm (Gt num) (Not fm) = false
- | eq_fm (Not fm) (Gt num) = false
- | eq_fm (Gt num) (And (fm1, fm2)) = false
- | eq_fm (And (fm1, fm2)) (Gt num) = false
- | eq_fm (Gt num) (Or (fm1, fm2)) = false
- | eq_fm (Or (fm1, fm2)) (Gt num) = false
- | eq_fm (Gt num) (Imp (fm1, fm2)) = false
- | eq_fm (Imp (fm1, fm2)) (Gt num) = false
- | eq_fm (Gt num) (Iff (fm1, fm2)) = false
- | eq_fm (Iff (fm1, fm2)) (Gt num) = false
- | eq_fm (Gt num) (E fm) = false
- | eq_fm (E fm) (Gt num) = false
- | eq_fm (Gt num) (A fm) = false
- | eq_fm (A fm) (Gt num) = false
- | eq_fm (Gt num) (Closed nat) = false
- | eq_fm (Closed nat) (Gt num) = false
- | eq_fm (Gt num) (NClosed nat) = false
- | eq_fm (NClosed nat) (Gt num) = false
- | eq_fm (Ge numa) (Eq num) = false
- | eq_fm (Eq numa) (Ge num) = false
- | eq_fm (Ge numa) (NEq num) = false
- | eq_fm (NEq numa) (Ge num) = false
- | eq_fm (Ge numa) (Dvd (inta, num)) = false
- | eq_fm (Dvd (inta, numa)) (Ge num) = false
- | eq_fm (Ge numa) (NDvd (inta, num)) = false
- | eq_fm (NDvd (inta, numa)) (Ge num) = false
- | eq_fm (Ge num) (Not fm) = false
- | eq_fm (Not fm) (Ge num) = false
- | eq_fm (Ge num) (And (fm1, fm2)) = false
- | eq_fm (And (fm1, fm2)) (Ge num) = false
- | eq_fm (Ge num) (Or (fm1, fm2)) = false
- | eq_fm (Or (fm1, fm2)) (Ge num) = false
- | eq_fm (Ge num) (Imp (fm1, fm2)) = false
- | eq_fm (Imp (fm1, fm2)) (Ge num) = false
- | eq_fm (Ge num) (Iff (fm1, fm2)) = false
- | eq_fm (Iff (fm1, fm2)) (Ge num) = false
- | eq_fm (Ge num) (E fm) = false
- | eq_fm (E fm) (Ge num) = false
- | eq_fm (Ge num) (A fm) = false
- | eq_fm (A fm) (Ge num) = false
- | eq_fm (Ge num) (Closed nat) = false
- | eq_fm (Closed nat) (Ge num) = false
- | eq_fm (Ge num) (NClosed nat) = false
- | eq_fm (NClosed nat) (Ge num) = false
- | eq_fm (Eq numa) (NEq num) = false
- | eq_fm (NEq numa) (Eq num) = false
- | eq_fm (Eq numa) (Dvd (inta, num)) = false
- | eq_fm (Dvd (inta, numa)) (Eq num) = false
- | eq_fm (Eq numa) (NDvd (inta, num)) = false
- | eq_fm (NDvd (inta, numa)) (Eq num) = false
- | eq_fm (Eq num) (Not fm) = false
- | eq_fm (Not fm) (Eq num) = false
- | eq_fm (Eq num) (And (fm1, fm2)) = false
- | eq_fm (And (fm1, fm2)) (Eq num) = false
- | eq_fm (Eq num) (Or (fm1, fm2)) = false
- | eq_fm (Or (fm1, fm2)) (Eq num) = false
- | eq_fm (Eq num) (Imp (fm1, fm2)) = false
- | eq_fm (Imp (fm1, fm2)) (Eq num) = false
- | eq_fm (Eq num) (Iff (fm1, fm2)) = false
- | eq_fm (Iff (fm1, fm2)) (Eq num) = false
- | eq_fm (Eq num) (E fm) = false
- | eq_fm (E fm) (Eq num) = false
- | eq_fm (Eq num) (A fm) = false
- | eq_fm (A fm) (Eq num) = false
- | eq_fm (Eq num) (Closed nat) = false
- | eq_fm (Closed nat) (Eq num) = false
- | eq_fm (Eq num) (NClosed nat) = false
- | eq_fm (NClosed nat) (Eq num) = false
- | eq_fm (NEq numa) (Dvd (inta, num)) = false
- | eq_fm (Dvd (inta, numa)) (NEq num) = false
- | eq_fm (NEq numa) (NDvd (inta, num)) = false
- | eq_fm (NDvd (inta, numa)) (NEq num) = false
- | eq_fm (NEq num) (Not fm) = false
- | eq_fm (Not fm) (NEq num) = false
- | eq_fm (NEq num) (And (fm1, fm2)) = false
- | eq_fm (And (fm1, fm2)) (NEq num) = false
- | eq_fm (NEq num) (Or (fm1, fm2)) = false
- | eq_fm (Or (fm1, fm2)) (NEq num) = false
- | eq_fm (NEq num) (Imp (fm1, fm2)) = false
- | eq_fm (Imp (fm1, fm2)) (NEq num) = false
- | eq_fm (NEq num) (Iff (fm1, fm2)) = false
- | eq_fm (Iff (fm1, fm2)) (NEq num) = false
- | eq_fm (NEq num) (E fm) = false
- | eq_fm (E fm) (NEq num) = false
- | eq_fm (NEq num) (A fm) = false
- | eq_fm (A fm) (NEq num) = false
- | eq_fm (NEq num) (Closed nat) = false
- | eq_fm (Closed nat) (NEq num) = false
- | eq_fm (NEq num) (NClosed nat) = false
- | eq_fm (NClosed nat) (NEq num) = false
- | eq_fm (Dvd (intaa, numa)) (NDvd (inta, num)) = false
- | eq_fm (NDvd (intaa, numa)) (Dvd (inta, num)) = false
- | eq_fm (Dvd (inta, num)) (Not fm) = false
- | eq_fm (Not fm) (Dvd (inta, num)) = false
- | eq_fm (Dvd (inta, num)) (And (fm1, fm2)) = false
- | eq_fm (And (fm1, fm2)) (Dvd (inta, num)) = false
- | eq_fm (Dvd (inta, num)) (Or (fm1, fm2)) = false
- | eq_fm (Or (fm1, fm2)) (Dvd (inta, num)) = false
- | eq_fm (Dvd (inta, num)) (Imp (fm1, fm2)) = false
- | eq_fm (Imp (fm1, fm2)) (Dvd (inta, num)) = false
- | eq_fm (Dvd (inta, num)) (Iff (fm1, fm2)) = false
- | eq_fm (Iff (fm1, fm2)) (Dvd (inta, num)) = false
- | eq_fm (Dvd (inta, num)) (E fm) = false
- | eq_fm (E fm) (Dvd (inta, num)) = false
- | eq_fm (Dvd (inta, num)) (A fm) = false
- | eq_fm (A fm) (Dvd (inta, num)) = false
- | eq_fm (Dvd (inta, num)) (Closed nat) = false
- | eq_fm (Closed nat) (Dvd (inta, num)) = false
- | eq_fm (Dvd (inta, num)) (NClosed nat) = false
- | eq_fm (NClosed nat) (Dvd (inta, num)) = false
- | eq_fm (NDvd (inta, num)) (Not fm) = false
- | eq_fm (Not fm) (NDvd (inta, num)) = false
- | eq_fm (NDvd (inta, num)) (And (fm1, fm2)) = false
- | eq_fm (And (fm1, fm2)) (NDvd (inta, num)) = false
- | eq_fm (NDvd (inta, num)) (Or (fm1, fm2)) = false
- | eq_fm (Or (fm1, fm2)) (NDvd (inta, num)) = false
- | eq_fm (NDvd (inta, num)) (Imp (fm1, fm2)) = false
- | eq_fm (Imp (fm1, fm2)) (NDvd (inta, num)) = false
- | eq_fm (NDvd (inta, num)) (Iff (fm1, fm2)) = false
- | eq_fm (Iff (fm1, fm2)) (NDvd (inta, num)) = false
- | eq_fm (NDvd (inta, num)) (E fm) = false
- | eq_fm (E fm) (NDvd (inta, num)) = false
- | eq_fm (NDvd (inta, num)) (A fm) = false
- | eq_fm (A fm) (NDvd (inta, num)) = false
- | eq_fm (NDvd (inta, num)) (Closed nat) = false
- | eq_fm (Closed nat) (NDvd (inta, num)) = false
- | eq_fm (NDvd (inta, num)) (NClosed nat) = false
- | eq_fm (NClosed nat) (NDvd (inta, num)) = false
- | eq_fm (Not fm) (And (fm1, fm2)) = false
- | eq_fm (And (fm1, fm2)) (Not fm) = false
- | eq_fm (Not fm) (Or (fm1, fm2)) = false
- | eq_fm (Or (fm1, fm2)) (Not fm) = false
- | eq_fm (Not fm) (Imp (fm1, fm2)) = false
- | eq_fm (Imp (fm1, fm2)) (Not fm) = false
- | eq_fm (Not fm) (Iff (fm1, fm2)) = false
- | eq_fm (Iff (fm1, fm2)) (Not fm) = false
- | eq_fm (Not fma) (E fm) = false
- | eq_fm (E fma) (Not fm) = false
- | eq_fm (Not fma) (A fm) = false
- | eq_fm (A fma) (Not fm) = false
- | eq_fm (Not fm) (Closed nat) = false
- | eq_fm (Closed nat) (Not fm) = false
- | eq_fm (Not fm) (NClosed nat) = false
- | eq_fm (NClosed nat) (Not fm) = false
- | eq_fm (And (fm1a, fm2a)) (Or (fm1, fm2)) = false
- | eq_fm (Or (fm1a, fm2a)) (And (fm1, fm2)) = false
- | eq_fm (And (fm1a, fm2a)) (Imp (fm1, fm2)) = false
- | eq_fm (Imp (fm1a, fm2a)) (And (fm1, fm2)) = false
- | eq_fm (And (fm1a, fm2a)) (Iff (fm1, fm2)) = false
- | eq_fm (Iff (fm1a, fm2a)) (And (fm1, fm2)) = false
- | eq_fm (And (fm1, fm2)) (E fm) = false
- | eq_fm (E fm) (And (fm1, fm2)) = false
- | eq_fm (And (fm1, fm2)) (A fm) = false
- | eq_fm (A fm) (And (fm1, fm2)) = false
- | eq_fm (And (fm1, fm2)) (Closed nat) = false
- | eq_fm (Closed nat) (And (fm1, fm2)) = false
- | eq_fm (And (fm1, fm2)) (NClosed nat) = false
- | eq_fm (NClosed nat) (And (fm1, fm2)) = false
- | eq_fm (Or (fm1a, fm2a)) (Imp (fm1, fm2)) = false
- | eq_fm (Imp (fm1a, fm2a)) (Or (fm1, fm2)) = false
- | eq_fm (Or (fm1a, fm2a)) (Iff (fm1, fm2)) = false
- | eq_fm (Iff (fm1a, fm2a)) (Or (fm1, fm2)) = false
- | eq_fm (Or (fm1, fm2)) (E fm) = false
- | eq_fm (E fm) (Or (fm1, fm2)) = false
- | eq_fm (Or (fm1, fm2)) (A fm) = false
- | eq_fm (A fm) (Or (fm1, fm2)) = false
- | eq_fm (Or (fm1, fm2)) (Closed nat) = false
- | eq_fm (Closed nat) (Or (fm1, fm2)) = false
- | eq_fm (Or (fm1, fm2)) (NClosed nat) = false
- | eq_fm (NClosed nat) (Or (fm1, fm2)) = false
- | eq_fm (Imp (fm1a, fm2a)) (Iff (fm1, fm2)) = false
- | eq_fm (Iff (fm1a, fm2a)) (Imp (fm1, fm2)) = false
- | eq_fm (Imp (fm1, fm2)) (E fm) = false
- | eq_fm (E fm) (Imp (fm1, fm2)) = false
- | eq_fm (Imp (fm1, fm2)) (A fm) = false
- | eq_fm (A fm) (Imp (fm1, fm2)) = false
- | eq_fm (Imp (fm1, fm2)) (Closed nat) = false
- | eq_fm (Closed nat) (Imp (fm1, fm2)) = false
- | eq_fm (Imp (fm1, fm2)) (NClosed nat) = false
- | eq_fm (NClosed nat) (Imp (fm1, fm2)) = false
- | eq_fm (Iff (fm1, fm2)) (E fm) = false
- | eq_fm (E fm) (Iff (fm1, fm2)) = false
- | eq_fm (Iff (fm1, fm2)) (A fm) = false
- | eq_fm (A fm) (Iff (fm1, fm2)) = false
- | eq_fm (Iff (fm1, fm2)) (Closed nat) = false
- | eq_fm (Closed nat) (Iff (fm1, fm2)) = false
- | eq_fm (Iff (fm1, fm2)) (NClosed nat) = false
- | eq_fm (NClosed nat) (Iff (fm1, fm2)) = false
- | eq_fm (E fma) (A fm) = false
- | eq_fm (A fma) (E fm) = false
- | eq_fm (E fm) (Closed nat) = false
- | eq_fm (Closed nat) (E fm) = false
- | eq_fm (E fm) (NClosed nat) = false
- | eq_fm (NClosed nat) (E fm) = false
- | eq_fm (A fm) (Closed nat) = false
- | eq_fm (Closed nat) (A fm) = false
- | eq_fm (A fm) (NClosed nat) = false
- | eq_fm (NClosed nat) (A fm) = false
- | eq_fm (Closed nata) (NClosed nat) = false
- | eq_fm (NClosed nata) (Closed nat) = false;
-
-fun djf f p q =
- (if eq_fm q T then T
- else (if eq_fm q F then f p
- else (case f p of T => T | F => q | Lt _ => Or (f p, q)
- | Le _ => Or (f p, q) | Gt _ => Or (f p, q)
- | Ge _ => Or (f p, q) | Eq _ => Or (f p, q)
- | NEq _ => Or (f p, q) | Dvd (_, _) => Or (f p, q)
- | NDvd (_, _) => Or (f p, q) | Not _ => Or (f p, q)
- | And (_, _) => Or (f p, q) | Or (_, _) => Or (f p, q)
- | Imp (_, _) => Or (f p, q) | Iff (_, _) => Or (f p, q)
- | E _ => Or (f p, q) | A _ => Or (f p, q)
- | Closed _ => Or (f p, q) | NClosed _ => Or (f p, q))));
-
-fun foldr f [] a = a
- | foldr f (x :: xs) a = f x (foldr f xs a);
-
-fun evaldjf f ps = foldr (djf f) ps F;
-
-fun dj f p = evaldjf f (disjuncts p);
-
-fun disj p q =
- (if eq_fm p T orelse eq_fm q T then T
- else (if eq_fm p F then q else (if eq_fm q F then p else Or (p, q))));
-
-fun minus_nat n m = IntInf.max (0, (IntInf.- (n, m)));
-
-fun decrnum (Bound n) = Bound (minus_nat n (1 : IntInf.int))
- | decrnum (Neg a) = Neg (decrnum a)
- | decrnum (Add (a, b)) = Add (decrnum a, decrnum b)
- | decrnum (Sub (a, b)) = Sub (decrnum a, decrnum b)
- | decrnum (Mul (c, a)) = Mul (c, decrnum a)
- | decrnum (Cn (n, i, a)) = Cn (minus_nat n (1 : IntInf.int), i, decrnum a)
- | decrnum (C u) = C u;
-
-fun decr (Lt a) = Lt (decrnum a)
- | decr (Le a) = Le (decrnum a)
- | decr (Gt a) = Gt (decrnum a)
- | decr (Ge a) = Ge (decrnum a)
- | decr (Eq a) = Eq (decrnum a)
- | decr (NEq a) = NEq (decrnum a)
- | decr (Dvd (i, a)) = Dvd (i, decrnum a)
- | decr (NDvd (i, a)) = NDvd (i, decrnum a)
- | decr (Not p) = Not (decr p)
- | decr (And (p, q)) = And (decr p, decr q)
- | decr (Or (p, q)) = Or (decr p, decr q)
- | decr (Imp (p, q)) = Imp (decr p, decr q)
- | decr (Iff (p, q)) = Iff (decr p, decr q)
- | decr T = T
- | decr F = F
- | decr (E ao) = E ao
- | decr (A ap) = A ap
- | decr (Closed aq) = Closed aq
- | decr (NClosed ar) = NClosed ar;
-
-fun concat_map f [] = []
- | concat_map f (x :: xs) = append (f x) (concat_map f xs);
-
-fun numsubst0 t (C c) = C c
- | numsubst0 t (Bound n) =
- (if ((n : IntInf.int) = (0 : IntInf.int)) then t else Bound n)
- | numsubst0 t (Neg a) = Neg (numsubst0 t a)
- | numsubst0 t (Add (a, b)) = Add (numsubst0 t a, numsubst0 t b)
- | numsubst0 t (Sub (a, b)) = Sub (numsubst0 t a, numsubst0 t b)
- | numsubst0 t (Mul (i, a)) = Mul (i, numsubst0 t a)
- | numsubst0 t (Cn (v, i, a)) =
- (if ((v : IntInf.int) = (0 : IntInf.int))
- then Add (Mul (i, t), numsubst0 t a)
- else Cn (suc (minus_nat v (1 : IntInf.int)), i, numsubst0 t a));
-
-fun subst0 t T = T
- | subst0 t F = F
- | subst0 t (Lt a) = Lt (numsubst0 t a)
- | subst0 t (Le a) = Le (numsubst0 t a)
- | subst0 t (Gt a) = Gt (numsubst0 t a)
- | subst0 t (Ge a) = Ge (numsubst0 t a)
- | subst0 t (Eq a) = Eq (numsubst0 t a)
- | subst0 t (NEq a) = NEq (numsubst0 t a)
- | subst0 t (Dvd (i, a)) = Dvd (i, numsubst0 t a)
- | subst0 t (NDvd (i, a)) = NDvd (i, numsubst0 t a)
- | subst0 t (Not p) = Not (subst0 t p)
- | subst0 t (And (p, q)) = And (subst0 t p, subst0 t q)
- | subst0 t (Or (p, q)) = Or (subst0 t p, subst0 t q)
- | subst0 t (Imp (p, q)) = Imp (subst0 t p, subst0 t q)
- | subst0 t (Iff (p, q)) = Iff (subst0 t p, subst0 t q)
- | subst0 t (Closed p) = Closed p
- | subst0 t (NClosed p) = NClosed p;
-
-fun minusinf (And (p, q)) = And (minusinf p, minusinf q)
- | minusinf (Or (p, q)) = Or (minusinf p, minusinf q)
- | minusinf T = T
- | minusinf F = F
- | minusinf (Lt (C bo)) = Lt (C bo)
- | minusinf (Lt (Bound bp)) = Lt (Bound bp)
- | minusinf (Lt (Neg bt)) = Lt (Neg bt)
- | minusinf (Lt (Add (bu, bv))) = Lt (Add (bu, bv))
- | minusinf (Lt (Sub (bw, bx))) = Lt (Sub (bw, bx))
- | minusinf (Lt (Mul (by, bz))) = Lt (Mul (by, bz))
- | minusinf (Le (C co)) = Le (C co)
- | minusinf (Le (Bound cp)) = Le (Bound cp)
- | minusinf (Le (Neg ct)) = Le (Neg ct)
- | minusinf (Le (Add (cu, cv))) = Le (Add (cu, cv))
- | minusinf (Le (Sub (cw, cx))) = Le (Sub (cw, cx))
- | minusinf (Le (Mul (cy, cz))) = Le (Mul (cy, cz))
- | minusinf (Gt (C doa)) = Gt (C doa)
- | minusinf (Gt (Bound dp)) = Gt (Bound dp)
- | minusinf (Gt (Neg dt)) = Gt (Neg dt)
- | minusinf (Gt (Add (du, dv))) = Gt (Add (du, dv))
- | minusinf (Gt (Sub (dw, dx))) = Gt (Sub (dw, dx))
- | minusinf (Gt (Mul (dy, dz))) = Gt (Mul (dy, dz))
- | minusinf (Ge (C eo)) = Ge (C eo)
- | minusinf (Ge (Bound ep)) = Ge (Bound ep)
- | minusinf (Ge (Neg et)) = Ge (Neg et)
- | minusinf (Ge (Add (eu, ev))) = Ge (Add (eu, ev))
- | minusinf (Ge (Sub (ew, ex))) = Ge (Sub (ew, ex))
- | minusinf (Ge (Mul (ey, ez))) = Ge (Mul (ey, ez))
- | minusinf (Eq (C fo)) = Eq (C fo)
- | minusinf (Eq (Bound fp)) = Eq (Bound fp)
- | minusinf (Eq (Neg ft)) = Eq (Neg ft)
- | minusinf (Eq (Add (fu, fv))) = Eq (Add (fu, fv))
- | minusinf (Eq (Sub (fw, fx))) = Eq (Sub (fw, fx))
- | minusinf (Eq (Mul (fy, fz))) = Eq (Mul (fy, fz))
- | minusinf (NEq (C go)) = NEq (C go)
- | minusinf (NEq (Bound gp)) = NEq (Bound gp)
- | minusinf (NEq (Neg gt)) = NEq (Neg gt)
- | minusinf (NEq (Add (gu, gv))) = NEq (Add (gu, gv))
- | minusinf (NEq (Sub (gw, gx))) = NEq (Sub (gw, gx))
- | minusinf (NEq (Mul (gy, gz))) = NEq (Mul (gy, gz))
- | minusinf (Dvd (aa, ab)) = Dvd (aa, ab)
- | minusinf (NDvd (ac, ad)) = NDvd (ac, ad)
- | minusinf (Not ae) = Not ae
- | minusinf (Imp (aj, ak)) = Imp (aj, ak)
- | minusinf (Iff (al, am)) = Iff (al, am)
- | minusinf (E an) = E an
- | minusinf (A ao) = A ao
- | minusinf (Closed ap) = Closed ap
- | minusinf (NClosed aq) = NClosed aq
- | minusinf (Lt (Cn (cm, c, e))) =
- (if ((cm : IntInf.int) = (0 : IntInf.int)) then T
- else Lt (Cn (suc (minus_nat cm (1 : IntInf.int)), c, e)))
- | minusinf (Le (Cn (dm, c, e))) =
- (if ((dm : IntInf.int) = (0 : IntInf.int)) then T
- else Le (Cn (suc (minus_nat dm (1 : IntInf.int)), c, e)))
- | minusinf (Gt (Cn (em, c, e))) =
- (if ((em : IntInf.int) = (0 : IntInf.int)) then F
- else Gt (Cn (suc (minus_nat em (1 : IntInf.int)), c, e)))
- | minusinf (Ge (Cn (fm, c, e))) =
- (if ((fm : IntInf.int) = (0 : IntInf.int)) then F
- else Ge (Cn (suc (minus_nat fm (1 : IntInf.int)), c, e)))
- | minusinf (Eq (Cn (gm, c, e))) =
- (if ((gm : IntInf.int) = (0 : IntInf.int)) then F
- else Eq (Cn (suc (minus_nat gm (1 : IntInf.int)), c, e)))
- | minusinf (NEq (Cn (hm, c, e))) =
- (if ((hm : IntInf.int) = (0 : IntInf.int)) then T
- else NEq (Cn (suc (minus_nat hm (1 : IntInf.int)), c, e)));
-
-val eq_int = {eq = (fn a => fn b => ((a : IntInf.int) = b))} : IntInf.int eq;
-
-val zero_int : IntInf.int = (0 : IntInf.int);
-
-type 'a zero = {zero : 'a};
-val zero = #zero : 'a zero -> 'a;
-
-val zero_inta = {zero = zero_int} : IntInf.int zero;
-
-type 'a times = {times : 'a -> 'a -> 'a};
-val times = #times : 'a times -> 'a -> 'a -> 'a;
-
-type 'a no_zero_divisors =
- {times_no_zero_divisors : 'a times, zero_no_zero_divisors : 'a zero};
-val times_no_zero_divisors = #times_no_zero_divisors :
- 'a no_zero_divisors -> 'a times;
-val zero_no_zero_divisors = #zero_no_zero_divisors :
- 'a no_zero_divisors -> 'a zero;
-
-val times_int = {times = (fn a => fn b => IntInf.* (a, b))} : IntInf.int times;
-
-val no_zero_divisors_int =
- {times_no_zero_divisors = times_int, zero_no_zero_divisors = zero_inta} :
- IntInf.int no_zero_divisors;
-
-type 'a one = {one : 'a};
-val one = #one : 'a one -> 'a;
-
-type 'a zero_neq_one = {one_zero_neq_one : 'a one, zero_zero_neq_one : 'a zero};
-val one_zero_neq_one = #one_zero_neq_one : 'a zero_neq_one -> 'a one;
-val zero_zero_neq_one = #zero_zero_neq_one : 'a zero_neq_one -> 'a zero;
-
-type 'a semigroup_mult = {times_semigroup_mult : 'a times};
-val times_semigroup_mult = #times_semigroup_mult :
- 'a semigroup_mult -> 'a times;
-
-type 'a plus = {plus : 'a -> 'a -> 'a};
-val plus = #plus : 'a plus -> 'a -> 'a -> 'a;
-
-type 'a semigroup_add = {plus_semigroup_add : 'a plus};
-val plus_semigroup_add = #plus_semigroup_add : 'a semigroup_add -> 'a plus;
-
-type 'a ab_semigroup_add = {semigroup_add_ab_semigroup_add : 'a semigroup_add};
-val semigroup_add_ab_semigroup_add = #semigroup_add_ab_semigroup_add :
- 'a ab_semigroup_add -> 'a semigroup_add;
-
-type 'a semiring =
- {ab_semigroup_add_semiring : 'a ab_semigroup_add,
- semigroup_mult_semiring : 'a semigroup_mult};
-val ab_semigroup_add_semiring = #ab_semigroup_add_semiring :
- 'a semiring -> 'a ab_semigroup_add;
-val semigroup_mult_semiring = #semigroup_mult_semiring :
- 'a semiring -> 'a semigroup_mult;
-
-type 'a mult_zero = {times_mult_zero : 'a times, zero_mult_zero : 'a zero};
-val times_mult_zero = #times_mult_zero : 'a mult_zero -> 'a times;
-val zero_mult_zero = #zero_mult_zero : 'a mult_zero -> 'a zero;
-
-type 'a monoid_add =
- {semigroup_add_monoid_add : 'a semigroup_add, zero_monoid_add : 'a zero};
-val semigroup_add_monoid_add = #semigroup_add_monoid_add :
- 'a monoid_add -> 'a semigroup_add;
-val zero_monoid_add = #zero_monoid_add : 'a monoid_add -> 'a zero;
-
-type 'a comm_monoid_add =
- {ab_semigroup_add_comm_monoid_add : 'a ab_semigroup_add,
- monoid_add_comm_monoid_add : 'a monoid_add};
-val ab_semigroup_add_comm_monoid_add = #ab_semigroup_add_comm_monoid_add :
- 'a comm_monoid_add -> 'a ab_semigroup_add;
-val monoid_add_comm_monoid_add = #monoid_add_comm_monoid_add :
- 'a comm_monoid_add -> 'a monoid_add;
-
-type 'a semiring_0 =
- {comm_monoid_add_semiring_0 : 'a comm_monoid_add,
- mult_zero_semiring_0 : 'a mult_zero, semiring_semiring_0 : 'a semiring};
-val comm_monoid_add_semiring_0 = #comm_monoid_add_semiring_0 :
- 'a semiring_0 -> 'a comm_monoid_add;
-val mult_zero_semiring_0 = #mult_zero_semiring_0 :
- 'a semiring_0 -> 'a mult_zero;
-val semiring_semiring_0 = #semiring_semiring_0 : 'a semiring_0 -> 'a semiring;
-
-type 'a power = {one_power : 'a one, times_power : 'a times};
-val one_power = #one_power : 'a power -> 'a one;
-val times_power = #times_power : 'a power -> 'a times;
-
-type 'a monoid_mult =
- {semigroup_mult_monoid_mult : 'a semigroup_mult,
- power_monoid_mult : 'a power};
-val semigroup_mult_monoid_mult = #semigroup_mult_monoid_mult :
- 'a monoid_mult -> 'a semigroup_mult;
-val power_monoid_mult = #power_monoid_mult : 'a monoid_mult -> 'a power;
-
-type 'a semiring_1 =
- {monoid_mult_semiring_1 : 'a monoid_mult,
- semiring_0_semiring_1 : 'a semiring_0,
- zero_neq_one_semiring_1 : 'a zero_neq_one};
-val monoid_mult_semiring_1 = #monoid_mult_semiring_1 :
- 'a semiring_1 -> 'a monoid_mult;
-val semiring_0_semiring_1 = #semiring_0_semiring_1 :
- 'a semiring_1 -> 'a semiring_0;
-val zero_neq_one_semiring_1 = #zero_neq_one_semiring_1 :
- 'a semiring_1 -> 'a zero_neq_one;
-
-type 'a cancel_semigroup_add =
- {semigroup_add_cancel_semigroup_add : 'a semigroup_add};
-val semigroup_add_cancel_semigroup_add = #semigroup_add_cancel_semigroup_add :
- 'a cancel_semigroup_add -> 'a semigroup_add;
-
-type 'a cancel_ab_semigroup_add =
- {ab_semigroup_add_cancel_ab_semigroup_add : 'a ab_semigroup_add,
- cancel_semigroup_add_cancel_ab_semigroup_add : 'a cancel_semigroup_add};
-val ab_semigroup_add_cancel_ab_semigroup_add =
- #ab_semigroup_add_cancel_ab_semigroup_add :
- 'a cancel_ab_semigroup_add -> 'a ab_semigroup_add;
-val cancel_semigroup_add_cancel_ab_semigroup_add =
- #cancel_semigroup_add_cancel_ab_semigroup_add :
- 'a cancel_ab_semigroup_add -> 'a cancel_semigroup_add;
-
-type 'a cancel_comm_monoid_add =
- {cancel_ab_semigroup_add_cancel_comm_monoid_add : 'a cancel_ab_semigroup_add,
- comm_monoid_add_cancel_comm_monoid_add : 'a comm_monoid_add};
-val cancel_ab_semigroup_add_cancel_comm_monoid_add =
- #cancel_ab_semigroup_add_cancel_comm_monoid_add :
- 'a cancel_comm_monoid_add -> 'a cancel_ab_semigroup_add;
-val comm_monoid_add_cancel_comm_monoid_add =
- #comm_monoid_add_cancel_comm_monoid_add :
- 'a cancel_comm_monoid_add -> 'a comm_monoid_add;
-
-type 'a semiring_0_cancel =
- {cancel_comm_monoid_add_semiring_0_cancel : 'a cancel_comm_monoid_add,
- semiring_0_semiring_0_cancel : 'a semiring_0};
-val cancel_comm_monoid_add_semiring_0_cancel =
- #cancel_comm_monoid_add_semiring_0_cancel :
- 'a semiring_0_cancel -> 'a cancel_comm_monoid_add;
-val semiring_0_semiring_0_cancel = #semiring_0_semiring_0_cancel :
- 'a semiring_0_cancel -> 'a semiring_0;
-
-type 'a semiring_1_cancel =
- {semiring_0_cancel_semiring_1_cancel : 'a semiring_0_cancel,
- semiring_1_semiring_1_cancel : 'a semiring_1};
-val semiring_0_cancel_semiring_1_cancel = #semiring_0_cancel_semiring_1_cancel :
- 'a semiring_1_cancel -> 'a semiring_0_cancel;
-val semiring_1_semiring_1_cancel = #semiring_1_semiring_1_cancel :
- 'a semiring_1_cancel -> 'a semiring_1;
-
-type 'a dvd = {times_dvd : 'a times};
-val times_dvd = #times_dvd : 'a dvd -> 'a times;
-
-type 'a ab_semigroup_mult =
- {semigroup_mult_ab_semigroup_mult : 'a semigroup_mult};
-val semigroup_mult_ab_semigroup_mult = #semigroup_mult_ab_semigroup_mult :
- 'a ab_semigroup_mult -> 'a semigroup_mult;
-
-type 'a comm_semiring =
- {ab_semigroup_mult_comm_semiring : 'a ab_semigroup_mult,
- semiring_comm_semiring : 'a semiring};
-val ab_semigroup_mult_comm_semiring = #ab_semigroup_mult_comm_semiring :
- 'a comm_semiring -> 'a ab_semigroup_mult;
-val semiring_comm_semiring = #semiring_comm_semiring :
- 'a comm_semiring -> 'a semiring;
-
-type 'a comm_semiring_0 =
- {comm_semiring_comm_semiring_0 : 'a comm_semiring,
- semiring_0_comm_semiring_0 : 'a semiring_0};
-val comm_semiring_comm_semiring_0 = #comm_semiring_comm_semiring_0 :
- 'a comm_semiring_0 -> 'a comm_semiring;
-val semiring_0_comm_semiring_0 = #semiring_0_comm_semiring_0 :
- 'a comm_semiring_0 -> 'a semiring_0;
-
-type 'a comm_monoid_mult =
- {ab_semigroup_mult_comm_monoid_mult : 'a ab_semigroup_mult,
- monoid_mult_comm_monoid_mult : 'a monoid_mult};
-val ab_semigroup_mult_comm_monoid_mult = #ab_semigroup_mult_comm_monoid_mult :
- 'a comm_monoid_mult -> 'a ab_semigroup_mult;
-val monoid_mult_comm_monoid_mult = #monoid_mult_comm_monoid_mult :
- 'a comm_monoid_mult -> 'a monoid_mult;
-
-type 'a comm_semiring_1 =
- {comm_monoid_mult_comm_semiring_1 : 'a comm_monoid_mult,
- comm_semiring_0_comm_semiring_1 : 'a comm_semiring_0,
- dvd_comm_semiring_1 : 'a dvd, semiring_1_comm_semiring_1 : 'a semiring_1};
-val comm_monoid_mult_comm_semiring_1 = #comm_monoid_mult_comm_semiring_1 :
- 'a comm_semiring_1 -> 'a comm_monoid_mult;
-val comm_semiring_0_comm_semiring_1 = #comm_semiring_0_comm_semiring_1 :
- 'a comm_semiring_1 -> 'a comm_semiring_0;
-val dvd_comm_semiring_1 = #dvd_comm_semiring_1 : 'a comm_semiring_1 -> 'a dvd;
-val semiring_1_comm_semiring_1 = #semiring_1_comm_semiring_1 :
- 'a comm_semiring_1 -> 'a semiring_1;
-
-type 'a comm_semiring_0_cancel =
- {comm_semiring_0_comm_semiring_0_cancel : 'a comm_semiring_0,
- semiring_0_cancel_comm_semiring_0_cancel : 'a semiring_0_cancel};
-val comm_semiring_0_comm_semiring_0_cancel =
- #comm_semiring_0_comm_semiring_0_cancel :
- 'a comm_semiring_0_cancel -> 'a comm_semiring_0;
-val semiring_0_cancel_comm_semiring_0_cancel =
- #semiring_0_cancel_comm_semiring_0_cancel :
- 'a comm_semiring_0_cancel -> 'a semiring_0_cancel;
-
-type 'a comm_semiring_1_cancel =
- {comm_semiring_0_cancel_comm_semiring_1_cancel : 'a comm_semiring_0_cancel,
- comm_semiring_1_comm_semiring_1_cancel : 'a comm_semiring_1,
- semiring_1_cancel_comm_semiring_1_cancel : 'a semiring_1_cancel};
-val comm_semiring_0_cancel_comm_semiring_1_cancel =
- #comm_semiring_0_cancel_comm_semiring_1_cancel :
- 'a comm_semiring_1_cancel -> 'a comm_semiring_0_cancel;
-val comm_semiring_1_comm_semiring_1_cancel =
- #comm_semiring_1_comm_semiring_1_cancel :
- 'a comm_semiring_1_cancel -> 'a comm_semiring_1;
-val semiring_1_cancel_comm_semiring_1_cancel =
- #semiring_1_cancel_comm_semiring_1_cancel :
- 'a comm_semiring_1_cancel -> 'a semiring_1_cancel;
-
-type 'a diva = {dvd_div : 'a dvd, diva : 'a -> 'a -> 'a, moda : 'a -> 'a -> 'a};
-val dvd_div = #dvd_div : 'a diva -> 'a dvd;
-val diva = #diva : 'a diva -> 'a -> 'a -> 'a;
-val moda = #moda : 'a diva -> 'a -> 'a -> 'a;
-
-type 'a semiring_div =
- {div_semiring_div : 'a diva,
- comm_semiring_1_cancel_semiring_div : 'a comm_semiring_1_cancel,
- no_zero_divisors_semiring_div : 'a no_zero_divisors};
-val div_semiring_div = #div_semiring_div : 'a semiring_div -> 'a diva;
-val comm_semiring_1_cancel_semiring_div = #comm_semiring_1_cancel_semiring_div :
- 'a semiring_div -> 'a comm_semiring_1_cancel;
-val no_zero_divisors_semiring_div = #no_zero_divisors_semiring_div :
- 'a semiring_div -> 'a no_zero_divisors;
-
-val one_int : IntInf.int = (1 : IntInf.int);
-
-val one_inta = {one = one_int} : IntInf.int one;
-
-val zero_neq_one_int =
- {one_zero_neq_one = one_inta, zero_zero_neq_one = zero_inta} :
- IntInf.int zero_neq_one;
-
-val semigroup_mult_int = {times_semigroup_mult = times_int} :
- IntInf.int semigroup_mult;
-
-val plus_int = {plus = (fn a => fn b => IntInf.+ (a, b))} : IntInf.int plus;
-
-val semigroup_add_int = {plus_semigroup_add = plus_int} :
- IntInf.int semigroup_add;
-
-val ab_semigroup_add_int = {semigroup_add_ab_semigroup_add = semigroup_add_int}
- : IntInf.int ab_semigroup_add;
-
-val semiring_int =
- {ab_semigroup_add_semiring = ab_semigroup_add_int,
- semigroup_mult_semiring = semigroup_mult_int}
- : IntInf.int semiring;
-
-val mult_zero_int = {times_mult_zero = times_int, zero_mult_zero = zero_inta} :
- IntInf.int mult_zero;
-
-val monoid_add_int =
- {semigroup_add_monoid_add = semigroup_add_int, zero_monoid_add = zero_inta} :
- IntInf.int monoid_add;
-
-val comm_monoid_add_int =
- {ab_semigroup_add_comm_monoid_add = ab_semigroup_add_int,
- monoid_add_comm_monoid_add = monoid_add_int}
- : IntInf.int comm_monoid_add;
-
-val semiring_0_int =
- {comm_monoid_add_semiring_0 = comm_monoid_add_int,
- mult_zero_semiring_0 = mult_zero_int, semiring_semiring_0 = semiring_int}
- : IntInf.int semiring_0;
-
-val power_int = {one_power = one_inta, times_power = times_int} :
- IntInf.int power;
-
-val monoid_mult_int =
- {semigroup_mult_monoid_mult = semigroup_mult_int,
- power_monoid_mult = power_int}
- : IntInf.int monoid_mult;
-
-val semiring_1_int =
- {monoid_mult_semiring_1 = monoid_mult_int,
- semiring_0_semiring_1 = semiring_0_int,
- zero_neq_one_semiring_1 = zero_neq_one_int}
- : IntInf.int semiring_1;
-
-val cancel_semigroup_add_int =
- {semigroup_add_cancel_semigroup_add = semigroup_add_int} :
- IntInf.int cancel_semigroup_add;
-
-val cancel_ab_semigroup_add_int =
- {ab_semigroup_add_cancel_ab_semigroup_add = ab_semigroup_add_int,
- cancel_semigroup_add_cancel_ab_semigroup_add = cancel_semigroup_add_int}
- : IntInf.int cancel_ab_semigroup_add;
-
-val cancel_comm_monoid_add_int =
- {cancel_ab_semigroup_add_cancel_comm_monoid_add = cancel_ab_semigroup_add_int,
- comm_monoid_add_cancel_comm_monoid_add = comm_monoid_add_int}
- : IntInf.int cancel_comm_monoid_add;
-
-val semiring_0_cancel_int =
- {cancel_comm_monoid_add_semiring_0_cancel = cancel_comm_monoid_add_int,
- semiring_0_semiring_0_cancel = semiring_0_int}
- : IntInf.int semiring_0_cancel;
-
-val semiring_1_cancel_int =
- {semiring_0_cancel_semiring_1_cancel = semiring_0_cancel_int,
- semiring_1_semiring_1_cancel = semiring_1_int}
- : IntInf.int semiring_1_cancel;
-
-val dvd_int = {times_dvd = times_int} : IntInf.int dvd;
-
-val ab_semigroup_mult_int =
- {semigroup_mult_ab_semigroup_mult = semigroup_mult_int} :
- IntInf.int ab_semigroup_mult;
-
-val comm_semiring_int =
- {ab_semigroup_mult_comm_semiring = ab_semigroup_mult_int,
- semiring_comm_semiring = semiring_int}
- : IntInf.int comm_semiring;
-
-val comm_semiring_0_int =
- {comm_semiring_comm_semiring_0 = comm_semiring_int,
- semiring_0_comm_semiring_0 = semiring_0_int}
- : IntInf.int comm_semiring_0;
-
-val comm_monoid_mult_int =
- {ab_semigroup_mult_comm_monoid_mult = ab_semigroup_mult_int,
- monoid_mult_comm_monoid_mult = monoid_mult_int}
- : IntInf.int comm_monoid_mult;
-
-val comm_semiring_1_int =
- {comm_monoid_mult_comm_semiring_1 = comm_monoid_mult_int,
- comm_semiring_0_comm_semiring_1 = comm_semiring_0_int,
- dvd_comm_semiring_1 = dvd_int, semiring_1_comm_semiring_1 = semiring_1_int}
- : IntInf.int comm_semiring_1;
-
-val comm_semiring_0_cancel_int =
- {comm_semiring_0_comm_semiring_0_cancel = comm_semiring_0_int,
- semiring_0_cancel_comm_semiring_0_cancel = semiring_0_cancel_int}
- : IntInf.int comm_semiring_0_cancel;
-
-val comm_semiring_1_cancel_int =
- {comm_semiring_0_cancel_comm_semiring_1_cancel = comm_semiring_0_cancel_int,
- comm_semiring_1_comm_semiring_1_cancel = comm_semiring_1_int,
- semiring_1_cancel_comm_semiring_1_cancel = semiring_1_cancel_int}
- : IntInf.int comm_semiring_1_cancel;
-
-fun abs_int i = (if IntInf.< (i, (0 : IntInf.int)) then IntInf.~ i else i);
-
-fun split f (a, b) = f a b;
-
-fun sgn_int i =
- (if ((i : IntInf.int) = (0 : IntInf.int)) then (0 : IntInf.int)
- else (if IntInf.< ((0 : IntInf.int), i) then (1 : IntInf.int)
- else IntInf.~ (1 : IntInf.int)));
-
-fun apsnd f (x, y) = (x, f y);
-
-fun divmod_int k l =
- (if ((k : IntInf.int) = (0 : IntInf.int))
- then ((0 : IntInf.int), (0 : IntInf.int))
- else (if ((l : IntInf.int) = (0 : IntInf.int)) then ((0 : IntInf.int), k)
- else apsnd (fn a => IntInf.* (sgn_int l, a))
- (if (((sgn_int k) : IntInf.int) = (sgn_int l))
- then IntInf.divMod (IntInf.abs k, IntInf.abs l)
- else let
- val (r, s) =
- IntInf.divMod (IntInf.abs k, IntInf.abs l);
- in
- (if ((s : IntInf.int) = (0 : IntInf.int))
- then (IntInf.~ r, (0 : IntInf.int))
- else (IntInf.- (IntInf.~ r, (1 : IntInf.int)),
- IntInf.- (abs_int l, s)))
- end)));
-
-fun snd (a, b) = b;
-
-fun mod_int a b = snd (divmod_int a b);
-
-fun fst (a, b) = a;
-
-fun div_int a b = fst (divmod_int a b);
-
-val div_inta = {dvd_div = dvd_int, diva = div_int, moda = mod_int} :
- IntInf.int diva;
-
-val semiring_div_int =
- {div_semiring_div = div_inta,
- comm_semiring_1_cancel_semiring_div = comm_semiring_1_cancel_int,
- no_zero_divisors_semiring_div = no_zero_divisors_int}
- : IntInf.int semiring_div;
-
-fun dvd (A1_, A2_) a b =
- eqa A2_ (moda (div_semiring_div A1_) b a)
- (zero ((zero_no_zero_divisors o no_zero_divisors_semiring_div) A1_));
-
-fun num_case f1 f2 f3 f4 f5 f6 f7 (Mul (inta, num)) = f7 inta num
- | num_case f1 f2 f3 f4 f5 f6 f7 (Sub (num1, num2)) = f6 num1 num2
- | num_case f1 f2 f3 f4 f5 f6 f7 (Add (num1, num2)) = f5 num1 num2
- | num_case f1 f2 f3 f4 f5 f6 f7 (Neg num) = f4 num
- | num_case f1 f2 f3 f4 f5 f6 f7 (Cn (nat, inta, num)) = f3 nat inta num
- | num_case f1 f2 f3 f4 f5 f6 f7 (Bound nat) = f2 nat
- | num_case f1 f2 f3 f4 f5 f6 f7 (C inta) = f1 inta;
-
-fun nummul i (C j) = C (IntInf.* (i, j))
- | nummul i (Cn (n, c, t)) = Cn (n, IntInf.* (c, i), nummul i t)
- | nummul i (Bound v) = Mul (i, Bound v)
- | nummul i (Neg v) = Mul (i, Neg v)
- | nummul i (Add (v, va)) = Mul (i, Add (v, va))
- | nummul i (Sub (v, va)) = Mul (i, Sub (v, va))
- | nummul i (Mul (v, va)) = Mul (i, Mul (v, va));
-
-fun numneg t = nummul (IntInf.~ (1 : IntInf.int)) t;
-
-fun numadd (Cn (n1, c1, r1), Cn (n2, c2, r2)) =
- (if ((n1 : IntInf.int) = n2)
- then let
- val c = IntInf.+ (c1, c2);
- in
- (if ((c : IntInf.int) = (0 : IntInf.int)) then numadd (r1, r2)
- else Cn (n1, c, numadd (r1, r2)))
- end
- else (if IntInf.<= (n1, n2)
- then Cn (n1, c1, numadd (r1, Add (Mul (c2, Bound n2), r2)))
- else Cn (n2, c2, numadd (Add (Mul (c1, Bound n1), r1), r2))))
- | numadd (Cn (n1, c1, r1), C dd) = Cn (n1, c1, numadd (r1, C dd))
- | numadd (Cn (n1, c1, r1), Bound de) = Cn (n1, c1, numadd (r1, Bound de))
- | numadd (Cn (n1, c1, r1), Neg di) = Cn (n1, c1, numadd (r1, Neg di))
- | numadd (Cn (n1, c1, r1), Add (dj, dk)) =
- Cn (n1, c1, numadd (r1, Add (dj, dk)))
- | numadd (Cn (n1, c1, r1), Sub (dl, dm)) =
- Cn (n1, c1, numadd (r1, Sub (dl, dm)))
- | numadd (Cn (n1, c1, r1), Mul (dn, doa)) =
- Cn (n1, c1, numadd (r1, Mul (dn, doa)))
- | numadd (C w, Cn (n2, c2, r2)) = Cn (n2, c2, numadd (C w, r2))
- | numadd (Bound x, Cn (n2, c2, r2)) = Cn (n2, c2, numadd (Bound x, r2))
- | numadd (Neg ac, Cn (n2, c2, r2)) = Cn (n2, c2, numadd (Neg ac, r2))
- | numadd (Add (ad, ae), Cn (n2, c2, r2)) =
- Cn (n2, c2, numadd (Add (ad, ae), r2))
- | numadd (Sub (af, ag), Cn (n2, c2, r2)) =
- Cn (n2, c2, numadd (Sub (af, ag), r2))
- | numadd (Mul (ah, ai), Cn (n2, c2, r2)) =
- Cn (n2, c2, numadd (Mul (ah, ai), r2))
- | numadd (C b1, C b2) = C (IntInf.+ (b1, b2))
- | numadd (C aj, Bound bi) = Add (C aj, Bound bi)
- | numadd (C aj, Neg bm) = Add (C aj, Neg bm)
- | numadd (C aj, Add (bn, bo)) = Add (C aj, Add (bn, bo))
- | numadd (C aj, Sub (bp, bq)) = Add (C aj, Sub (bp, bq))
- | numadd (C aj, Mul (br, bs)) = Add (C aj, Mul (br, bs))
- | numadd (Bound ak, C cf) = Add (Bound ak, C cf)
- | numadd (Bound ak, Bound cg) = Add (Bound ak, Bound cg)
- | numadd (Bound ak, Neg ck) = Add (Bound ak, Neg ck)
- | numadd (Bound ak, Add (cl, cm)) = Add (Bound ak, Add (cl, cm))
- | numadd (Bound ak, Sub (cn, co)) = Add (Bound ak, Sub (cn, co))
- | numadd (Bound ak, Mul (cp, cq)) = Add (Bound ak, Mul (cp, cq))
- | numadd (Neg ao, C en) = Add (Neg ao, C en)
- | numadd (Neg ao, Bound eo) = Add (Neg ao, Bound eo)
- | numadd (Neg ao, Neg es) = Add (Neg ao, Neg es)
- | numadd (Neg ao, Add (et, eu)) = Add (Neg ao, Add (et, eu))
- | numadd (Neg ao, Sub (ev, ew)) = Add (Neg ao, Sub (ev, ew))
- | numadd (Neg ao, Mul (ex, ey)) = Add (Neg ao, Mul (ex, ey))
- | numadd (Add (ap, aq), C fl) = Add (Add (ap, aq), C fl)
- | numadd (Add (ap, aq), Bound fm) = Add (Add (ap, aq), Bound fm)
- | numadd (Add (ap, aq), Neg fq) = Add (Add (ap, aq), Neg fq)
- | numadd (Add (ap, aq), Add (fr, fs)) = Add (Add (ap, aq), Add (fr, fs))
- | numadd (Add (ap, aq), Sub (ft, fu)) = Add (Add (ap, aq), Sub (ft, fu))
- | numadd (Add (ap, aq), Mul (fv, fw)) = Add (Add (ap, aq), Mul (fv, fw))
- | numadd (Sub (ar, asa), C gj) = Add (Sub (ar, asa), C gj)
- | numadd (Sub (ar, asa), Bound gk) = Add (Sub (ar, asa), Bound gk)
- | numadd (Sub (ar, asa), Neg go) = Add (Sub (ar, asa), Neg go)
- | numadd (Sub (ar, asa), Add (gp, gq)) = Add (Sub (ar, asa), Add (gp, gq))
- | numadd (Sub (ar, asa), Sub (gr, gs)) = Add (Sub (ar, asa), Sub (gr, gs))
- | numadd (Sub (ar, asa), Mul (gt, gu)) = Add (Sub (ar, asa), Mul (gt, gu))
- | numadd (Mul (at, au), C hh) = Add (Mul (at, au), C hh)
- | numadd (Mul (at, au), Bound hi) = Add (Mul (at, au), Bound hi)
- | numadd (Mul (at, au), Neg hm) = Add (Mul (at, au), Neg hm)
- | numadd (Mul (at, au), Add (hn, ho)) = Add (Mul (at, au), Add (hn, ho))
- | numadd (Mul (at, au), Sub (hp, hq)) = Add (Mul (at, au), Sub (hp, hq))
- | numadd (Mul (at, au), Mul (hr, hs)) = Add (Mul (at, au), Mul (hr, hs));
-
-fun numsub s t =
- (if eq_num s t then C (0 : IntInf.int) else numadd (s, numneg t));
-
-fun simpnum (C j) = C j
- | simpnum (Bound n) = Cn (n, (1 : IntInf.int), C (0 : IntInf.int))
- | simpnum (Neg t) = numneg (simpnum t)
- | simpnum (Add (t, s)) = numadd (simpnum t, simpnum s)
- | simpnum (Sub (t, s)) = numsub (simpnum t) (simpnum s)
- | simpnum (Mul (i, t)) =
- (if ((i : IntInf.int) = (0 : IntInf.int)) then C (0 : IntInf.int)
- else nummul i (simpnum t))
- | simpnum (Cn (v, va, vb)) = Cn (v, va, vb);
-
-fun nota (Not p) = p
- | nota T = F
- | nota F = T
- | nota (Lt v) = Not (Lt v)
- | nota (Le v) = Not (Le v)
- | nota (Gt v) = Not (Gt v)
- | nota (Ge v) = Not (Ge v)
- | nota (Eq v) = Not (Eq v)
- | nota (NEq v) = Not (NEq v)
- | nota (Dvd (v, va)) = Not (Dvd (v, va))
- | nota (NDvd (v, va)) = Not (NDvd (v, va))
- | nota (And (v, va)) = Not (And (v, va))
- | nota (Or (v, va)) = Not (Or (v, va))
- | nota (Imp (v, va)) = Not (Imp (v, va))
- | nota (Iff (v, va)) = Not (Iff (v, va))
- | nota (E v) = Not (E v)
- | nota (A v) = Not (A v)
- | nota (Closed v) = Not (Closed v)
- | nota (NClosed v) = Not (NClosed v);
-
-fun iffa p q =
- (if eq_fm p q then T
- else (if eq_fm p (nota q) orelse eq_fm (nota p) q then F
- else (if eq_fm p F then nota q
- else (if eq_fm q F then nota p
- else (if eq_fm p T then q
- else (if eq_fm q T then p else Iff (p, q)))))));
-
-fun impa p q =
- (if eq_fm p F orelse eq_fm q T then T
- else (if eq_fm p T then q else (if eq_fm q F then nota p else Imp (p, q))));
-
-fun conj p q =
- (if eq_fm p F orelse eq_fm q F then F
- else (if eq_fm p T then q else (if eq_fm q T then p else And (p, q))));
-
-fun simpfm (And (p, q)) = conj (simpfm p) (simpfm q)
- | simpfm (Or (p, q)) = disj (simpfm p) (simpfm q)
- | simpfm (Imp (p, q)) = impa (simpfm p) (simpfm q)
- | simpfm (Iff (p, q)) = iffa (simpfm p) (simpfm q)
- | simpfm (Not p) = nota (simpfm p)
- | simpfm (Lt a) =
- let
- val aa = simpnum a;
- in
- (case aa of C v => (if IntInf.< (v, (0 : IntInf.int)) then T else F)
- | Bound _ => Lt aa | Cn (_, _, _) => Lt aa | Neg _ => Lt aa
- | Add (_, _) => Lt aa | Sub (_, _) => Lt aa | Mul (_, _) => Lt aa)
- end
- | simpfm (Le a) =
- let
- val aa = simpnum a;
- in
- (case aa of C v => (if IntInf.<= (v, (0 : IntInf.int)) then T else F)
- | Bound _ => Le aa | Cn (_, _, _) => Le aa | Neg _ => Le aa
- | Add (_, _) => Le aa | Sub (_, _) => Le aa | Mul (_, _) => Le aa)
- end
- | simpfm (Gt a) =
- let
- val aa = simpnum a;
- in
- (case aa of C v => (if IntInf.< ((0 : IntInf.int), v) then T else F)
- | Bound _ => Gt aa | Cn (_, _, _) => Gt aa | Neg _ => Gt aa
- | Add (_, _) => Gt aa | Sub (_, _) => Gt aa | Mul (_, _) => Gt aa)
- end
- | simpfm (Ge a) =
- let
- val aa = simpnum a;
- in
- (case aa of C v => (if IntInf.<= ((0 : IntInf.int), v) then T else F)
- | Bound _ => Ge aa | Cn (_, _, _) => Ge aa | Neg _ => Ge aa
- | Add (_, _) => Ge aa | Sub (_, _) => Ge aa | Mul (_, _) => Ge aa)
- end
- | simpfm (Eq a) =
- let
- val aa = simpnum a;
- in
- (case aa
- of C v => (if ((v : IntInf.int) = (0 : IntInf.int)) then T else F)
- | Bound _ => Eq aa | Cn (_, _, _) => Eq aa | Neg _ => Eq aa
- | Add (_, _) => Eq aa | Sub (_, _) => Eq aa | Mul (_, _) => Eq aa)
- end
- | simpfm (NEq a) =
- let
- val aa = simpnum a;
- in
- (case aa
- of C v => (if not ((v : IntInf.int) = (0 : IntInf.int)) then T else F)
- | Bound _ => NEq aa | Cn (_, _, _) => NEq aa | Neg _ => NEq aa
- | Add (_, _) => NEq aa | Sub (_, _) => NEq aa | Mul (_, _) => NEq aa)
- end
- | simpfm (Dvd (i, a)) =
- (if ((i : IntInf.int) = (0 : IntInf.int)) then simpfm (Eq a)
- else (if (((abs_int i) : IntInf.int) = (1 : IntInf.int)) then T
- else let
- val aa = simpnum a;
- in
- (case aa
- of C v =>
- (if dvd (semiring_div_int, eq_int) i v then T else F)
- | Bound _ => Dvd (i, aa) | Cn (_, _, _) => Dvd (i, aa)
- | Neg _ => Dvd (i, aa) | Add (_, _) => Dvd (i, aa)
- | Sub (_, _) => Dvd (i, aa) | Mul (_, _) => Dvd (i, aa))
- end))
- | simpfm (NDvd (i, a)) =
- (if ((i : IntInf.int) = (0 : IntInf.int)) then simpfm (NEq a)
- else (if (((abs_int i) : IntInf.int) = (1 : IntInf.int)) then F
- else let
- val aa = simpnum a;
- in
- (case aa
- of C v =>
- (if not (dvd (semiring_div_int, eq_int) i v) then T
- else F)
- | Bound _ => NDvd (i, aa) | Cn (_, _, _) => NDvd (i, aa)
- | Neg _ => NDvd (i, aa) | Add (_, _) => NDvd (i, aa)
- | Sub (_, _) => NDvd (i, aa) | Mul (_, _) => NDvd (i, aa))
- end))
- | simpfm T = T
- | simpfm F = F
- | simpfm (E v) = E v
- | simpfm (A v) = A v
- | simpfm (Closed v) = Closed v
- | simpfm (NClosed v) = NClosed v;
-
-fun iupt i j =
- (if IntInf.< (j, i) then []
- else i :: iupt (IntInf.+ (i, (1 : IntInf.int))) j);
-
-fun mirror (And (p, q)) = And (mirror p, mirror q)
- | mirror (Or (p, q)) = Or (mirror p, mirror q)
- | mirror T = T
- | mirror F = F
- | mirror (Lt (C bo)) = Lt (C bo)
- | mirror (Lt (Bound bp)) = Lt (Bound bp)
- | mirror (Lt (Neg bt)) = Lt (Neg bt)
- | mirror (Lt (Add (bu, bv))) = Lt (Add (bu, bv))
- | mirror (Lt (Sub (bw, bx))) = Lt (Sub (bw, bx))
- | mirror (Lt (Mul (by, bz))) = Lt (Mul (by, bz))
- | mirror (Le (C co)) = Le (C co)
- | mirror (Le (Bound cp)) = Le (Bound cp)
- | mirror (Le (Neg ct)) = Le (Neg ct)
- | mirror (Le (Add (cu, cv))) = Le (Add (cu, cv))
- | mirror (Le (Sub (cw, cx))) = Le (Sub (cw, cx))
- | mirror (Le (Mul (cy, cz))) = Le (Mul (cy, cz))
- | mirror (Gt (C doa)) = Gt (C doa)
- | mirror (Gt (Bound dp)) = Gt (Bound dp)
- | mirror (Gt (Neg dt)) = Gt (Neg dt)
- | mirror (Gt (Add (du, dv))) = Gt (Add (du, dv))
- | mirror (Gt (Sub (dw, dx))) = Gt (Sub (dw, dx))
- | mirror (Gt (Mul (dy, dz))) = Gt (Mul (dy, dz))
- | mirror (Ge (C eo)) = Ge (C eo)
- | mirror (Ge (Bound ep)) = Ge (Bound ep)
- | mirror (Ge (Neg et)) = Ge (Neg et)
- | mirror (Ge (Add (eu, ev))) = Ge (Add (eu, ev))
- | mirror (Ge (Sub (ew, ex))) = Ge (Sub (ew, ex))
- | mirror (Ge (Mul (ey, ez))) = Ge (Mul (ey, ez))
- | mirror (Eq (C fo)) = Eq (C fo)
- | mirror (Eq (Bound fp)) = Eq (Bound fp)
- | mirror (Eq (Neg ft)) = Eq (Neg ft)
- | mirror (Eq (Add (fu, fv))) = Eq (Add (fu, fv))
- | mirror (Eq (Sub (fw, fx))) = Eq (Sub (fw, fx))
- | mirror (Eq (Mul (fy, fz))) = Eq (Mul (fy, fz))
- | mirror (NEq (C go)) = NEq (C go)
- | mirror (NEq (Bound gp)) = NEq (Bound gp)
- | mirror (NEq (Neg gt)) = NEq (Neg gt)
- | mirror (NEq (Add (gu, gv))) = NEq (Add (gu, gv))
- | mirror (NEq (Sub (gw, gx))) = NEq (Sub (gw, gx))
- | mirror (NEq (Mul (gy, gz))) = NEq (Mul (gy, gz))
- | mirror (Dvd (aa, C ho)) = Dvd (aa, C ho)
- | mirror (Dvd (aa, Bound hp)) = Dvd (aa, Bound hp)
- | mirror (Dvd (aa, Neg ht)) = Dvd (aa, Neg ht)
- | mirror (Dvd (aa, Add (hu, hv))) = Dvd (aa, Add (hu, hv))
- | mirror (Dvd (aa, Sub (hw, hx))) = Dvd (aa, Sub (hw, hx))
- | mirror (Dvd (aa, Mul (hy, hz))) = Dvd (aa, Mul (hy, hz))
- | mirror (NDvd (ac, C io)) = NDvd (ac, C io)
- | mirror (NDvd (ac, Bound ip)) = NDvd (ac, Bound ip)
- | mirror (NDvd (ac, Neg it)) = NDvd (ac, Neg it)
- | mirror (NDvd (ac, Add (iu, iv))) = NDvd (ac, Add (iu, iv))
- | mirror (NDvd (ac, Sub (iw, ix))) = NDvd (ac, Sub (iw, ix))
- | mirror (NDvd (ac, Mul (iy, iz))) = NDvd (ac, Mul (iy, iz))
- | mirror (Not ae) = Not ae
- | mirror (Imp (aj, ak)) = Imp (aj, ak)
- | mirror (Iff (al, am)) = Iff (al, am)
- | mirror (E an) = E an
- | mirror (A ao) = A ao
- | mirror (Closed ap) = Closed ap
- | mirror (NClosed aq) = NClosed aq
- | mirror (Lt (Cn (cm, c, e))) =
- (if ((cm : IntInf.int) = (0 : IntInf.int))
- then Gt (Cn ((0 : IntInf.int), c, Neg e))
- else Lt (Cn (suc (minus_nat cm (1 : IntInf.int)), c, e)))
- | mirror (Le (Cn (dm, c, e))) =
- (if ((dm : IntInf.int) = (0 : IntInf.int))
- then Ge (Cn ((0 : IntInf.int), c, Neg e))
- else Le (Cn (suc (minus_nat dm (1 : IntInf.int)), c, e)))
- | mirror (Gt (Cn (em, c, e))) =
- (if ((em : IntInf.int) = (0 : IntInf.int))
- then Lt (Cn ((0 : IntInf.int), c, Neg e))
- else Gt (Cn (suc (minus_nat em (1 : IntInf.int)), c, e)))
- | mirror (Ge (Cn (fm, c, e))) =
- (if ((fm : IntInf.int) = (0 : IntInf.int))
- then Le (Cn ((0 : IntInf.int), c, Neg e))
- else Ge (Cn (suc (minus_nat fm (1 : IntInf.int)), c, e)))
- | mirror (Eq (Cn (gm, c, e))) =
- (if ((gm : IntInf.int) = (0 : IntInf.int))
- then Eq (Cn ((0 : IntInf.int), c, Neg e))
- else Eq (Cn (suc (minus_nat gm (1 : IntInf.int)), c, e)))
- | mirror (NEq (Cn (hm, c, e))) =
- (if ((hm : IntInf.int) = (0 : IntInf.int))
- then NEq (Cn ((0 : IntInf.int), c, Neg e))
- else NEq (Cn (suc (minus_nat hm (1 : IntInf.int)), c, e)))
- | mirror (Dvd (i, Cn (im, c, e))) =
- (if ((im : IntInf.int) = (0 : IntInf.int))
- then Dvd (i, Cn ((0 : IntInf.int), c, Neg e))
- else Dvd (i, Cn (suc (minus_nat im (1 : IntInf.int)), c, e)))
- | mirror (NDvd (i, Cn (jm, c, e))) =
- (if ((jm : IntInf.int) = (0 : IntInf.int))
- then NDvd (i, Cn ((0 : IntInf.int), c, Neg e))
- else NDvd (i, Cn (suc (minus_nat jm (1 : IntInf.int)), c, e)));
-
-fun size_list [] = (0 : IntInf.int)
- | size_list (a :: lista) = IntInf.+ (size_list lista, suc (0 : IntInf.int));
-
-fun alpha (And (p, q)) = append (alpha p) (alpha q)
- | alpha (Or (p, q)) = append (alpha p) (alpha q)
- | alpha T = []
- | alpha F = []
- | alpha (Lt (C bo)) = []
- | alpha (Lt (Bound bp)) = []
- | alpha (Lt (Neg bt)) = []
- | alpha (Lt (Add (bu, bv))) = []
- | alpha (Lt (Sub (bw, bx))) = []
- | alpha (Lt (Mul (by, bz))) = []
- | alpha (Le (C co)) = []
- | alpha (Le (Bound cp)) = []
- | alpha (Le (Neg ct)) = []
- | alpha (Le (Add (cu, cv))) = []
- | alpha (Le (Sub (cw, cx))) = []
- | alpha (Le (Mul (cy, cz))) = []
- | alpha (Gt (C doa)) = []
- | alpha (Gt (Bound dp)) = []
- | alpha (Gt (Neg dt)) = []
- | alpha (Gt (Add (du, dv))) = []
- | alpha (Gt (Sub (dw, dx))) = []
- | alpha (Gt (Mul (dy, dz))) = []
- | alpha (Ge (C eo)) = []
- | alpha (Ge (Bound ep)) = []
- | alpha (Ge (Neg et)) = []
- | alpha (Ge (Add (eu, ev))) = []
- | alpha (Ge (Sub (ew, ex))) = []
- | alpha (Ge (Mul (ey, ez))) = []
- | alpha (Eq (C fo)) = []
- | alpha (Eq (Bound fp)) = []
- | alpha (Eq (Neg ft)) = []
- | alpha (Eq (Add (fu, fv))) = []
- | alpha (Eq (Sub (fw, fx))) = []
- | alpha (Eq (Mul (fy, fz))) = []
- | alpha (NEq (C go)) = []
- | alpha (NEq (Bound gp)) = []
- | alpha (NEq (Neg gt)) = []
- | alpha (NEq (Add (gu, gv))) = []
- | alpha (NEq (Sub (gw, gx))) = []
- | alpha (NEq (Mul (gy, gz))) = []
- | alpha (Dvd (aa, ab)) = []
- | alpha (NDvd (ac, ad)) = []
- | alpha (Not ae) = []
- | alpha (Imp (aj, ak)) = []
- | alpha (Iff (al, am)) = []
- | alpha (E an) = []
- | alpha (A ao) = []
- | alpha (Closed ap) = []
- | alpha (NClosed aq) = []
- | alpha (Lt (Cn (cm, c, e))) =
- (if ((cm : IntInf.int) = (0 : IntInf.int)) then [e] else [])
- | alpha (Le (Cn (dm, c, e))) =
- (if ((dm : IntInf.int) = (0 : IntInf.int))
- then [Add (C (~1 : IntInf.int), e)] else [])
- | alpha (Gt (Cn (em, c, e))) =
- (if ((em : IntInf.int) = (0 : IntInf.int)) then [] else [])
- | alpha (Ge (Cn (fm, c, e))) =
- (if ((fm : IntInf.int) = (0 : IntInf.int)) then [] else [])
- | alpha (Eq (Cn (gm, c, e))) =
- (if ((gm : IntInf.int) = (0 : IntInf.int))
- then [Add (C (~1 : IntInf.int), e)] else [])
- | alpha (NEq (Cn (hm, c, e))) =
- (if ((hm : IntInf.int) = (0 : IntInf.int)) then [e] else []);
-
-fun beta (And (p, q)) = append (beta p) (beta q)
- | beta (Or (p, q)) = append (beta p) (beta q)
- | beta T = []
- | beta F = []
- | beta (Lt (C bo)) = []
- | beta (Lt (Bound bp)) = []
- | beta (Lt (Neg bt)) = []
- | beta (Lt (Add (bu, bv))) = []
- | beta (Lt (Sub (bw, bx))) = []
- | beta (Lt (Mul (by, bz))) = []
- | beta (Le (C co)) = []
- | beta (Le (Bound cp)) = []
- | beta (Le (Neg ct)) = []
- | beta (Le (Add (cu, cv))) = []
- | beta (Le (Sub (cw, cx))) = []
- | beta (Le (Mul (cy, cz))) = []
- | beta (Gt (C doa)) = []
- | beta (Gt (Bound dp)) = []
- | beta (Gt (Neg dt)) = []
- | beta (Gt (Add (du, dv))) = []
- | beta (Gt (Sub (dw, dx))) = []
- | beta (Gt (Mul (dy, dz))) = []
- | beta (Ge (C eo)) = []
- | beta (Ge (Bound ep)) = []
- | beta (Ge (Neg et)) = []
- | beta (Ge (Add (eu, ev))) = []
- | beta (Ge (Sub (ew, ex))) = []
- | beta (Ge (Mul (ey, ez))) = []
- | beta (Eq (C fo)) = []
- | beta (Eq (Bound fp)) = []
- | beta (Eq (Neg ft)) = []
- | beta (Eq (Add (fu, fv))) = []
- | beta (Eq (Sub (fw, fx))) = []
- | beta (Eq (Mul (fy, fz))) = []
- | beta (NEq (C go)) = []
- | beta (NEq (Bound gp)) = []
- | beta (NEq (Neg gt)) = []
- | beta (NEq (Add (gu, gv))) = []
- | beta (NEq (Sub (gw, gx))) = []
- | beta (NEq (Mul (gy, gz))) = []
- | beta (Dvd (aa, ab)) = []
- | beta (NDvd (ac, ad)) = []
- | beta (Not ae) = []
- | beta (Imp (aj, ak)) = []
- | beta (Iff (al, am)) = []
- | beta (E an) = []
- | beta (A ao) = []
- | beta (Closed ap) = []
- | beta (NClosed aq) = []
- | beta (Lt (Cn (cm, c, e))) =
- (if ((cm : IntInf.int) = (0 : IntInf.int)) then [] else [])
- | beta (Le (Cn (dm, c, e))) =
- (if ((dm : IntInf.int) = (0 : IntInf.int)) then [] else [])
- | beta (Gt (Cn (em, c, e))) =
- (if ((em : IntInf.int) = (0 : IntInf.int)) then [Neg e] else [])
- | beta (Ge (Cn (fm, c, e))) =
- (if ((fm : IntInf.int) = (0 : IntInf.int))
- then [Sub (C (~1 : IntInf.int), e)] else [])
- | beta (Eq (Cn (gm, c, e))) =
- (if ((gm : IntInf.int) = (0 : IntInf.int))
- then [Sub (C (~1 : IntInf.int), e)] else [])
- | beta (NEq (Cn (hm, c, e))) =
- (if ((hm : IntInf.int) = (0 : IntInf.int)) then [Neg e] else []);
-
-val eq_numa = {eq = eq_num} : num eq;
-
-fun member A_ x [] = false
- | member A_ x (y :: ys) = eqa A_ x y orelse member A_ x ys;
-
-fun remdups A_ [] = []
- | remdups A_ (x :: xs) =
- (if member A_ x xs then remdups A_ xs else x :: remdups A_ xs);
-
-fun gcd_int k l =
- abs_int
- (if ((l : IntInf.int) = (0 : IntInf.int)) then k
- else gcd_int l (mod_int (abs_int k) (abs_int l)));
-
-fun lcm_int a b = div_int (IntInf.* (abs_int a, abs_int b)) (gcd_int a b);
-
-fun delta (And (p, q)) = lcm_int (delta p) (delta q)
- | delta (Or (p, q)) = lcm_int (delta p) (delta q)
- | delta T = (1 : IntInf.int)
- | delta F = (1 : IntInf.int)
- | delta (Lt u) = (1 : IntInf.int)
- | delta (Le v) = (1 : IntInf.int)
- | delta (Gt w) = (1 : IntInf.int)
- | delta (Ge x) = (1 : IntInf.int)
- | delta (Eq y) = (1 : IntInf.int)
- | delta (NEq z) = (1 : IntInf.int)
- | delta (Dvd (aa, C bo)) = (1 : IntInf.int)
- | delta (Dvd (aa, Bound bp)) = (1 : IntInf.int)
- | delta (Dvd (aa, Neg bt)) = (1 : IntInf.int)
- | delta (Dvd (aa, Add (bu, bv))) = (1 : IntInf.int)
- | delta (Dvd (aa, Sub (bw, bx))) = (1 : IntInf.int)
- | delta (Dvd (aa, Mul (by, bz))) = (1 : IntInf.int)
- | delta (NDvd (ac, C co)) = (1 : IntInf.int)
- | delta (NDvd (ac, Bound cp)) = (1 : IntInf.int)
- | delta (NDvd (ac, Neg ct)) = (1 : IntInf.int)
- | delta (NDvd (ac, Add (cu, cv))) = (1 : IntInf.int)
- | delta (NDvd (ac, Sub (cw, cx))) = (1 : IntInf.int)
- | delta (NDvd (ac, Mul (cy, cz))) = (1 : IntInf.int)
- | delta (Not ae) = (1 : IntInf.int)
- | delta (Imp (aj, ak)) = (1 : IntInf.int)
- | delta (Iff (al, am)) = (1 : IntInf.int)
- | delta (E an) = (1 : IntInf.int)
- | delta (A ao) = (1 : IntInf.int)
- | delta (Closed ap) = (1 : IntInf.int)
- | delta (NClosed aq) = (1 : IntInf.int)
- | delta (Dvd (i, Cn (cm, c, e))) =
- (if ((cm : IntInf.int) = (0 : IntInf.int)) then i else (1 : IntInf.int))
- | delta (NDvd (i, Cn (dm, c, e))) =
- (if ((dm : IntInf.int) = (0 : IntInf.int)) then i else (1 : IntInf.int));
-
-fun a_beta (And (p, q)) = (fn k => And (a_beta p k, a_beta q k))
- | a_beta (Or (p, q)) = (fn k => Or (a_beta p k, a_beta q k))
- | a_beta T = (fn _ => T)
- | a_beta F = (fn _ => F)
- | a_beta (Lt (C bo)) = (fn _ => Lt (C bo))
- | a_beta (Lt (Bound bp)) = (fn _ => Lt (Bound bp))
- | a_beta (Lt (Neg bt)) = (fn _ => Lt (Neg bt))
- | a_beta (Lt (Add (bu, bv))) = (fn _ => Lt (Add (bu, bv)))
- | a_beta (Lt (Sub (bw, bx))) = (fn _ => Lt (Sub (bw, bx)))
- | a_beta (Lt (Mul (by, bz))) = (fn _ => Lt (Mul (by, bz)))
- | a_beta (Le (C co)) = (fn _ => Le (C co))
- | a_beta (Le (Bound cp)) = (fn _ => Le (Bound cp))
- | a_beta (Le (Neg ct)) = (fn _ => Le (Neg ct))
- | a_beta (Le (Add (cu, cv))) = (fn _ => Le (Add (cu, cv)))
- | a_beta (Le (Sub (cw, cx))) = (fn _ => Le (Sub (cw, cx)))
- | a_beta (Le (Mul (cy, cz))) = (fn _ => Le (Mul (cy, cz)))
- | a_beta (Gt (C doa)) = (fn _ => Gt (C doa))
- | a_beta (Gt (Bound dp)) = (fn _ => Gt (Bound dp))
- | a_beta (Gt (Neg dt)) = (fn _ => Gt (Neg dt))
- | a_beta (Gt (Add (du, dv))) = (fn _ => Gt (Add (du, dv)))
- | a_beta (Gt (Sub (dw, dx))) = (fn _ => Gt (Sub (dw, dx)))
- | a_beta (Gt (Mul (dy, dz))) = (fn _ => Gt (Mul (dy, dz)))
- | a_beta (Ge (C eo)) = (fn _ => Ge (C eo))
- | a_beta (Ge (Bound ep)) = (fn _ => Ge (Bound ep))
- | a_beta (Ge (Neg et)) = (fn _ => Ge (Neg et))
- | a_beta (Ge (Add (eu, ev))) = (fn _ => Ge (Add (eu, ev)))
- | a_beta (Ge (Sub (ew, ex))) = (fn _ => Ge (Sub (ew, ex)))
- | a_beta (Ge (Mul (ey, ez))) = (fn _ => Ge (Mul (ey, ez)))
- | a_beta (Eq (C fo)) = (fn _ => Eq (C fo))
- | a_beta (Eq (Bound fp)) = (fn _ => Eq (Bound fp))
- | a_beta (Eq (Neg ft)) = (fn _ => Eq (Neg ft))
- | a_beta (Eq (Add (fu, fv))) = (fn _ => Eq (Add (fu, fv)))
- | a_beta (Eq (Sub (fw, fx))) = (fn _ => Eq (Sub (fw, fx)))
- | a_beta (Eq (Mul (fy, fz))) = (fn _ => Eq (Mul (fy, fz)))
- | a_beta (NEq (C go)) = (fn _ => NEq (C go))
- | a_beta (NEq (Bound gp)) = (fn _ => NEq (Bound gp))
- | a_beta (NEq (Neg gt)) = (fn _ => NEq (Neg gt))
- | a_beta (NEq (Add (gu, gv))) = (fn _ => NEq (Add (gu, gv)))
- | a_beta (NEq (Sub (gw, gx))) = (fn _ => NEq (Sub (gw, gx)))
- | a_beta (NEq (Mul (gy, gz))) = (fn _ => NEq (Mul (gy, gz)))
- | a_beta (Dvd (aa, C ho)) = (fn _ => Dvd (aa, C ho))
- | a_beta (Dvd (aa, Bound hp)) = (fn _ => Dvd (aa, Bound hp))
- | a_beta (Dvd (aa, Neg ht)) = (fn _ => Dvd (aa, Neg ht))
- | a_beta (Dvd (aa, Add (hu, hv))) = (fn _ => Dvd (aa, Add (hu, hv)))
- | a_beta (Dvd (aa, Sub (hw, hx))) = (fn _ => Dvd (aa, Sub (hw, hx)))
- | a_beta (Dvd (aa, Mul (hy, hz))) = (fn _ => Dvd (aa, Mul (hy, hz)))
- | a_beta (NDvd (ac, C io)) = (fn _ => NDvd (ac, C io))
- | a_beta (NDvd (ac, Bound ip)) = (fn _ => NDvd (ac, Bound ip))
- | a_beta (NDvd (ac, Neg it)) = (fn _ => NDvd (ac, Neg it))
- | a_beta (NDvd (ac, Add (iu, iv))) = (fn _ => NDvd (ac, Add (iu, iv)))
- | a_beta (NDvd (ac, Sub (iw, ix))) = (fn _ => NDvd (ac, Sub (iw, ix)))
- | a_beta (NDvd (ac, Mul (iy, iz))) = (fn _ => NDvd (ac, Mul (iy, iz)))
- | a_beta (Not ae) = (fn _ => Not ae)
- | a_beta (Imp (aj, ak)) = (fn _ => Imp (aj, ak))
- | a_beta (Iff (al, am)) = (fn _ => Iff (al, am))
- | a_beta (E an) = (fn _ => E an)
- | a_beta (A ao) = (fn _ => A ao)
- | a_beta (Closed ap) = (fn _ => Closed ap)
- | a_beta (NClosed aq) = (fn _ => NClosed aq)
- | a_beta (Lt (Cn (cm, c, e))) =
- (if ((cm : IntInf.int) = (0 : IntInf.int))
- then (fn k =>
- Lt (Cn ((0 : IntInf.int), (1 : IntInf.int), Mul (div_int k c, e))))
- else (fn _ => Lt (Cn (suc (minus_nat cm (1 : IntInf.int)), c, e))))
- | a_beta (Le (Cn (dm, c, e))) =
- (if ((dm : IntInf.int) = (0 : IntInf.int))
- then (fn k =>
- Le (Cn ((0 : IntInf.int), (1 : IntInf.int), Mul (div_int k c, e))))
- else (fn _ => Le (Cn (suc (minus_nat dm (1 : IntInf.int)), c, e))))
- | a_beta (Gt (Cn (em, c, e))) =
- (if ((em : IntInf.int) = (0 : IntInf.int))
- then (fn k =>
- Gt (Cn ((0 : IntInf.int), (1 : IntInf.int), Mul (div_int k c, e))))
- else (fn _ => Gt (Cn (suc (minus_nat em (1 : IntInf.int)), c, e))))
- | a_beta (Ge (Cn (fm, c, e))) =
- (if ((fm : IntInf.int) = (0 : IntInf.int))
- then (fn k =>
- Ge (Cn ((0 : IntInf.int), (1 : IntInf.int), Mul (div_int k c, e))))
- else (fn _ => Ge (Cn (suc (minus_nat fm (1 : IntInf.int)), c, e))))
- | a_beta (Eq (Cn (gm, c, e))) =
- (if ((gm : IntInf.int) = (0 : IntInf.int))
- then (fn k =>
- Eq (Cn ((0 : IntInf.int), (1 : IntInf.int), Mul (div_int k c, e))))
- else (fn _ => Eq (Cn (suc (minus_nat gm (1 : IntInf.int)), c, e))))
- | a_beta (NEq (Cn (hm, c, e))) =
- (if ((hm : IntInf.int) = (0 : IntInf.int))
- then (fn k =>
- NEq (Cn ((0 : IntInf.int), (1 : IntInf.int),
- Mul (div_int k c, e))))
- else (fn _ => NEq (Cn (suc (minus_nat hm (1 : IntInf.int)), c, e))))
- | a_beta (Dvd (i, Cn (im, c, e))) =
- (if ((im : IntInf.int) = (0 : IntInf.int))
- then (fn k =>
- Dvd (IntInf.* (div_int k c, i),
- Cn ((0 : IntInf.int), (1 : IntInf.int),
- Mul (div_int k c, e))))
- else (fn _ => Dvd (i, Cn (suc (minus_nat im (1 : IntInf.int)), c, e))))
- | a_beta (NDvd (i, Cn (jm, c, e))) =
- (if ((jm : IntInf.int) = (0 : IntInf.int))
- then (fn k =>
- NDvd (IntInf.* (div_int k c, i),
- Cn ((0 : IntInf.int), (1 : IntInf.int),
- Mul (div_int k c, e))))
- else (fn _ => NDvd (i, Cn (suc (minus_nat jm (1 : IntInf.int)), c, e))));
-
-fun zeta (And (p, q)) = lcm_int (zeta p) (zeta q)
- | zeta (Or (p, q)) = lcm_int (zeta p) (zeta q)
- | zeta T = (1 : IntInf.int)
- | zeta F = (1 : IntInf.int)
- | zeta (Lt (C bo)) = (1 : IntInf.int)
- | zeta (Lt (Bound bp)) = (1 : IntInf.int)
- | zeta (Lt (Neg bt)) = (1 : IntInf.int)
- | zeta (Lt (Add (bu, bv))) = (1 : IntInf.int)
- | zeta (Lt (Sub (bw, bx))) = (1 : IntInf.int)
- | zeta (Lt (Mul (by, bz))) = (1 : IntInf.int)
- | zeta (Le (C co)) = (1 : IntInf.int)
- | zeta (Le (Bound cp)) = (1 : IntInf.int)
- | zeta (Le (Neg ct)) = (1 : IntInf.int)
- | zeta (Le (Add (cu, cv))) = (1 : IntInf.int)
- | zeta (Le (Sub (cw, cx))) = (1 : IntInf.int)
- | zeta (Le (Mul (cy, cz))) = (1 : IntInf.int)
- | zeta (Gt (C doa)) = (1 : IntInf.int)
- | zeta (Gt (Bound dp)) = (1 : IntInf.int)
- | zeta (Gt (Neg dt)) = (1 : IntInf.int)
- | zeta (Gt (Add (du, dv))) = (1 : IntInf.int)
- | zeta (Gt (Sub (dw, dx))) = (1 : IntInf.int)
- | zeta (Gt (Mul (dy, dz))) = (1 : IntInf.int)
- | zeta (Ge (C eo)) = (1 : IntInf.int)
- | zeta (Ge (Bound ep)) = (1 : IntInf.int)
- | zeta (Ge (Neg et)) = (1 : IntInf.int)
- | zeta (Ge (Add (eu, ev))) = (1 : IntInf.int)
- | zeta (Ge (Sub (ew, ex))) = (1 : IntInf.int)
- | zeta (Ge (Mul (ey, ez))) = (1 : IntInf.int)
- | zeta (Eq (C fo)) = (1 : IntInf.int)
- | zeta (Eq (Bound fp)) = (1 : IntInf.int)
- | zeta (Eq (Neg ft)) = (1 : IntInf.int)
- | zeta (Eq (Add (fu, fv))) = (1 : IntInf.int)
- | zeta (Eq (Sub (fw, fx))) = (1 : IntInf.int)
- | zeta (Eq (Mul (fy, fz))) = (1 : IntInf.int)
- | zeta (NEq (C go)) = (1 : IntInf.int)
- | zeta (NEq (Bound gp)) = (1 : IntInf.int)
- | zeta (NEq (Neg gt)) = (1 : IntInf.int)
- | zeta (NEq (Add (gu, gv))) = (1 : IntInf.int)
- | zeta (NEq (Sub (gw, gx))) = (1 : IntInf.int)
- | zeta (NEq (Mul (gy, gz))) = (1 : IntInf.int)
- | zeta (Dvd (aa, C ho)) = (1 : IntInf.int)
- | zeta (Dvd (aa, Bound hp)) = (1 : IntInf.int)
- | zeta (Dvd (aa, Neg ht)) = (1 : IntInf.int)
- | zeta (Dvd (aa, Add (hu, hv))) = (1 : IntInf.int)
- | zeta (Dvd (aa, Sub (hw, hx))) = (1 : IntInf.int)
- | zeta (Dvd (aa, Mul (hy, hz))) = (1 : IntInf.int)
- | zeta (NDvd (ac, C io)) = (1 : IntInf.int)
- | zeta (NDvd (ac, Bound ip)) = (1 : IntInf.int)
- | zeta (NDvd (ac, Neg it)) = (1 : IntInf.int)
- | zeta (NDvd (ac, Add (iu, iv))) = (1 : IntInf.int)
- | zeta (NDvd (ac, Sub (iw, ix))) = (1 : IntInf.int)
- | zeta (NDvd (ac, Mul (iy, iz))) = (1 : IntInf.int)
- | zeta (Not ae) = (1 : IntInf.int)
- | zeta (Imp (aj, ak)) = (1 : IntInf.int)
- | zeta (Iff (al, am)) = (1 : IntInf.int)
- | zeta (E an) = (1 : IntInf.int)
- | zeta (A ao) = (1 : IntInf.int)
- | zeta (Closed ap) = (1 : IntInf.int)
- | zeta (NClosed aq) = (1 : IntInf.int)
- | zeta (Lt (Cn (cm, c, e))) =
- (if ((cm : IntInf.int) = (0 : IntInf.int)) then c else (1 : IntInf.int))
- | zeta (Le (Cn (dm, c, e))) =
- (if ((dm : IntInf.int) = (0 : IntInf.int)) then c else (1 : IntInf.int))
- | zeta (Gt (Cn (em, c, e))) =
- (if ((em : IntInf.int) = (0 : IntInf.int)) then c else (1 : IntInf.int))
- | zeta (Ge (Cn (fm, c, e))) =
- (if ((fm : IntInf.int) = (0 : IntInf.int)) then c else (1 : IntInf.int))
- | zeta (Eq (Cn (gm, c, e))) =
- (if ((gm : IntInf.int) = (0 : IntInf.int)) then c else (1 : IntInf.int))
- | zeta (NEq (Cn (hm, c, e))) =
- (if ((hm : IntInf.int) = (0 : IntInf.int)) then c else (1 : IntInf.int))
- | zeta (Dvd (i, Cn (im, c, e))) =
- (if ((im : IntInf.int) = (0 : IntInf.int)) then c else (1 : IntInf.int))
- | zeta (NDvd (i, Cn (jm, c, e))) =
- (if ((jm : IntInf.int) = (0 : IntInf.int)) then c else (1 : IntInf.int));
-
-fun zsplit0 (C c) = ((0 : IntInf.int), C c)
- | zsplit0 (Bound n) =
- (if ((n : IntInf.int) = (0 : IntInf.int))
- then ((1 : IntInf.int), C (0 : IntInf.int))
- else ((0 : IntInf.int), Bound n))
- | zsplit0 (Cn (n, i, a)) =
- let
- val (ia, aa) = zsplit0 a;
- in
- (if ((n : IntInf.int) = (0 : IntInf.int)) then (IntInf.+ (i, ia), aa)
- else (ia, Cn (n, i, aa)))
- end
- | zsplit0 (Neg a) =
- let
- val (i, aa) = zsplit0 a;
- in
- (IntInf.~ i, Neg aa)
- end
- | zsplit0 (Add (a, b)) =
- let
- val (ia, aa) = zsplit0 a;
- val (ib, ba) = zsplit0 b;
- in
- (IntInf.+ (ia, ib), Add (aa, ba))
- end
- | zsplit0 (Sub (a, b)) =
- let
- val (ia, aa) = zsplit0 a;
- val (ib, ba) = zsplit0 b;
- in
- (IntInf.- (ia, ib), Sub (aa, ba))
- end
- | zsplit0 (Mul (i, a)) =
- let
- val (ia, aa) = zsplit0 a;
- in
- (IntInf.* (i, ia), Mul (i, aa))
- end;
-
-fun zlfm (And (p, q)) = And (zlfm p, zlfm q)
- | zlfm (Or (p, q)) = Or (zlfm p, zlfm q)
- | zlfm (Imp (p, q)) = Or (zlfm (Not p), zlfm q)
- | zlfm (Iff (p, q)) =
- Or (And (zlfm p, zlfm q), And (zlfm (Not p), zlfm (Not q)))
- | zlfm (Lt a) =
- let
- val (c, r) = zsplit0 a;
- in
- (if ((c : IntInf.int) = (0 : IntInf.int)) then Lt r
- else (if IntInf.< ((0 : IntInf.int), c)
- then Lt (Cn ((0 : IntInf.int), c, r))
- else Gt (Cn ((0 : IntInf.int), IntInf.~ c, Neg r))))
- end
- | zlfm (Le a) =
- let
- val (c, r) = zsplit0 a;
- in
- (if ((c : IntInf.int) = (0 : IntInf.int)) then Le r
- else (if IntInf.< ((0 : IntInf.int), c)
- then Le (Cn ((0 : IntInf.int), c, r))
- else Ge (Cn ((0 : IntInf.int), IntInf.~ c, Neg r))))
- end
- | zlfm (Gt a) =
- let
- val (c, r) = zsplit0 a;
- in
- (if ((c : IntInf.int) = (0 : IntInf.int)) then Gt r
- else (if IntInf.< ((0 : IntInf.int), c)
- then Gt (Cn ((0 : IntInf.int), c, r))
- else Lt (Cn ((0 : IntInf.int), IntInf.~ c, Neg r))))
- end
- | zlfm (Ge a) =
- let
- val (c, r) = zsplit0 a;
- in
- (if ((c : IntInf.int) = (0 : IntInf.int)) then Ge r
- else (if IntInf.< ((0 : IntInf.int), c)
- then Ge (Cn ((0 : IntInf.int), c, r))
- else Le (Cn ((0 : IntInf.int), IntInf.~ c, Neg r))))
- end
- | zlfm (Eq a) =
- let
- val (c, r) = zsplit0 a;
- in
- (if ((c : IntInf.int) = (0 : IntInf.int)) then Eq r
- else (if IntInf.< ((0 : IntInf.int), c)
- then Eq (Cn ((0 : IntInf.int), c, r))
- else Eq (Cn ((0 : IntInf.int), IntInf.~ c, Neg r))))
- end
- | zlfm (NEq a) =
- let
- val (c, r) = zsplit0 a;
- in
- (if ((c : IntInf.int) = (0 : IntInf.int)) then NEq r
- else (if IntInf.< ((0 : IntInf.int), c)
- then NEq (Cn ((0 : IntInf.int), c, r))
- else NEq (Cn ((0 : IntInf.int), IntInf.~ c, Neg r))))
- end
- | zlfm (Dvd (i, a)) =
- (if ((i : IntInf.int) = (0 : IntInf.int)) then zlfm (Eq a)
- else let
- val (c, r) = zsplit0 a;
- in
- (if ((c : IntInf.int) = (0 : IntInf.int)) then Dvd (abs_int i, r)
- else (if IntInf.< ((0 : IntInf.int), c)
- then Dvd (abs_int i, Cn ((0 : IntInf.int), c, r))
- else Dvd (abs_int i,
- Cn ((0 : IntInf.int), IntInf.~ c, Neg r))))
- end)
- | zlfm (NDvd (i, a)) =
- (if ((i : IntInf.int) = (0 : IntInf.int)) then zlfm (NEq a)
- else let
- val (c, r) = zsplit0 a;
- in
- (if ((c : IntInf.int) = (0 : IntInf.int)) then NDvd (abs_int i, r)
- else (if IntInf.< ((0 : IntInf.int), c)
- then NDvd (abs_int i, Cn ((0 : IntInf.int), c, r))
- else NDvd (abs_int i,
- Cn ((0 : IntInf.int), IntInf.~ c, Neg r))))
- end)
- | zlfm (Not (And (p, q))) = Or (zlfm (Not p), zlfm (Not q))
- | zlfm (Not (Or (p, q))) = And (zlfm (Not p), zlfm (Not q))
- | zlfm (Not (Imp (p, q))) = And (zlfm p, zlfm (Not q))
- | zlfm (Not (Iff (p, q))) =
- Or (And (zlfm p, zlfm (Not q)), And (zlfm (Not p), zlfm q))
- | zlfm (Not (Not p)) = zlfm p
- | zlfm (Not T) = F
- | zlfm (Not F) = T
- | zlfm (Not (Lt a)) = zlfm (Ge a)
- | zlfm (Not (Le a)) = zlfm (Gt a)
- | zlfm (Not (Gt a)) = zlfm (Le a)
- | zlfm (Not (Ge a)) = zlfm (Lt a)
- | zlfm (Not (Eq a)) = zlfm (NEq a)
- | zlfm (Not (NEq a)) = zlfm (Eq a)
- | zlfm (Not (Dvd (i, a))) = zlfm (NDvd (i, a))
- | zlfm (Not (NDvd (i, a))) = zlfm (Dvd (i, a))
- | zlfm (Not (Closed p)) = NClosed p
- | zlfm (Not (NClosed p)) = Closed p
- | zlfm T = T
- | zlfm F = F
- | zlfm (Not (E ci)) = Not (E ci)
- | zlfm (Not (A cj)) = Not (A cj)
- | zlfm (E ao) = E ao
- | zlfm (A ap) = A ap
- | zlfm (Closed aq) = Closed aq
- | zlfm (NClosed ar) = NClosed ar;
-
-fun unita p =
- let
- val pa = zlfm p;
- val l = zeta pa;
- val q =
- And (Dvd (l, Cn ((0 : IntInf.int), (1 : IntInf.int), C (0 : IntInf.int))),
- a_beta pa l);
- val d = delta q;
- val b = remdups eq_numa (map simpnum (beta q));
- val a = remdups eq_numa (map simpnum (alpha q));
- in
- (if IntInf.<= (size_list b, size_list a) then (q, (b, d))
- else (mirror q, (a, d)))
- end;
-
-fun cooper p =
- let
- val (q, (b, d)) = unita p;
- val js = iupt (1 : IntInf.int) d;
- val mq = simpfm (minusinf q);
- val md = evaldjf (fn j => simpfm (subst0 (C j) mq)) js;
- in
- (if eq_fm md T then T
- else let
- val qd =
- evaldjf (fn (ba, j) => simpfm (subst0 (Add (ba, C j)) q))
- (concat_map (fn ba => map (fn a => (ba, a)) js) b);
- in
- decr (disj md qd)
- end)
- end;
-
-fun prep (E T) = T
- | prep (E F) = F
- | prep (E (Or (p, q))) = Or (prep (E p), prep (E q))
- | prep (E (Imp (p, q))) = Or (prep (E (Not p)), prep (E q))
- | prep (E (Iff (p, q))) =
- Or (prep (E (And (p, q))), prep (E (And (Not p, Not q))))
- | prep (E (Not (And (p, q)))) = Or (prep (E (Not p)), prep (E (Not q)))
- | prep (E (Not (Imp (p, q)))) = prep (E (And (p, Not q)))
- | prep (E (Not (Iff (p, q)))) =
- Or (prep (E (And (p, Not q))), prep (E (And (Not p, q))))
- | prep (E (Lt ef)) = E (prep (Lt ef))
- | prep (E (Le eg)) = E (prep (Le eg))
- | prep (E (Gt eh)) = E (prep (Gt eh))
- | prep (E (Ge ei)) = E (prep (Ge ei))
- | prep (E (Eq ej)) = E (prep (Eq ej))
- | prep (E (NEq ek)) = E (prep (NEq ek))
- | prep (E (Dvd (el, em))) = E (prep (Dvd (el, em)))
- | prep (E (NDvd (en, eo))) = E (prep (NDvd (en, eo)))
- | prep (E (Not T)) = E (prep (Not T))
- | prep (E (Not F)) = E (prep (Not F))
- | prep (E (Not (Lt gw))) = E (prep (Not (Lt gw)))
- | prep (E (Not (Le gx))) = E (prep (Not (Le gx)))
- | prep (E (Not (Gt gy))) = E (prep (Not (Gt gy)))
- | prep (E (Not (Ge gz))) = E (prep (Not (Ge gz)))
- | prep (E (Not (Eq ha))) = E (prep (Not (Eq ha)))
- | prep (E (Not (NEq hb))) = E (prep (Not (NEq hb)))
- | prep (E (Not (Dvd (hc, hd)))) = E (prep (Not (Dvd (hc, hd))))
- | prep (E (Not (NDvd (he, hf)))) = E (prep (Not (NDvd (he, hf))))
- | prep (E (Not (Not hg))) = E (prep (Not (Not hg)))
- | prep (E (Not (Or (hj, hk)))) = E (prep (Not (Or (hj, hk))))
- | prep (E (Not (E hp))) = E (prep (Not (E hp)))
- | prep (E (Not (A hq))) = E (prep (Not (A hq)))
- | prep (E (Not (Closed hr))) = E (prep (Not (Closed hr)))
- | prep (E (Not (NClosed hs))) = E (prep (Not (NClosed hs)))
- | prep (E (And (eq, er))) = E (prep (And (eq, er)))
- | prep (E (E ey)) = E (prep (E ey))
- | prep (E (A ez)) = E (prep (A ez))
- | prep (E (Closed fa)) = E (prep (Closed fa))
- | prep (E (NClosed fb)) = E (prep (NClosed fb))
- | prep (A (And (p, q))) = And (prep (A p), prep (A q))
- | prep (A T) = prep (Not (E (Not T)))
- | prep (A F) = prep (Not (E (Not F)))
- | prep (A (Lt jn)) = prep (Not (E (Not (Lt jn))))
- | prep (A (Le jo)) = prep (Not (E (Not (Le jo))))
- | prep (A (Gt jp)) = prep (Not (E (Not (Gt jp))))
- | prep (A (Ge jq)) = prep (Not (E (Not (Ge jq))))
- | prep (A (Eq jr)) = prep (Not (E (Not (Eq jr))))
- | prep (A (NEq js)) = prep (Not (E (Not (NEq js))))
- | prep (A (Dvd (jt, ju))) = prep (Not (E (Not (Dvd (jt, ju)))))
- | prep (A (NDvd (jv, jw))) = prep (Not (E (Not (NDvd (jv, jw)))))
- | prep (A (Not jx)) = prep (Not (E (Not (Not jx))))
- | prep (A (Or (ka, kb))) = prep (Not (E (Not (Or (ka, kb)))))
- | prep (A (Imp (kc, kd))) = prep (Not (E (Not (Imp (kc, kd)))))
- | prep (A (Iff (ke, kf))) = prep (Not (E (Not (Iff (ke, kf)))))
- | prep (A (E kg)) = prep (Not (E (Not (E kg))))
- | prep (A (A kh)) = prep (Not (E (Not (A kh))))
- | prep (A (Closed ki)) = prep (Not (E (Not (Closed ki))))
- | prep (A (NClosed kj)) = prep (Not (E (Not (NClosed kj))))
- | prep (Not (Not p)) = prep p
- | prep (Not (And (p, q))) = Or (prep (Not p), prep (Not q))
- | prep (Not (A p)) = prep (E (Not p))
- | prep (Not (Or (p, q))) = And (prep (Not p), prep (Not q))
- | prep (Not (Imp (p, q))) = And (prep p, prep (Not q))
- | prep (Not (Iff (p, q))) = Or (prep (And (p, Not q)), prep (And (Not p, q)))
- | prep (Not T) = Not (prep T)
- | prep (Not F) = Not (prep F)
- | prep (Not (Lt bo)) = Not (prep (Lt bo))
- | prep (Not (Le bp)) = Not (prep (Le bp))
- | prep (Not (Gt bq)) = Not (prep (Gt bq))
- | prep (Not (Ge br)) = Not (prep (Ge br))
- | prep (Not (Eq bs)) = Not (prep (Eq bs))
- | prep (Not (NEq bt)) = Not (prep (NEq bt))
- | prep (Not (Dvd (bu, bv))) = Not (prep (Dvd (bu, bv)))
- | prep (Not (NDvd (bw, bx))) = Not (prep (NDvd (bw, bx)))
- | prep (Not (E ch)) = Not (prep (E ch))
- | prep (Not (Closed cj)) = Not (prep (Closed cj))
- | prep (Not (NClosed ck)) = Not (prep (NClosed ck))
- | prep (Or (p, q)) = Or (prep p, prep q)
- | prep (And (p, q)) = And (prep p, prep q)
- | prep (Imp (p, q)) = prep (Or (Not p, q))
- | prep (Iff (p, q)) = Or (prep (And (p, q)), prep (And (Not p, Not q)))
- | prep T = T
- | prep F = F
- | prep (Lt u) = Lt u
- | prep (Le v) = Le v
- | prep (Gt w) = Gt w
- | prep (Ge x) = Ge x
- | prep (Eq y) = Eq y
- | prep (NEq z) = NEq z
- | prep (Dvd (aa, ab)) = Dvd (aa, ab)
- | prep (NDvd (ac, ad)) = NDvd (ac, ad)
- | prep (Closed ap) = Closed ap
- | prep (NClosed aq) = NClosed aq;
-
-fun qelim (E p) = (fn qe => dj qe (qelim p qe))
- | qelim (A p) = (fn qe => nota (qe (qelim (Not p) qe)))
- | qelim (Not p) = (fn qe => nota (qelim p qe))
- | qelim (And (p, q)) = (fn qe => conj (qelim p qe) (qelim q qe))
- | qelim (Or (p, q)) = (fn qe => disj (qelim p qe) (qelim q qe))
- | qelim (Imp (p, q)) = (fn qe => impa (qelim p qe) (qelim q qe))
- | qelim (Iff (p, q)) = (fn qe => iffa (qelim p qe) (qelim q qe))
- | qelim T = (fn _ => simpfm T)
- | qelim F = (fn _ => simpfm F)
- | qelim (Lt u) = (fn _ => simpfm (Lt u))
- | qelim (Le v) = (fn _ => simpfm (Le v))
- | qelim (Gt w) = (fn _ => simpfm (Gt w))
- | qelim (Ge x) = (fn _ => simpfm (Ge x))
- | qelim (Eq y) = (fn _ => simpfm (Eq y))
- | qelim (NEq z) = (fn _ => simpfm (NEq z))
- | qelim (Dvd (aa, ab)) = (fn _ => simpfm (Dvd (aa, ab)))
- | qelim (NDvd (ac, ad)) = (fn _ => simpfm (NDvd (ac, ad)))
- | qelim (Closed ap) = (fn _ => simpfm (Closed ap))
- | qelim (NClosed aq) = (fn _ => simpfm (NClosed aq));
-
-fun pa p = qelim (prep p) cooper;
-
-end; (*struct Generated_Cooper*)
--- a/src/HOL/Tools/Qelim/presburger.ML Tue May 11 09:10:31 2010 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,185 +0,0 @@
-(* Title: HOL/Tools/Qelim/presburger.ML
- Author: Amine Chaieb, TU Muenchen
-*)
-
-signature PRESBURGER =
-sig
- val cooper_tac: bool -> thm list -> thm list -> Proof.context -> int -> tactic
-end;
-
-structure Presburger : PRESBURGER =
-struct
-
-open Conv;
-val comp_ss = HOL_ss addsimps @{thms semiring_norm};
-
-fun strip_objimp ct =
- (case Thm.term_of ct of
- Const ("op -->", _) $ _ $ _ =>
- let val (A, B) = Thm.dest_binop ct
- in A :: strip_objimp B end
- | _ => [ct]);
-
-fun strip_objall ct =
- case term_of ct of
- Const ("All", _) $ Abs (xn,xT,p) =>
- let val (a,(v,t')) = (apsnd (Thm.dest_abs (SOME xn)) o Thm.dest_comb) ct
- in apfst (cons (a,v)) (strip_objall t')
- end
-| _ => ([],ct);
-
-local
- val all_maxscope_ss =
- HOL_basic_ss addsimps map (fn th => th RS sym) @{thms "all_simps"}
-in
-fun thin_prems_tac P = simp_tac all_maxscope_ss THEN'
- CSUBGOAL (fn (p', i) =>
- let
- val (qvs, p) = strip_objall (Thm.dest_arg p')
- val (ps, c) = split_last (strip_objimp p)
- val qs = filter P ps
- val q = if P c then c else @{cterm "False"}
- val ng = fold_rev (fn (a,v) => fn t => Thm.capply a (Thm.cabs v t)) qvs
- (fold_rev (fn p => fn q => Thm.capply (Thm.capply @{cterm "op -->"} p) q) qs q)
- val g = Thm.capply (Thm.capply @{cterm "op ==>"} (Thm.capply @{cterm "Trueprop"} ng)) p'
- val ntac = (case qs of [] => q aconvc @{cterm "False"}
- | _ => false)
- in
- if ntac then no_tac
- else rtac (Goal.prove_internal [] g (K (blast_tac HOL_cs 1))) i
- end)
-end;
-
-local
- fun isnum t = case t of
- Const(@{const_name Groups.zero},_) => true
- | Const(@{const_name Groups.one},_) => true
- | @{term "Suc"}$s => isnum s
- | @{term "nat"}$s => isnum s
- | @{term "int"}$s => isnum s
- | Const(@{const_name Groups.uminus},_)$s => isnum s
- | Const(@{const_name Groups.plus},_)$l$r => isnum l andalso isnum r
- | Const(@{const_name Groups.times},_)$l$r => isnum l andalso isnum r
- | Const(@{const_name Groups.minus},_)$l$r => isnum l andalso isnum r
- | Const(@{const_name Power.power},_)$l$r => isnum l andalso isnum r
- | Const(@{const_name Divides.mod},_)$l$r => isnum l andalso isnum r
- | Const(@{const_name Divides.div},_)$l$r => isnum l andalso isnum r
- | _ => can HOLogic.dest_number t orelse can HOLogic.dest_nat t
-
- fun ty cts t =
- if not (member (op =) [HOLogic.intT, HOLogic.natT, HOLogic.boolT] (typ_of (ctyp_of_term t))) then false
- else case term_of t of
- c$l$r => if member (op =) [@{term"op *::int => _"}, @{term"op *::nat => _"}] c
- then not (isnum l orelse isnum r)
- else not (member (op aconv) cts c)
- | c$_ => not (member (op aconv) cts c)
- | c => not (member (op aconv) cts c)
-
- val term_constants =
- let fun h acc t = case t of
- Const _ => insert (op aconv) t acc
- | a$b => h (h acc a) b
- | Abs (_,_,t) => h acc t
- | _ => acc
- in h [] end;
-in
-fun is_relevant ctxt ct =
- subset (op aconv) (term_constants (term_of ct) , snd (CooperData.get ctxt))
- andalso forall (fn Free (_,T) => member (op =) [@{typ int}, @{typ nat}] T) (OldTerm.term_frees (term_of ct))
- andalso forall (fn Var (_,T) => member (op =) [@{typ int}, @{typ nat}] T) (OldTerm.term_vars (term_of ct));
-
-fun int_nat_terms ctxt ct =
- let
- val cts = snd (CooperData.get ctxt)
- fun h acc t = if ty cts t then insert (op aconvc) t acc else
- case (term_of t) of
- _$_ => h (h acc (Thm.dest_arg t)) (Thm.dest_fun t)
- | Abs(_,_,_) => Thm.dest_abs NONE t ||> h acc |> uncurry (remove (op aconvc))
- | _ => acc
- in h [] ct end
-end;
-
-fun generalize_tac f = CSUBGOAL (fn (p, i) => PRIMITIVE (fn st =>
- let
- fun all T = Drule.cterm_rule (instantiate' [SOME T] []) @{cpat "all"}
- fun gen x t = Thm.capply (all (ctyp_of_term x)) (Thm.cabs x t)
- val ts = sort (fn (a,b) => Term_Ord.fast_term_ord (term_of a, term_of b)) (f p)
- val p' = fold_rev gen ts p
- in implies_intr p' (implies_elim st (fold forall_elim ts (assume p'))) end));
-
-local
-val ss1 = comp_ss
- addsimps @{thms simp_thms} @ [@{thm "nat_number_of_def"}, @{thm "zdvd_int"}]
- @ map (fn r => r RS sym)
- [@{thm "int_int_eq"}, @{thm "zle_int"}, @{thm "zless_int"}, @{thm "zadd_int"},
- @{thm "zmult_int"}]
- addsplits [@{thm "zdiff_int_split"}]
-
-val ss2 = HOL_basic_ss
- addsimps [@{thm "nat_0_le"}, @{thm "int_nat_number_of"},
- @{thm "all_nat"}, @{thm "ex_nat"}, @{thm "number_of1"},
- @{thm "number_of2"}, @{thm "int_0"}, @{thm "int_1"}, @{thm "Suc_eq_plus1"}]
- addcongs [@{thm "conj_le_cong"}, @{thm "imp_le_cong"}]
-val div_mod_ss = HOL_basic_ss addsimps @{thms simp_thms}
- @ map (symmetric o mk_meta_eq)
- [@{thm "dvd_eq_mod_eq_0"},
- @{thm "mod_add_left_eq"}, @{thm "mod_add_right_eq"},
- @{thm "mod_add_eq"}, @{thm "div_add1_eq"}, @{thm "zdiv_zadd1_eq"}]
- @ [@{thm "mod_self"}, @{thm "zmod_self"}, @{thm "mod_by_0"},
- @{thm "div_by_0"}, @{thm "DIVISION_BY_ZERO"} RS conjunct1,
- @{thm "DIVISION_BY_ZERO"} RS conjunct2, @{thm "zdiv_zero"}, @{thm "zmod_zero"},
- @{thm "div_0"}, @{thm "mod_0"}, @{thm "div_by_1"}, @{thm "mod_by_1"}, @{thm "div_1"},
- @{thm "mod_1"}, @{thm "Suc_eq_plus1"}]
- @ @{thms add_ac}
- addsimprocs [cancel_div_mod_nat_proc, cancel_div_mod_int_proc]
- val splits_ss = comp_ss addsimps [@{thm "mod_div_equality'"}] addsplits
- [@{thm "split_zdiv"}, @{thm "split_zmod"}, @{thm "split_div'"},
- @{thm "split_min"}, @{thm "split_max"}, @{thm "abs_split"}]
-in
-fun nat_to_int_tac ctxt =
- simp_tac (Simplifier.context ctxt ss1) THEN_ALL_NEW
- simp_tac (Simplifier.context ctxt ss2) THEN_ALL_NEW
- simp_tac (Simplifier.context ctxt comp_ss);
-
-fun div_mod_tac ctxt i = simp_tac (Simplifier.context ctxt div_mod_ss) i;
-fun splits_tac ctxt i = simp_tac (Simplifier.context ctxt splits_ss) i;
-end;
-
-
-fun core_cooper_tac ctxt = CSUBGOAL (fn (p, i) =>
- let
- val cpth =
- if !quick_and_dirty
- then linzqe_oracle (Thm.cterm_of (ProofContext.theory_of ctxt)
- (Envir.beta_norm (Pattern.eta_long [] (term_of (Thm.dest_arg p)))))
- else arg_conv (Cooper.cooper_conv ctxt) p
- val p' = Thm.rhs_of cpth
- val th = implies_intr p' (equal_elim (symmetric cpth) (assume p'))
- in rtac th i end
- handle Cooper.COOPER _ => no_tac);
-
-fun finish_tac q = SUBGOAL (fn (_, i) =>
- (if q then I else TRY) (rtac TrueI i));
-
-fun cooper_tac elim add_ths del_ths ctxt =
-let val ss = Simplifier.context ctxt (fst (CooperData.get ctxt)) delsimps del_ths addsimps add_ths
- val aprems = Arith_Data.get_arith_facts ctxt
-in
- Method.insert_tac aprems
- THEN_ALL_NEW Object_Logic.full_atomize_tac
- THEN_ALL_NEW CONVERSION Thm.eta_long_conversion
- THEN_ALL_NEW simp_tac ss
- THEN_ALL_NEW (TRY o generalize_tac (int_nat_terms ctxt))
- THEN_ALL_NEW Object_Logic.full_atomize_tac
- THEN_ALL_NEW (thin_prems_tac (is_relevant ctxt))
- THEN_ALL_NEW Object_Logic.full_atomize_tac
- THEN_ALL_NEW div_mod_tac ctxt
- THEN_ALL_NEW splits_tac ctxt
- THEN_ALL_NEW simp_tac ss
- THEN_ALL_NEW CONVERSION Thm.eta_long_conversion
- THEN_ALL_NEW nat_to_int_tac ctxt
- THEN_ALL_NEW (core_cooper_tac ctxt)
- THEN_ALL_NEW finish_tac elim
-end;
-
-end;
--- a/src/HOL/ex/Landau.thy Tue May 11 09:10:31 2010 -0700
+++ b/src/HOL/ex/Landau.thy Tue May 11 11:02:56 2010 -0700
@@ -8,8 +8,8 @@
begin
text {*
- We establish a preorder releation @{text "\<lesssim>"} on functions
- from @{text "\<nat>"} to @{text "\<nat>"} such that @{text "f \<lesssim> g \<longleftrightarrow> f \<in> O(g)"}.
+ We establish a preorder releation @{text "\<lesssim>"} on functions from
+ @{text "\<nat>"} to @{text "\<nat>"} such that @{text "f \<lesssim> g \<longleftrightarrow> f \<in> O(g)"}.
*}
subsection {* Auxiliary *}
@@ -175,12 +175,12 @@
text {*
We would like to show (or refute) that @{text "f \<prec> g \<longleftrightarrow> f \<in> o(g)"},
- i.e.~@{prop "f \<prec> g \<longleftrightarrow> (\<forall>c. \<exists>n. \<forall>m>n. f m < Suc c * g m)"} but did not manage to
- do so.
+ i.e.~@{prop "f \<prec> g \<longleftrightarrow> (\<forall>c. \<exists>n. \<forall>m>n. f m < Suc c * g m)"} but did not
+ manage to do so.
*}
-subsection {* Assert that @{text "\<lesssim>"} is ineed a preorder *}
+subsection {* Assert that @{text "\<lesssim>"} is indeed a preorder *}
interpretation fun_order: preorder_equiv less_eq_fun less_fun
where "preorder_equiv.equiv less_eq_fun = equiv_fun"
--- a/src/Provers/blast.ML Tue May 11 09:10:31 2010 -0700
+++ b/src/Provers/blast.ML Tue May 11 11:02:56 2010 -0700
@@ -1278,7 +1278,7 @@
val (depth_limit, setup_depth_limit) = Attrib.config_int_global "blast_depth_limit" (K 20);
fun blast_tac cs i st =
- ((DEEPEN (1, Config.get_thy (Thm.theory_of_thm st) depth_limit)
+ ((DEEPEN (1, Config.get_global (Thm.theory_of_thm st) depth_limit)
(timing_depth_tac (start_timing ()) cs) 0) i
THEN flexflex_tac) st
handle TRANS s =>
--- a/src/Pure/Isar/attrib.ML Tue May 11 09:10:31 2010 -0700
+++ b/src/Pure/Isar/attrib.ML Tue May 11 11:02:56 2010 -0700
@@ -355,7 +355,7 @@
| scan_value (Config.String _) = equals |-- Args.name >> Config.String;
fun scan_config thy config =
- let val config_type = Config.get_thy thy config
+ let val config_type = Config.get_global thy config
in scan_value config_type >> (K o Thm.declaration_attribute o K o Config.put_generic config) end;
in
--- a/src/Pure/System/isabelle_system.scala Tue May 11 09:10:31 2010 -0700
+++ b/src/Pure/System/isabelle_system.scala Tue May 11 11:02:56 2010 -0700
@@ -318,7 +318,7 @@
val font_family = "IsabelleText"
- def get_font(bold: Boolean = false, size: Int = 1): Font =
+ def get_font(size: Int = 1, bold: Boolean = false): Font =
new Font(font_family, if (bold) Font.BOLD else Font.PLAIN, size)
def install_fonts()
@@ -330,7 +330,7 @@
else "$ISABELLE_HOME/lib/fonts/IsabelleText.ttf"
Font.createFont(Font.TRUETYPE_FONT, platform_file(name))
}
- def check_font() = get_font(false).getFamily == font_family
+ def check_font() = get_font().getFamily == font_family
if (!check_font()) {
val font = create_font(false)
--- a/src/Pure/config.ML Tue May 11 09:10:31 2010 -0700
+++ b/src/Pure/config.ML Tue May 11 11:02:56 2010 -0700
@@ -16,9 +16,9 @@
val get: Proof.context -> 'a T -> 'a
val map: 'a T -> ('a -> 'a) -> Proof.context -> Proof.context
val put: 'a T -> 'a -> Proof.context -> Proof.context
- val get_thy: theory -> 'a T -> 'a
- val map_thy: 'a T -> ('a -> 'a) -> theory -> theory
- val put_thy: 'a T -> 'a -> theory -> theory
+ val get_global: theory -> 'a T -> 'a
+ val map_global: 'a T -> ('a -> 'a) -> theory -> theory
+ val put_global: 'a T -> 'a -> theory -> theory
val get_generic: Context.generic -> 'a T -> 'a
val map_generic: 'a T -> ('a -> 'a) -> Context.generic -> Context.generic
val put_generic: 'a T -> 'a -> Context.generic -> Context.generic
@@ -83,9 +83,9 @@
fun map_ctxt config f = Context.proof_map (map_generic config f);
fun put_ctxt config value = map_ctxt config (K value);
-fun get_thy thy = get_generic (Context.Theory thy);
-fun map_thy config f = Context.theory_map (map_generic config f);
-fun put_thy config value = map_thy config (K value);
+fun get_global thy = get_generic (Context.Theory thy);
+fun map_global config f = Context.theory_map (map_generic config f);
+fun put_global config value = map_global config (K value);
(* context information *)
--- a/src/Pure/library.scala Tue May 11 09:10:31 2010 -0700
+++ b/src/Pure/library.scala Tue May 11 11:02:56 2010 -0700
@@ -76,9 +76,11 @@
private def simple_dialog(kind: Int, default_title: String)
(parent: Component, title: String, message: Any*)
{
- JOptionPane.showMessageDialog(parent,
- message.toArray.asInstanceOf[Array[AnyRef]],
- if (title == null) default_title else title, kind)
+ Swing_Thread.now {
+ JOptionPane.showMessageDialog(parent,
+ message.toArray.asInstanceOf[Array[AnyRef]],
+ if (title == null) default_title else title, kind)
+ }
}
def dialog = simple_dialog(JOptionPane.PLAIN_MESSAGE, null) _
--- a/src/Pure/unify.ML Tue May 11 09:10:31 2010 -0700
+++ b/src/Pure/unify.ML Tue May 11 11:02:56 2010 -0700
@@ -349,7 +349,7 @@
fun matchcopy thy vname = let fun mc(rbinder, targs, u, ed as (env,dpairs))
: (term * (Envir.env * dpair list))Seq.seq =
let
- val trace_tps = Config.get_thy thy trace_types;
+ val trace_tps = Config.get_global thy trace_types;
(*Produce copies of uarg and cons them in front of uargs*)
fun copycons uarg (uargs, (env, dpairs)) =
Seq.map(fn (uarg', ed') => (uarg'::uargs, ed'))
@@ -584,9 +584,9 @@
fun hounifiers (thy,env, tus : (term*term)list)
: (Envir.env * (term*term)list)Seq.seq =
let
- val trace_bnd = Config.get_thy thy trace_bound;
- val search_bnd = Config.get_thy thy search_bound;
- val trace_smp = Config.get_thy thy trace_simp;
+ val trace_bnd = Config.get_global thy trace_bound;
+ val search_bnd = Config.get_global thy search_bound;
+ val trace_smp = Config.get_global thy trace_simp;
fun add_unify tdepth ((env,dpairs), reseq) =
Seq.make (fn()=>
let val (env',flexflex,flexrigid) =
--- a/src/Tools/jEdit/README_BUILD Tue May 11 09:10:31 2010 -0700
+++ b/src/Tools/jEdit/README_BUILD Tue May 11 11:02:56 2010 -0700
@@ -8,10 +8,10 @@
* Netbeans 6.8
http://www.netbeans.org/downloads/index.html
-* Scala for Netbeans: version 6.8v1.1
- http://sourceforge.net/project/showfiles.php?group_id=192439&package_id=256544
+* Scala for Netbeans: version 6.8v1.1.0rc2
+ http://wiki.netbeans.org/Scala
+ http://sourceforge.net/projects/erlybird/files/nb-scala/6.8v1.1.0rc2
http://blogtrader.net/dcaoyuan/category/NetBeans
- http://wiki.netbeans.org/Scala
* jEdit 4.3.1 or 4.3.2
http://www.jedit.org/
--- a/src/Tools/jEdit/dist-template/properties/jedit.props Tue May 11 09:10:31 2010 -0700
+++ b/src/Tools/jEdit/dist-template/properties/jedit.props Tue May 11 11:02:56 2010 -0700
@@ -185,6 +185,7 @@
sidekick.complete-delay=300
sidekick.splitter.location=721
tip.show=false
+twoStageSave=false
view.antiAlias=standard
view.blockCaret=true
view.caretBlink=false
--- a/src/Tools/jEdit/nbproject/build-impl.xml Tue May 11 09:10:31 2010 -0700
+++ b/src/Tools/jEdit/nbproject/build-impl.xml Tue May 11 11:02:56 2010 -0700
@@ -230,7 +230,7 @@
<attribute default="" name="sourcepath"/>
<element name="customize" optional="true"/>
<sequential>
- <scalac addparams="-make:transitive -dependencyfile ${basedir}/${build.dir}/.scala_dependencies @{addparams}" deprecation="${scalac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" extdirs="@{extdirs}" force="yes" fork="true" includes="@{includes}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="jvm-${javac.target}" unchecked="${scalac.unchecked}">
+ <scalac addparams="-make:transitive -dependencyfile "${basedir}/${build.dir}/.scala_dependencies" @{addparams}" deprecation="${scalac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" extdirs="@{extdirs}" force="yes" fork="true" includes="@{includes}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="jvm-${javac.target}" unchecked="${scalac.unchecked}">
<classpath>
<path>
<pathelement path="@{classpath}"/>
@@ -549,7 +549,7 @@
-->
<target depends="init" name="-javadoc-build">
<mkdir dir="${dist.javadoc.dir}"/>
- <scaladoc addparams="${javadoc.additionalparam}" deprecation="yes" destdir="${dist.javadoc.dir}" doctitle="${javadoc.windowtitle}" encoding="${javadoc.encoding.used}" srcdir="${src.dir}" unchecked="yes" windowtitle="${javadoc.windowtitle}">
+ <scaladoc addparams="${javadoc.additionalparam}" deprecation="yes" destdir="${dist.javadoc.dir}" doctitle="${javadoc.windowtitle}" encoding="${javadoc.encoding.used}" srcdir="${src.dir}" unchecked="yes">
<classpath>
<path path="${javac.classpath}"/>
<fileset dir="${scala.lib}">
--- a/src/Tools/jEdit/nbproject/genfiles.properties Tue May 11 09:10:31 2010 -0700
+++ b/src/Tools/jEdit/nbproject/genfiles.properties Tue May 11 11:02:56 2010 -0700
@@ -4,5 +4,5 @@
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=8f41dcce
-nbproject/build-impl.xml.script.CRC32=1c29c971
-nbproject/build-impl.xml.stylesheet.CRC32=8c3c03dd@1.3.4
+nbproject/build-impl.xml.script.CRC32=e3e2a5d5
+nbproject/build-impl.xml.stylesheet.CRC32=5220179f@1.3.5
--- a/src/Tools/jEdit/plugin/Isabelle.props Tue May 11 09:10:31 2010 -0700
+++ b/src/Tools/jEdit/plugin/Isabelle.props Tue May 11 11:02:56 2010 -0700
@@ -25,8 +25,10 @@
options.isabelle.label=Isabelle
options.isabelle.code=new isabelle.jedit.Isabelle_Options();
options.isabelle.logic.title=Logic
-options.isabelle.font-size.title=Font Size
-options.isabelle.font-size=14
+options.isabelle.relative-font-size.title=Relative Font Size
+options.isabelle.relative-font-size=100
+options.isabelle.relative-margin.title=Relative Margin
+options.isabelle.relative-margin=90
options.isabelle.startup-timeout=10000
#menu actions
--- a/src/Tools/jEdit/src/jedit/html_panel.scala Tue May 11 09:10:31 2010 -0700
+++ b/src/Tools/jEdit/src/jedit/html_panel.scala Tue May 11 11:02:56 2010 -0700
@@ -10,7 +10,7 @@
import isabelle._
import java.io.StringReader
-import java.awt.{BorderLayout, Dimension}
+import java.awt.{BorderLayout, Dimension, GraphicsEnvironment, Toolkit}
import java.awt.event.MouseEvent
import javax.swing.{JButton, JPanel, JScrollPane}
@@ -40,7 +40,7 @@
class HTML_Panel(
sys: Isabelle_System,
- initial_font_size: Int,
+ font_size0: Int, relative_margin0: Int,
handler: PartialFunction[HTML_Panel.Event, Unit]) extends HtmlPanel
{
// global logging
@@ -56,6 +56,15 @@
}
private def template(font_size: Int): String =
+ {
+ // re-adjustment according to org.lobobrowser.html.style.HtmlValues.getFontSize
+ val dpi =
+ if (GraphicsEnvironment.isHeadless()) 72
+ else Toolkit.getDefaultToolkit().getScreenResolution()
+
+ val size0 = font_size * dpi / 96
+ val size = if (size0 * 96 / dpi == font_size) size0 else size0 + 1
+
"""<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@@ -65,13 +74,24 @@
""" +
try_file("$ISABELLE_HOME/lib/html/isabelle.css") + "\n" +
try_file("$ISABELLE_HOME_USER/etc/isabelle.css") + "\n" +
- "body { font-family: " + sys.font_family + "; font-size: " + font_size + "px }" +
+ "body { font-family: " + sys.font_family + "; font-size: " + size + "px }" +
"""
</style>
</head>
<body/>
</html>
"""
+ }
+
+
+ def panel_width(font_size: Int, relative_margin: Int): Int =
+ {
+ val font = sys.get_font(font_size)
+ Swing_Thread.now {
+ val char_width = (getFontMetrics(font).stringWidth("mix") / 3) max 1
+ ((getWidth() * relative_margin) / (100 * char_width)) max 20
+ }
+ }
/* actor with local state */
@@ -98,7 +118,7 @@
private val builder = new DocumentBuilderImpl(ucontext, rcontext)
- private case class Init(font_size: Int)
+ private case class Init(font_size: Int, relative_margin: Int)
private case class Render(body: List[XML.Tree])
private val main_actor = actor {
@@ -106,9 +126,15 @@
var doc1: org.w3c.dom.Document = null
var doc2: org.w3c.dom.Document = null
+ var current_font_size = 16
+ var current_relative_margin = 90
+
loop {
react {
- case Init(font_size) =>
+ case Init(font_size, relative_margin) =>
+ current_font_size = font_size
+ current_relative_margin = relative_margin
+
val src = template(font_size)
def parse() =
builder.parse(new InputSourceImpl(new StringReader(src), "http://localhost"))
@@ -118,7 +144,9 @@
case Render(body) =>
val doc = doc2
- val html_body = Pretty.formatted(body).map(t => XML.elem(HTML.PRE, HTML.spans(t)))
+ val html_body =
+ Pretty.formatted(body, panel_width(current_font_size, current_relative_margin))
+ .map(t => XML.elem(HTML.PRE, HTML.spans(t)))
val node = XML.document_node(doc, XML.elem(HTML.BODY, html_body))
doc.removeChild(doc.getLastChild())
doc.appendChild(node)
@@ -131,11 +159,11 @@
}
}
- main_actor ! Init(initial_font_size)
-
/* main method wrappers */
- def init(font_size: Int) { main_actor ! Init(font_size) }
+ def init(font_size: Int, relative_margin: Int) { main_actor ! Init(font_size, relative_margin) }
def render(body: List[XML.Tree]) { main_actor ! Render(body) }
+
+ init(font_size0, relative_margin0)
}
--- a/src/Tools/jEdit/src/jedit/isabelle_options.scala Tue May 11 09:10:31 2010 -0700
+++ b/src/Tools/jEdit/src/jedit/isabelle_options.scala Tue May 11 11:02:56 2010 -0700
@@ -15,7 +15,8 @@
class Isabelle_Options extends AbstractOptionPane("isabelle")
{
private val logic_name = new JComboBox()
- private val font_size = new JSpinner()
+ private val relative_font_size = new JSpinner()
+ private val relative_margin = new JSpinner()
private class List_Item(val name: String, val descr: String) {
def this(name: String) = this(name, name)
@@ -36,18 +37,26 @@
logic_name
})
- addComponent(Isabelle.Property("font-size.title"), {
- font_size.setValue(Isabelle.Int_Property("font-size"))
- font_size
+ addComponent(Isabelle.Property("relative-font-size.title"), {
+ relative_font_size.setValue(Isabelle.Int_Property("relative-font-size"))
+ relative_font_size
+ })
+
+ addComponent(Isabelle.Property("relative-margin.title"), {
+ relative_margin.setValue(Isabelle.Int_Property("relative-margin"))
+ relative_margin
})
}
override def _save()
{
- val logic = logic_name.getSelectedItem.asInstanceOf[List_Item].name
- Isabelle.Property("logic") = logic
+ Isabelle.Property("logic") =
+ logic_name.getSelectedItem.asInstanceOf[List_Item].name
- val size = font_size.getValue().asInstanceOf[Int]
- Isabelle.Int_Property("font-size") = size
+ Isabelle.Int_Property("relative-font-size") =
+ relative_font_size.getValue().asInstanceOf[Int]
+
+ Isabelle.Int_Property("relative-margin") =
+ relative_margin.getValue().asInstanceOf[Int]
}
}
--- a/src/Tools/jEdit/src/jedit/output_dockable.scala Tue May 11 09:10:31 2010 -0700
+++ b/src/Tools/jEdit/src/jedit/output_dockable.scala Tue May 11 11:02:56 2010 -0700
@@ -24,8 +24,9 @@
if (position == DockableWindowManager.FLOATING)
setPreferredSize(new Dimension(500, 250))
- private val html_panel =
- new HTML_Panel(Isabelle.system, Isabelle.Int_Property("font-size"), null)
+ val html_panel =
+ new HTML_Panel(Isabelle.system,
+ Isabelle.font_size(), Isabelle.Int_Property("relative-margin"), null)
add(html_panel, BorderLayout.CENTER)
@@ -43,7 +44,7 @@
}
case Session.Global_Settings =>
- html_panel.init(Isabelle.Int_Property("font-size"))
+ html_panel.init(Isabelle.font_size(), Isabelle.Int_Property("relative-margin"))
case bad => System.err.println("output_actor: ignoring bad message " + bad)
}
--- a/src/Tools/jEdit/src/jedit/plugin.scala Tue May 11 09:10:31 2010 -0700
+++ b/src/Tools/jEdit/src/jedit/plugin.scala Tue May 11 11:02:56 2010 -0700
@@ -42,22 +42,37 @@
object Property
{
- def apply(name: String): String = jEdit.getProperty(OPTION_PREFIX + name)
- def update(name: String, value: String) = jEdit.setProperty(OPTION_PREFIX + name, value)
+ def apply(name: String): String =
+ jEdit.getProperty(OPTION_PREFIX + name)
+ def apply(name: String, default: String): String =
+ jEdit.getProperty(OPTION_PREFIX + name, default)
+ def update(name: String, value: String) =
+ jEdit.setProperty(OPTION_PREFIX + name, value)
}
object Boolean_Property
{
- def apply(name: String): Boolean = jEdit.getBooleanProperty(OPTION_PREFIX + name)
- def update(name: String, value: Boolean) = jEdit.setBooleanProperty(OPTION_PREFIX + name, value)
+ def apply(name: String): Boolean =
+ jEdit.getBooleanProperty(OPTION_PREFIX + name)
+ def apply(name: String, default: Boolean): Boolean =
+ jEdit.getBooleanProperty(OPTION_PREFIX + name, default)
+ def update(name: String, value: Boolean) =
+ jEdit.setBooleanProperty(OPTION_PREFIX + name, value)
}
object Int_Property
{
- def apply(name: String): Int = jEdit.getIntegerProperty(OPTION_PREFIX + name)
- def update(name: String, value: Int) = jEdit.setIntegerProperty(OPTION_PREFIX + name, value)
+ def apply(name: String): Int =
+ jEdit.getIntegerProperty(OPTION_PREFIX + name)
+ def apply(name: String, default: Int): Int =
+ jEdit.getIntegerProperty(OPTION_PREFIX + name, default)
+ def update(name: String, value: Int) =
+ jEdit.setIntegerProperty(OPTION_PREFIX + name, value)
}
+ def font_size(): Int =
+ (jEdit.getIntegerProperty("view.fontsize", 16) * Int_Property("relative-font-size", 100)) / 100
+
/* settings */