author | nipkow |
Wed, 31 Mar 2021 18:18:03 +0200 | |
changeset 73526 | a3cc9fa1295d |
child 74625 | e6f0c9bf966c |
permissions | -rw-r--r-- |
73526
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
1 |
structure Order_Procedure : sig |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
2 |
datatype int = Int_of_integer of IntInf.int |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
3 |
val integer_of_int : int -> IntInf.int |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
4 |
datatype 'a fm = Atom of 'a | And of 'a fm * 'a fm | Or of 'a fm * 'a fm | |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
5 |
Neg of 'a fm |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
6 |
datatype trm = Const of string | App of trm * trm | Var of int |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
7 |
datatype prf_trm = PThm of string | Appt of prf_trm * trm | |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
8 |
AppP of prf_trm * prf_trm | AbsP of trm * prf_trm | Bound of trm | |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
9 |
Conv of trm * prf_trm * prf_trm |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
10 |
datatype o_atom = EQ of int * int | LEQ of int * int | LESS of int * int |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
11 |
val lo_contr_prf : (bool * o_atom) fm -> prf_trm option |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
12 |
val po_contr_prf : (bool * o_atom) fm -> prf_trm option |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
13 |
end = struct |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
14 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
15 |
datatype int = Int_of_integer of IntInf.int; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
16 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
17 |
fun integer_of_int (Int_of_integer k) = k; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
18 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
19 |
fun equal_inta k l = (((integer_of_int k) : IntInf.int) = (integer_of_int l)); |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
20 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
21 |
type 'a equal = {equal : 'a -> 'a -> bool}; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
22 |
val equal = #equal : 'a equal -> 'a -> 'a -> bool; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
23 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
24 |
val equal_int = {equal = equal_inta} : int equal; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
25 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
26 |
fun less_eq_int k l = IntInf.<= (integer_of_int k, integer_of_int l); |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
27 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
28 |
type 'a ord = {less_eq : 'a -> 'a -> bool, less : 'a -> 'a -> bool}; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
29 |
val less_eq = #less_eq : 'a ord -> 'a -> 'a -> bool; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
30 |
val less = #less : 'a ord -> 'a -> 'a -> bool; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
31 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
32 |
fun less_int k l = IntInf.< (integer_of_int k, integer_of_int l); |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
33 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
34 |
val ord_int = {less_eq = less_eq_int, less = less_int} : int ord; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
35 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
36 |
type 'a preorder = {ord_preorder : 'a ord}; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
37 |
val ord_preorder = #ord_preorder : 'a preorder -> 'a ord; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
38 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
39 |
type 'a order = {preorder_order : 'a preorder}; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
40 |
val preorder_order = #preorder_order : 'a order -> 'a preorder; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
41 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
42 |
val preorder_int = {ord_preorder = ord_int} : int preorder; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
43 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
44 |
val order_int = {preorder_order = preorder_int} : int order; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
45 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
46 |
type 'a linorder = {order_linorder : 'a order}; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
47 |
val order_linorder = #order_linorder : 'a linorder -> 'a order; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
48 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
49 |
val linorder_int = {order_linorder = order_int} : int linorder; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
50 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
51 |
fun eq A_ a b = equal A_ a b; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
52 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
53 |
fun equal_proda A_ B_ (x1, x2) (y1, y2) = eq A_ x1 y1 andalso eq B_ x2 y2; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
54 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
55 |
fun equal_prod A_ B_ = {equal = equal_proda A_ B_} : ('a * 'b) equal; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
56 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
57 |
fun less_eq_prod A_ B_ (x1, y1) (x2, y2) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
58 |
less A_ x1 x2 orelse less_eq A_ x1 x2 andalso less_eq B_ y1 y2; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
59 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
60 |
fun less_prod A_ B_ (x1, y1) (x2, y2) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
61 |
less A_ x1 x2 orelse less_eq A_ x1 x2 andalso less B_ y1 y2; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
62 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
63 |
fun ord_prod A_ B_ = {less_eq = less_eq_prod A_ B_, less = less_prod A_ B_} : |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
64 |
('a * 'b) ord; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
65 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
66 |
fun preorder_prod A_ B_ = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
67 |
{ord_preorder = ord_prod (ord_preorder A_) (ord_preorder B_)} : |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
68 |
('a * 'b) preorder; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
69 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
70 |
fun order_prod A_ B_ = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
71 |
{preorder_order = preorder_prod (preorder_order A_) (preorder_order B_)} : |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
72 |
('a * 'b) order; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
73 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
74 |
fun linorder_prod A_ B_ = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
75 |
{order_linorder = order_prod (order_linorder A_) (order_linorder B_)} : |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
76 |
('a * 'b) linorder; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
77 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
78 |
datatype nat = Zero_nat | Suc of nat; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
79 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
80 |
datatype color = R | B; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
81 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
82 |
datatype ('a, 'b) rbta = Empty | |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
83 |
Branch of color * ('a, 'b) rbta * 'a * 'b * ('a, 'b) rbta; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
84 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
85 |
datatype ('b, 'a) rbt = RBT of ('b, 'a) rbta; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
86 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
87 |
datatype 'a set = Set of 'a list | Coset of 'a list; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
88 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
89 |
datatype 'a fm = Atom of 'a | And of 'a fm * 'a fm | Or of 'a fm * 'a fm | |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
90 |
Neg of 'a fm; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
91 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
92 |
datatype trm = Const of string | App of trm * trm | Var of int; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
93 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
94 |
datatype prf_trm = PThm of string | Appt of prf_trm * trm | |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
95 |
AppP of prf_trm * prf_trm | AbsP of trm * prf_trm | Bound of trm | |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
96 |
Conv of trm * prf_trm * prf_trm; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
97 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
98 |
datatype ('a, 'b) mapping = Mapping of ('a, 'b) rbt; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
99 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
100 |
datatype o_atom = EQ of int * int | LEQ of int * int | LESS of int * int; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
101 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
102 |
fun id x = (fn xa => xa) x; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
103 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
104 |
fun impl_of B_ (RBT x) = x; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
105 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
106 |
fun folda f (Branch (c, lt, k, v, rt)) x = folda f rt (f k v (folda f lt x)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
107 |
| folda f Empty x = x; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
108 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
109 |
fun fold A_ x xc = folda x (impl_of A_ xc); |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
110 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
111 |
fun gen_keys kts (Branch (c, l, k, v, r)) = gen_keys ((k, r) :: kts) l |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
112 |
| gen_keys ((k, t) :: kts) Empty = k :: gen_keys kts t |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
113 |
| gen_keys [] Empty = []; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
114 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
115 |
fun keysb x = gen_keys [] x; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
116 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
117 |
fun keys A_ x = keysb (impl_of A_ x); |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
118 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
119 |
fun maps f [] = [] |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
120 |
| maps f (x :: xs) = f x @ maps f xs; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
121 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
122 |
fun empty A_ = RBT Empty; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
123 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
124 |
fun foldl f a [] = a |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
125 |
| foldl f a (x :: xs) = foldl f (f a x) xs; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
126 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
127 |
fun foldr f [] = id |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
128 |
| foldr f (x :: xs) = f x o foldr f xs; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
129 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
130 |
fun balance (Branch (R, a, w, x, b)) s t (Branch (R, c, y, z, d)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
131 |
Branch (R, Branch (B, a, w, x, b), s, t, Branch (B, c, y, z, d)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
132 |
| balance (Branch (R, Branch (R, a, w, x, b), s, t, c)) y z Empty = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
133 |
Branch (R, Branch (B, a, w, x, b), s, t, Branch (B, c, y, z, Empty)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
134 |
| balance (Branch (R, Branch (R, a, w, x, b), s, t, c)) y z |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
135 |
(Branch (B, va, vb, vc, vd)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
136 |
Branch |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
137 |
(R, Branch (B, a, w, x, b), s, t, |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
138 |
Branch (B, c, y, z, Branch (B, va, vb, vc, vd))) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
139 |
| balance (Branch (R, Empty, w, x, Branch (R, b, s, t, c))) y z Empty = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
140 |
Branch (R, Branch (B, Empty, w, x, b), s, t, Branch (B, c, y, z, Empty)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
141 |
| balance |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
142 |
(Branch (R, Branch (B, va, vb, vc, vd), w, x, Branch (R, b, s, t, c))) y z |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
143 |
Empty = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
144 |
Branch |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
145 |
(R, Branch (B, Branch (B, va, vb, vc, vd), w, x, b), s, t, |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
146 |
Branch (B, c, y, z, Empty)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
147 |
| balance (Branch (R, Empty, w, x, Branch (R, b, s, t, c))) y z |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
148 |
(Branch (B, va, vb, vc, vd)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
149 |
Branch |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
150 |
(R, Branch (B, Empty, w, x, b), s, t, |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
151 |
Branch (B, c, y, z, Branch (B, va, vb, vc, vd))) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
152 |
| balance |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
153 |
(Branch (R, Branch (B, ve, vf, vg, vh), w, x, Branch (R, b, s, t, c))) y z |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
154 |
(Branch (B, va, vb, vc, vd)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
155 |
Branch |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
156 |
(R, Branch (B, Branch (B, ve, vf, vg, vh), w, x, b), s, t, |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
157 |
Branch (B, c, y, z, Branch (B, va, vb, vc, vd))) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
158 |
| balance Empty w x (Branch (R, b, s, t, Branch (R, c, y, z, d))) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
159 |
Branch (R, Branch (B, Empty, w, x, b), s, t, Branch (B, c, y, z, d)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
160 |
| balance (Branch (B, va, vb, vc, vd)) w x |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
161 |
(Branch (R, b, s, t, Branch (R, c, y, z, d))) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
162 |
Branch |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
163 |
(R, Branch (B, Branch (B, va, vb, vc, vd), w, x, b), s, t, |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
164 |
Branch (B, c, y, z, d)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
165 |
| balance Empty w x (Branch (R, Branch (R, b, s, t, c), y, z, Empty)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
166 |
Branch (R, Branch (B, Empty, w, x, b), s, t, Branch (B, c, y, z, Empty)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
167 |
| balance Empty w x |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
168 |
(Branch (R, Branch (R, b, s, t, c), y, z, Branch (B, va, vb, vc, vd))) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
169 |
Branch |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
170 |
(R, Branch (B, Empty, w, x, b), s, t, |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
171 |
Branch (B, c, y, z, Branch (B, va, vb, vc, vd))) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
172 |
| balance (Branch (B, va, vb, vc, vd)) w x |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
173 |
(Branch (R, Branch (R, b, s, t, c), y, z, Empty)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
174 |
Branch |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
175 |
(R, Branch (B, Branch (B, va, vb, vc, vd), w, x, b), s, t, |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
176 |
Branch (B, c, y, z, Empty)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
177 |
| balance (Branch (B, va, vb, vc, vd)) w x |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
178 |
(Branch (R, Branch (R, b, s, t, c), y, z, Branch (B, ve, vf, vg, vh))) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
179 |
Branch |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
180 |
(R, Branch (B, Branch (B, va, vb, vc, vd), w, x, b), s, t, |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
181 |
Branch (B, c, y, z, Branch (B, ve, vf, vg, vh))) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
182 |
| balance Empty s t Empty = Branch (B, Empty, s, t, Empty) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
183 |
| balance Empty s t (Branch (B, va, vb, vc, vd)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
184 |
Branch (B, Empty, s, t, Branch (B, va, vb, vc, vd)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
185 |
| balance Empty s t (Branch (v, Empty, vb, vc, Empty)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
186 |
Branch (B, Empty, s, t, Branch (v, Empty, vb, vc, Empty)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
187 |
| balance Empty s t (Branch (v, Branch (B, ve, vf, vg, vh), vb, vc, Empty)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
188 |
Branch |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
189 |
(B, Empty, s, t, Branch (v, Branch (B, ve, vf, vg, vh), vb, vc, Empty)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
190 |
| balance Empty s t (Branch (v, Empty, vb, vc, Branch (B, vf, vg, vh, vi))) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
191 |
Branch |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
192 |
(B, Empty, s, t, Branch (v, Empty, vb, vc, Branch (B, vf, vg, vh, vi))) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
193 |
| balance Empty s t |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
194 |
(Branch (v, Branch (B, ve, vj, vk, vl), vb, vc, Branch (B, vf, vg, vh, vi))) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
195 |
= Branch |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
196 |
(B, Empty, s, t, |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
197 |
Branch |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
198 |
(v, Branch (B, ve, vj, vk, vl), vb, vc, Branch (B, vf, vg, vh, vi))) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
199 |
| balance (Branch (B, va, vb, vc, vd)) s t Empty = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
200 |
Branch (B, Branch (B, va, vb, vc, vd), s, t, Empty) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
201 |
| balance (Branch (B, va, vb, vc, vd)) s t (Branch (B, ve, vf, vg, vh)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
202 |
Branch (B, Branch (B, va, vb, vc, vd), s, t, Branch (B, ve, vf, vg, vh)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
203 |
| balance (Branch (B, va, vb, vc, vd)) s t (Branch (v, Empty, vf, vg, Empty)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
204 |
= Branch |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
205 |
(B, Branch (B, va, vb, vc, vd), s, t, Branch (v, Empty, vf, vg, Empty)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
206 |
| balance (Branch (B, va, vb, vc, vd)) s t |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
207 |
(Branch (v, Branch (B, vi, vj, vk, vl), vf, vg, Empty)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
208 |
Branch |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
209 |
(B, Branch (B, va, vb, vc, vd), s, t, |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
210 |
Branch (v, Branch (B, vi, vj, vk, vl), vf, vg, Empty)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
211 |
| balance (Branch (B, va, vb, vc, vd)) s t |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
212 |
(Branch (v, Empty, vf, vg, Branch (B, vj, vk, vl, vm))) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
213 |
Branch |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
214 |
(B, Branch (B, va, vb, vc, vd), s, t, |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
215 |
Branch (v, Empty, vf, vg, Branch (B, vj, vk, vl, vm))) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
216 |
| balance (Branch (B, va, vb, vc, vd)) s t |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
217 |
(Branch (v, Branch (B, vi, vn, vo, vp), vf, vg, Branch (B, vj, vk, vl, vm))) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
218 |
= Branch |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
219 |
(B, Branch (B, va, vb, vc, vd), s, t, |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
220 |
Branch |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
221 |
(v, Branch (B, vi, vn, vo, vp), vf, vg, Branch (B, vj, vk, vl, vm))) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
222 |
| balance (Branch (v, Empty, vb, vc, Empty)) s t Empty = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
223 |
Branch (B, Branch (v, Empty, vb, vc, Empty), s, t, Empty) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
224 |
| balance (Branch (v, Empty, vb, vc, Branch (B, ve, vf, vg, vh))) s t Empty = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
225 |
Branch |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
226 |
(B, Branch (v, Empty, vb, vc, Branch (B, ve, vf, vg, vh)), s, t, Empty) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
227 |
| balance (Branch (v, Branch (B, vf, vg, vh, vi), vb, vc, Empty)) s t Empty = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
228 |
Branch |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
229 |
(B, Branch (v, Branch (B, vf, vg, vh, vi), vb, vc, Empty), s, t, Empty) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
230 |
| balance |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
231 |
(Branch (v, Branch (B, vf, vg, vh, vi), vb, vc, Branch (B, ve, vj, vk, vl))) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
232 |
s t Empty = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
233 |
Branch |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
234 |
(B, Branch |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
235 |
(v, Branch (B, vf, vg, vh, vi), vb, vc, Branch (B, ve, vj, vk, vl)), |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
236 |
s, t, Empty) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
237 |
| balance (Branch (v, Empty, vf, vg, Empty)) s t (Branch (B, va, vb, vc, vd)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
238 |
= Branch |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
239 |
(B, Branch (v, Empty, vf, vg, Empty), s, t, Branch (B, va, vb, vc, vd)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
240 |
| balance (Branch (v, Empty, vf, vg, Branch (B, vi, vj, vk, vl))) s t |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
241 |
(Branch (B, va, vb, vc, vd)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
242 |
Branch |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
243 |
(B, Branch (v, Empty, vf, vg, Branch (B, vi, vj, vk, vl)), s, t, |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
244 |
Branch (B, va, vb, vc, vd)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
245 |
| balance (Branch (v, Branch (B, vj, vk, vl, vm), vf, vg, Empty)) s t |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
246 |
(Branch (B, va, vb, vc, vd)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
247 |
Branch |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
248 |
(B, Branch (v, Branch (B, vj, vk, vl, vm), vf, vg, Empty), s, t, |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
249 |
Branch (B, va, vb, vc, vd)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
250 |
| balance |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
251 |
(Branch (v, Branch (B, vj, vk, vl, vm), vf, vg, Branch (B, vi, vn, vo, vp))) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
252 |
s t (Branch (B, va, vb, vc, vd)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
253 |
Branch |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
254 |
(B, Branch |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
255 |
(v, Branch (B, vj, vk, vl, vm), vf, vg, Branch (B, vi, vn, vo, vp)), |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
256 |
s, t, Branch (B, va, vb, vc, vd)); |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
257 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
258 |
fun rbt_ins A_ f k v Empty = Branch (R, Empty, k, v, Empty) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
259 |
| rbt_ins A_ f k v (Branch (B, l, x, y, r)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
260 |
(if less A_ k x then balance (rbt_ins A_ f k v l) x y r |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
261 |
else (if less A_ x k then balance l x y (rbt_ins A_ f k v r) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
262 |
else Branch (B, l, x, f k y v, r))) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
263 |
| rbt_ins A_ f k v (Branch (R, l, x, y, r)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
264 |
(if less A_ k x then Branch (R, rbt_ins A_ f k v l, x, y, r) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
265 |
else (if less A_ x k then Branch (R, l, x, y, rbt_ins A_ f k v r) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
266 |
else Branch (R, l, x, f k y v, r))); |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
267 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
268 |
fun paint c Empty = Empty |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
269 |
| paint c (Branch (uu, l, k, v, r)) = Branch (c, l, k, v, r); |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
270 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
271 |
fun rbt_insert_with_key A_ f k v t = paint B (rbt_ins A_ f k v t); |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
272 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
273 |
fun rbt_insert A_ = rbt_insert_with_key A_ (fn _ => fn _ => fn nv => nv); |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
274 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
275 |
fun insert A_ xc xd xe = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
276 |
RBT (rbt_insert ((ord_preorder o preorder_order o order_linorder) A_) xc xd |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
277 |
(impl_of A_ xe)); |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
278 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
279 |
fun rbt_lookup A_ Empty k = NONE |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
280 |
| rbt_lookup A_ (Branch (uu, l, x, y, r)) k = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
281 |
(if less A_ k x then rbt_lookup A_ l k |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
282 |
else (if less A_ x k then rbt_lookup A_ r k else SOME y)); |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
283 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
284 |
fun lookup A_ x = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
285 |
rbt_lookup ((ord_preorder o preorder_order o order_linorder) A_) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
286 |
(impl_of A_ x); |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
287 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
288 |
fun member A_ [] y = false |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
289 |
| member A_ (x :: xs) y = eq A_ x y orelse member A_ xs y; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
290 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
291 |
fun hd (x21 :: x22) = x21; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
292 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
293 |
fun tl [] = [] |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
294 |
| tl (x21 :: x22) = x22; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
295 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
296 |
fun remdups A_ [] = [] |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
297 |
| remdups A_ (x :: xs) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
298 |
(if member A_ xs x then remdups A_ xs else x :: remdups A_ xs); |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
299 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
300 |
fun dnf_and_fm (Or (phi_1, phi_2)) psi = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
301 |
Or (dnf_and_fm phi_1 psi, dnf_and_fm phi_2 psi) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
302 |
| dnf_and_fm (Atom v) (Or (phi_1, phi_2)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
303 |
Or (dnf_and_fm (Atom v) phi_1, dnf_and_fm (Atom v) phi_2) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
304 |
| dnf_and_fm (And (v, va)) (Or (phi_1, phi_2)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
305 |
Or (dnf_and_fm (And (v, va)) phi_1, dnf_and_fm (And (v, va)) phi_2) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
306 |
| dnf_and_fm (Neg v) (Or (phi_1, phi_2)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
307 |
Or (dnf_and_fm (Neg v) phi_1, dnf_and_fm (Neg v) phi_2) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
308 |
| dnf_and_fm (Atom v) (Atom va) = And (Atom v, Atom va) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
309 |
| dnf_and_fm (Atom v) (And (va, vb)) = And (Atom v, And (va, vb)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
310 |
| dnf_and_fm (Atom v) (Neg va) = And (Atom v, Neg va) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
311 |
| dnf_and_fm (And (v, va)) (Atom vb) = And (And (v, va), Atom vb) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
312 |
| dnf_and_fm (And (v, va)) (And (vb, vc)) = And (And (v, va), And (vb, vc)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
313 |
| dnf_and_fm (And (v, va)) (Neg vb) = And (And (v, va), Neg vb) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
314 |
| dnf_and_fm (Neg v) (Atom va) = And (Neg v, Atom va) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
315 |
| dnf_and_fm (Neg v) (And (va, vb)) = And (Neg v, And (va, vb)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
316 |
| dnf_and_fm (Neg v) (Neg va) = And (Neg v, Neg va); |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
317 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
318 |
fun dnf_fm (And (phi_1, phi_2)) = dnf_and_fm (dnf_fm phi_1) (dnf_fm phi_2) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
319 |
| dnf_fm (Or (phi_1, phi_2)) = Or (dnf_fm phi_1, dnf_fm phi_2) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
320 |
| dnf_fm (Atom v) = Atom v |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
321 |
| dnf_fm (Neg v) = Neg v; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
322 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
323 |
fun keysa A_ (Mapping t) = Set (keys A_ t); |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
324 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
325 |
fun amap_fm h (Atom a) = h a |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
326 |
| amap_fm h (And (phi_1, phi_2)) = And (amap_fm h phi_1, amap_fm h phi_2) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
327 |
| amap_fm h (Or (phi_1, phi_2)) = Or (amap_fm h phi_1, amap_fm h phi_2) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
328 |
| amap_fm h (Neg phi) = Neg (amap_fm h phi); |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
329 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
330 |
fun emptya A_ = Mapping (empty A_); |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
331 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
332 |
fun lookupa A_ (Mapping t) = lookup A_ t; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
333 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
334 |
fun update A_ k v (Mapping t) = Mapping (insert A_ k v t); |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
335 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
336 |
fun gen_length n (x :: xs) = gen_length (Suc n) xs |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
337 |
| gen_length n [] = n; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
338 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
339 |
fun size_list x = gen_length Zero_nat x; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
340 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
341 |
fun card A_ (Set xs) = size_list (remdups A_ xs); |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
342 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
343 |
fun conj_list (And (phi_1, phi_2)) = conj_list phi_1 @ conj_list phi_2 |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
344 |
| conj_list (Atom a) = [a]; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
345 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
346 |
fun trm_of_fm f (Atom a) = f a |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
347 |
| trm_of_fm f (And (phi_1, phi_2)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
348 |
App (App (Const "conj", trm_of_fm f phi_1), trm_of_fm f phi_2) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
349 |
| trm_of_fm f (Or (phi_1, phi_2)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
350 |
App (App (Const "disj", trm_of_fm f phi_1), trm_of_fm f phi_2) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
351 |
| trm_of_fm f (Neg phi) = App (Const "Not", trm_of_fm f phi); |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
352 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
353 |
fun dnf_and_fm_prf (Or (phi_1, phi_2)) psi = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
354 |
foldl (fn a => fn b => AppP (a, b)) (PThm "then_conv") |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
355 |
[PThm "conj_disj_distribR_conv", |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
356 |
foldl (fn a => fn b => AppP (a, b)) (PThm "combination_conv") |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
357 |
[AppP (PThm "arg_conv", |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
358 |
hd [dnf_and_fm_prf phi_1 psi, dnf_and_fm_prf phi_2 psi]), |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
359 |
hd (tl [dnf_and_fm_prf phi_1 psi, dnf_and_fm_prf phi_2 psi])]] |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
360 |
| dnf_and_fm_prf (Atom v) (Or (phi_1, phi_2)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
361 |
foldl (fn a => fn b => AppP (a, b)) (PThm "then_conv") |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
362 |
[PThm "conj_disj_distribL_conv", |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
363 |
foldl (fn a => fn b => AppP (a, b)) (PThm "combination_conv") |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
364 |
[AppP (PThm "arg_conv", |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
365 |
hd [dnf_and_fm_prf (Atom v) phi_1, |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
366 |
dnf_and_fm_prf (Atom v) phi_2]), |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
367 |
hd (tl [dnf_and_fm_prf (Atom v) phi_1, |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
368 |
dnf_and_fm_prf (Atom v) phi_2])]] |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
369 |
| dnf_and_fm_prf (And (v, va)) (Or (phi_1, phi_2)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
370 |
foldl (fn a => fn b => AppP (a, b)) (PThm "then_conv") |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
371 |
[PThm "conj_disj_distribL_conv", |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
372 |
foldl (fn a => fn b => AppP (a, b)) (PThm "combination_conv") |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
373 |
[AppP (PThm "arg_conv", |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
374 |
hd [dnf_and_fm_prf (And (v, va)) phi_1, |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
375 |
dnf_and_fm_prf (And (v, va)) phi_2]), |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
376 |
hd (tl [dnf_and_fm_prf (And (v, va)) phi_1, |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
377 |
dnf_and_fm_prf (And (v, va)) phi_2])]] |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
378 |
| dnf_and_fm_prf (Neg v) (Or (phi_1, phi_2)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
379 |
foldl (fn a => fn b => AppP (a, b)) (PThm "then_conv") |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
380 |
[PThm "conj_disj_distribL_conv", |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
381 |
foldl (fn a => fn b => AppP (a, b)) (PThm "combination_conv") |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
382 |
[AppP (PThm "arg_conv", |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
383 |
hd [dnf_and_fm_prf (Neg v) phi_1, |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
384 |
dnf_and_fm_prf (Neg v) phi_2]), |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
385 |
hd (tl [dnf_and_fm_prf (Neg v) phi_1, |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
386 |
dnf_and_fm_prf (Neg v) phi_2])]] |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
387 |
| dnf_and_fm_prf (Atom v) (Atom va) = PThm "all_conv" |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
388 |
| dnf_and_fm_prf (Atom v) (And (va, vb)) = PThm "all_conv" |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
389 |
| dnf_and_fm_prf (Atom v) (Neg va) = PThm "all_conv" |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
390 |
| dnf_and_fm_prf (And (v, va)) (Atom vb) = PThm "all_conv" |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
391 |
| dnf_and_fm_prf (And (v, va)) (And (vb, vc)) = PThm "all_conv" |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
392 |
| dnf_and_fm_prf (And (v, va)) (Neg vb) = PThm "all_conv" |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
393 |
| dnf_and_fm_prf (Neg v) (Atom va) = PThm "all_conv" |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
394 |
| dnf_and_fm_prf (Neg v) (And (va, vb)) = PThm "all_conv" |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
395 |
| dnf_and_fm_prf (Neg v) (Neg va) = PThm "all_conv"; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
396 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
397 |
fun dnf_fm_prf (And (phi_1, phi_2)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
398 |
foldl (fn a => fn b => AppP (a, b)) (PThm "then_conv") |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
399 |
[foldl (fn a => fn b => AppP (a, b)) (PThm "combination_conv") |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
400 |
[AppP (PThm "arg_conv", hd [dnf_fm_prf phi_1, dnf_fm_prf phi_2]), |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
401 |
hd (tl [dnf_fm_prf phi_1, dnf_fm_prf phi_2])], |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
402 |
dnf_and_fm_prf (dnf_fm phi_1) (dnf_fm phi_2)] |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
403 |
| dnf_fm_prf (Or (phi_1, phi_2)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
404 |
foldl (fn a => fn b => AppP (a, b)) (PThm "combination_conv") |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
405 |
[AppP (PThm "arg_conv", hd [dnf_fm_prf phi_1, dnf_fm_prf phi_2]), |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
406 |
hd (tl [dnf_fm_prf phi_1, dnf_fm_prf phi_2])] |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
407 |
| dnf_fm_prf (Atom v) = PThm "all_conv" |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
408 |
| dnf_fm_prf (Neg v) = PThm "all_conv"; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
409 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
410 |
fun of_alist A_ xs = foldr (fn (a, b) => update A_ a b) xs (emptya A_); |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
411 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
412 |
fun deneg (true, LESS (x, y)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
413 |
And (Atom (true, LEQ (x, y)), Atom (false, EQ (x, y))) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
414 |
| deneg (false, LESS (x, y)) = Atom (true, LEQ (y, x)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
415 |
| deneg (false, LEQ (x, y)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
416 |
And (Atom (true, LEQ (y, x)), Atom (false, EQ (y, x))) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
417 |
| deneg (false, EQ (v, vb)) = Atom (false, EQ (v, vb)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
418 |
| deneg (v, EQ (vb, vc)) = Atom (v, EQ (vb, vc)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
419 |
| deneg (true, LEQ (vb, vc)) = Atom (true, LEQ (vb, vc)); |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
420 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
421 |
fun from_conj_prf trm_of_atom p (And (a, b)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
422 |
foldl (fn aa => fn ba => AppP (aa, ba)) (PThm "conjE") |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
423 |
[Bound (trm_of_fm trm_of_atom (And (a, b))), |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
424 |
AbsP (trm_of_fm trm_of_atom a, |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
425 |
AbsP (trm_of_fm trm_of_atom b, |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
426 |
from_conj_prf trm_of_atom (from_conj_prf trm_of_atom p b) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
427 |
a))] |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
428 |
| from_conj_prf trm_of_atom p (Atom a) = p; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
429 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
430 |
fun contr_fm_prf trm_of_atom contr_atom_prf (Or (c, d)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
431 |
(case (contr_fm_prf trm_of_atom contr_atom_prf c, |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
432 |
contr_fm_prf trm_of_atom contr_atom_prf d) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
433 |
of (NONE, _) => NONE | (SOME _, NONE) => NONE |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
434 |
| (SOME p1, SOME p2) => |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
435 |
SOME (foldl (fn a => fn b => AppP (a, b)) (PThm "disjE") |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
436 |
[Bound (trm_of_fm trm_of_atom (Or (c, d))), |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
437 |
AbsP (trm_of_fm trm_of_atom c, p1), |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
438 |
AbsP (trm_of_fm trm_of_atom d, p2)])) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
439 |
| contr_fm_prf trm_of_atom contr_atom_prf (And (a, b)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
440 |
(case contr_atom_prf (conj_list (And (a, b))) of NONE => NONE |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
441 |
| SOME p => SOME (from_conj_prf trm_of_atom p (And (a, b)))) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
442 |
| contr_fm_prf trm_of_atom contr_atom_prf (Atom a) = contr_atom_prf [a]; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
443 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
444 |
fun deless (true, LESS (x, y)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
445 |
And (Atom (true, LEQ (x, y)), Atom (false, EQ (x, y))) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
446 |
| deless (false, LESS (x, y)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
447 |
Or (Atom (false, LEQ (x, y)), Atom (true, EQ (x, y))) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
448 |
| deless (false, EQ (v, vb)) = Atom (false, EQ (v, vb)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
449 |
| deless (false, LEQ (v, vb)) = Atom (false, LEQ (v, vb)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
450 |
| deless (v, EQ (vb, vc)) = Atom (v, EQ (vb, vc)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
451 |
| deless (v, LEQ (vb, vc)) = Atom (v, LEQ (vb, vc)); |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
452 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
453 |
fun deneg_prf (true, LESS (x, y)) = PThm "less_le" |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
454 |
| deneg_prf (false, LESS (x, y)) = PThm "nless_le" |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
455 |
| deneg_prf (false, LEQ (x, y)) = PThm "nle_le" |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
456 |
| deneg_prf (false, EQ (v, vb)) = PThm "all_conv" |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
457 |
| deneg_prf (v, EQ (vb, vc)) = PThm "all_conv" |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
458 |
| deneg_prf (true, LEQ (vb, vc)) = PThm "all_conv"; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
459 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
460 |
val one_nat : nat = Suc Zero_nat; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
461 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
462 |
fun map_option f NONE = NONE |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
463 |
| map_option f (SOME x2) = SOME (f x2); |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
464 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
465 |
fun deless_prf (true, LESS (x, y)) = PThm "less_le" |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
466 |
| deless_prf (false, LESS (x, y)) = PThm "nless_le" |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
467 |
| deless_prf (false, EQ (v, vb)) = PThm "all_conv" |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
468 |
| deless_prf (false, LEQ (v, vb)) = PThm "all_conv" |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
469 |
| deless_prf (v, EQ (vb, vc)) = PThm "all_conv" |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
470 |
| deless_prf (v, LEQ (vb, vc)) = PThm "all_conv"; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
471 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
472 |
fun trm_of_oatom (EQ (x, y)) = App (App (Const "eq", Var x), Var y) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
473 |
| trm_of_oatom (LEQ (x, y)) = App (App (Const "le", Var x), Var y) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
474 |
| trm_of_oatom (LESS (x, y)) = App (App (Const "lt", Var x), Var y); |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
475 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
476 |
fun minus_nat (Suc m) (Suc n) = minus_nat m n |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
477 |
| minus_nat Zero_nat n = Zero_nat |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
478 |
| minus_nat m Zero_nat = m; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
479 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
480 |
fun mapping_fold A_ f (Mapping t) a = fold A_ f t a; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
481 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
482 |
fun relcomp1_mapping A_ (B1_, B2_) x y1 pxy pm pma = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
483 |
mapping_fold (linorder_prod B2_ B2_) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
484 |
(fn (y2, z) => fn pyz => fn pmb => |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
485 |
(if eq B1_ y1 y2 andalso not (eq B1_ y2 z) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
486 |
then update (linorder_prod A_ B2_) (x, z) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
487 |
(foldl (fn a => fn b => AppP (a, b)) (PThm "trans") [pxy, pyz]) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
488 |
pmb |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
489 |
else pmb)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
490 |
pm pma; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
491 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
492 |
fun relcomp_mapping (A1_, A2_) pm1 pm2 pma = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
493 |
mapping_fold (linorder_prod A2_ A2_) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
494 |
(fn (x, y) => fn pxy => fn pm => |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
495 |
(if eq A1_ x y then pm |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
496 |
else relcomp1_mapping A2_ (A1_, A2_) x y pxy pm2 pm)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
497 |
pm1 pma; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
498 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
499 |
fun ntrancl_mapping (A1_, A2_) Zero_nat m = m |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
500 |
| ntrancl_mapping (A1_, A2_) (Suc k) m = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
501 |
let |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
502 |
val trclm = ntrancl_mapping (A1_, A2_) k m; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
503 |
in |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
504 |
relcomp_mapping (A1_, A2_) trclm m trclm |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
505 |
end; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
506 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
507 |
fun trancl_mapping (A1_, A2_) m = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
508 |
ntrancl_mapping (A1_, A2_) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
509 |
(minus_nat (card (equal_prod A1_ A1_) (keysa (linorder_prod A2_ A2_) m)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
510 |
one_nat) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
511 |
m; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
512 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
513 |
fun is_in_leq leqm l = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
514 |
let |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
515 |
val (x, y) = l; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
516 |
in |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
517 |
(if equal_inta x y then SOME (Appt (PThm "refl", Var x)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
518 |
else lookupa (linorder_prod linorder_int linorder_int) leqm l) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
519 |
end; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
520 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
521 |
fun is_in_eq leqm l = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
522 |
let |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
523 |
val (x, y) = l; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
524 |
in |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
525 |
(case (is_in_leq leqm (x, y), is_in_leq leqm (y, x)) of (NONE, _) => NONE |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
526 |
| (SOME _, NONE) => NONE |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
527 |
| (SOME p1, SOME p2) => |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
528 |
SOME (foldl (fn a => fn b => AppP (a, b)) (PThm "antisym") [p1, p2])) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
529 |
end; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
530 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
531 |
fun trm_of_oliteral (true, a) = trm_of_oatom a |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
532 |
| trm_of_oliteral (false, a) = App (Const "Not", trm_of_oatom a); |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
533 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
534 |
fun contr1_list leqm (false, LEQ (x, y)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
535 |
map_option |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
536 |
(fn a => |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
537 |
AppP (AppP (PThm "contr", Bound (trm_of_oliteral (false, LEQ (x, y)))), |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
538 |
a)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
539 |
(is_in_leq leqm (x, y)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
540 |
| contr1_list leqm (false, EQ (x, y)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
541 |
map_option |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
542 |
(fn a => |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
543 |
AppP (AppP (PThm "contr", Bound (trm_of_oliteral (false, EQ (x, y)))), |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
544 |
a)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
545 |
(is_in_eq leqm (x, y)) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
546 |
| contr1_list uu (true, va) = NONE |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
547 |
| contr1_list uu (v, LESS (vb, vc)) = NONE; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
548 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
549 |
fun contr_list_aux leqm [] = NONE |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
550 |
| contr_list_aux leqm (l :: ls) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
551 |
(case contr1_list leqm l of NONE => contr_list_aux leqm ls |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
552 |
| SOME a => SOME a); |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
553 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
554 |
fun leq1_member_list (true, LEQ (x, y)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
555 |
[((x, y), Bound (trm_of_oliteral (true, LEQ (x, y))))] |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
556 |
| leq1_member_list (true, EQ (x, y)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
557 |
[((x, y), AppP (PThm "eqD1", Bound (trm_of_oliteral (true, EQ (x, y))))), |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
558 |
((y, x), AppP (PThm "eqD2", Bound (trm_of_oliteral (true, EQ (x, y)))))] |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
559 |
| leq1_member_list (false, va) = [] |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
560 |
| leq1_member_list (v, LESS (vb, vc)) = []; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
561 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
562 |
fun leq1_list a = maps leq1_member_list a; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
563 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
564 |
fun leq1_mapping a = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
565 |
of_alist (linorder_prod linorder_int linorder_int) (leq1_list a); |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
566 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
567 |
fun contr_list a = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
568 |
contr_list_aux (trancl_mapping (equal_int, linorder_int) (leq1_mapping a)) a; |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
569 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
570 |
fun contr_prf atom_conv phi = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
571 |
contr_fm_prf trm_of_oliteral contr_list (dnf_fm (amap_fm atom_conv phi)); |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
572 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
573 |
fun amap_f_m_prf ap (Atom a) = AppP (PThm "atom_conv", ap a) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
574 |
| amap_f_m_prf ap (And (phi_1, phi_2)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
575 |
foldl (fn a => fn b => AppP (a, b)) (PThm "combination_conv") |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
576 |
[AppP (PThm "arg_conv", |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
577 |
hd [amap_f_m_prf ap phi_1, amap_f_m_prf ap phi_2]), |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
578 |
hd (tl [amap_f_m_prf ap phi_1, amap_f_m_prf ap phi_2])] |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
579 |
| amap_f_m_prf ap (Or (phi_1, phi_2)) = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
580 |
foldl (fn a => fn b => AppP (a, b)) (PThm "combination_conv") |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
581 |
[AppP (PThm "arg_conv", |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
582 |
hd [amap_f_m_prf ap phi_1, amap_f_m_prf ap phi_2]), |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
583 |
hd (tl [amap_f_m_prf ap phi_1, amap_f_m_prf ap phi_2])] |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
584 |
| amap_f_m_prf ap (Neg phi) = AppP (PThm "arg_conv", amap_f_m_prf ap phi); |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
585 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
586 |
fun lo_contr_prf phi = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
587 |
map_option |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
588 |
((fn a => |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
589 |
Conv (trm_of_fm trm_of_oliteral phi, amap_f_m_prf deneg_prf phi, a)) o |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
590 |
(fn a => |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
591 |
Conv (trm_of_fm trm_of_oliteral (amap_fm deneg phi), |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
592 |
dnf_fm_prf (amap_fm deneg phi), a))) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
593 |
(contr_prf deneg phi); |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
594 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
595 |
fun po_contr_prf phi = |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
596 |
map_option |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
597 |
((fn a => |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
598 |
Conv (trm_of_fm trm_of_oliteral phi, amap_f_m_prf deless_prf phi, a)) o |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
599 |
(fn a => |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
600 |
Conv (trm_of_fm trm_of_oliteral (amap_fm deless phi), |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
601 |
dnf_fm_prf (amap_fm deless phi), a))) |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
602 |
(contr_prf deless phi); |
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
603 |
|
a3cc9fa1295d
new automatic order prover: stateless, complete, verified
nipkow
parents:
diff
changeset
|
604 |
end; (*struct Order_Procedure*) |