src/HOL/Tools/Qelim/generated_cooper.ML
author haftmann
Mon, 06 Jul 2009 14:19:13 +0200
changeset 31949 3f933687fae9
parent 29939 2138ff0ec94a
child 36528 48c35032d060
permissions -rw-r--r--
moved Inductive.myinv to Fun.inv; tuned
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24584
01e83ffa6c54 fixed title
haftmann
parents: 23714
diff changeset
     1
(*  Title:      HOL/Tools/Qelim/generated_cooper.ML
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
     2
29823
0ab754d13ccd session Reflecion renamed to Decision_Procs, moved Dense_Linear_Order there
haftmann
parents: 29787
diff changeset
     3
This file is generated from HOL/Decision_Procs/Cooper.thy.  DO NOT EDIT.
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
     4
*)
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
     5
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
     6
structure GeneratedCooper = 
23466
886655a150f6 moved quantifier elimination tools to Tools/Qelim/;
wenzelm
parents:
diff changeset
     7
struct
886655a150f6 moved quantifier elimination tools to Tools/Qelim/;
wenzelm
parents:
diff changeset
     8
23714
49b08f25db29 now a monolithic module
haftmann
parents: 23689
diff changeset
     9
type 'a eq = {eq : 'a -> 'a -> bool};
49b08f25db29 now a monolithic module
haftmann
parents: 23689
diff changeset
    10
fun eq (A_:'a eq) = #eq A_;
23466
886655a150f6 moved quantifier elimination tools to Tools/Qelim/;
wenzelm
parents:
diff changeset
    11
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    12
val eq_nat = {eq = (fn a => fn b => ((a : IntInf.int) = b))} : IntInf.int eq;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    13
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    14
fun eqop A_ a b = eq A_ a b;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    15
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    16
fun divmod n m = (if eqop eq_nat m 0 then (0, n) else IntInf.divMod (n, m));
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    17
29939
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
    18
fun snd (a, b) = b;
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    19
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    20
fun mod_nat m n = snd (divmod m n);
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    21
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    22
fun gcd m n = (if eqop eq_nat n 0 then m else gcd n (mod_nat m n));
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    23
29939
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
    24
fun fst (a, b) = a;
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    25
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    26
fun div_nat m n = fst (divmod m n);
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    27
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    28
fun lcm m n = div_nat (IntInf.* (m, n)) (gcd m n);
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    29
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    30
fun leta s f = f s;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    31
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    32
fun suc n = IntInf.+ (n, 1);
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    33
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    34
datatype num = Mul of IntInf.int * num | Sub of num * num | Add of num * num |
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    35
  Neg of num | Cn of IntInf.int * IntInf.int * num | Bound of IntInf.int |
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    36
  C of IntInf.int;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    37
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    38
datatype fm = NClosed of IntInf.int | Closed of IntInf.int | A of fm | E of fm |
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    39
  Iff of fm * fm | Imp of fm * fm | Or of fm * fm | And of fm * fm | Not of fm |
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    40
  NDvd of IntInf.int * num | Dvd of IntInf.int * num | NEq of num | Eq of num |
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    41
  Ge of num | Gt of num | Le of num | Lt of num | F | T;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    42
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    43
fun abs_int i = (if IntInf.< (i, (0 : IntInf.int)) then IntInf.~ i else i);
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    44
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    45
fun zlcm i j =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    46
  (lcm (IntInf.max (0, (abs_int i))) (IntInf.max (0, (abs_int j))));
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    47
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    48
fun map f [] = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    49
  | map f (x :: xs) = f x :: map f xs;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    50
29939
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
    51
fun append [] ys = ys
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    52
  | append (x :: xs) ys = x :: append xs ys;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    53
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    54
fun disjuncts (Or (p, q)) = append (disjuncts p) (disjuncts q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    55
  | disjuncts F = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    56
  | disjuncts T = [T]
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    57
  | disjuncts (Lt u) = [Lt u]
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    58
  | disjuncts (Le v) = [Le v]
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    59
  | disjuncts (Gt w) = [Gt w]
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    60
  | disjuncts (Ge x) = [Ge x]
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    61
  | disjuncts (Eq y) = [Eq y]
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    62
  | disjuncts (NEq z) = [NEq z]
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    63
  | disjuncts (Dvd (aa, ab)) = [Dvd (aa, ab)]
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    64
  | disjuncts (NDvd (ac, ad)) = [NDvd (ac, ad)]
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    65
  | disjuncts (Not ae) = [Not ae]
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    66
  | disjuncts (And (af, ag)) = [And (af, ag)]
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    67
  | disjuncts (Imp (aj, ak)) = [Imp (aj, ak)]
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    68
  | disjuncts (Iff (al, am)) = [Iff (al, am)]
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    69
  | disjuncts (E an) = [E an]
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    70
  | disjuncts (A ao) = [A ao]
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    71
  | disjuncts (Closed ap) = [Closed ap]
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    72
  | disjuncts (NClosed aq) = [NClosed aq];
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    73
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    74
fun fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    75
  (NClosed nat) = f19 nat
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    76
  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    77
    (Closed nat) = f18 nat
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    78
  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    79
    (A fm) = f17 fm
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    80
  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    81
    (E fm) = f16 fm
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    82
  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    83
    (Iff (fm1, fm2)) = f15 fm1 fm2
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    84
  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    85
    (Imp (fm1, fm2)) = f14 fm1 fm2
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    86
  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    87
    (Or (fm1, fm2)) = f13 fm1 fm2
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    88
  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    89
    (And (fm1, fm2)) = f12 fm1 fm2
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    90
  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    91
    (Not fm) = f11 fm
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    92
  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    93
    (NDvd (inta, num)) = f10 inta num
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    94
  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    95
    (Dvd (inta, num)) = f9 inta num
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    96
  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    97
    (NEq num) = f8 num
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    98
  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
    99
    (Eq num) = f7 num
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   100
  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   101
    (Ge num) = f6 num
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   102
  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   103
    (Gt num) = f5 num
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   104
  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   105
    (Le num) = f4 num
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   106
  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   107
    (Lt num) = f3 num
29939
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   108
  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19 F
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   109
    = f2
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   110
  | fm_case f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19 T
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   111
    = f1;
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   112
29939
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   113
fun eq_num (Mul (c, d)) (Sub (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   114
  | eq_num (Mul (c, d)) (Add (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   115
  | eq_num (Sub (c, d)) (Add (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   116
  | eq_num (Mul (b, c)) (Neg a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   117
  | eq_num (Sub (b, c)) (Neg a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   118
  | eq_num (Add (b, c)) (Neg a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   119
  | eq_num (Mul (d, e)) (Cn (a, b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   120
  | eq_num (Sub (d, e)) (Cn (a, b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   121
  | eq_num (Add (d, e)) (Cn (a, b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   122
  | eq_num (Neg d) (Cn (a, b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   123
  | eq_num (Mul (b, c)) (Bound a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   124
  | eq_num (Sub (b, c)) (Bound a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   125
  | eq_num (Add (b, c)) (Bound a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   126
  | eq_num (Neg b) (Bound a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   127
  | eq_num (Cn (b, c, d)) (Bound a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   128
  | eq_num (Mul (b, c)) (C a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   129
  | eq_num (Sub (b, c)) (C a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   130
  | eq_num (Add (b, c)) (C a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   131
  | eq_num (Neg b) (C a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   132
  | eq_num (Cn (b, c, d)) (C a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   133
  | eq_num (Bound b) (C a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   134
  | eq_num (Sub (a, b)) (Mul (c, d)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   135
  | eq_num (Add (a, b)) (Mul (c, d)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   136
  | eq_num (Add (a, b)) (Sub (c, d)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   137
  | eq_num (Neg a) (Mul (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   138
  | eq_num (Neg a) (Sub (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   139
  | eq_num (Neg a) (Add (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   140
  | eq_num (Cn (a, b, c)) (Mul (d, e)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   141
  | eq_num (Cn (a, b, c)) (Sub (d, e)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   142
  | eq_num (Cn (a, b, c)) (Add (d, e)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   143
  | eq_num (Cn (a, b, c)) (Neg d) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   144
  | eq_num (Bound a) (Mul (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   145
  | eq_num (Bound a) (Sub (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   146
  | eq_num (Bound a) (Add (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   147
  | eq_num (Bound a) (Neg b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   148
  | eq_num (Bound a) (Cn (b, c, d)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   149
  | eq_num (C a) (Mul (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   150
  | eq_num (C a) (Sub (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   151
  | eq_num (C a) (Add (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   152
  | eq_num (C a) (Neg b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   153
  | eq_num (C a) (Cn (b, c, d)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   154
  | eq_num (C a) (Bound b) = false
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   155
  | eq_num (Mul (inta, num)) (Mul (int', num')) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   156
    ((inta : IntInf.int) = int') andalso eq_num num num'
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   157
  | eq_num (Sub (num1, num2)) (Sub (num1', num2')) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   158
    eq_num num1 num1' andalso eq_num num2 num2'
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   159
  | eq_num (Add (num1, num2)) (Add (num1', num2')) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   160
    eq_num num1 num1' andalso eq_num num2 num2'
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   161
  | eq_num (Neg num) (Neg num') = eq_num num num'
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   162
  | eq_num (Cn (nat, inta, num)) (Cn (nat', int', num')) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   163
    ((nat : IntInf.int) = nat') andalso
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   164
      (((inta : IntInf.int) = int') andalso eq_num num num')
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   165
  | eq_num (Bound nat) (Bound nat') = ((nat : IntInf.int) = nat')
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   166
  | eq_num (C inta) (C int') = ((inta : IntInf.int) = int');
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   167
29939
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   168
fun eq_fm (NClosed b) (Closed a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   169
  | eq_fm (NClosed b) (A a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   170
  | eq_fm (Closed b) (A a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   171
  | eq_fm (NClosed b) (E a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   172
  | eq_fm (Closed b) (E a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   173
  | eq_fm (A b) (E a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   174
  | eq_fm (NClosed c) (Iff (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   175
  | eq_fm (Closed c) (Iff (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   176
  | eq_fm (A c) (Iff (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   177
  | eq_fm (E c) (Iff (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   178
  | eq_fm (NClosed c) (Imp (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   179
  | eq_fm (Closed c) (Imp (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   180
  | eq_fm (A c) (Imp (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   181
  | eq_fm (E c) (Imp (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   182
  | eq_fm (Iff (c, d)) (Imp (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   183
  | eq_fm (NClosed c) (Or (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   184
  | eq_fm (Closed c) (Or (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   185
  | eq_fm (A c) (Or (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   186
  | eq_fm (E c) (Or (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   187
  | eq_fm (Iff (c, d)) (Or (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   188
  | eq_fm (Imp (c, d)) (Or (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   189
  | eq_fm (NClosed c) (And (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   190
  | eq_fm (Closed c) (And (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   191
  | eq_fm (A c) (And (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   192
  | eq_fm (E c) (And (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   193
  | eq_fm (Iff (c, d)) (And (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   194
  | eq_fm (Imp (c, d)) (And (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   195
  | eq_fm (Or (c, d)) (And (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   196
  | eq_fm (NClosed b) (Not a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   197
  | eq_fm (Closed b) (Not a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   198
  | eq_fm (A b) (Not a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   199
  | eq_fm (E b) (Not a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   200
  | eq_fm (Iff (b, c)) (Not a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   201
  | eq_fm (Imp (b, c)) (Not a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   202
  | eq_fm (Or (b, c)) (Not a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   203
  | eq_fm (And (b, c)) (Not a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   204
  | eq_fm (NClosed c) (NDvd (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   205
  | eq_fm (Closed c) (NDvd (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   206
  | eq_fm (A c) (NDvd (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   207
  | eq_fm (E c) (NDvd (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   208
  | eq_fm (Iff (c, d)) (NDvd (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   209
  | eq_fm (Imp (c, d)) (NDvd (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   210
  | eq_fm (Or (c, d)) (NDvd (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   211
  | eq_fm (And (c, d)) (NDvd (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   212
  | eq_fm (Not c) (NDvd (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   213
  | eq_fm (NClosed c) (Dvd (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   214
  | eq_fm (Closed c) (Dvd (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   215
  | eq_fm (A c) (Dvd (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   216
  | eq_fm (E c) (Dvd (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   217
  | eq_fm (Iff (c, d)) (Dvd (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   218
  | eq_fm (Imp (c, d)) (Dvd (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   219
  | eq_fm (Or (c, d)) (Dvd (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   220
  | eq_fm (And (c, d)) (Dvd (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   221
  | eq_fm (Not c) (Dvd (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   222
  | eq_fm (NDvd (c, d)) (Dvd (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   223
  | eq_fm (NClosed b) (NEq a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   224
  | eq_fm (Closed b) (NEq a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   225
  | eq_fm (A b) (NEq a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   226
  | eq_fm (E b) (NEq a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   227
  | eq_fm (Iff (b, c)) (NEq a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   228
  | eq_fm (Imp (b, c)) (NEq a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   229
  | eq_fm (Or (b, c)) (NEq a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   230
  | eq_fm (And (b, c)) (NEq a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   231
  | eq_fm (Not b) (NEq a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   232
  | eq_fm (NDvd (b, c)) (NEq a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   233
  | eq_fm (Dvd (b, c)) (NEq a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   234
  | eq_fm (NClosed b) (Eq a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   235
  | eq_fm (Closed b) (Eq a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   236
  | eq_fm (A b) (Eq a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   237
  | eq_fm (E b) (Eq a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   238
  | eq_fm (Iff (b, c)) (Eq a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   239
  | eq_fm (Imp (b, c)) (Eq a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   240
  | eq_fm (Or (b, c)) (Eq a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   241
  | eq_fm (And (b, c)) (Eq a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   242
  | eq_fm (Not b) (Eq a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   243
  | eq_fm (NDvd (b, c)) (Eq a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   244
  | eq_fm (Dvd (b, c)) (Eq a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   245
  | eq_fm (NEq b) (Eq a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   246
  | eq_fm (NClosed b) (Ge a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   247
  | eq_fm (Closed b) (Ge a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   248
  | eq_fm (A b) (Ge a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   249
  | eq_fm (E b) (Ge a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   250
  | eq_fm (Iff (b, c)) (Ge a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   251
  | eq_fm (Imp (b, c)) (Ge a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   252
  | eq_fm (Or (b, c)) (Ge a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   253
  | eq_fm (And (b, c)) (Ge a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   254
  | eq_fm (Not b) (Ge a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   255
  | eq_fm (NDvd (b, c)) (Ge a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   256
  | eq_fm (Dvd (b, c)) (Ge a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   257
  | eq_fm (NEq b) (Ge a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   258
  | eq_fm (Eq b) (Ge a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   259
  | eq_fm (NClosed b) (Gt a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   260
  | eq_fm (Closed b) (Gt a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   261
  | eq_fm (A b) (Gt a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   262
  | eq_fm (E b) (Gt a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   263
  | eq_fm (Iff (b, c)) (Gt a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   264
  | eq_fm (Imp (b, c)) (Gt a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   265
  | eq_fm (Or (b, c)) (Gt a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   266
  | eq_fm (And (b, c)) (Gt a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   267
  | eq_fm (Not b) (Gt a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   268
  | eq_fm (NDvd (b, c)) (Gt a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   269
  | eq_fm (Dvd (b, c)) (Gt a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   270
  | eq_fm (NEq b) (Gt a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   271
  | eq_fm (Eq b) (Gt a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   272
  | eq_fm (Ge b) (Gt a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   273
  | eq_fm (NClosed b) (Le a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   274
  | eq_fm (Closed b) (Le a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   275
  | eq_fm (A b) (Le a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   276
  | eq_fm (E b) (Le a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   277
  | eq_fm (Iff (b, c)) (Le a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   278
  | eq_fm (Imp (b, c)) (Le a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   279
  | eq_fm (Or (b, c)) (Le a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   280
  | eq_fm (And (b, c)) (Le a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   281
  | eq_fm (Not b) (Le a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   282
  | eq_fm (NDvd (b, c)) (Le a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   283
  | eq_fm (Dvd (b, c)) (Le a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   284
  | eq_fm (NEq b) (Le a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   285
  | eq_fm (Eq b) (Le a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   286
  | eq_fm (Ge b) (Le a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   287
  | eq_fm (Gt b) (Le a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   288
  | eq_fm (NClosed b) (Lt a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   289
  | eq_fm (Closed b) (Lt a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   290
  | eq_fm (A b) (Lt a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   291
  | eq_fm (E b) (Lt a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   292
  | eq_fm (Iff (b, c)) (Lt a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   293
  | eq_fm (Imp (b, c)) (Lt a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   294
  | eq_fm (Or (b, c)) (Lt a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   295
  | eq_fm (And (b, c)) (Lt a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   296
  | eq_fm (Not b) (Lt a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   297
  | eq_fm (NDvd (b, c)) (Lt a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   298
  | eq_fm (Dvd (b, c)) (Lt a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   299
  | eq_fm (NEq b) (Lt a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   300
  | eq_fm (Eq b) (Lt a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   301
  | eq_fm (Ge b) (Lt a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   302
  | eq_fm (Gt b) (Lt a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   303
  | eq_fm (Le b) (Lt a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   304
  | eq_fm (NClosed a) F = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   305
  | eq_fm (Closed a) F = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   306
  | eq_fm (A a) F = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   307
  | eq_fm (E a) F = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   308
  | eq_fm (Iff (a, b)) F = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   309
  | eq_fm (Imp (a, b)) F = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   310
  | eq_fm (Or (a, b)) F = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   311
  | eq_fm (And (a, b)) F = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   312
  | eq_fm (Not a) F = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   313
  | eq_fm (NDvd (a, b)) F = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   314
  | eq_fm (Dvd (a, b)) F = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   315
  | eq_fm (NEq a) F = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   316
  | eq_fm (Eq a) F = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   317
  | eq_fm (Ge a) F = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   318
  | eq_fm (Gt a) F = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   319
  | eq_fm (Le a) F = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   320
  | eq_fm (Lt a) F = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   321
  | eq_fm (NClosed a) T = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   322
  | eq_fm (Closed a) T = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   323
  | eq_fm (A a) T = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   324
  | eq_fm (E a) T = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   325
  | eq_fm (Iff (a, b)) T = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   326
  | eq_fm (Imp (a, b)) T = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   327
  | eq_fm (Or (a, b)) T = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   328
  | eq_fm (And (a, b)) T = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   329
  | eq_fm (Not a) T = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   330
  | eq_fm (NDvd (a, b)) T = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   331
  | eq_fm (Dvd (a, b)) T = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   332
  | eq_fm (NEq a) T = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   333
  | eq_fm (Eq a) T = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   334
  | eq_fm (Ge a) T = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   335
  | eq_fm (Gt a) T = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   336
  | eq_fm (Le a) T = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   337
  | eq_fm (Lt a) T = false
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   338
  | eq_fm F T = false
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   339
  | eq_fm (Closed a) (NClosed b) = false
29939
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   340
  | eq_fm (A a) (NClosed b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   341
  | eq_fm (A a) (Closed b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   342
  | eq_fm (E a) (NClosed b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   343
  | eq_fm (E a) (Closed b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   344
  | eq_fm (E a) (A b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   345
  | eq_fm (Iff (a, b)) (NClosed c) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   346
  | eq_fm (Iff (a, b)) (Closed c) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   347
  | eq_fm (Iff (a, b)) (A c) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   348
  | eq_fm (Iff (a, b)) (E c) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   349
  | eq_fm (Imp (a, b)) (NClosed c) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   350
  | eq_fm (Imp (a, b)) (Closed c) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   351
  | eq_fm (Imp (a, b)) (A c) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   352
  | eq_fm (Imp (a, b)) (E c) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   353
  | eq_fm (Imp (a, b)) (Iff (c, d)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   354
  | eq_fm (Or (a, b)) (NClosed c) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   355
  | eq_fm (Or (a, b)) (Closed c) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   356
  | eq_fm (Or (a, b)) (A c) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   357
  | eq_fm (Or (a, b)) (E c) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   358
  | eq_fm (Or (a, b)) (Iff (c, d)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   359
  | eq_fm (Or (a, b)) (Imp (c, d)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   360
  | eq_fm (And (a, b)) (NClosed c) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   361
  | eq_fm (And (a, b)) (Closed c) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   362
  | eq_fm (And (a, b)) (A c) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   363
  | eq_fm (And (a, b)) (E c) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   364
  | eq_fm (And (a, b)) (Iff (c, d)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   365
  | eq_fm (And (a, b)) (Imp (c, d)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   366
  | eq_fm (And (a, b)) (Or (c, d)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   367
  | eq_fm (Not a) (NClosed b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   368
  | eq_fm (Not a) (Closed b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   369
  | eq_fm (Not a) (A b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   370
  | eq_fm (Not a) (E b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   371
  | eq_fm (Not a) (Iff (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   372
  | eq_fm (Not a) (Imp (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   373
  | eq_fm (Not a) (Or (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   374
  | eq_fm (Not a) (And (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   375
  | eq_fm (NDvd (a, b)) (NClosed c) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   376
  | eq_fm (NDvd (a, b)) (Closed c) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   377
  | eq_fm (NDvd (a, b)) (A c) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   378
  | eq_fm (NDvd (a, b)) (E c) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   379
  | eq_fm (NDvd (a, b)) (Iff (c, d)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   380
  | eq_fm (NDvd (a, b)) (Imp (c, d)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   381
  | eq_fm (NDvd (a, b)) (Or (c, d)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   382
  | eq_fm (NDvd (a, b)) (And (c, d)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   383
  | eq_fm (NDvd (a, b)) (Not c) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   384
  | eq_fm (Dvd (a, b)) (NClosed c) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   385
  | eq_fm (Dvd (a, b)) (Closed c) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   386
  | eq_fm (Dvd (a, b)) (A c) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   387
  | eq_fm (Dvd (a, b)) (E c) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   388
  | eq_fm (Dvd (a, b)) (Iff (c, d)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   389
  | eq_fm (Dvd (a, b)) (Imp (c, d)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   390
  | eq_fm (Dvd (a, b)) (Or (c, d)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   391
  | eq_fm (Dvd (a, b)) (And (c, d)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   392
  | eq_fm (Dvd (a, b)) (Not c) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   393
  | eq_fm (Dvd (a, b)) (NDvd (c, d)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   394
  | eq_fm (NEq a) (NClosed b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   395
  | eq_fm (NEq a) (Closed b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   396
  | eq_fm (NEq a) (A b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   397
  | eq_fm (NEq a) (E b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   398
  | eq_fm (NEq a) (Iff (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   399
  | eq_fm (NEq a) (Imp (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   400
  | eq_fm (NEq a) (Or (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   401
  | eq_fm (NEq a) (And (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   402
  | eq_fm (NEq a) (Not b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   403
  | eq_fm (NEq a) (NDvd (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   404
  | eq_fm (NEq a) (Dvd (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   405
  | eq_fm (Eq a) (NClosed b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   406
  | eq_fm (Eq a) (Closed b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   407
  | eq_fm (Eq a) (A b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   408
  | eq_fm (Eq a) (E b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   409
  | eq_fm (Eq a) (Iff (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   410
  | eq_fm (Eq a) (Imp (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   411
  | eq_fm (Eq a) (Or (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   412
  | eq_fm (Eq a) (And (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   413
  | eq_fm (Eq a) (Not b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   414
  | eq_fm (Eq a) (NDvd (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   415
  | eq_fm (Eq a) (Dvd (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   416
  | eq_fm (Eq a) (NEq b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   417
  | eq_fm (Ge a) (NClosed b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   418
  | eq_fm (Ge a) (Closed b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   419
  | eq_fm (Ge a) (A b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   420
  | eq_fm (Ge a) (E b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   421
  | eq_fm (Ge a) (Iff (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   422
  | eq_fm (Ge a) (Imp (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   423
  | eq_fm (Ge a) (Or (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   424
  | eq_fm (Ge a) (And (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   425
  | eq_fm (Ge a) (Not b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   426
  | eq_fm (Ge a) (NDvd (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   427
  | eq_fm (Ge a) (Dvd (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   428
  | eq_fm (Ge a) (NEq b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   429
  | eq_fm (Ge a) (Eq b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   430
  | eq_fm (Gt a) (NClosed b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   431
  | eq_fm (Gt a) (Closed b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   432
  | eq_fm (Gt a) (A b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   433
  | eq_fm (Gt a) (E b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   434
  | eq_fm (Gt a) (Iff (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   435
  | eq_fm (Gt a) (Imp (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   436
  | eq_fm (Gt a) (Or (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   437
  | eq_fm (Gt a) (And (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   438
  | eq_fm (Gt a) (Not b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   439
  | eq_fm (Gt a) (NDvd (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   440
  | eq_fm (Gt a) (Dvd (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   441
  | eq_fm (Gt a) (NEq b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   442
  | eq_fm (Gt a) (Eq b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   443
  | eq_fm (Gt a) (Ge b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   444
  | eq_fm (Le a) (NClosed b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   445
  | eq_fm (Le a) (Closed b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   446
  | eq_fm (Le a) (A b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   447
  | eq_fm (Le a) (E b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   448
  | eq_fm (Le a) (Iff (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   449
  | eq_fm (Le a) (Imp (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   450
  | eq_fm (Le a) (Or (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   451
  | eq_fm (Le a) (And (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   452
  | eq_fm (Le a) (Not b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   453
  | eq_fm (Le a) (NDvd (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   454
  | eq_fm (Le a) (Dvd (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   455
  | eq_fm (Le a) (NEq b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   456
  | eq_fm (Le a) (Eq b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   457
  | eq_fm (Le a) (Ge b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   458
  | eq_fm (Le a) (Gt b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   459
  | eq_fm (Lt a) (NClosed b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   460
  | eq_fm (Lt a) (Closed b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   461
  | eq_fm (Lt a) (A b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   462
  | eq_fm (Lt a) (E b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   463
  | eq_fm (Lt a) (Iff (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   464
  | eq_fm (Lt a) (Imp (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   465
  | eq_fm (Lt a) (Or (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   466
  | eq_fm (Lt a) (And (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   467
  | eq_fm (Lt a) (Not b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   468
  | eq_fm (Lt a) (NDvd (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   469
  | eq_fm (Lt a) (Dvd (b, c)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   470
  | eq_fm (Lt a) (NEq b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   471
  | eq_fm (Lt a) (Eq b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   472
  | eq_fm (Lt a) (Ge b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   473
  | eq_fm (Lt a) (Gt b) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   474
  | eq_fm (Lt a) (Le b) = false
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   475
  | eq_fm F (NClosed a) = false
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   476
  | eq_fm F (Closed a) = false
29939
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   477
  | eq_fm F (A a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   478
  | eq_fm F (E a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   479
  | eq_fm F (Iff (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   480
  | eq_fm F (Imp (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   481
  | eq_fm F (Or (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   482
  | eq_fm F (And (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   483
  | eq_fm F (Not a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   484
  | eq_fm F (NDvd (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   485
  | eq_fm F (Dvd (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   486
  | eq_fm F (NEq a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   487
  | eq_fm F (Eq a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   488
  | eq_fm F (Ge a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   489
  | eq_fm F (Gt a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   490
  | eq_fm F (Le a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   491
  | eq_fm F (Lt a) = false
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   492
  | eq_fm T (NClosed a) = false
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   493
  | eq_fm T (Closed a) = false
29939
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   494
  | eq_fm T (A a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   495
  | eq_fm T (E a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   496
  | eq_fm T (Iff (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   497
  | eq_fm T (Imp (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   498
  | eq_fm T (Or (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   499
  | eq_fm T (And (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   500
  | eq_fm T (Not a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   501
  | eq_fm T (NDvd (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   502
  | eq_fm T (Dvd (a, b)) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   503
  | eq_fm T (NEq a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   504
  | eq_fm T (Eq a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   505
  | eq_fm T (Ge a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   506
  | eq_fm T (Gt a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   507
  | eq_fm T (Le a) = false
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   508
  | eq_fm T (Lt a) = false
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   509
  | eq_fm T F = false
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   510
  | eq_fm (NClosed nat) (NClosed nat') = ((nat : IntInf.int) = nat')
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   511
  | eq_fm (Closed nat) (Closed nat') = ((nat : IntInf.int) = nat')
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   512
  | eq_fm (A fm) (A fm') = eq_fm fm fm'
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   513
  | eq_fm (E fm) (E fm') = eq_fm fm fm'
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   514
  | eq_fm (Iff (fm1, fm2)) (Iff (fm1', fm2')) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   515
    eq_fm fm1 fm1' andalso eq_fm fm2 fm2'
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   516
  | eq_fm (Imp (fm1, fm2)) (Imp (fm1', fm2')) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   517
    eq_fm fm1 fm1' andalso eq_fm fm2 fm2'
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   518
  | eq_fm (Or (fm1, fm2)) (Or (fm1', fm2')) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   519
    eq_fm fm1 fm1' andalso eq_fm fm2 fm2'
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   520
  | eq_fm (And (fm1, fm2)) (And (fm1', fm2')) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   521
    eq_fm fm1 fm1' andalso eq_fm fm2 fm2'
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   522
  | eq_fm (Not fm) (Not fm') = eq_fm fm fm'
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   523
  | eq_fm (NDvd (inta, num)) (NDvd (int', num')) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   524
    ((inta : IntInf.int) = int') andalso eq_num num num'
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   525
  | eq_fm (Dvd (inta, num)) (Dvd (int', num')) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   526
    ((inta : IntInf.int) = int') andalso eq_num num num'
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   527
  | eq_fm (NEq num) (NEq num') = eq_num num num'
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   528
  | eq_fm (Eq num) (Eq num') = eq_num num num'
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   529
  | eq_fm (Ge num) (Ge num') = eq_num num num'
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   530
  | eq_fm (Gt num) (Gt num') = eq_num num num'
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   531
  | eq_fm (Le num) (Le num') = eq_num num num'
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   532
  | eq_fm (Lt num) (Lt num') = eq_num num num'
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   533
  | eq_fm F F = true
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   534
  | eq_fm T T = true;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   535
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   536
val eq_fma = {eq = eq_fm} : fm eq;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   537
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   538
fun djf f p q =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   539
  (if eqop eq_fma q T then T
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   540
    else (if eqop eq_fma q F then f p
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   541
           else let
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   542
                  val a = f p;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   543
                in
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   544
                  (case a of T => T | F => q | Lt num => Or (f p, q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   545
                     | Le num => Or (f p, q) | Gt num => Or (f p, q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   546
                     | Ge num => Or (f p, q) | Eq num => Or (f p, q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   547
                     | NEq num => Or (f p, q) | Dvd (inta, num) => Or (f p, q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   548
                     | NDvd (inta, num) => Or (f p, q) | Not fm => Or (f p, q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   549
                     | And (fm1, fm2) => Or (f p, q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   550
                     | Or (fm1, fm2) => Or (f p, q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   551
                     | Imp (fm1, fm2) => Or (f p, q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   552
                     | Iff (fm1, fm2) => Or (f p, q) | E fm => Or (f p, q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   553
                     | A fm => Or (f p, q) | Closed nat => Or (f p, q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   554
                     | NClosed nat => Or (f p, q))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   555
                end));
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   556
29939
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   557
fun foldr f [] a = a
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   558
  | foldr f (x :: xs) a = f x (foldr f xs a);
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   559
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   560
fun evaldjf f ps = foldr (djf f) ps F;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   561
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   562
fun dj f p = evaldjf f (disjuncts p);
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   563
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   564
fun disj p q =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   565
  (if eqop eq_fma p T orelse eqop eq_fma q T then T
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   566
    else (if eqop eq_fma p F then q
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   567
           else (if eqop eq_fma q F then p else Or (p, q))));
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   568
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   569
fun minus_nat n m = IntInf.max (0, (IntInf.- (n, m)));
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   570
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   571
fun decrnum (Bound n) = Bound (minus_nat n 1)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   572
  | decrnum (Neg a) = Neg (decrnum a)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   573
  | decrnum (Add (a, b)) = Add (decrnum a, decrnum b)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   574
  | decrnum (Sub (a, b)) = Sub (decrnum a, decrnum b)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   575
  | decrnum (Mul (c, a)) = Mul (c, decrnum a)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   576
  | decrnum (Cn (n, i, a)) = Cn (minus_nat n 1, i, decrnum a)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   577
  | decrnum (C u) = C u;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   578
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   579
fun decr (Lt a) = Lt (decrnum a)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   580
  | decr (Le a) = Le (decrnum a)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   581
  | decr (Gt a) = Gt (decrnum a)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   582
  | decr (Ge a) = Ge (decrnum a)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   583
  | decr (Eq a) = Eq (decrnum a)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   584
  | decr (NEq a) = NEq (decrnum a)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   585
  | decr (Dvd (i, a)) = Dvd (i, decrnum a)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   586
  | decr (NDvd (i, a)) = NDvd (i, decrnum a)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   587
  | decr (Not p) = Not (decr p)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   588
  | decr (And (p, q)) = And (decr p, decr q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   589
  | decr (Or (p, q)) = Or (decr p, decr q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   590
  | decr (Imp (p, q)) = Imp (decr p, decr q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   591
  | decr (Iff (p, q)) = Iff (decr p, decr q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   592
  | decr T = T
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   593
  | decr F = F
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   594
  | decr (E ao) = E ao
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   595
  | decr (A ap) = A ap
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   596
  | decr (Closed aq) = Closed aq
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   597
  | decr (NClosed ar) = NClosed ar;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   598
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   599
fun concat [] = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   600
  | concat (x :: xs) = append x (concat xs);
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   601
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   602
fun split f (a, b) = f a b;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   603
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   604
fun numsubst0 t (C c) = C c
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   605
  | numsubst0 t (Bound n) = (if eqop eq_nat n 0 then t else Bound n)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   606
  | numsubst0 t (Neg a) = Neg (numsubst0 t a)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   607
  | numsubst0 t (Add (a, b)) = Add (numsubst0 t a, numsubst0 t b)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   608
  | numsubst0 t (Sub (a, b)) = Sub (numsubst0 t a, numsubst0 t b)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   609
  | numsubst0 t (Mul (i, a)) = Mul (i, numsubst0 t a)
29939
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   610
  | numsubst0 t (Cn (v, i, a)) =
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   611
    (if eqop eq_nat v 0 then Add (Mul (i, t), numsubst0 t a)
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   612
      else Cn (suc (minus_nat v 1), i, numsubst0 t a));
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   613
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   614
fun subst0 t T = T
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   615
  | subst0 t F = F
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   616
  | subst0 t (Lt a) = Lt (numsubst0 t a)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   617
  | subst0 t (Le a) = Le (numsubst0 t a)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   618
  | subst0 t (Gt a) = Gt (numsubst0 t a)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   619
  | subst0 t (Ge a) = Ge (numsubst0 t a)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   620
  | subst0 t (Eq a) = Eq (numsubst0 t a)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   621
  | subst0 t (NEq a) = NEq (numsubst0 t a)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   622
  | subst0 t (Dvd (i, a)) = Dvd (i, numsubst0 t a)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   623
  | subst0 t (NDvd (i, a)) = NDvd (i, numsubst0 t a)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   624
  | subst0 t (Not p) = Not (subst0 t p)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   625
  | subst0 t (And (p, q)) = And (subst0 t p, subst0 t q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   626
  | subst0 t (Or (p, q)) = Or (subst0 t p, subst0 t q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   627
  | subst0 t (Imp (p, q)) = Imp (subst0 t p, subst0 t q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   628
  | subst0 t (Iff (p, q)) = Iff (subst0 t p, subst0 t q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   629
  | subst0 t (Closed p) = Closed p
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   630
  | subst0 t (NClosed p) = NClosed p;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   631
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   632
fun minusinf (And (p, q)) = And (minusinf p, minusinf q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   633
  | minusinf (Or (p, q)) = Or (minusinf p, minusinf q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   634
  | minusinf T = T
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   635
  | minusinf F = F
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   636
  | minusinf (Lt (C bo)) = Lt (C bo)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   637
  | minusinf (Lt (Bound bp)) = Lt (Bound bp)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   638
  | minusinf (Lt (Neg bt)) = Lt (Neg bt)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   639
  | minusinf (Lt (Add (bu, bv))) = Lt (Add (bu, bv))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   640
  | minusinf (Lt (Sub (bw, bx))) = Lt (Sub (bw, bx))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   641
  | minusinf (Lt (Mul (by, bz))) = Lt (Mul (by, bz))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   642
  | minusinf (Le (C co)) = Le (C co)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   643
  | minusinf (Le (Bound cp)) = Le (Bound cp)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   644
  | minusinf (Le (Neg ct)) = Le (Neg ct)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   645
  | minusinf (Le (Add (cu, cv))) = Le (Add (cu, cv))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   646
  | minusinf (Le (Sub (cw, cx))) = Le (Sub (cw, cx))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   647
  | minusinf (Le (Mul (cy, cz))) = Le (Mul (cy, cz))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   648
  | minusinf (Gt (C doa)) = Gt (C doa)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   649
  | minusinf (Gt (Bound dp)) = Gt (Bound dp)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   650
  | minusinf (Gt (Neg dt)) = Gt (Neg dt)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   651
  | minusinf (Gt (Add (du, dv))) = Gt (Add (du, dv))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   652
  | minusinf (Gt (Sub (dw, dx))) = Gt (Sub (dw, dx))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   653
  | minusinf (Gt (Mul (dy, dz))) = Gt (Mul (dy, dz))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   654
  | minusinf (Ge (C eo)) = Ge (C eo)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   655
  | minusinf (Ge (Bound ep)) = Ge (Bound ep)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   656
  | minusinf (Ge (Neg et)) = Ge (Neg et)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   657
  | minusinf (Ge (Add (eu, ev))) = Ge (Add (eu, ev))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   658
  | minusinf (Ge (Sub (ew, ex))) = Ge (Sub (ew, ex))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   659
  | minusinf (Ge (Mul (ey, ez))) = Ge (Mul (ey, ez))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   660
  | minusinf (Eq (C fo)) = Eq (C fo)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   661
  | minusinf (Eq (Bound fp)) = Eq (Bound fp)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   662
  | minusinf (Eq (Neg ft)) = Eq (Neg ft)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   663
  | minusinf (Eq (Add (fu, fv))) = Eq (Add (fu, fv))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   664
  | minusinf (Eq (Sub (fw, fx))) = Eq (Sub (fw, fx))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   665
  | minusinf (Eq (Mul (fy, fz))) = Eq (Mul (fy, fz))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   666
  | minusinf (NEq (C go)) = NEq (C go)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   667
  | minusinf (NEq (Bound gp)) = NEq (Bound gp)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   668
  | minusinf (NEq (Neg gt)) = NEq (Neg gt)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   669
  | minusinf (NEq (Add (gu, gv))) = NEq (Add (gu, gv))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   670
  | minusinf (NEq (Sub (gw, gx))) = NEq (Sub (gw, gx))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   671
  | minusinf (NEq (Mul (gy, gz))) = NEq (Mul (gy, gz))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   672
  | minusinf (Dvd (aa, ab)) = Dvd (aa, ab)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   673
  | minusinf (NDvd (ac, ad)) = NDvd (ac, ad)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   674
  | minusinf (Not ae) = Not ae
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   675
  | minusinf (Imp (aj, ak)) = Imp (aj, ak)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   676
  | minusinf (Iff (al, am)) = Iff (al, am)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   677
  | minusinf (E an) = E an
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   678
  | minusinf (A ao) = A ao
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   679
  | minusinf (Closed ap) = Closed ap
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   680
  | minusinf (NClosed aq) = NClosed aq
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   681
  | minusinf (Lt (Cn (cm, c, e))) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   682
    (if eqop eq_nat cm 0 then T else Lt (Cn (suc (minus_nat cm 1), c, e)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   683
  | minusinf (Le (Cn (dm, c, e))) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   684
    (if eqop eq_nat dm 0 then T else Le (Cn (suc (minus_nat dm 1), c, e)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   685
  | minusinf (Gt (Cn (em, c, e))) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   686
    (if eqop eq_nat em 0 then F else Gt (Cn (suc (minus_nat em 1), c, e)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   687
  | minusinf (Ge (Cn (fm, c, e))) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   688
    (if eqop eq_nat fm 0 then F else Ge (Cn (suc (minus_nat fm 1), c, e)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   689
  | minusinf (Eq (Cn (gm, c, e))) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   690
    (if eqop eq_nat gm 0 then F else Eq (Cn (suc (minus_nat gm 1), c, e)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   691
  | minusinf (NEq (Cn (hm, c, e))) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   692
    (if eqop eq_nat hm 0 then T else NEq (Cn (suc (minus_nat hm 1), c, e)));
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
   693
29939
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   694
val eq_int = {eq = (fn a => fn b => ((a : IntInf.int) = b))} : IntInf.int eq;
23466
886655a150f6 moved quantifier elimination tools to Tools/Qelim/;
wenzelm
parents:
diff changeset
   695
29939
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   696
fun sgn_int i =
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   697
  (if eqop eq_int i (0 : IntInf.int) then (0 : IntInf.int)
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   698
    else (if IntInf.< ((0 : IntInf.int), i) then (1 : IntInf.int)
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   699
           else IntInf.~ (1 : IntInf.int)));
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
   700
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   701
fun apsnd f (x, y) = (x, f y);
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   702
29939
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   703
fun divmoda k l =
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   704
  (if eqop eq_int k (0 : IntInf.int) then ((0 : IntInf.int), (0 : IntInf.int))
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   705
    else (if eqop eq_int l (0 : IntInf.int) then ((0 : IntInf.int), k)
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   706
           else apsnd (fn a => IntInf.* (sgn_int l, a))
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   707
                  (if eqop eq_int (sgn_int k) (sgn_int l)
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   708
                    then (fn k => fn l => IntInf.divMod (IntInf.abs k,
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   709
                           IntInf.abs l))
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   710
                           k l
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   711
                    else let
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   712
                           val a =
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   713
                             (fn k => fn l => IntInf.divMod (IntInf.abs k,
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   714
                               IntInf.abs l))
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   715
                               k l;
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   716
                           val (r, s) = a;
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   717
                         in
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   718
                           (if eqop eq_int s (0 : IntInf.int)
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   719
                             then (IntInf.~ r, (0 : IntInf.int))
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   720
                             else (IntInf.- (IntInf.~ r, (1 : IntInf.int)),
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   721
                                    IntInf.- (abs_int l, s)))
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   722
                         end)));
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
   723
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   724
fun mod_int a b = snd (divmoda a b);
23714
49b08f25db29 now a monolithic module
haftmann
parents: 23689
diff changeset
   725
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   726
fun num_case f1 f2 f3 f4 f5 f6 f7 (Mul (inta, num)) = f7 inta num
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   727
  | num_case f1 f2 f3 f4 f5 f6 f7 (Sub (num1, num2)) = f6 num1 num2
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   728
  | num_case f1 f2 f3 f4 f5 f6 f7 (Add (num1, num2)) = f5 num1 num2
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   729
  | num_case f1 f2 f3 f4 f5 f6 f7 (Neg num) = f4 num
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   730
  | num_case f1 f2 f3 f4 f5 f6 f7 (Cn (nat, inta, num)) = f3 nat inta num
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   731
  | num_case f1 f2 f3 f4 f5 f6 f7 (Bound nat) = f2 nat
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   732
  | num_case f1 f2 f3 f4 f5 f6 f7 (C inta) = f1 inta;
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
   733
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   734
fun nummul i (C j) = C (IntInf.* (i, j))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   735
  | nummul i (Cn (n, c, t)) = Cn (n, IntInf.* (c, i), nummul i t)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   736
  | nummul i (Bound v) = Mul (i, Bound v)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   737
  | nummul i (Neg v) = Mul (i, Neg v)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   738
  | nummul i (Add (v, va)) = Mul (i, Add (v, va))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   739
  | nummul i (Sub (v, va)) = Mul (i, Sub (v, va))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   740
  | nummul i (Mul (v, va)) = Mul (i, Mul (v, va));
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
   741
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   742
fun numneg t = nummul (IntInf.~ (1 : IntInf.int)) t;
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
   743
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   744
fun numadd (Cn (n1, c1, r1), Cn (n2, c2, r2)) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   745
  (if eqop eq_nat n1 n2
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   746
    then let
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   747
           val c = IntInf.+ (c1, c2);
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   748
         in
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   749
           (if eqop eq_int c (0 : IntInf.int) then numadd (r1, r2)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   750
             else Cn (n1, c, numadd (r1, r2)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   751
         end
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   752
    else (if IntInf.<= (n1, n2)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   753
           then Cn (n1, c1, numadd (r1, Add (Mul (c2, Bound n2), r2)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   754
           else Cn (n2, c2, numadd (Add (Mul (c1, Bound n1), r1), r2))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   755
  | numadd (Cn (n1, c1, r1), C dd) = Cn (n1, c1, numadd (r1, C dd))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   756
  | numadd (Cn (n1, c1, r1), Bound de) = Cn (n1, c1, numadd (r1, Bound de))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   757
  | numadd (Cn (n1, c1, r1), Neg di) = Cn (n1, c1, numadd (r1, Neg di))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   758
  | numadd (Cn (n1, c1, r1), Add (dj, dk)) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   759
    Cn (n1, c1, numadd (r1, Add (dj, dk)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   760
  | numadd (Cn (n1, c1, r1), Sub (dl, dm)) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   761
    Cn (n1, c1, numadd (r1, Sub (dl, dm)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   762
  | numadd (Cn (n1, c1, r1), Mul (dn, doa)) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   763
    Cn (n1, c1, numadd (r1, Mul (dn, doa)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   764
  | numadd (C w, Cn (n2, c2, r2)) = Cn (n2, c2, numadd (C w, r2))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   765
  | numadd (Bound x, Cn (n2, c2, r2)) = Cn (n2, c2, numadd (Bound x, r2))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   766
  | numadd (Neg ac, Cn (n2, c2, r2)) = Cn (n2, c2, numadd (Neg ac, r2))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   767
  | numadd (Add (ad, ae), Cn (n2, c2, r2)) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   768
    Cn (n2, c2, numadd (Add (ad, ae), r2))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   769
  | numadd (Sub (af, ag), Cn (n2, c2, r2)) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   770
    Cn (n2, c2, numadd (Sub (af, ag), r2))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   771
  | numadd (Mul (ah, ai), Cn (n2, c2, r2)) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   772
    Cn (n2, c2, numadd (Mul (ah, ai), r2))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   773
  | numadd (C b1, C b2) = C (IntInf.+ (b1, b2))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   774
  | numadd (C aj, Bound bi) = Add (C aj, Bound bi)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   775
  | numadd (C aj, Neg bm) = Add (C aj, Neg bm)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   776
  | numadd (C aj, Add (bn, bo)) = Add (C aj, Add (bn, bo))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   777
  | numadd (C aj, Sub (bp, bq)) = Add (C aj, Sub (bp, bq))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   778
  | numadd (C aj, Mul (br, bs)) = Add (C aj, Mul (br, bs))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   779
  | numadd (Bound ak, C cf) = Add (Bound ak, C cf)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   780
  | numadd (Bound ak, Bound cg) = Add (Bound ak, Bound cg)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   781
  | numadd (Bound ak, Neg ck) = Add (Bound ak, Neg ck)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   782
  | numadd (Bound ak, Add (cl, cm)) = Add (Bound ak, Add (cl, cm))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   783
  | numadd (Bound ak, Sub (cn, co)) = Add (Bound ak, Sub (cn, co))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   784
  | numadd (Bound ak, Mul (cp, cq)) = Add (Bound ak, Mul (cp, cq))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   785
  | numadd (Neg ao, C en) = Add (Neg ao, C en)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   786
  | numadd (Neg ao, Bound eo) = Add (Neg ao, Bound eo)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   787
  | numadd (Neg ao, Neg es) = Add (Neg ao, Neg es)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   788
  | numadd (Neg ao, Add (et, eu)) = Add (Neg ao, Add (et, eu))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   789
  | numadd (Neg ao, Sub (ev, ew)) = Add (Neg ao, Sub (ev, ew))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   790
  | numadd (Neg ao, Mul (ex, ey)) = Add (Neg ao, Mul (ex, ey))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   791
  | numadd (Add (ap, aq), C fl) = Add (Add (ap, aq), C fl)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   792
  | numadd (Add (ap, aq), Bound fm) = Add (Add (ap, aq), Bound fm)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   793
  | numadd (Add (ap, aq), Neg fq) = Add (Add (ap, aq), Neg fq)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   794
  | numadd (Add (ap, aq), Add (fr, fs)) = Add (Add (ap, aq), Add (fr, fs))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   795
  | numadd (Add (ap, aq), Sub (ft, fu)) = Add (Add (ap, aq), Sub (ft, fu))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   796
  | numadd (Add (ap, aq), Mul (fv, fw)) = Add (Add (ap, aq), Mul (fv, fw))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   797
  | numadd (Sub (ar, asa), C gj) = Add (Sub (ar, asa), C gj)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   798
  | numadd (Sub (ar, asa), Bound gk) = Add (Sub (ar, asa), Bound gk)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   799
  | numadd (Sub (ar, asa), Neg go) = Add (Sub (ar, asa), Neg go)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   800
  | numadd (Sub (ar, asa), Add (gp, gq)) = Add (Sub (ar, asa), Add (gp, gq))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   801
  | numadd (Sub (ar, asa), Sub (gr, gs)) = Add (Sub (ar, asa), Sub (gr, gs))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   802
  | numadd (Sub (ar, asa), Mul (gt, gu)) = Add (Sub (ar, asa), Mul (gt, gu))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   803
  | numadd (Mul (at, au), C hh) = Add (Mul (at, au), C hh)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   804
  | numadd (Mul (at, au), Bound hi) = Add (Mul (at, au), Bound hi)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   805
  | numadd (Mul (at, au), Neg hm) = Add (Mul (at, au), Neg hm)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   806
  | numadd (Mul (at, au), Add (hn, ho)) = Add (Mul (at, au), Add (hn, ho))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   807
  | numadd (Mul (at, au), Sub (hp, hq)) = Add (Mul (at, au), Sub (hp, hq))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   808
  | numadd (Mul (at, au), Mul (hr, hs)) = Add (Mul (at, au), Mul (hr, hs));
23714
49b08f25db29 now a monolithic module
haftmann
parents: 23689
diff changeset
   809
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   810
val eq_numa = {eq = eq_num} : num eq;
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
   811
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   812
fun numsub s t =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   813
  (if eqop eq_numa s t then C (0 : IntInf.int) else numadd (s, numneg t));
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
   814
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   815
fun simpnum (C j) = C j
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   816
  | simpnum (Bound n) = Cn (n, (1 : IntInf.int), C (0 : IntInf.int))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   817
  | simpnum (Neg t) = numneg (simpnum t)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   818
  | simpnum (Add (t, s)) = numadd (simpnum t, simpnum s)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   819
  | simpnum (Sub (t, s)) = numsub (simpnum t) (simpnum s)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   820
  | simpnum (Mul (i, t)) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   821
    (if eqop eq_int i (0 : IntInf.int) then C (0 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   822
      else nummul i (simpnum t))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   823
  | simpnum (Cn (v, va, vb)) = Cn (v, va, vb);
23714
49b08f25db29 now a monolithic module
haftmann
parents: 23689
diff changeset
   824
29939
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   825
fun nota (Not p) = p
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   826
  | nota T = F
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   827
  | nota F = T
29939
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   828
  | nota (Lt v) = Not (Lt v)
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   829
  | nota (Le v) = Not (Le v)
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   830
  | nota (Gt v) = Not (Gt v)
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   831
  | nota (Ge v) = Not (Ge v)
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   832
  | nota (Eq v) = Not (Eq v)
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   833
  | nota (NEq v) = Not (NEq v)
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   834
  | nota (Dvd (v, va)) = Not (Dvd (v, va))
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   835
  | nota (NDvd (v, va)) = Not (NDvd (v, va))
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   836
  | nota (And (v, va)) = Not (And (v, va))
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   837
  | nota (Or (v, va)) = Not (Or (v, va))
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   838
  | nota (Imp (v, va)) = Not (Imp (v, va))
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   839
  | nota (Iff (v, va)) = Not (Iff (v, va))
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   840
  | nota (E v) = Not (E v)
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
   841
  | nota (A v) = Not (A v)
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   842
  | nota (Closed v) = Not (Closed v)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   843
  | nota (NClosed v) = Not (NClosed v);
23714
49b08f25db29 now a monolithic module
haftmann
parents: 23689
diff changeset
   844
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   845
fun iffa p q =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   846
  (if eqop eq_fma p q then T
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   847
    else (if eqop eq_fma p (nota q) orelse eqop eq_fma (nota p) q then F
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   848
           else (if eqop eq_fma p F then nota q
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   849
                  else (if eqop eq_fma q F then nota p
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   850
                         else (if eqop eq_fma p T then q
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   851
                                else (if eqop eq_fma q T then p
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   852
                                       else Iff (p, q)))))));
23466
886655a150f6 moved quantifier elimination tools to Tools/Qelim/;
wenzelm
parents:
diff changeset
   853
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   854
fun impa p q =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   855
  (if eqop eq_fma p F orelse eqop eq_fma q T then T
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   856
    else (if eqop eq_fma p T then q
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   857
           else (if eqop eq_fma q F then nota p else Imp (p, q))));
23714
49b08f25db29 now a monolithic module
haftmann
parents: 23689
diff changeset
   858
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   859
fun conj p q =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   860
  (if eqop eq_fma p F orelse eqop eq_fma q F then F
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   861
    else (if eqop eq_fma p T then q
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   862
           else (if eqop eq_fma q T then p else And (p, q))));
23714
49b08f25db29 now a monolithic module
haftmann
parents: 23689
diff changeset
   863
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   864
fun simpfm (And (p, q)) = conj (simpfm p) (simpfm q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   865
  | simpfm (Or (p, q)) = disj (simpfm p) (simpfm q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   866
  | simpfm (Imp (p, q)) = impa (simpfm p) (simpfm q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   867
  | simpfm (Iff (p, q)) = iffa (simpfm p) (simpfm q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   868
  | simpfm (Not p) = nota (simpfm p)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   869
  | simpfm (Lt a) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   870
    let
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   871
      val a' = simpnum a;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   872
    in
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   873
      (case a' of C v => (if IntInf.< (v, (0 : IntInf.int)) then T else F)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   874
         | Bound nat => Lt a' | Cn (nat, inta, num) => Lt a' | Neg num => Lt a'
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   875
         | Add (num1, num2) => Lt a' | Sub (num1, num2) => Lt a'
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   876
         | Mul (inta, num) => Lt a')
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   877
    end
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   878
  | simpfm (Le a) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   879
    let
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   880
      val a' = simpnum a;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   881
    in
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   882
      (case a' of C v => (if IntInf.<= (v, (0 : IntInf.int)) then T else F)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   883
         | Bound nat => Le a' | Cn (nat, inta, num) => Le a' | Neg num => Le a'
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   884
         | Add (num1, num2) => Le a' | Sub (num1, num2) => Le a'
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   885
         | Mul (inta, num) => Le a')
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   886
    end
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   887
  | simpfm (Gt a) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   888
    let
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   889
      val a' = simpnum a;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   890
    in
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   891
      (case a' of C v => (if IntInf.< ((0 : IntInf.int), v) then T else F)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   892
         | Bound nat => Gt a' | Cn (nat, inta, num) => Gt a' | Neg num => Gt a'
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   893
         | Add (num1, num2) => Gt a' | Sub (num1, num2) => Gt a'
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   894
         | Mul (inta, num) => Gt a')
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   895
    end
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   896
  | simpfm (Ge a) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   897
    let
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   898
      val a' = simpnum a;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   899
    in
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   900
      (case a' of C v => (if IntInf.<= ((0 : IntInf.int), v) then T else F)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   901
         | Bound nat => Ge a' | Cn (nat, inta, num) => Ge a' | Neg num => Ge a'
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   902
         | Add (num1, num2) => Ge a' | Sub (num1, num2) => Ge a'
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   903
         | Mul (inta, num) => Ge a')
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   904
    end
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   905
  | simpfm (Eq a) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   906
    let
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   907
      val a' = simpnum a;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   908
    in
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   909
      (case a' of C v => (if eqop eq_int v (0 : IntInf.int) then T else F)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   910
         | Bound nat => Eq a' | Cn (nat, inta, num) => Eq a' | Neg num => Eq a'
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   911
         | Add (num1, num2) => Eq a' | Sub (num1, num2) => Eq a'
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   912
         | Mul (inta, num) => Eq a')
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   913
    end
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   914
  | simpfm (NEq a) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   915
    let
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   916
      val a' = simpnum a;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   917
    in
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   918
      (case a' of C v => (if not (eqop eq_int v (0 : IntInf.int)) then T else F)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   919
         | Bound nat => NEq a' | Cn (nat, inta, num) => NEq a'
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   920
         | Neg num => NEq a' | Add (num1, num2) => NEq a'
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   921
         | Sub (num1, num2) => NEq a' | Mul (inta, num) => NEq a')
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   922
    end
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   923
  | simpfm (Dvd (i, a)) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   924
    (if eqop eq_int i (0 : IntInf.int) then simpfm (Eq a)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   925
      else (if eqop eq_int (abs_int i) (1 : IntInf.int) then T
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   926
             else let
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   927
                    val a' = simpnum a;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   928
                  in
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   929
                    (case a'
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   930
                       of C v =>
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   931
                         (if eqop eq_int (mod_int v i) (0 : IntInf.int) then T
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   932
                           else F)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   933
                       | Bound nat => Dvd (i, a')
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   934
                       | Cn (nat, inta, num) => Dvd (i, a')
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   935
                       | Neg num => Dvd (i, a')
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   936
                       | Add (num1, num2) => Dvd (i, a')
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   937
                       | Sub (num1, num2) => Dvd (i, a')
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   938
                       | Mul (inta, num) => Dvd (i, a'))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   939
                  end))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   940
  | simpfm (NDvd (i, a)) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   941
    (if eqop eq_int i (0 : IntInf.int) then simpfm (NEq a)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   942
      else (if eqop eq_int (abs_int i) (1 : IntInf.int) then F
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   943
             else let
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   944
                    val a' = simpnum a;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   945
                  in
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   946
                    (case a'
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   947
                       of C v =>
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   948
                         (if not (eqop eq_int (mod_int v i) (0 : IntInf.int))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   949
                           then T else F)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   950
                       | Bound nat => NDvd (i, a')
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   951
                       | Cn (nat, inta, num) => NDvd (i, a')
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   952
                       | Neg num => NDvd (i, a')
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   953
                       | Add (num1, num2) => NDvd (i, a')
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   954
                       | Sub (num1, num2) => NDvd (i, a')
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   955
                       | Mul (inta, num) => NDvd (i, a'))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   956
                  end))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   957
  | simpfm T = T
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   958
  | simpfm F = F
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   959
  | simpfm (E v) = E v
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   960
  | simpfm (A v) = A v
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   961
  | simpfm (Closed v) = Closed v
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   962
  | simpfm (NClosed v) = NClosed v;
23466
886655a150f6 moved quantifier elimination tools to Tools/Qelim/;
wenzelm
parents:
diff changeset
   963
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   964
fun iupt i j =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   965
  (if IntInf.< (j, i) then []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   966
    else i :: iupt (IntInf.+ (i, (1 : IntInf.int))) j);
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   967
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   968
fun mirror (And (p, q)) = And (mirror p, mirror q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   969
  | mirror (Or (p, q)) = Or (mirror p, mirror q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   970
  | mirror T = T
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   971
  | mirror F = F
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   972
  | mirror (Lt (C bo)) = Lt (C bo)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   973
  | mirror (Lt (Bound bp)) = Lt (Bound bp)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   974
  | mirror (Lt (Neg bt)) = Lt (Neg bt)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   975
  | mirror (Lt (Add (bu, bv))) = Lt (Add (bu, bv))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   976
  | mirror (Lt (Sub (bw, bx))) = Lt (Sub (bw, bx))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   977
  | mirror (Lt (Mul (by, bz))) = Lt (Mul (by, bz))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   978
  | mirror (Le (C co)) = Le (C co)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   979
  | mirror (Le (Bound cp)) = Le (Bound cp)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   980
  | mirror (Le (Neg ct)) = Le (Neg ct)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   981
  | mirror (Le (Add (cu, cv))) = Le (Add (cu, cv))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   982
  | mirror (Le (Sub (cw, cx))) = Le (Sub (cw, cx))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   983
  | mirror (Le (Mul (cy, cz))) = Le (Mul (cy, cz))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   984
  | mirror (Gt (C doa)) = Gt (C doa)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   985
  | mirror (Gt (Bound dp)) = Gt (Bound dp)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   986
  | mirror (Gt (Neg dt)) = Gt (Neg dt)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   987
  | mirror (Gt (Add (du, dv))) = Gt (Add (du, dv))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   988
  | mirror (Gt (Sub (dw, dx))) = Gt (Sub (dw, dx))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   989
  | mirror (Gt (Mul (dy, dz))) = Gt (Mul (dy, dz))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   990
  | mirror (Ge (C eo)) = Ge (C eo)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   991
  | mirror (Ge (Bound ep)) = Ge (Bound ep)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   992
  | mirror (Ge (Neg et)) = Ge (Neg et)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   993
  | mirror (Ge (Add (eu, ev))) = Ge (Add (eu, ev))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   994
  | mirror (Ge (Sub (ew, ex))) = Ge (Sub (ew, ex))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   995
  | mirror (Ge (Mul (ey, ez))) = Ge (Mul (ey, ez))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   996
  | mirror (Eq (C fo)) = Eq (C fo)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   997
  | mirror (Eq (Bound fp)) = Eq (Bound fp)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   998
  | mirror (Eq (Neg ft)) = Eq (Neg ft)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
   999
  | mirror (Eq (Add (fu, fv))) = Eq (Add (fu, fv))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1000
  | mirror (Eq (Sub (fw, fx))) = Eq (Sub (fw, fx))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1001
  | mirror (Eq (Mul (fy, fz))) = Eq (Mul (fy, fz))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1002
  | mirror (NEq (C go)) = NEq (C go)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1003
  | mirror (NEq (Bound gp)) = NEq (Bound gp)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1004
  | mirror (NEq (Neg gt)) = NEq (Neg gt)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1005
  | mirror (NEq (Add (gu, gv))) = NEq (Add (gu, gv))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1006
  | mirror (NEq (Sub (gw, gx))) = NEq (Sub (gw, gx))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1007
  | mirror (NEq (Mul (gy, gz))) = NEq (Mul (gy, gz))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1008
  | mirror (Dvd (aa, C ho)) = Dvd (aa, C ho)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1009
  | mirror (Dvd (aa, Bound hp)) = Dvd (aa, Bound hp)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1010
  | mirror (Dvd (aa, Neg ht)) = Dvd (aa, Neg ht)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1011
  | mirror (Dvd (aa, Add (hu, hv))) = Dvd (aa, Add (hu, hv))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1012
  | mirror (Dvd (aa, Sub (hw, hx))) = Dvd (aa, Sub (hw, hx))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1013
  | mirror (Dvd (aa, Mul (hy, hz))) = Dvd (aa, Mul (hy, hz))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1014
  | mirror (NDvd (ac, C io)) = NDvd (ac, C io)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1015
  | mirror (NDvd (ac, Bound ip)) = NDvd (ac, Bound ip)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1016
  | mirror (NDvd (ac, Neg it)) = NDvd (ac, Neg it)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1017
  | mirror (NDvd (ac, Add (iu, iv))) = NDvd (ac, Add (iu, iv))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1018
  | mirror (NDvd (ac, Sub (iw, ix))) = NDvd (ac, Sub (iw, ix))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1019
  | mirror (NDvd (ac, Mul (iy, iz))) = NDvd (ac, Mul (iy, iz))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1020
  | mirror (Not ae) = Not ae
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1021
  | mirror (Imp (aj, ak)) = Imp (aj, ak)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1022
  | mirror (Iff (al, am)) = Iff (al, am)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1023
  | mirror (E an) = E an
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1024
  | mirror (A ao) = A ao
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1025
  | mirror (Closed ap) = Closed ap
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1026
  | mirror (NClosed aq) = NClosed aq
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1027
  | mirror (Lt (Cn (cm, c, e))) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1028
    (if eqop eq_nat cm 0 then Gt (Cn (0, c, Neg e))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1029
      else Lt (Cn (suc (minus_nat cm 1), c, e)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1030
  | mirror (Le (Cn (dm, c, e))) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1031
    (if eqop eq_nat dm 0 then Ge (Cn (0, c, Neg e))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1032
      else Le (Cn (suc (minus_nat dm 1), c, e)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1033
  | mirror (Gt (Cn (em, c, e))) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1034
    (if eqop eq_nat em 0 then Lt (Cn (0, c, Neg e))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1035
      else Gt (Cn (suc (minus_nat em 1), c, e)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1036
  | mirror (Ge (Cn (fm, c, e))) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1037
    (if eqop eq_nat fm 0 then Le (Cn (0, c, Neg e))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1038
      else Ge (Cn (suc (minus_nat fm 1), c, e)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1039
  | mirror (Eq (Cn (gm, c, e))) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1040
    (if eqop eq_nat gm 0 then Eq (Cn (0, c, Neg e))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1041
      else Eq (Cn (suc (minus_nat gm 1), c, e)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1042
  | mirror (NEq (Cn (hm, c, e))) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1043
    (if eqop eq_nat hm 0 then NEq (Cn (0, c, Neg e))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1044
      else NEq (Cn (suc (minus_nat hm 1), c, e)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1045
  | mirror (Dvd (i, Cn (im, c, e))) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1046
    (if eqop eq_nat im 0 then Dvd (i, Cn (0, c, Neg e))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1047
      else Dvd (i, Cn (suc (minus_nat im 1), c, e)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1048
  | mirror (NDvd (i, Cn (jm, c, e))) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1049
    (if eqop eq_nat jm 0 then NDvd (i, Cn (0, c, Neg e))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1050
      else NDvd (i, Cn (suc (minus_nat jm 1), c, e)));
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1051
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1052
fun size_list [] = 0
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1053
  | size_list (a :: lista) = IntInf.+ (size_list lista, suc 0);
23466
886655a150f6 moved quantifier elimination tools to Tools/Qelim/;
wenzelm
parents:
diff changeset
  1054
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1055
fun alpha (And (p, q)) = append (alpha p) (alpha q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1056
  | alpha (Or (p, q)) = append (alpha p) (alpha q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1057
  | alpha T = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1058
  | alpha F = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1059
  | alpha (Lt (C bo)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1060
  | alpha (Lt (Bound bp)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1061
  | alpha (Lt (Neg bt)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1062
  | alpha (Lt (Add (bu, bv))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1063
  | alpha (Lt (Sub (bw, bx))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1064
  | alpha (Lt (Mul (by, bz))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1065
  | alpha (Le (C co)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1066
  | alpha (Le (Bound cp)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1067
  | alpha (Le (Neg ct)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1068
  | alpha (Le (Add (cu, cv))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1069
  | alpha (Le (Sub (cw, cx))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1070
  | alpha (Le (Mul (cy, cz))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1071
  | alpha (Gt (C doa)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1072
  | alpha (Gt (Bound dp)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1073
  | alpha (Gt (Neg dt)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1074
  | alpha (Gt (Add (du, dv))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1075
  | alpha (Gt (Sub (dw, dx))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1076
  | alpha (Gt (Mul (dy, dz))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1077
  | alpha (Ge (C eo)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1078
  | alpha (Ge (Bound ep)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1079
  | alpha (Ge (Neg et)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1080
  | alpha (Ge (Add (eu, ev))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1081
  | alpha (Ge (Sub (ew, ex))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1082
  | alpha (Ge (Mul (ey, ez))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1083
  | alpha (Eq (C fo)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1084
  | alpha (Eq (Bound fp)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1085
  | alpha (Eq (Neg ft)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1086
  | alpha (Eq (Add (fu, fv))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1087
  | alpha (Eq (Sub (fw, fx))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1088
  | alpha (Eq (Mul (fy, fz))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1089
  | alpha (NEq (C go)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1090
  | alpha (NEq (Bound gp)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1091
  | alpha (NEq (Neg gt)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1092
  | alpha (NEq (Add (gu, gv))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1093
  | alpha (NEq (Sub (gw, gx))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1094
  | alpha (NEq (Mul (gy, gz))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1095
  | alpha (Dvd (aa, ab)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1096
  | alpha (NDvd (ac, ad)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1097
  | alpha (Not ae) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1098
  | alpha (Imp (aj, ak)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1099
  | alpha (Iff (al, am)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1100
  | alpha (E an) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1101
  | alpha (A ao) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1102
  | alpha (Closed ap) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1103
  | alpha (NClosed aq) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1104
  | alpha (Lt (Cn (cm, c, e))) = (if eqop eq_nat cm 0 then [e] else [])
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1105
  | alpha (Le (Cn (dm, c, e))) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1106
    (if eqop eq_nat dm 0 then [Add (C (~1 : IntInf.int), e)] else [])
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1107
  | alpha (Gt (Cn (em, c, e))) = (if eqop eq_nat em 0 then [] else [])
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1108
  | alpha (Ge (Cn (fm, c, e))) = (if eqop eq_nat fm 0 then [] else [])
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1109
  | alpha (Eq (Cn (gm, c, e))) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1110
    (if eqop eq_nat gm 0 then [Add (C (~1 : IntInf.int), e)] else [])
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1111
  | alpha (NEq (Cn (hm, c, e))) = (if eqop eq_nat hm 0 then [e] else []);
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1112
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1113
fun beta (And (p, q)) = append (beta p) (beta q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1114
  | beta (Or (p, q)) = append (beta p) (beta q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1115
  | beta T = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1116
  | beta F = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1117
  | beta (Lt (C bo)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1118
  | beta (Lt (Bound bp)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1119
  | beta (Lt (Neg bt)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1120
  | beta (Lt (Add (bu, bv))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1121
  | beta (Lt (Sub (bw, bx))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1122
  | beta (Lt (Mul (by, bz))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1123
  | beta (Le (C co)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1124
  | beta (Le (Bound cp)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1125
  | beta (Le (Neg ct)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1126
  | beta (Le (Add (cu, cv))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1127
  | beta (Le (Sub (cw, cx))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1128
  | beta (Le (Mul (cy, cz))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1129
  | beta (Gt (C doa)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1130
  | beta (Gt (Bound dp)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1131
  | beta (Gt (Neg dt)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1132
  | beta (Gt (Add (du, dv))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1133
  | beta (Gt (Sub (dw, dx))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1134
  | beta (Gt (Mul (dy, dz))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1135
  | beta (Ge (C eo)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1136
  | beta (Ge (Bound ep)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1137
  | beta (Ge (Neg et)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1138
  | beta (Ge (Add (eu, ev))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1139
  | beta (Ge (Sub (ew, ex))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1140
  | beta (Ge (Mul (ey, ez))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1141
  | beta (Eq (C fo)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1142
  | beta (Eq (Bound fp)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1143
  | beta (Eq (Neg ft)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1144
  | beta (Eq (Add (fu, fv))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1145
  | beta (Eq (Sub (fw, fx))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1146
  | beta (Eq (Mul (fy, fz))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1147
  | beta (NEq (C go)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1148
  | beta (NEq (Bound gp)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1149
  | beta (NEq (Neg gt)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1150
  | beta (NEq (Add (gu, gv))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1151
  | beta (NEq (Sub (gw, gx))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1152
  | beta (NEq (Mul (gy, gz))) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1153
  | beta (Dvd (aa, ab)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1154
  | beta (NDvd (ac, ad)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1155
  | beta (Not ae) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1156
  | beta (Imp (aj, ak)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1157
  | beta (Iff (al, am)) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1158
  | beta (E an) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1159
  | beta (A ao) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1160
  | beta (Closed ap) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1161
  | beta (NClosed aq) = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1162
  | beta (Lt (Cn (cm, c, e))) = (if eqop eq_nat cm 0 then [] else [])
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1163
  | beta (Le (Cn (dm, c, e))) = (if eqop eq_nat dm 0 then [] else [])
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1164
  | beta (Gt (Cn (em, c, e))) = (if eqop eq_nat em 0 then [Neg e] else [])
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1165
  | beta (Ge (Cn (fm, c, e))) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1166
    (if eqop eq_nat fm 0 then [Sub (C (~1 : IntInf.int), e)] else [])
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1167
  | beta (Eq (Cn (gm, c, e))) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1168
    (if eqop eq_nat gm 0 then [Sub (C (~1 : IntInf.int), e)] else [])
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1169
  | beta (NEq (Cn (hm, c, e))) = (if eqop eq_nat hm 0 then [Neg e] else []);
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1170
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1171
fun member A_ x [] = false
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1172
  | member A_ x (y :: ys) = eqop A_ x y orelse member A_ x ys;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1173
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1174
fun remdups A_ [] = []
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1175
  | remdups A_ (x :: xs) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1176
    (if member A_ x xs then remdups A_ xs else x :: remdups A_ xs);
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1177
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1178
fun delta (And (p, q)) = zlcm (delta p) (delta q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1179
  | delta (Or (p, q)) = zlcm (delta p) (delta q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1180
  | delta T = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1181
  | delta F = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1182
  | delta (Lt u) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1183
  | delta (Le v) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1184
  | delta (Gt w) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1185
  | delta (Ge x) = (1 : IntInf.int)
29939
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
  1186
  | delta (Eq y) = (1 : IntInf.int)
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1187
  | delta (NEq z) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1188
  | delta (Dvd (aa, C bo)) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1189
  | delta (Dvd (aa, Bound bp)) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1190
  | delta (Dvd (aa, Neg bt)) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1191
  | delta (Dvd (aa, Add (bu, bv))) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1192
  | delta (Dvd (aa, Sub (bw, bx))) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1193
  | delta (Dvd (aa, Mul (by, bz))) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1194
  | delta (NDvd (ac, C co)) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1195
  | delta (NDvd (ac, Bound cp)) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1196
  | delta (NDvd (ac, Neg ct)) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1197
  | delta (NDvd (ac, Add (cu, cv))) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1198
  | delta (NDvd (ac, Sub (cw, cx))) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1199
  | delta (NDvd (ac, Mul (cy, cz))) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1200
  | delta (Not ae) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1201
  | delta (Imp (aj, ak)) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1202
  | delta (Iff (al, am)) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1203
  | delta (E an) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1204
  | delta (A ao) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1205
  | delta (Closed ap) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1206
  | delta (NClosed aq) = (1 : IntInf.int)
29939
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
  1207
  | delta (Dvd (i, Cn (cm, c, e))) =
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
  1208
    (if eqop eq_nat cm 0 then i else (1 : IntInf.int))
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
  1209
  | delta (NDvd (i, Cn (dm, c, e))) =
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
  1210
    (if eqop eq_nat dm 0 then i else (1 : IntInf.int));
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1211
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1212
fun div_int a b = fst (divmoda a b);
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1213
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1214
fun a_beta (And (p, q)) = (fn k => And (a_beta p k, a_beta q k))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1215
  | a_beta (Or (p, q)) = (fn k => Or (a_beta p k, a_beta q k))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1216
  | a_beta T = (fn k => T)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1217
  | a_beta F = (fn k => F)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1218
  | a_beta (Lt (C bo)) = (fn k => Lt (C bo))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1219
  | a_beta (Lt (Bound bp)) = (fn k => Lt (Bound bp))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1220
  | a_beta (Lt (Neg bt)) = (fn k => Lt (Neg bt))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1221
  | a_beta (Lt (Add (bu, bv))) = (fn k => Lt (Add (bu, bv)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1222
  | a_beta (Lt (Sub (bw, bx))) = (fn k => Lt (Sub (bw, bx)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1223
  | a_beta (Lt (Mul (by, bz))) = (fn k => Lt (Mul (by, bz)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1224
  | a_beta (Le (C co)) = (fn k => Le (C co))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1225
  | a_beta (Le (Bound cp)) = (fn k => Le (Bound cp))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1226
  | a_beta (Le (Neg ct)) = (fn k => Le (Neg ct))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1227
  | a_beta (Le (Add (cu, cv))) = (fn k => Le (Add (cu, cv)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1228
  | a_beta (Le (Sub (cw, cx))) = (fn k => Le (Sub (cw, cx)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1229
  | a_beta (Le (Mul (cy, cz))) = (fn k => Le (Mul (cy, cz)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1230
  | a_beta (Gt (C doa)) = (fn k => Gt (C doa))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1231
  | a_beta (Gt (Bound dp)) = (fn k => Gt (Bound dp))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1232
  | a_beta (Gt (Neg dt)) = (fn k => Gt (Neg dt))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1233
  | a_beta (Gt (Add (du, dv))) = (fn k => Gt (Add (du, dv)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1234
  | a_beta (Gt (Sub (dw, dx))) = (fn k => Gt (Sub (dw, dx)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1235
  | a_beta (Gt (Mul (dy, dz))) = (fn k => Gt (Mul (dy, dz)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1236
  | a_beta (Ge (C eo)) = (fn k => Ge (C eo))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1237
  | a_beta (Ge (Bound ep)) = (fn k => Ge (Bound ep))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1238
  | a_beta (Ge (Neg et)) = (fn k => Ge (Neg et))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1239
  | a_beta (Ge (Add (eu, ev))) = (fn k => Ge (Add (eu, ev)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1240
  | a_beta (Ge (Sub (ew, ex))) = (fn k => Ge (Sub (ew, ex)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1241
  | a_beta (Ge (Mul (ey, ez))) = (fn k => Ge (Mul (ey, ez)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1242
  | a_beta (Eq (C fo)) = (fn k => Eq (C fo))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1243
  | a_beta (Eq (Bound fp)) = (fn k => Eq (Bound fp))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1244
  | a_beta (Eq (Neg ft)) = (fn k => Eq (Neg ft))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1245
  | a_beta (Eq (Add (fu, fv))) = (fn k => Eq (Add (fu, fv)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1246
  | a_beta (Eq (Sub (fw, fx))) = (fn k => Eq (Sub (fw, fx)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1247
  | a_beta (Eq (Mul (fy, fz))) = (fn k => Eq (Mul (fy, fz)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1248
  | a_beta (NEq (C go)) = (fn k => NEq (C go))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1249
  | a_beta (NEq (Bound gp)) = (fn k => NEq (Bound gp))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1250
  | a_beta (NEq (Neg gt)) = (fn k => NEq (Neg gt))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1251
  | a_beta (NEq (Add (gu, gv))) = (fn k => NEq (Add (gu, gv)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1252
  | a_beta (NEq (Sub (gw, gx))) = (fn k => NEq (Sub (gw, gx)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1253
  | a_beta (NEq (Mul (gy, gz))) = (fn k => NEq (Mul (gy, gz)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1254
  | a_beta (Dvd (aa, C ho)) = (fn k => Dvd (aa, C ho))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1255
  | a_beta (Dvd (aa, Bound hp)) = (fn k => Dvd (aa, Bound hp))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1256
  | a_beta (Dvd (aa, Neg ht)) = (fn k => Dvd (aa, Neg ht))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1257
  | a_beta (Dvd (aa, Add (hu, hv))) = (fn k => Dvd (aa, Add (hu, hv)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1258
  | a_beta (Dvd (aa, Sub (hw, hx))) = (fn k => Dvd (aa, Sub (hw, hx)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1259
  | a_beta (Dvd (aa, Mul (hy, hz))) = (fn k => Dvd (aa, Mul (hy, hz)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1260
  | a_beta (NDvd (ac, C io)) = (fn k => NDvd (ac, C io))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1261
  | a_beta (NDvd (ac, Bound ip)) = (fn k => NDvd (ac, Bound ip))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1262
  | a_beta (NDvd (ac, Neg it)) = (fn k => NDvd (ac, Neg it))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1263
  | a_beta (NDvd (ac, Add (iu, iv))) = (fn k => NDvd (ac, Add (iu, iv)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1264
  | a_beta (NDvd (ac, Sub (iw, ix))) = (fn k => NDvd (ac, Sub (iw, ix)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1265
  | a_beta (NDvd (ac, Mul (iy, iz))) = (fn k => NDvd (ac, Mul (iy, iz)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1266
  | a_beta (Not ae) = (fn k => Not ae)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1267
  | a_beta (Imp (aj, ak)) = (fn k => Imp (aj, ak))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1268
  | a_beta (Iff (al, am)) = (fn k => Iff (al, am))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1269
  | a_beta (E an) = (fn k => E an)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1270
  | a_beta (A ao) = (fn k => A ao)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1271
  | a_beta (Closed ap) = (fn k => Closed ap)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1272
  | a_beta (NClosed aq) = (fn k => NClosed aq)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1273
  | a_beta (Lt (Cn (cm, c, e))) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1274
    (if eqop eq_nat cm 0
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1275
      then (fn k => Lt (Cn (0, (1 : IntInf.int), Mul (div_int k c, e))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1276
      else (fn k => Lt (Cn (suc (minus_nat cm 1), c, e))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1277
  | a_beta (Le (Cn (dm, c, e))) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1278
    (if eqop eq_nat dm 0
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1279
      then (fn k => Le (Cn (0, (1 : IntInf.int), Mul (div_int k c, e))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1280
      else (fn k => Le (Cn (suc (minus_nat dm 1), c, e))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1281
  | a_beta (Gt (Cn (em, c, e))) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1282
    (if eqop eq_nat em 0
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1283
      then (fn k => Gt (Cn (0, (1 : IntInf.int), Mul (div_int k c, e))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1284
      else (fn k => Gt (Cn (suc (minus_nat em 1), c, e))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1285
  | a_beta (Ge (Cn (fm, c, e))) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1286
    (if eqop eq_nat fm 0
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1287
      then (fn k => Ge (Cn (0, (1 : IntInf.int), Mul (div_int k c, e))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1288
      else (fn k => Ge (Cn (suc (minus_nat fm 1), c, e))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1289
  | a_beta (Eq (Cn (gm, c, e))) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1290
    (if eqop eq_nat gm 0
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1291
      then (fn k => Eq (Cn (0, (1 : IntInf.int), Mul (div_int k c, e))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1292
      else (fn k => Eq (Cn (suc (minus_nat gm 1), c, e))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1293
  | a_beta (NEq (Cn (hm, c, e))) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1294
    (if eqop eq_nat hm 0
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1295
      then (fn k => NEq (Cn (0, (1 : IntInf.int), Mul (div_int k c, e))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1296
      else (fn k => NEq (Cn (suc (minus_nat hm 1), c, e))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1297
  | a_beta (Dvd (i, Cn (im, c, e))) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1298
    (if eqop eq_nat im 0
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1299
      then (fn k =>
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1300
             Dvd (IntInf.* (div_int k c, i),
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1301
                   Cn (0, (1 : IntInf.int), Mul (div_int k c, e))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1302
      else (fn k => Dvd (i, Cn (suc (minus_nat im 1), c, e))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1303
  | a_beta (NDvd (i, Cn (jm, c, e))) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1304
    (if eqop eq_nat jm 0
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1305
      then (fn k =>
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1306
             NDvd (IntInf.* (div_int k c, i),
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1307
                    Cn (0, (1 : IntInf.int), Mul (div_int k c, e))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1308
      else (fn k => NDvd (i, Cn (suc (minus_nat jm 1), c, e))));
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1309
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1310
fun zeta (And (p, q)) = zlcm (zeta p) (zeta q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1311
  | zeta (Or (p, q)) = zlcm (zeta p) (zeta q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1312
  | zeta T = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1313
  | zeta F = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1314
  | zeta (Lt (C bo)) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1315
  | zeta (Lt (Bound bp)) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1316
  | zeta (Lt (Neg bt)) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1317
  | zeta (Lt (Add (bu, bv))) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1318
  | zeta (Lt (Sub (bw, bx))) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1319
  | zeta (Lt (Mul (by, bz))) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1320
  | zeta (Le (C co)) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1321
  | zeta (Le (Bound cp)) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1322
  | zeta (Le (Neg ct)) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1323
  | zeta (Le (Add (cu, cv))) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1324
  | zeta (Le (Sub (cw, cx))) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1325
  | zeta (Le (Mul (cy, cz))) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1326
  | zeta (Gt (C doa)) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1327
  | zeta (Gt (Bound dp)) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1328
  | zeta (Gt (Neg dt)) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1329
  | zeta (Gt (Add (du, dv))) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1330
  | zeta (Gt (Sub (dw, dx))) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1331
  | zeta (Gt (Mul (dy, dz))) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1332
  | zeta (Ge (C eo)) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1333
  | zeta (Ge (Bound ep)) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1334
  | zeta (Ge (Neg et)) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1335
  | zeta (Ge (Add (eu, ev))) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1336
  | zeta (Ge (Sub (ew, ex))) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1337
  | zeta (Ge (Mul (ey, ez))) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1338
  | zeta (Eq (C fo)) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1339
  | zeta (Eq (Bound fp)) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1340
  | zeta (Eq (Neg ft)) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1341
  | zeta (Eq (Add (fu, fv))) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1342
  | zeta (Eq (Sub (fw, fx))) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1343
  | zeta (Eq (Mul (fy, fz))) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1344
  | zeta (NEq (C go)) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1345
  | zeta (NEq (Bound gp)) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1346
  | zeta (NEq (Neg gt)) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1347
  | zeta (NEq (Add (gu, gv))) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1348
  | zeta (NEq (Sub (gw, gx))) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1349
  | zeta (NEq (Mul (gy, gz))) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1350
  | zeta (Dvd (aa, C ho)) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1351
  | zeta (Dvd (aa, Bound hp)) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1352
  | zeta (Dvd (aa, Neg ht)) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1353
  | zeta (Dvd (aa, Add (hu, hv))) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1354
  | zeta (Dvd (aa, Sub (hw, hx))) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1355
  | zeta (Dvd (aa, Mul (hy, hz))) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1356
  | zeta (NDvd (ac, C io)) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1357
  | zeta (NDvd (ac, Bound ip)) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1358
  | zeta (NDvd (ac, Neg it)) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1359
  | zeta (NDvd (ac, Add (iu, iv))) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1360
  | zeta (NDvd (ac, Sub (iw, ix))) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1361
  | zeta (NDvd (ac, Mul (iy, iz))) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1362
  | zeta (Not ae) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1363
  | zeta (Imp (aj, ak)) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1364
  | zeta (Iff (al, am)) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1365
  | zeta (E an) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1366
  | zeta (A ao) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1367
  | zeta (Closed ap) = (1 : IntInf.int)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1368
  | zeta (NClosed aq) = (1 : IntInf.int)
29939
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
  1369
  | zeta (Lt (Cn (cm, c, e))) =
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
  1370
    (if eqop eq_nat cm 0 then c else (1 : IntInf.int))
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
  1371
  | zeta (Le (Cn (dm, c, e))) =
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
  1372
    (if eqop eq_nat dm 0 then c else (1 : IntInf.int))
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
  1373
  | zeta (Gt (Cn (em, c, e))) =
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
  1374
    (if eqop eq_nat em 0 then c else (1 : IntInf.int))
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
  1375
  | zeta (Ge (Cn (fm, c, e))) =
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
  1376
    (if eqop eq_nat fm 0 then c else (1 : IntInf.int))
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
  1377
  | zeta (Eq (Cn (gm, c, e))) =
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
  1378
    (if eqop eq_nat gm 0 then c else (1 : IntInf.int))
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
  1379
  | zeta (NEq (Cn (hm, c, e))) =
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
  1380
    (if eqop eq_nat hm 0 then c else (1 : IntInf.int))
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
  1381
  | zeta (Dvd (i, Cn (im, c, e))) =
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
  1382
    (if eqop eq_nat im 0 then c else (1 : IntInf.int))
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
  1383
  | zeta (NDvd (i, Cn (jm, c, e))) =
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
  1384
    (if eqop eq_nat jm 0 then c else (1 : IntInf.int));
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1385
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1386
fun zsplit0 (C c) = ((0 : IntInf.int), C c)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1387
  | zsplit0 (Bound n) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1388
    (if eqop eq_nat n 0 then ((1 : IntInf.int), C (0 : IntInf.int))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1389
      else ((0 : IntInf.int), Bound n))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1390
  | zsplit0 (Cn (n, i, a)) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1391
    let
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1392
      val aa = zsplit0 a;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1393
      val (i', a') = aa;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1394
    in
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1395
      (if eqop eq_nat n 0 then (IntInf.+ (i, i'), a') else (i', Cn (n, i, a')))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1396
    end
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1397
  | zsplit0 (Neg a) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1398
    let
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1399
      val aa = zsplit0 a;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1400
      val (i', a') = aa;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1401
    in
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1402
      (IntInf.~ i', Neg a')
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1403
    end
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1404
  | zsplit0 (Add (a, b)) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1405
    let
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1406
      val aa = zsplit0 a;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1407
      val (ia, a') = aa;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1408
      val ab = zsplit0 b;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1409
      val (ib, b') = ab;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1410
    in
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1411
      (IntInf.+ (ia, ib), Add (a', b'))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1412
    end
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1413
  | zsplit0 (Sub (a, b)) =
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1414
    let
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1415
      val aa = zsplit0 a;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1416
      val (ia, a') = aa;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1417
      val ab = zsplit0 b;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1418
      val (ib, b') = ab;
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1419
    in
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1420
      (IntInf.- (ia, ib), Sub (a', b'))
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1421
    end
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1422
  | zsplit0 (Mul (i, a)) =
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1423
    let
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1424
      val aa = zsplit0 a;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1425
      val (i', a') = aa;
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1426
    in
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1427
      (IntInf.* (i, i'), Mul (i, a'))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1428
    end;
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1429
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1430
fun zlfm (And (p, q)) = And (zlfm p, zlfm q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1431
  | zlfm (Or (p, q)) = Or (zlfm p, zlfm q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1432
  | zlfm (Imp (p, q)) = Or (zlfm (Not p), zlfm q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1433
  | zlfm (Iff (p, q)) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1434
    Or (And (zlfm p, zlfm q), And (zlfm (Not p), zlfm (Not q)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1435
  | zlfm (Lt a) =
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1436
    let
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1437
      val aa = zsplit0 a;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1438
      val (c, r) = aa;
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1439
    in
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1440
      (if eqop eq_int c (0 : IntInf.int) then Lt r
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1441
        else (if IntInf.< ((0 : IntInf.int), c) then Lt (Cn (0, c, r))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1442
               else Gt (Cn (0, IntInf.~ c, Neg r))))
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1443
    end
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1444
  | zlfm (Le a) =
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1445
    let
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1446
      val aa = zsplit0 a;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1447
      val (c, r) = aa;
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1448
    in
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1449
      (if eqop eq_int c (0 : IntInf.int) then Le r
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1450
        else (if IntInf.< ((0 : IntInf.int), c) then Le (Cn (0, c, r))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1451
               else Ge (Cn (0, IntInf.~ c, Neg r))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1452
    end
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1453
  | zlfm (Gt a) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1454
    let
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1455
      val aa = zsplit0 a;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1456
      val (c, r) = aa;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1457
    in
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1458
      (if eqop eq_int c (0 : IntInf.int) then Gt r
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1459
        else (if IntInf.< ((0 : IntInf.int), c) then Gt (Cn (0, c, r))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1460
               else Lt (Cn (0, IntInf.~ c, Neg r))))
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1461
    end
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1462
  | zlfm (Ge a) =
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1463
    let
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1464
      val aa = zsplit0 a;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1465
      val (c, r) = aa;
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1466
    in
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1467
      (if eqop eq_int c (0 : IntInf.int) then Ge r
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1468
        else (if IntInf.< ((0 : IntInf.int), c) then Ge (Cn (0, c, r))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1469
               else Le (Cn (0, IntInf.~ c, Neg r))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1470
    end
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1471
  | zlfm (Eq a) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1472
    let
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1473
      val aa = zsplit0 a;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1474
      val (c, r) = aa;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1475
    in
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1476
      (if eqop eq_int c (0 : IntInf.int) then Eq r
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1477
        else (if IntInf.< ((0 : IntInf.int), c) then Eq (Cn (0, c, r))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1478
               else Eq (Cn (0, IntInf.~ c, Neg r))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1479
    end
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1480
  | zlfm (NEq a) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1481
    let
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1482
      val aa = zsplit0 a;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1483
      val (c, r) = aa;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1484
    in
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1485
      (if eqop eq_int c (0 : IntInf.int) then NEq r
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1486
        else (if IntInf.< ((0 : IntInf.int), c) then NEq (Cn (0, c, r))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1487
               else NEq (Cn (0, IntInf.~ c, Neg r))))
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1488
    end
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1489
  | zlfm (Dvd (i, a)) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1490
    (if eqop eq_int i (0 : IntInf.int) then zlfm (Eq a)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1491
      else let
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1492
             val aa = zsplit0 a;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1493
             val (c, r) = aa;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1494
           in
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1495
             (if eqop eq_int c (0 : IntInf.int) then Dvd (abs_int i, r)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1496
               else (if IntInf.< ((0 : IntInf.int), c)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1497
                      then Dvd (abs_int i, Cn (0, c, r))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1498
                      else Dvd (abs_int i, Cn (0, IntInf.~ c, Neg r))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1499
           end)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1500
  | zlfm (NDvd (i, a)) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1501
    (if eqop eq_int i (0 : IntInf.int) then zlfm (NEq a)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1502
      else let
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1503
             val aa = zsplit0 a;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1504
             val (c, r) = aa;
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1505
           in
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1506
             (if eqop eq_int c (0 : IntInf.int) then NDvd (abs_int i, r)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1507
               else (if IntInf.< ((0 : IntInf.int), c)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1508
                      then NDvd (abs_int i, Cn (0, c, r))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1509
                      else NDvd (abs_int i, Cn (0, IntInf.~ c, Neg r))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1510
           end)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1511
  | zlfm (Not (And (p, q))) = Or (zlfm (Not p), zlfm (Not q))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1512
  | zlfm (Not (Or (p, q))) = And (zlfm (Not p), zlfm (Not q))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1513
  | zlfm (Not (Imp (p, q))) = And (zlfm p, zlfm (Not q))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1514
  | zlfm (Not (Iff (p, q))) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1515
    Or (And (zlfm p, zlfm (Not q)), And (zlfm (Not p), zlfm q))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1516
  | zlfm (Not (Not p)) = zlfm p
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1517
  | zlfm (Not T) = F
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1518
  | zlfm (Not F) = T
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1519
  | zlfm (Not (Lt a)) = zlfm (Ge a)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1520
  | zlfm (Not (Le a)) = zlfm (Gt a)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1521
  | zlfm (Not (Gt a)) = zlfm (Le a)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1522
  | zlfm (Not (Ge a)) = zlfm (Lt a)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1523
  | zlfm (Not (Eq a)) = zlfm (NEq a)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1524
  | zlfm (Not (NEq a)) = zlfm (Eq a)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1525
  | zlfm (Not (Dvd (i, a))) = zlfm (NDvd (i, a))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1526
  | zlfm (Not (NDvd (i, a))) = zlfm (Dvd (i, a))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1527
  | zlfm (Not (Closed p)) = NClosed p
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1528
  | zlfm (Not (NClosed p)) = Closed p
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1529
  | zlfm T = T
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1530
  | zlfm F = F
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1531
  | zlfm (Not (E ci)) = Not (E ci)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1532
  | zlfm (Not (A cj)) = Not (A cj)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1533
  | zlfm (E ao) = E ao
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1534
  | zlfm (A ap) = A ap
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1535
  | zlfm (Closed aq) = Closed aq
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1536
  | zlfm (NClosed ar) = NClosed ar;
23466
886655a150f6 moved quantifier elimination tools to Tools/Qelim/;
wenzelm
parents:
diff changeset
  1537
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1538
fun unita p =
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1539
  let
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1540
    val p' = zlfm p;
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1541
    val l = zeta p';
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1542
    val q =
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1543
      And (Dvd (l, Cn (0, (1 : IntInf.int), C (0 : IntInf.int))), a_beta p' l);
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1544
    val d = delta q;
23714
49b08f25db29 now a monolithic module
haftmann
parents: 23689
diff changeset
  1545
    val b = remdups eq_numa (map simpnum (beta q));
49b08f25db29 now a monolithic module
haftmann
parents: 23689
diff changeset
  1546
    val a = remdups eq_numa (map simpnum (alpha q));
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1547
  in
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1548
    (if IntInf.<= (size_list b, size_list a) then (q, (b, d))
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1549
      else (mirror q, (a, d)))
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1550
  end;
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1551
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1552
fun cooper p =
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1553
  let
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1554
    val a = unita p;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1555
    val (q, aa) = a;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1556
    val (b, d) = aa;
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1557
    val js = iupt (1 : IntInf.int) d;
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1558
    val mq = simpfm (minusinf q);
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1559
    val md = evaldjf (fn j => simpfm (subst0 (C j) mq)) js;
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1560
  in
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1561
    (if eqop eq_fma md T then T
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1562
      else let
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1563
             val qd =
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1564
               evaldjf (fn ab as (ba, j) => simpfm (subst0 (Add (ba, C j)) q))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1565
                 (concat (map (fn ba => map (fn ab => (ba, ab)) js) b));
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1566
           in
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1567
             decr (disj md qd)
23466
886655a150f6 moved quantifier elimination tools to Tools/Qelim/;
wenzelm
parents:
diff changeset
  1568
           end)
886655a150f6 moved quantifier elimination tools to Tools/Qelim/;
wenzelm
parents:
diff changeset
  1569
  end;
886655a150f6 moved quantifier elimination tools to Tools/Qelim/;
wenzelm
parents:
diff changeset
  1570
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1571
fun prep (E T) = T
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1572
  | prep (E F) = F
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1573
  | prep (E (Or (p, q))) = Or (prep (E p), prep (E q))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1574
  | prep (E (Imp (p, q))) = Or (prep (E (Not p)), prep (E q))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1575
  | prep (E (Iff (p, q))) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1576
    Or (prep (E (And (p, q))), prep (E (And (Not p, Not q))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1577
  | prep (E (Not (And (p, q)))) = Or (prep (E (Not p)), prep (E (Not q)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1578
  | prep (E (Not (Imp (p, q)))) = prep (E (And (p, Not q)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1579
  | prep (E (Not (Iff (p, q)))) =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1580
    Or (prep (E (And (p, Not q))), prep (E (And (Not p, q))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1581
  | prep (E (Lt ef)) = E (prep (Lt ef))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1582
  | prep (E (Le eg)) = E (prep (Le eg))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1583
  | prep (E (Gt eh)) = E (prep (Gt eh))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1584
  | prep (E (Ge ei)) = E (prep (Ge ei))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1585
  | prep (E (Eq ej)) = E (prep (Eq ej))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1586
  | prep (E (NEq ek)) = E (prep (NEq ek))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1587
  | prep (E (Dvd (el, em))) = E (prep (Dvd (el, em)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1588
  | prep (E (NDvd (en, eo))) = E (prep (NDvd (en, eo)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1589
  | prep (E (Not T)) = E (prep (Not T))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1590
  | prep (E (Not F)) = E (prep (Not F))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1591
  | prep (E (Not (Lt gw))) = E (prep (Not (Lt gw)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1592
  | prep (E (Not (Le gx))) = E (prep (Not (Le gx)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1593
  | prep (E (Not (Gt gy))) = E (prep (Not (Gt gy)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1594
  | prep (E (Not (Ge gz))) = E (prep (Not (Ge gz)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1595
  | prep (E (Not (Eq ha))) = E (prep (Not (Eq ha)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1596
  | prep (E (Not (NEq hb))) = E (prep (Not (NEq hb)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1597
  | prep (E (Not (Dvd (hc, hd)))) = E (prep (Not (Dvd (hc, hd))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1598
  | prep (E (Not (NDvd (he, hf)))) = E (prep (Not (NDvd (he, hf))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1599
  | prep (E (Not (Not hg))) = E (prep (Not (Not hg)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1600
  | prep (E (Not (Or (hj, hk)))) = E (prep (Not (Or (hj, hk))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1601
  | prep (E (Not (E hp))) = E (prep (Not (E hp)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1602
  | prep (E (Not (A hq))) = E (prep (Not (A hq)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1603
  | prep (E (Not (Closed hr))) = E (prep (Not (Closed hr)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1604
  | prep (E (Not (NClosed hs))) = E (prep (Not (NClosed hs)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1605
  | prep (E (And (eq, er))) = E (prep (And (eq, er)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1606
  | prep (E (E ey)) = E (prep (E ey))
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1607
  | prep (E (A ez)) = E (prep (A ez))
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1608
  | prep (E (Closed fa)) = E (prep (Closed fa))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1609
  | prep (E (NClosed fb)) = E (prep (NClosed fb))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1610
  | prep (A (And (p, q))) = And (prep (A p), prep (A q))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1611
  | prep (A T) = prep (Not (E (Not T)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1612
  | prep (A F) = prep (Not (E (Not F)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1613
  | prep (A (Lt jn)) = prep (Not (E (Not (Lt jn))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1614
  | prep (A (Le jo)) = prep (Not (E (Not (Le jo))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1615
  | prep (A (Gt jp)) = prep (Not (E (Not (Gt jp))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1616
  | prep (A (Ge jq)) = prep (Not (E (Not (Ge jq))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1617
  | prep (A (Eq jr)) = prep (Not (E (Not (Eq jr))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1618
  | prep (A (NEq js)) = prep (Not (E (Not (NEq js))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1619
  | prep (A (Dvd (jt, ju))) = prep (Not (E (Not (Dvd (jt, ju)))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1620
  | prep (A (NDvd (jv, jw))) = prep (Not (E (Not (NDvd (jv, jw)))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1621
  | prep (A (Not jx)) = prep (Not (E (Not (Not jx))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1622
  | prep (A (Or (ka, kb))) = prep (Not (E (Not (Or (ka, kb)))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1623
  | prep (A (Imp (kc, kd))) = prep (Not (E (Not (Imp (kc, kd)))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1624
  | prep (A (Iff (ke, kf))) = prep (Not (E (Not (Iff (ke, kf)))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1625
  | prep (A (E kg)) = prep (Not (E (Not (E kg))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1626
  | prep (A (A kh)) = prep (Not (E (Not (A kh))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1627
  | prep (A (Closed ki)) = prep (Not (E (Not (Closed ki))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1628
  | prep (A (NClosed kj)) = prep (Not (E (Not (NClosed kj))))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1629
  | prep (Not (Not p)) = prep p
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1630
  | prep (Not (And (p, q))) = Or (prep (Not p), prep (Not q))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1631
  | prep (Not (A p)) = prep (E (Not p))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1632
  | prep (Not (Or (p, q))) = And (prep (Not p), prep (Not q))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1633
  | prep (Not (Imp (p, q))) = And (prep p, prep (Not q))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1634
  | prep (Not (Iff (p, q))) = Or (prep (And (p, Not q)), prep (And (Not p, q)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1635
  | prep (Not T) = Not (prep T)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1636
  | prep (Not F) = Not (prep F)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1637
  | prep (Not (Lt bo)) = Not (prep (Lt bo))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1638
  | prep (Not (Le bp)) = Not (prep (Le bp))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1639
  | prep (Not (Gt bq)) = Not (prep (Gt bq))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1640
  | prep (Not (Ge br)) = Not (prep (Ge br))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1641
  | prep (Not (Eq bs)) = Not (prep (Eq bs))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1642
  | prep (Not (NEq bt)) = Not (prep (NEq bt))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1643
  | prep (Not (Dvd (bu, bv))) = Not (prep (Dvd (bu, bv)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1644
  | prep (Not (NDvd (bw, bx))) = Not (prep (NDvd (bw, bx)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1645
  | prep (Not (E ch)) = Not (prep (E ch))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1646
  | prep (Not (Closed cj)) = Not (prep (Closed cj))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1647
  | prep (Not (NClosed ck)) = Not (prep (NClosed ck))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1648
  | prep (Or (p, q)) = Or (prep p, prep q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1649
  | prep (And (p, q)) = And (prep p, prep q)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1650
  | prep (Imp (p, q)) = prep (Or (Not p, q))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1651
  | prep (Iff (p, q)) = Or (prep (And (p, q)), prep (And (Not p, Not q)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1652
  | prep T = T
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1653
  | prep F = F
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1654
  | prep (Lt u) = Lt u
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1655
  | prep (Le v) = Le v
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1656
  | prep (Gt w) = Gt w
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1657
  | prep (Ge x) = Ge x
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1658
  | prep (Eq y) = Eq y
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1659
  | prep (NEq z) = NEq z
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1660
  | prep (Dvd (aa, ab)) = Dvd (aa, ab)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1661
  | prep (NDvd (ac, ad)) = NDvd (ac, ad)
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1662
  | prep (Closed ap) = Closed ap
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1663
  | prep (NClosed aq) = NClosed aq;
23466
886655a150f6 moved quantifier elimination tools to Tools/Qelim/;
wenzelm
parents:
diff changeset
  1664
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1665
fun qelim (E p) = (fn qe => dj qe (qelim p qe))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1666
  | qelim (A p) = (fn qe => nota (qe (qelim (Not p) qe)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1667
  | qelim (Not p) = (fn qe => nota (qelim p qe))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1668
  | qelim (And (p, q)) = (fn qe => conj (qelim p qe) (qelim q qe))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1669
  | qelim (Or (p, q)) = (fn qe => disj (qelim p qe) (qelim q qe))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1670
  | qelim (Imp (p, q)) = (fn qe => impa (qelim p qe) (qelim q qe))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1671
  | qelim (Iff (p, q)) = (fn qe => iffa (qelim p qe) (qelim q qe))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1672
  | qelim T = (fn y => simpfm T)
23689
0410269099dc replaced code generator framework for reflected cooper
haftmann
parents: 23466
diff changeset
  1673
  | qelim F = (fn y => simpfm F)
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1674
  | qelim (Lt u) = (fn y => simpfm (Lt u))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1675
  | qelim (Le v) = (fn y => simpfm (Le v))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1676
  | qelim (Gt w) = (fn y => simpfm (Gt w))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1677
  | qelim (Ge x) = (fn y => simpfm (Ge x))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1678
  | qelim (Eq y) = (fn ya => simpfm (Eq y))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1679
  | qelim (NEq z) = (fn y => simpfm (NEq z))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1680
  | qelim (Dvd (aa, ab)) = (fn y => simpfm (Dvd (aa, ab)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1681
  | qelim (NDvd (ac, ad)) = (fn y => simpfm (NDvd (ac, ad)))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1682
  | qelim (Closed ap) = (fn y => simpfm (Closed ap))
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1683
  | qelim (NClosed aq) = (fn y => simpfm (NClosed aq));
23466
886655a150f6 moved quantifier elimination tools to Tools/Qelim/;
wenzelm
parents:
diff changeset
  1684
29787
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1685
fun pa p = qelim (prep p) cooper;
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1686
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1687
fun neg z = IntInf.< (z, (0 : IntInf.int));
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1688
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1689
fun nat_aux i n =
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1690
  (if IntInf.<= (i, (0 : IntInf.int)) then n
23bf900a21db regenerated presburger code
haftmann
parents: 24584
diff changeset
  1691
    else nat_aux (IntInf.- (i, (1 : IntInf.int))) (suc n));
23466
886655a150f6 moved quantifier elimination tools to Tools/Qelim/;
wenzelm
parents:
diff changeset
  1692
29939
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
  1693
fun adjust b =
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
  1694
  (fn a as (q, r) =>
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
  1695
    (if IntInf.<= ((0 : IntInf.int), IntInf.- (r, b))
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
  1696
      then (IntInf.+ (IntInf.* ((2 : IntInf.int), q), (1 : IntInf.int)),
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
  1697
             IntInf.- (r, b))
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
  1698
      else (IntInf.* ((2 : IntInf.int), q), r)));
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
  1699
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
  1700
fun posDivAlg a b =
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
  1701
  (if IntInf.< (a, b) orelse IntInf.<= (b, (0 : IntInf.int))
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
  1702
    then ((0 : IntInf.int), a)
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
  1703
    else adjust b (posDivAlg a (IntInf.* ((2 : IntInf.int), b))));
2138ff0ec94a re-generated
haftmann
parents: 29823
diff changeset
  1704
23714
49b08f25db29 now a monolithic module
haftmann
parents: 23689
diff changeset
  1705
end; (*struct GeneratedCooper*)