author | wenzelm |
Sat, 08 Jul 2006 12:54:37 +0200 | |
changeset 20049 | f48c4a3a34bc |
parent 19640 | 40ec89317425 |
child 20194 | c9dbce9a23a1 |
permissions | -rw-r--r-- |
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
1 |
(* |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
2 |
ID: $Id$ |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
3 |
Author: Amine Chaieb, TU Muenchen |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
4 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
5 |
LCF proof synthesis for Ferrante and Rackoff. |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
6 |
*) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
7 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
8 |
structure Ferrante_Rackoff_Proof: |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
9 |
sig |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
10 |
val qelim: cterm -> thm |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
11 |
exception FAILURE of string |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
12 |
end = |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
13 |
struct |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
14 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
15 |
(* Some certified types *) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
16 |
val cbT = ctyp_of (the_context()) HOLogic.boolT; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
17 |
val rT = Type("RealDef.real",[]); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
18 |
val crT = ctyp_of (the_context()) (Type("RealDef.real",[])); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
19 |
(* Normalization*) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
20 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
21 |
|
20049 | 22 |
(* Computation of uset *) |
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
23 |
fun uset x fm = |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
24 |
case fm of |
20049 | 25 |
Const("op &",_)$p$q => (uset x p) union (uset x q) |
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
26 |
| Const("op |",_)$p$q => (uset x p) union (uset x q) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
27 |
| Const("Orderings.less",_)$s$t => if s=x then [t] |
20049 | 28 |
else if t = x then [s] |
29 |
else [] |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
30 |
| Const("Orderings.less_eq",_)$s$t => if s=x then [t] |
20049 | 31 |
else if t = x then [s] |
32 |
else [] |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
33 |
| Const("op =",_)$s$t => if s=x then [t] |
20049 | 34 |
else [] |
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
35 |
| Const("Not",_)$ (Const("op =",_)$s$t) => if s=x then [t] |
20049 | 36 |
else [] |
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
37 |
| _ => []; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
38 |
val rsT = Type("set",[rT]); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
39 |
fun holrealset [] = Const("{}",rsT) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
40 |
| holrealset (x::xs) = Const("insert",[rT,rsT] ---> rsT)$x$(holrealset xs); |
20049 | 41 |
fun prove_bysimp thy ss t = Goal.prove (ProofContext.init thy) [] [] |
42 |
(HOLogic.mk_Trueprop t) (fn _ => simp_tac ss 1); |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
43 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
44 |
fun inusetthms sg x fm = |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
45 |
let val U = uset x fm |
20049 | 46 |
val hU = holrealset U |
47 |
fun inC T = Const("op :",[T,Type("set",[T])] ---> HOLogic.boolT); |
|
48 |
val ss = simpset_of sg |
|
49 |
fun proveinU t = prove_bysimp sg ss ((inC rT)$t$hU) |
|
50 |
val uf = prove_bysimp sg ss ((inC rsT)$hU$Const("Finite_Set.Finites",Type("set",[rsT]))) |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
51 |
in (U,cterm_of sg hU,map proveinU U,uf) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
52 |
end; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
53 |
|
20049 | 54 |
(* Theorems for minus/plusinfinity *) |
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
55 |
val [minf_lt,minf_gt,minf_le,minf_ge,minf_eq,minf_neq,minf_fm,minf_conj,minf_disj] = thms"minf"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
56 |
val [pinf_lt,pinf_gt,pinf_le,pinf_ge,pinf_eq,pinf_neq,pinf_fm,pinf_conj,pinf_disj] = thms"pinf"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
57 |
(* Theorems for boundedness from below/above *) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
58 |
val [nmilbnd_lt,nmilbnd_gt,nmilbnd_le,nmilbnd_ge,nmilbnd_eq,nmilbnd_neq,nmilbnd_fm,nmilbnd_conj,nmilbnd_disj] = thms"nmilbnd"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
59 |
val [npiubnd_lt,npiubnd_gt,npiubnd_le,npiubnd_ge,npiubnd_eq,npiubnd_neq,npiubnd_fm,npiubnd_conj,npiubnd_disj] = thms"npiubnd"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
60 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
61 |
(* Theorems for no changes over smallest intervals in U *) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
62 |
val lin_dense_lt = thm "lin_dense_lt"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
63 |
val lin_dense_le = thm "lin_dense_le"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
64 |
val lin_dense_gt = thm "lin_dense_gt"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
65 |
val lin_dense_ge = thm "lin_dense_ge"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
66 |
val lin_dense_eq = thm "lin_dense_eq"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
67 |
val lin_dense_neq = thm "lin_dense_neq"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
68 |
val lin_dense_conj = thm "lin_dense_conj"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
69 |
val lin_dense_disj = thm "lin_dense_disj"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
70 |
val lin_dense_fm = thm "lin_dense_fm"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
71 |
val fr_eq = thm "fr_eq"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
72 |
val fr_simps = thms "fr_simps"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
73 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
74 |
fun dest5 [] = ([],[],[],[],[]) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
75 |
| dest5 ((x,y,z,w,v)::xs) = |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
76 |
let val (x',y',z',w',v') = dest5 xs |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
77 |
in (x::x',y::y',z::z',w::w',v::v') end ; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
78 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
79 |
fun dest2 [] = ([],[]) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
80 |
| dest2 ((x,y)::xs) = let val (x',y') = dest2 xs |
20049 | 81 |
in (x::x',y::y') end ; |
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
82 |
fun myfwd (th1,th2,th3,th4,th5) xs = |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
83 |
let val (ths1,ths2,ths3,ths4,ths5) = dest5 xs |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
84 |
in (ths1 MRS th1,ths2 MRS th2,ths3 MRS th3,ths4 MRS th4, ths5 MRS th5) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
85 |
end; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
86 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
87 |
fun myfwd2 (th1,th2) xs = |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
88 |
let val (ths1,ths2) = dest2 xs |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
89 |
in (ths1 MRS th1,ths2 MRS th2) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
90 |
end; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
91 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
92 |
fun decomp_mpinf sg x (U,CU,uths) fm = |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
93 |
let val cx = cterm_of sg x in |
20049 | 94 |
(case fm of |
95 |
Const("op &",_)$p$q => |
|
96 |
([p,q],myfwd (minf_conj,pinf_conj, nmilbnd_conj, npiubnd_conj,lin_dense_conj)) |
|
97 |
| Const("op |",_)$p$q => |
|
98 |
([p,q],myfwd (minf_disj,pinf_disj, nmilbnd_disj,npiubnd_disj,lin_dense_disj)) |
|
99 |
| Const("Orderings.less",_)$s$t => |
|
100 |
if s= x then |
|
101 |
let val ct = cterm_of sg t |
|
102 |
val tinU = nth uths (find_index (fn a => a=t) U) |
|
103 |
val mith = instantiate' [] [SOME ct] minf_lt |
|
104 |
val pith = instantiate' [] [SOME ct] pinf_lt |
|
105 |
val nmilth = tinU RS nmilbnd_lt |
|
106 |
val npiuth = tinU RS npiubnd_lt |
|
107 |
val lindth = tinU RS lin_dense_lt |
|
108 |
in ([],myfwd (mith,pith,nmilth,npiuth,lindth)) |
|
109 |
end |
|
110 |
else if t = x then |
|
111 |
let val ct = cterm_of sg s |
|
112 |
val tinU = nth uths (find_index (fn a => a=s) U) |
|
113 |
val mith = instantiate' [] [SOME ct] minf_gt |
|
114 |
val pith = instantiate' [] [SOME ct] pinf_gt |
|
115 |
val nmilth = tinU RS nmilbnd_gt |
|
116 |
val npiuth = tinU RS npiubnd_gt |
|
117 |
val lindth = tinU RS lin_dense_gt |
|
118 |
in ([],myfwd (mith,pith,nmilth,npiuth,lindth)) |
|
119 |
end |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
120 |
|
20049 | 121 |
else |
122 |
let val cfm = cterm_of sg fm |
|
123 |
val mith = instantiate' [] [SOME cfm] minf_fm |
|
124 |
val pith = instantiate' [] [SOME cfm] pinf_fm |
|
125 |
val nmilth = instantiate' [] [SOME cfm, SOME CU] nmilbnd_fm |
|
126 |
val npiuth = instantiate' [] [SOME cfm, SOME CU] npiubnd_fm |
|
127 |
val lindth = instantiate' [] [SOME CU, SOME cfm] lin_dense_fm |
|
128 |
in ([], myfwd (mith,pith,nmilth,npiuth,lindth)) |
|
129 |
end |
|
130 |
| Const("Orderings.less_eq",_)$s$t => |
|
131 |
if s= x then |
|
132 |
let val ct = cterm_of sg t |
|
133 |
val tinU = nth uths (find_index (fn a => a=t) U) |
|
134 |
val mith = instantiate' [] [SOME ct] minf_le |
|
135 |
val pith = instantiate' [] [SOME ct] pinf_le |
|
136 |
val nmilth = tinU RS nmilbnd_le |
|
137 |
val npiuth = tinU RS npiubnd_le |
|
138 |
val lindth = tinU RS lin_dense_le |
|
139 |
in ([],myfwd (mith,pith,nmilth,npiuth,lindth)) |
|
140 |
end |
|
141 |
else if t = x then |
|
142 |
let val ct = cterm_of sg s |
|
143 |
val tinU = nth uths (find_index (fn a => a=s) U) |
|
144 |
val mith = instantiate' [] [SOME ct] minf_ge |
|
145 |
val pith = instantiate' [] [SOME ct] pinf_ge |
|
146 |
val nmilth = tinU RS nmilbnd_ge |
|
147 |
val npiuth = tinU RS npiubnd_ge |
|
148 |
val lindth = tinU RS lin_dense_ge |
|
149 |
in ([],myfwd (mith,pith,nmilth,npiuth,lindth)) |
|
150 |
end |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
151 |
|
20049 | 152 |
else |
153 |
let val cfm = cterm_of sg fm |
|
154 |
val mith = instantiate' [] [SOME cfm] minf_fm |
|
155 |
val pith = instantiate' [] [SOME cfm] pinf_fm |
|
156 |
val nmilth = instantiate' [] [SOME cfm, SOME CU] nmilbnd_fm |
|
157 |
val npiuth = instantiate' [] [SOME cfm, SOME CU] npiubnd_fm |
|
158 |
val lindth = instantiate' [] [SOME CU, SOME cfm] lin_dense_fm |
|
159 |
in ([], myfwd (mith,pith,nmilth,npiuth,lindth)) |
|
160 |
end |
|
161 |
| Const("op =",_)$s$t => |
|
162 |
if s= x then |
|
163 |
let val ct = cterm_of sg t |
|
164 |
val tinU = nth uths (find_index (fn a => a=t) U) |
|
165 |
val mith = instantiate' [] [SOME ct] minf_eq |
|
166 |
val pith = instantiate' [] [SOME ct] pinf_eq |
|
167 |
val nmilth = tinU RS nmilbnd_eq |
|
168 |
val npiuth = tinU RS npiubnd_eq |
|
169 |
val lindth = tinU RS lin_dense_eq |
|
170 |
in ([],myfwd (mith,pith,nmilth,npiuth,lindth)) |
|
171 |
end |
|
172 |
else |
|
173 |
let val cfm = cterm_of sg fm |
|
174 |
val mith = instantiate' [] [SOME cfm] minf_fm |
|
175 |
val pith = instantiate' [] [SOME cfm] pinf_fm |
|
176 |
val nmilth = instantiate' [] [SOME cfm, SOME CU] nmilbnd_fm |
|
177 |
val npiuth = instantiate' [] [SOME cfm, SOME CU] npiubnd_fm |
|
178 |
val lindth = instantiate' [] [SOME CU, SOME cfm] lin_dense_fm |
|
179 |
in ([], myfwd (mith,pith,nmilth,npiuth,lindth)) |
|
180 |
end |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
181 |
|
20049 | 182 |
| Const("Not",_)$(Const("op =",_)$s$t) => |
183 |
if s= x then |
|
184 |
let val ct = cterm_of sg t |
|
185 |
val tinU = nth uths (find_index (fn a => a=t) U) |
|
186 |
val mith = instantiate' [] [SOME ct] minf_neq |
|
187 |
val pith = instantiate' [] [SOME ct] pinf_neq |
|
188 |
val nmilth = tinU RS nmilbnd_neq |
|
189 |
val npiuth = tinU RS npiubnd_neq |
|
190 |
val lindth = tinU RS lin_dense_neq |
|
191 |
in ([],myfwd (mith,pith,nmilth,npiuth,lindth)) |
|
192 |
end |
|
193 |
else |
|
194 |
let val cfm = cterm_of sg fm |
|
195 |
val mith = instantiate' [] [SOME cfm] minf_fm |
|
196 |
val pith = instantiate' [] [SOME cfm] pinf_fm |
|
197 |
val nmilth = instantiate' [] [SOME cfm, SOME CU] nmilbnd_fm |
|
198 |
val npiuth = instantiate' [] [SOME cfm, SOME CU] npiubnd_fm |
|
199 |
val lindth = instantiate' [] [SOME CU, SOME cfm] lin_dense_fm |
|
200 |
in ([], myfwd (mith,pith,nmilth,npiuth,lindth)) |
|
201 |
end |
|
202 |
| _ => let val cfm = cterm_of sg fm |
|
203 |
val mith = instantiate' [] [SOME cfm] minf_fm |
|
204 |
val pith = instantiate' [] [SOME cfm] pinf_fm |
|
205 |
val nmilth = instantiate' [] [SOME cfm, SOME CU] nmilbnd_fm |
|
206 |
val npiuth = instantiate' [] [SOME cfm, SOME CU] npiubnd_fm |
|
207 |
val lindth = instantiate' [] [SOME CU, SOME cfm] lin_dense_fm |
|
208 |
in ([], myfwd (mith,pith,nmilth,npiuth,lindth)) |
|
209 |
end) |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
210 |
end; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
211 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
212 |
fun ferrack_eq thy p = |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
213 |
case p of |
20049 | 214 |
Const("Ex",_)$Abs(x1,T,p1) => |
215 |
let val (xn,fm) = variant_abs(x1,T,p1) |
|
216 |
val x = Free(xn,T) |
|
217 |
val (u,cu,uths,uf) = inusetthms thy x fm |
|
218 |
val (mi,pi,nmi,npi,lind) = divide_and_conquer (decomp_mpinf thy x (u,cu,uths)) fm |
|
219 |
val frth = [uf,lind,nmi,npi,mi,pi] MRS fr_eq |
|
220 |
val (cTp,ceq) = Thm.dest_comb (cprop_of frth) |
|
221 |
val qth = (Simplifier.rewrite (HOL_basic_ss addsimps fr_simps addsimps [refl]) |
|
222 |
(snd (Thm.dest_comb ceq))) RS meta_eq_to_obj_eq |
|
223 |
in [frth,qth] MRS trans |
|
224 |
end |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
225 |
| _ => instantiate' [SOME cbT] [SOME (cterm_of thy p)] refl; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
226 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
227 |
(* Code for normalization of terms and Formulae *) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
228 |
(* For NNF reuse the CooperProof methods*) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
229 |
(*FIXME:: This is copied from cooper_proof.ML *) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
230 |
val FWD = fn th => fn ths => ths MRS th; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
231 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
232 |
val qe_Not = thm "qe_Not"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
233 |
val qe_conjI = thm "qe_conjI"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
234 |
val qe_disjI = thm "qe_disjI"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
235 |
val qe_impI = thm "qe_impI"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
236 |
val qe_eqI = thm "qe_eqI"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
237 |
val qe_exI = thm "qe_exI"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
238 |
val qe_ALLI = thm "qe_ALLI"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
239 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
240 |
val nnf_nn = thm "nnf_nn"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
241 |
val nnf_im = thm "nnf_im"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
242 |
val nnf_eq = thm "nnf_eq"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
243 |
val nnf_sdj = thm "nnf_sdj"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
244 |
val nnf_ncj = thm "nnf_ncj"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
245 |
val nnf_nim = thm "nnf_nim"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
246 |
val nnf_neq = thm "nnf_neq"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
247 |
val nnf_ndj = thm "nnf_ndj"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
248 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
249 |
fun decomp_cnnf lfnp P = |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
250 |
case P of |
20049 | 251 |
Const ("op &",_) $ p $q => ([p,q] , FWD qe_conjI ) |
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
252 |
| Const ("op |",_) $ p $q => ([p,q] , FWD qe_disjI) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
253 |
| Const ("Not",_) $ (Const("Not",_) $ p) => ([p], FWD nnf_nn) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
254 |
| Const("Not",_) $ (Const(opn,T) $ p $ q) => |
20049 | 255 |
if opn = "op |" |
256 |
then |
|
257 |
(case (p,q) of |
|
258 |
(A as (Const ("op &",_) $ r $ s),B as (Const ("op &",_) $ r1 $ t)) => |
|
259 |
if r1 = CooperDec.negate r |
|
260 |
then ([r,HOLogic.Not$s,r1,HOLogic.Not$t], |
|
261 |
fn [th1_1,th1_2,th2_1,th2_2] => |
|
262 |
[[th1_1,th1_1] MRS qe_conjI,[th2_1,th2_2] MRS qe_conjI] MRS nnf_sdj) |
|
263 |
||
264 |
else ([HOLogic.Not $ p,HOLogic.Not $ q ], FWD nnf_ndj) |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
265 |
| (_,_) => ([HOLogic.Not $ p,HOLogic.Not $ q ], FWD nnf_ndj)) |
20049 | 266 |
else ( |
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
267 |
case (opn,T) of |
20049 | 268 |
("op &",_) => ([HOLogic.Not $ p,HOLogic.Not $ q ], FWD nnf_ncj ) |
269 |
| ("op -->",_) => ([p,HOLogic.Not $ q ], FWD nnf_nim ) |
|
270 |
| ("op =",Type ("fun",[Type ("bool", []),_])) => |
|
271 |
([HOLogic.conj $ p $ (HOLogic.Not $ q),HOLogic.conj $ (HOLogic.Not $ p) $ q], |
|
272 |
FWD nnf_neq) |
|
273 |
| (_,_) => ([], fn [] => lfnp P)) |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
274 |
| (Const ("op -->",_) $ p $ q) => ([HOLogic.Not$p,q], FWD nnf_im) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
275 |
| (Const ("op =", Type ("fun",[Type ("bool", []),_])) $ p $ q) => |
20049 | 276 |
([HOLogic.conj $ p $ q,HOLogic.conj $ (HOLogic.Not $ p) $ (HOLogic.Not $ q) ], FWD nnf_eq ) |
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
277 |
| _ => ([], fn [] => lfnp P); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
278 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
279 |
fun nnfp afnp vs p = |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
280 |
let val th = divide_and_conquer (decomp_cnnf (afnp vs)) p |
20049 | 281 |
val Pth = (Simplifier.rewrite |
282 |
(HOL_basic_ss addsimps fr_simps addsimps [refl]) |
|
283 |
(snd(Thm.dest_comb(snd(Thm.dest_comb (cprop_of th)))))) |
|
284 |
RS meta_eq_to_obj_eq |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
285 |
in [th,Pth] MRS trans |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
286 |
end; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
287 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
288 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
289 |
(* Normalization of arithmetical expressions *) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
290 |
val rzero = Const("0",rT); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
291 |
val rone = Const("1",rT); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
292 |
fun mk_real i = |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
293 |
case i of |
20049 | 294 |
0 => rzero |
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
295 |
| 1 => rone |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
296 |
| _ => (HOLogic.number_of_const rT)$(HOLogic.mk_binum i); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
297 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
298 |
fun dest_real (Const("0",_)) = 0 |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
299 |
| dest_real (Const("1",_)) = 1 |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
300 |
| dest_real (Const("Numeral.number_of",_)$b) = HOLogic.dest_binum b; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
301 |
|
20049 | 302 |
(* Normal form for terms is: |
303 |
(c0*x0 + ... + cn*xn + k) / c , where ci!=0 and x0<..<xn ordered according to vs*) |
|
304 |
(* functions to prove trivial properties about numbers *) |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
305 |
fun proveq thy n m = prove_bysimp thy (simpset_of thy) (HOLogic.mk_eq(mk_real n,mk_real m)); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
306 |
fun provenz thy n = |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
307 |
prove_bysimp thy (simpset_of thy) (HOLogic.Not$(HOLogic.mk_eq(mk_real n,rzero))); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
308 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
309 |
fun proveprod thy m n = |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
310 |
prove_bysimp thy (simpset_of thy) |
20049 | 311 |
(HOLogic.mk_eq(HOLogic.mk_binop "HOL.times" (mk_real m,mk_real n),mk_real (m*n))); |
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
312 |
fun proveadd thy m n = |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
313 |
prove_bysimp thy (simpset_of thy) |
20049 | 314 |
(HOLogic.mk_eq(HOLogic.mk_binop "HOL.plus" (mk_real m,mk_real n),mk_real (m+n))); |
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
315 |
fun provediv thy m n = |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
316 |
let val g = gcd (m,n) |
20049 | 317 |
val m' = m div g |
318 |
val n'= n div g |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
319 |
in |
20049 | 320 |
(prove_bysimp thy (simpset_of thy) |
321 |
(HOLogic.mk_eq(HOLogic.mk_binop "HOL.divide" (mk_real m,mk_real n), |
|
322 |
HOLogic.mk_binop "HOL.divide" |
|
323 |
(mk_real m',mk_real n'))),m') |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
324 |
end; |
20049 | 325 |
(* Multiplication of a normal term by a constant *) |
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
326 |
val ncmul_congh = thm "ncmul_congh"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
327 |
val ncmul_cong = thm "ncmul_cong"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
328 |
fun decomp_ncmulh thy c t = |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
329 |
if c = 0 then ([],fn _ => instantiate' [SOME crT] [SOME (cterm_of thy t)] mult_zero_left) else |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
330 |
case t of |
20049 | 331 |
Const("HOL.plus",_)$(Const("HOL.times",_)$c'$v)$b => |
332 |
([b],FWD (instantiate' [] [NONE, NONE, SOME (cterm_of thy v)] |
|
333 |
((proveprod thy c (dest_real c')) RS ncmul_congh))) |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
334 |
| _ => ([],fn _ => proveprod thy c (dest_real t)); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
335 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
336 |
fun prove_ncmulh thy c = divide_and_conquer (decomp_ncmulh thy c); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
337 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
338 |
(* prove_ncmul thy n t n = a theorem : "c*(t/n) = (t'/n')*) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
339 |
fun prove_ncmul thy c (t,m) = |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
340 |
let val (eq1,c') = provediv thy c m |
20049 | 341 |
val tt' = prove_ncmulh thy c' t |
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
342 |
in [eq1,tt'] MRS ncmul_cong |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
343 |
end; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
344 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
345 |
(* prove_nneg returns "-(t/n) = t'/n'" ; normally t'=t and n' = -n*) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
346 |
val nneg_cong = thm "nneg_cong"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
347 |
fun prove_nneg thy (t,m) = (prove_ncmul thy ~1 (t, m)) RS nneg_cong; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
348 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
349 |
(* Addition of 2 expressions in normal form*) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
350 |
val naddh_cong_same = thm "naddh_cong_same"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
351 |
val naddh_cong_same0 = thm "naddh_cong_same0"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
352 |
val naddh_cong_ts = thm "naddh_cong_ts"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
353 |
val naddh_cong_st = thm "naddh_cong_st"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
354 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
355 |
fun earlier [] x y = false |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
356 |
| earlier (h::t) x y = |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
357 |
if h = y then false |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
358 |
else if h = x then true |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
359 |
else earlier t x y ; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
360 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
361 |
fun decomp_naddh thy vs (t,s) = |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
362 |
case (t,s) of |
20049 | 363 |
(Const("HOL.plus",_)$(ctv as Const("HOL.times",_)$tc$tv)$tr, |
364 |
Const("HOL.plus",_)$(csv as Const("HOL.times",_)$sc$sv)$sr) => |
|
365 |
if tv = sv then |
|
366 |
let val ntc = dest_real tc |
|
367 |
val nsc = dest_real sc |
|
368 |
val addth = proveadd thy ntc nsc |
|
369 |
in if ntc + nsc = 0 |
|
370 |
then ([(tr,sr)], FWD (instantiate' [] [NONE,NONE,NONE,SOME (cterm_of thy tv)] |
|
371 |
(addth RS naddh_cong_same0))) |
|
372 |
else ([(tr,sr)], FWD (instantiate' [] [NONE,NONE,NONE,SOME (cterm_of thy tv)] |
|
373 |
(addth RS naddh_cong_same))) |
|
374 |
end |
|
375 |
else if earlier vs tv sv |
|
376 |
then ([(tr,s)],FWD (instantiate' [] [NONE,NONE,NONE,SOME(cterm_of thy ctv)] naddh_cong_ts)) |
|
377 |
else ([(t,sr)],FWD (instantiate' [] [NONE,NONE,NONE,SOME(cterm_of thy csv)] naddh_cong_st)) |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
378 |
| (Const("HOL.plus",_)$(ctv as Const("HOL.times",_)$tc$tv)$tr,_) => |
20049 | 379 |
([(tr,s)],FWD (instantiate' [] [NONE,NONE,NONE,SOME(cterm_of thy ctv)] naddh_cong_ts)) |
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
380 |
| (_,Const("HOL.plus",_)$(csv as Const("HOL.times",_)$sc$sv)$sr) => |
20049 | 381 |
([(t,sr)],FWD (instantiate' [] [NONE,NONE,NONE,SOME(cterm_of thy csv)] naddh_cong_st)) |
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
382 |
| (_,_) => ([], fn _ => proveadd thy (dest_real t) (dest_real s)); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
383 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
384 |
(* prove_naddh returns "t + s = t'*) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
385 |
fun prove_naddh thy vs = divide_and_conquer (decomp_naddh thy vs); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
386 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
387 |
val nadd_cong_same = thm "nadd_cong_same"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
388 |
val nadd_cong = thm "nadd_cong"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
389 |
val plus_cong = thm "plus_cong"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
390 |
(* prove_nadd resturns: "t/m + s/n = t'/m'"*) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
391 |
fun prove_nadd thy vs (t,m) (s,n) = |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
392 |
if n=m then |
20049 | 393 |
let val nm = proveq thy n m |
394 |
val ts = prove_naddh thy vs (t,s) |
|
395 |
in [nm,ts] MRS nadd_cong_same |
|
396 |
end |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
397 |
else let val l = lcm (m,n) |
20049 | 398 |
val m' = l div m |
399 |
val n' = l div n |
|
400 |
val mml = proveprod thy m' m |
|
401 |
val nnl = proveprod thy n' n |
|
402 |
val mnz = provenz thy m |
|
403 |
val nnz = provenz thy n |
|
404 |
val lnz = provenz thy l |
|
405 |
val mt = prove_ncmulh thy m' t |
|
406 |
val ns = prove_ncmulh thy n' s |
|
407 |
val _$(_$_$t') = prop_of mt |
|
408 |
val _$(_$_$s') = prop_of ns |
|
409 |
in [mml,nnl,mnz,nnz,lnz,[mt,ns,prove_naddh thy vs (t',s')] MRS plus_cong] |
|
410 |
MRS nadd_cong |
|
411 |
end; |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
412 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
413 |
(* prove_nsub returns: "t/m - s/n = t'/m'"*) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
414 |
val nsub_cong = thm "nsub_cong"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
415 |
fun prove_nsub thy vs (t,m) (s,n) = |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
416 |
let val nsm = prove_nneg thy (s,n) |
20049 | 417 |
val _$(_$_$(_$s'$n')) = prop_of nsm |
418 |
val ts = prove_nadd thy vs (t,m) (s',dest_real n') |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
419 |
in [nsm,ts] MRS nsub_cong |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
420 |
end; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
421 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
422 |
val ndivide_cong = thm "ndivide_cong"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
423 |
fun prove_ndivide thy (t,m) n = instantiate' [] [SOME(cterm_of thy t)] |
20049 | 424 |
((proveprod thy m n) RS ndivide_cong); |
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
425 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
426 |
exception FAILURE of string; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
427 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
428 |
val divide_cong = thm"divide_cong"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
429 |
val diff_cong = thm"diff_cong"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
430 |
val uminus_cong = thm"uminus_cong"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
431 |
val mult_cong = thm"mult_cong"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
432 |
val mult_cong2 = thm"mult_cong2"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
433 |
val normalizeh_var = thm "normalizeh_var"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
434 |
val nrefl = thm "nrefl"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
435 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
436 |
fun decomp_normalizeh thy vs t = |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
437 |
case t of |
20049 | 438 |
Free _ => ([], fn _ => instantiate' [] [SOME(cterm_of thy t)] normalizeh_var) |
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
439 |
| Const("HOL.uminus",_)$a => |
20049 | 440 |
([a], |
441 |
fn [tha] => let val _$(_$_$(_$a'$n')) = prop_of tha |
|
442 |
in [tha,prove_nneg thy (a',dest_real n')] |
|
443 |
MRS uminus_cong |
|
444 |
end ) |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
445 |
| Const("HOL.plus",_)$a$b => |
20049 | 446 |
([a,b], |
447 |
fn [tha,thb] => let val _$(_$_$(_$a'$n')) = prop_of tha |
|
448 |
val _$(_$_$(_$b'$m')) = prop_of thb |
|
449 |
in [tha,thb,prove_nadd thy vs (a',dest_real n') (b',dest_real m')] |
|
450 |
MRS plus_cong |
|
451 |
end ) |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
452 |
| Const("HOL.minus",_)$a$b => |
20049 | 453 |
([a,b], |
454 |
fn [tha,thb] => let val _$(_$_$(_$a'$n')) = prop_of tha |
|
455 |
val _$(_$_$(_$b'$m')) = prop_of thb |
|
456 |
in [tha,thb,prove_nsub thy vs (a',dest_real n') (b',dest_real m')] |
|
457 |
MRS diff_cong |
|
458 |
end ) |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
459 |
| Const("HOL.times",_)$a$b => |
20049 | 460 |
if can dest_real a |
461 |
then ([b], fn [thb] => |
|
462 |
let val _$(_$_$(_$b'$m')) = prop_of thb |
|
463 |
in [thb, prove_ncmul thy (dest_real a) (b',dest_real m')] MRS mult_cong |
|
464 |
end ) |
|
465 |
else if can dest_real b |
|
466 |
then ([a], fn [tha] => |
|
467 |
let val _$(_$_$(_$a'$m')) = prop_of tha |
|
468 |
in [tha, prove_ncmul thy (dest_real b) (a',dest_real m')] MRS mult_cong2 |
|
469 |
end ) |
|
470 |
else raise FAILURE "decomp_normalizeh: non linear term" |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
471 |
| Const("HOL.divide",_)$a$b => |
20049 | 472 |
if can dest_real b |
473 |
then ([a], fn [tha] => |
|
474 |
let val _$(_$_$(_$a'$m')) = prop_of tha |
|
475 |
in [tha, prove_ndivide thy (a',dest_real m') (dest_real b)] MRS divide_cong |
|
476 |
end ) |
|
477 |
else raise FAILURE "decomp_normalizeh: non linear term" |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
478 |
| _ => ([], fn _ => instantiate' [] [SOME (cterm_of thy t)] nrefl); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
479 |
fun prove_normalizeh thy vs = divide_and_conquer (decomp_normalizeh thy vs); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
480 |
fun dest_xth vs th = |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
481 |
let val _$(_$_$(_$t$n)) = prop_of th |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
482 |
in (case t of |
20049 | 483 |
Const("HOL.plus",_)$(Const("HOL.times",_)$c$y)$r => |
484 |
if vs = [] then (0,t,dest_real n) |
|
485 |
else if hd vs = y then (dest_real c, r,dest_real n) |
|
486 |
else (0,t,dest_real n) |
|
487 |
| _ => (0,t,dest_real n)) |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
488 |
end; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
489 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
490 |
fun prove_strictsign thy n = |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
491 |
prove_bysimp thy (simpset_of thy) |
20049 | 492 |
(HOLogic.mk_binrel "Orderings.less" |
493 |
(if n > 0 then (rzero, mk_real n) else (mk_real n, rzero))); |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
494 |
fun prove_fracsign thy (m,n) = |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
495 |
let val mn = HOLogic.mk_binop "HOL.divide" (mk_real m, mk_real n) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
496 |
in prove_bysimp thy (simpset_of thy) |
20049 | 497 |
(HOLogic.mk_binrel "Orderings.less" |
498 |
(if m*n > 0 then (rzero, mn) else (mn, rzero))) |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
499 |
end; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
500 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
501 |
fun holbool_of true = HOLogic.true_const |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
502 |
| holbool_of false = HOLogic.false_const; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
503 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
504 |
fun prove_fracsign_eq thy s (m,n) = |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
505 |
let fun f s = the (AList.lookup (op =) [("Orderings.less", op <),("Orderings.less_eq", op <=),("op =", op =)] s) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
506 |
in |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
507 |
prove_bysimp thy (simpset_of thy) (HOLogic.mk_eq |
20049 | 508 |
(HOLogic.mk_binrel s |
509 |
(HOLogic.mk_binop "HOL.divide" (mk_real m, mk_real n),rzero), |
|
510 |
holbool_of (f s (m*n,0)))) |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
511 |
end; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
512 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
513 |
fun proveq_eq thy n m = |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
514 |
prove_bysimp thy (simpset_of thy) |
20049 | 515 |
(HOLogic.mk_eq |
516 |
(HOLogic.mk_eq(mk_real n, mk_real m),holbool_of (n = m))); |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
517 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
518 |
val sum_of_same_denoms = thm "sum_of_same_denoms"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
519 |
val sum_of_opposite_denoms = thm "sum_of_opposite_denoms"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
520 |
val trivial_sum_of_opposites = thm "trivial_sum_of_opposites"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
521 |
val normalize_ltground_cong = thm "normalize_ltground_cong"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
522 |
val normalize_ltnoxpos_cong = thm "normalize_ltnoxpos_cong"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
523 |
val normalize_ltnoxneg_cong = thm "normalize_ltnoxneg_cong"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
524 |
val normalize_ltxpos_cong = thm "normalize_ltxpos_cong"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
525 |
val normalize_ltxneg_cong = thm "normalize_ltxneg_cong"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
526 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
527 |
val normalize_leground_cong = thm "normalize_leground_cong"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
528 |
val normalize_lenoxpos_cong = thm "normalize_lenoxpos_cong"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
529 |
val normalize_lenoxneg_cong = thm "normalize_lenoxneg_cong"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
530 |
val normalize_lexpos_cong = thm "normalize_lexpos_cong"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
531 |
val normalize_lexneg_cong = thm "normalize_lexneg_cong"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
532 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
533 |
val normalize_eqground_cong = thm "normalize_eqground_cong"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
534 |
val normalize_eqnox_cong = thm "normalize_eqnox_cong"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
535 |
val normalize_eqxpos_cong = thm "normalize_eqxpos_cong"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
536 |
val normalize_eqxneg_cong = thm "normalize_eqxneg_cong"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
537 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
538 |
val normalize_not_lt = thm "normalize_not_lt"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
539 |
val normalize_not_le = thm "normalize_not_le"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
540 |
val normalize_not_eq = thm "normalize_not_eq"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
541 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
542 |
fun prove_normalize thy vs at = |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
543 |
case at of |
20049 | 544 |
Const("Orderings.less",_)$s$t => |
545 |
let val smtth = prove_normalizeh thy vs (HOLogic.mk_binop "HOL.minus" (s,t)) |
|
546 |
val (cx,r,n) = dest_xth vs smtth |
|
547 |
in if cx = 0 then if can dest_real r |
|
548 |
then [smtth, prove_fracsign_eq thy "Orderings.less" (dest_real r, n)] |
|
549 |
MRS normalize_ltground_cong |
|
550 |
else [smtth, prove_strictsign thy n] |
|
551 |
MRS (if n > 0 then normalize_ltnoxpos_cong |
|
552 |
else normalize_ltnoxneg_cong) |
|
553 |
else let val srn = prove_fracsign thy (n,cx) |
|
554 |
val rr' = if cx < 0 |
|
555 |
then instantiate' [] [SOME (cterm_of thy r)] |
|
556 |
((proveadd thy cx (~cx)) RS sum_of_opposite_denoms) |
|
557 |
else instantiate' [] [SOME (cterm_of thy (mk_real cx))] |
|
558 |
(((prove_ncmulh thy ~1 r) RS nneg_cong) |
|
559 |
RS sum_of_same_denoms) |
|
560 |
in [smtth,srn,rr'] MRS (if n*cx < 0 then normalize_ltxneg_cong |
|
561 |
else normalize_ltxpos_cong) |
|
562 |
end |
|
563 |
end |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
564 |
| Const("Orderings.less_eq",_)$s$t => |
20049 | 565 |
let val smtth = prove_normalizeh thy vs (HOLogic.mk_binop "HOL.minus" (s,t)) |
566 |
val (cx,r,n) = dest_xth vs smtth |
|
567 |
in if cx = 0 then if can dest_real r |
|
568 |
then [smtth, prove_fracsign_eq thy "Orderings.less_eq" (dest_real r, n)] |
|
569 |
MRS normalize_leground_cong |
|
570 |
else [smtth, prove_strictsign thy n] |
|
571 |
MRS (if n > 0 then normalize_lenoxpos_cong |
|
572 |
else normalize_lenoxneg_cong) |
|
573 |
else let val srn = prove_fracsign thy (n,cx) |
|
574 |
val rr' = if cx < 0 |
|
575 |
then instantiate' [] [SOME (cterm_of thy r)] |
|
576 |
((proveadd thy cx (~cx)) RS sum_of_opposite_denoms) |
|
577 |
else instantiate' [] [SOME (cterm_of thy (mk_real cx))] |
|
578 |
(((prove_ncmulh thy ~1 r) RS nneg_cong) |
|
579 |
RS sum_of_same_denoms) |
|
580 |
in [smtth,srn,rr'] MRS (if n*cx < 0 then normalize_lexneg_cong |
|
581 |
else normalize_lexpos_cong) |
|
582 |
end |
|
583 |
end |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
584 |
| Const("op =",_)$s$t => |
20049 | 585 |
let val smtth = prove_normalizeh thy vs (HOLogic.mk_binop "HOL.minus" (s,t)) |
586 |
val (cx,r,n) = dest_xth vs smtth |
|
587 |
in if cx = 0 then if can dest_real r |
|
588 |
then [smtth, provenz thy n, |
|
589 |
proveq_eq thy (dest_real r) 0] |
|
590 |
MRS normalize_eqground_cong |
|
591 |
else [smtth, provenz thy n] |
|
592 |
MRS normalize_eqnox_cong |
|
593 |
else let val scx = prove_strictsign thy cx |
|
594 |
val nnz = provenz thy n |
|
595 |
val rr' = if cx < 0 |
|
596 |
then proveadd thy cx (~cx) |
|
597 |
else ((prove_ncmulh thy ~1 r) RS nneg_cong) |
|
598 |
RS trivial_sum_of_opposites |
|
599 |
in [smtth,scx,nnz,rr'] MRS (if cx < 0 then normalize_eqxneg_cong |
|
600 |
else normalize_eqxpos_cong) |
|
601 |
end |
|
602 |
end |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
603 |
| Const("Not",_)$(Const("Orderings.less",T)$s$t) => |
20049 | 604 |
(prove_normalize thy vs (Const("Orderings.less_eq",T)$t$s)) RS normalize_not_lt |
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
605 |
| Const("Not",_)$(Const("Orderings.less_eq",T)$s$t) => |
20049 | 606 |
(prove_normalize thy vs (Const("Orderings.less",T)$t$s)) RS normalize_not_le |
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
607 |
| (nt as Const("Not",_))$(Const("op =",T)$s$t) => |
20049 | 608 |
(prove_normalize thy vs (Const("op =",T)$s$t)) RS qe_Not |
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
609 |
| _ => instantiate' [SOME cbT] [SOME (cterm_of thy at)] refl; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
610 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
611 |
(* Generic quantifier elimination *) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
612 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
613 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
614 |
val qe_ex_conj = thm "qe_ex_conj"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
615 |
val qe_ex_nconj = thm "qe_ex_nconj"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
616 |
val qe_ALL = thm "qe_ALL"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
617 |
val ex_eq_cong = thm "ex_eq_cong"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
618 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
619 |
fun decomp_genqelim thy afnp nfnp qfnp (P,vs) = |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
620 |
case P of |
20049 | 621 |
(Const("op &",_)$A$B) => ([(A,vs),(B,vs)], fn [th1,th2] => [th1,th2] MRS qe_conjI) |
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
622 |
| (Const("op |",_)$A$B) => ([(A,vs),(B,vs)], fn [th1,th2] => [th1,th2] MRS qe_disjI) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
623 |
| (Const("op -->",_)$A$B) => ([(A,vs),(B,vs)], fn [th1,th2] => [th1,th2] MRS qe_impI) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
624 |
| (Const("op =", Type ("fun",[Type ("bool", []),_]))$A$B) => |
20049 | 625 |
([(A,vs),(B,vs)], fn [th1,th2] => [th1,th2] MRS qe_eqI) |
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
626 |
| (Const("Not",_)$p) => ([(p,vs)],fn [th] => th RS qe_Not) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
627 |
| (Const("Ex",_)$Abs(xn,xT,p)) => |
20049 | 628 |
let val (xn1,p1) = variant_abs(xn,xT,p) |
629 |
val x= Free(xn1,xT) |
|
630 |
in ([(p1,x::vs)], |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
631 |
fn [th1_1] => |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
632 |
let val th2 = [th1_1,nfnp (x::vs) (snd (CooperProof.qe_get_terms th1_1))] MRS trans |
20049 | 633 |
val eth1 = (forall_intr (cterm_of thy (Free(xn1,xT))) th2) COMP ex_eq_cong |
634 |
val th3 = qfnp (snd(CooperProof.qe_get_terms eth1)) |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
635 |
in [eth1,th3] MRS trans |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
636 |
end ) |
20049 | 637 |
end |
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
638 |
| (Const("All",_)$Abs(xn,xT,p)) => |
20049 | 639 |
([((HOLogic.exists_const xT)$Abs(xn,xT,HOLogic.Not $ p),vs)], fn [th] => th RS qe_ALL) |
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
640 |
| _ => ([], fn [] => afnp vs P); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
641 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
642 |
val fr_prepqelim = thms "fr_prepqelim"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
643 |
val prepare_qelim_ss = HOL_basic_ss |
20049 | 644 |
addsimps simp_thms |
645 |
addsimps (List.take(ex_simps,4)) |
|
646 |
addsimps fr_prepqelim |
|
647 |
addsimps [not_all,ex_disj_distrib]; |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
648 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
649 |
fun prove_genqelim thy afnp nfnp qfnp P = |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
650 |
let val thP = (Simplifier.rewrite prepare_qelim_ss P) RS meta_eq_to_obj_eq |
20049 | 651 |
val _$(_$_$P') = prop_of thP |
652 |
val vs = term_frees P' |
|
653 |
val qeth = divide_and_conquer (decomp_genqelim thy afnp nfnp qfnp) (Pattern.eta_long [] P',vs) |
|
654 |
val _$(_$_$p'') = prop_of qeth |
|
655 |
val thp' = nfnp vs p'' |
|
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
656 |
in [[thP, qeth] MRS trans, thp'] MRS trans |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
657 |
end; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
658 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
659 |
fun qelim P = |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
660 |
let val {thy, ...} = Thm.rep_cterm P |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
661 |
in prove_genqelim thy (prove_normalize thy) (nnfp (prove_normalize thy)) (ferrack_eq thy) P end; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
662 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
663 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
664 |
(* Just for testing!! *) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
665 |
(* |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
666 |
val thy = the_context(); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
667 |
fun parseb s = term_of (read_cterm thy (s,HOLogic.boolT)); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
668 |
fun parser s = term_of (read_cterm thy (s,rT)); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
669 |
val fm = parseb "(x::real) < y + t & (y - 5 < x | 34 < y + t) & (x = s + 3*y) | (x ~= y - s)"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
670 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
671 |
provediv thy 4 2; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
672 |
provediv thy ~4 2; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
673 |
provediv thy 4 ~2; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
674 |
provediv thy 44 32; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
675 |
provediv thy ~34 20000; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
676 |
provediv thy ~4000000 ~27676; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
677 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
678 |
val vs = [Free("x",rT),Free("y",rT),Free("z",rT)] ; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
679 |
prove_nsub thy vs |
20049 | 680 |
(parser "4*(x::real) + (3*y + 5)" ,54) (parser "3*(y::real) + (4*z + 5)",9); |
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
681 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
682 |
prove_ndivide thy (parser "4*(x::real) + (3*y + 5)" ,5) 4; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
683 |
prove_normalizeh thy [Free("x",rT),Free("y",rT),Free("z",rT)] |
20049 | 684 |
(parser "4*(x::real) + 3* ((3*y + 5) + x)"); |
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
685 |
prove_normalizeh thy [Free("x",rT),Free("y",rT),Free("z",rT)] |
20049 | 686 |
(parser "4*(x::real) - 3* ((3*y + 5)*9 + x)"); |
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
687 |
prove_normalizeh thy [Free("x",rT),Free("y",rT),Free("z",rT)] |
20049 | 688 |
(parser "- x"); |
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
689 |
prove_normalizeh thy [Free("x",rT),Free("y",rT),Free("z",rT)] |
20049 | 690 |
(parser "4*(x::real) +3* ((3*y + 5) / 3 - (- x))"); |
19640
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
691 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
692 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
693 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
694 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
695 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
696 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
697 |
fun test xn s = ferrack_eq thy (parseb ("EX (" ^ xn ^ "::real)." ^ s)); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
698 |
test "x" "(x::real) < y + t & (y - 5 < x | 34 < y + t) & (x = s + 3*y) | (x ~= y - s) & (x::real) <= y + t & (y - 5 <= x)"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
699 |
test "x" "(x::real) < y + t & y - 5 < x & (x ~= y - s)"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
700 |
test "x" "(x::real) < y + t"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
701 |
test "x" "(x::real) > y + t"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
702 |
test "x" "(x::real) = y + t"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
703 |
test "x" "(x::real) ~= y + t"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
704 |
test "x" "34 < y + (t::real)"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
705 |
test "x" "(x::real) ~= y + t & 34 < y + (t::real)"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
706 |
test "x" "(x::real) ~= y + t & (x::real) < y + t"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
707 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
708 |
prove_normalize thy vs (parseb "(x::real) + 4* (y - 15*z) / 3 <= x + y"); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
709 |
prove_normalize thy vs (parseb "(x::real) + 4* (y - 15*z) / 3 <= 3*x + y"); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
710 |
prove_normalize thy vs (parseb "(x::real) + 4* (y - 15*z) / 3 <= (-1)*x + y"); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
711 |
prove_normalize thy vs (parseb "(x::real) + 4* (y - 15*z) / 3 <= x + 3 + 4* (y - 15*z) / 3 "); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
712 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
713 |
prove_normalize thy vs (parseb "(x::real) + 4* (y - 15*z) / 3 < x + y"); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
714 |
prove_normalize thy vs (parseb "(x::real) + 4* (y - 15*z) / 3 < 3*x + y"); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
715 |
prove_normalize thy vs (parseb "(x::real) + 4* (y - 15*z) / 3 < (-1)*x + y"); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
716 |
prove_normalize thy vs (parseb "(x::real) + 4* (y - 15*z) / 3 < x + 3 + 4* (y - 15*z) / 3 "); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
717 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
718 |
prove_normalize thy vs (parseb "(x::real) + 4* (y - 15*z) / 3 = x + y"); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
719 |
prove_normalize thy vs (parseb "(x::real) + 4* (y - 15*z) / 3 = 3*x + y"); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
720 |
prove_normalize thy vs (parseb "(x::real) + 4* (y - 15*z) / 3 = (-1)*x + y"); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
721 |
prove_normalize thy vs (parseb "(x::real) + 4* (y - 15*z) / 3 = x + 3 + 4* (y - 15*z) / 3 "); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
722 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
723 |
prove_normalize thy vs (parseb "~ ((x::real) + 4* (y - 15*z) / 3 <= x + y)"); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
724 |
prove_normalize thy vs (parseb "~ ((x::real) + 4* (y - 15*z) / 3 <= 3*x + y)"); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
725 |
prove_normalize thy vs (parseb "~ ((x::real) + 4* (y - 15*z) / 3 <= (-1)*x + y)"); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
726 |
prove_normalize thy vs (parseb "~ ((x::real) + 4* (y - 15*z) / 3 <= x + 3 + 4* (y - 15*z) / 3 )"); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
727 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
728 |
prove_normalize thy vs (parseb "~((x::real) + 4* (y - 15*z) / 3 < x + y)"); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
729 |
prove_normalize thy vs (parseb "~((x::real) + 4* (y - 15*z) / 3 < 3*x + y)"); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
730 |
prove_normalize thy vs (parseb "~((x::real) + 4* (y - 15*z) / 3 < (-1)*x + y)"); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
731 |
prove_normalize thy vs (parseb "~((x::real) + 4* (y - 15*z) / 3 < x + 3 + 4* (y - 15*z) / 3 )"); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
732 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
733 |
prove_normalize thy vs (parseb "(x::real) + 4* (y - 15*z) / 3 ~= x + y"); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
734 |
prove_normalize thy vs (parseb "(x::real) + 4* (y - 15*z) / 3 ~= 3*x + y"); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
735 |
prove_normalize thy vs (parseb "(x::real) + 4* (y - 15*z) / 3 ~= (-1)*x + y"); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
736 |
prove_normalize thy vs (parseb "(x::real) + 4* (y - 15*z) / 3 ~= x + 3 + 4* (y - 15*z) / 3 "); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
737 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
738 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
739 |
nnfp (prove_normalize thy) vs |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
740 |
(parseb "~((x::real) + 4* (y - 15*z) / 3 ~= x + 3 + 4* (y - 15*z) / 3 | (~ (~((x::real) + 4* (y - 15*z) / 3 < x + 3 + 4* (y - 15*z) / 3 ) & (x::real) + 4* (y - 15*z) / 3 <= x + y)))"); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
741 |
nnfp (prove_normalize thy) vs |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
742 |
(parseb "~ ~((x::real) + 4* (y - 15*z) / 3 ~= x + 3 + 4* (y - 15*z) / 3 | (~ (~((x::real) + 4* (y - 15*z) / 3 < x + 3 + 4* (y - 15*z) / 3 ) & (x::real) + 4* (y - 15*z) / 3 <= x + y)))"); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
743 |
|
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
744 |
fun frtest s = frqelim thy (read_cterm thy (s,HOLogic.boolT)); |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
745 |
frtest "~ (ALL (x::real) y. x < y --> 10*x < 11*y)"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
746 |
frtest "ALL (x::real) y. x < y --> (10*(x + 5*y + -1) < 60*y)"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
747 |
frtest "EX (x::real) y. x ~= y --> x < y"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
748 |
frtest "EX (x::real) y. (x ~= y & 10*x ~= 9*y & 10*x < y) --> x < y"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
749 |
frtest "ALL (x::real) y. (x ~= y & 5*x <= y) --> 500*x <= 100*y"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
750 |
*) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
751 |
(* 1 Alternations *) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
752 |
(* |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
753 |
frtest "ALL (x::real). (EX (y::real). 4*x + 3*y <= 0 & 4*x + 3*y >= -1)"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
754 |
frtest "ALL (x::real) < 0. (EX (y::real) > 0. 7*x + y > 0 & x - y <= 9)"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
755 |
frtest "EX (x::real). (0 < x & x < 1) --> (ALL y > 1. x + y ~= 1)"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
756 |
frtest "EX (x::real). 0 < x & x < 1 & (ALL y. (1 < y & y < 2) --> (1 < 2*(y - x) & 2*(y - x) <3))"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
757 |
frtest "ALL (x::real). x < 10 | x > 20 | (EX y. y>= 0 & y <= 10 & x+y = 20)"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
758 |
*) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
759 |
(* Formulae with 3 quantifiers *) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
760 |
(* 0 Alternations *) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
761 |
(* |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
762 |
frtest "ALL (x::real) y z. x + y < z --> y >= z --> x < 0"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
763 |
frtest "EX (x::real) y z. x + 7*y < 5* z & 5*y >= 7*z & x < 0"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
764 |
frtest "ALL (x::real) y z. abs (x + y) <= z --> (abs z = z)"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
765 |
frtest "EX (x::real) y z. x + 7*y - 5* z < 0 & 5*y + 7*z + 3*x < 0"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
766 |
frtest "ALL (x::real) y z. (abs (5*x+3*y+z) <= 5*x+3*y+z & abs (5*x+3*y+z) >= - (5*x+3*y+z)) | (abs (5*x+3*y+z) >= 5*x+3*y+z & abs (5*x+3*y+z) <= - (5*x+3*y+z))"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
767 |
*) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
768 |
(* 1 Alternations *) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
769 |
(* |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
770 |
frtest "ALL (x::real) y. x < y --> (EX z>0. x+z = y)"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
771 |
frtest "ALL (x::real) y. (EX z>0. abs (x - y) <= z )"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
772 |
frtest "EX (x::real) y. (ALL z>0. (z < x --> z <= 5) & (z > y --> z >= x))"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
773 |
frtest "EX (x::real) y. (ALL z<0. (z < x --> z <= y) & (z > y --> z >= x))"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
774 |
frtest "EX (x::real) y. (ALL z>0. abs (3*x - 7*y) >= 5 & abs (3*x+7*y) <= 2*z + 1)"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
775 |
*) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
776 |
(* 2 Alternations *) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
777 |
(* |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
778 |
frtest "EX (x::real)>0. (ALL y >0. (EX z>7. 5*x - 3*y <= 7*z))"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
779 |
frtest "EX (x::real). abs x < 4 & (ALL y > 0. (EX z. 5*x - 3*y <= 7*z))"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
780 |
frtest "ALL (x::real). (EX y > x. (ALL z < y. x+z < 2*y))" ; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
781 |
frtest "ALL (x::real). (EX y<(3*x - 1). (ALL z >= (3*x - 1). x - y + z > x ))" ; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
782 |
frtest "EX (x::real). abs x < 100 & (ALL y > x. (EX z<2*y - x. 5*x - 3*y <= 7*z))"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
783 |
*) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
784 |
(* Formulae with 4 quantifiers *) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
785 |
(* 0 Alternations *) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
786 |
(* |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
787 |
frtest "ALL (x::real) y z w. 7*x<3*y --> 5*y < 7*z --> z < 2*w --> 7*(2*w-x) > 2*y"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
788 |
frtest "ALL (x::real) y. ALL z >x. ALL w > y. abs (z-x) + abs (y-w + x) <= z - x + w-y+abs x"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
789 |
frtest "EX (x::real) y z w. 5*x + 3*z - 17*w + abs (y - 8*x + z) <= 89"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
790 |
frtest "EX (x::real) y z w. abs (5*x + 3*z - 17*w) + 7* abs (y - 8*x + z) <= max y (7*z - x + w)"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
791 |
frtest "EX (x::real) y z w. min (5*x + 3*z) (17*w) + 5* abs (y - 8*x + z) <= max y (7*z - x + w)"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
792 |
*) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
793 |
(* 1 Alternations *) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
794 |
(* |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
795 |
frtest "ALL (x::real) y z. (EX w >= abs (x+y+z). w <= abs x + abs y + abs z)"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
796 |
frtest "ALL (x::real). (EX y z w. x< y & x < z & x> w & 3*x < w + y)"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
797 |
frtest "ALL (x::real) y. (EX z w. abs (x-y) = abs (z-w) & z < x & w ~= y)"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
798 |
frtest "ALL (x::real). (EX y z w. min (5*x + 3*z) (17*w) + 5* abs (y - 8*x + z) <= max y (7*z - x + w))"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
799 |
frtest "EX (x::real) y z. (ALL w >= abs (x+y+z). w >= abs x + abs y + abs z)"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
800 |
*) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
801 |
(* 2 Alternations *) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
802 |
(* |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
803 |
frtest "EX z. (ALL (x::real) y. (EX w >= abs (x+y+z). w <= abs x + abs y + abs z))"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
804 |
frtest "EX z. (ALL (x::real) < z. (EX y w. x< y & x < z & x> w & 3*x < w + y))"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
805 |
frtest "ALL (x::real) y. (EX z. (ALL w. abs (x-y) = abs (z-w) --> z < x & w ~= y))"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
806 |
frtest "EX y. (ALL (x::real). (EX z w. min (5*x + 3*z) (17*w) + 5* abs (y - 8*x + z) <= max y (7*z - x + w)))"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
807 |
frtest "EX (x::real) z. (ALL w >= abs (x+z). (EX y. w >= abs x + abs y + abs z))"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
808 |
*) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
809 |
(* 3 Alternations *) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
810 |
(* |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
811 |
frtest "EX (x::real). (ALL y < x. (EX z > (x+y). (ALL w. 5*w + 10*x - z >= y --> w + 7*x + 3*z >= 2*y)))"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
812 |
frtest "EX (x::real). (ALL y < 3*x. (EX z > max x y. |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
813 |
(ALL w . abs w < 13 --> w + 10*x - z >= y --> 5*w + 7*x + 13*z >= 2*y)))"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
814 |
frtest "ALL (x::real). (EX y. (ALL z>19. y <= x + z & (EX w. abs (y - x) < w)))"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
815 |
frtest "ALL (x::real). (EX y. (ALL z>19. abs (y) <= abs (x + z) & (EX w. abs (x + z) < w - y)))"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
816 |
frtest "ALL (x::real). (EX y. abs y ~= abs x & (ALL z> max x y. (EX w. w ~= y & w ~= z & 3*w - z >= x + y)))"; |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
817 |
*) |
40ec89317425
added Ferrante and Rackoff Algorithm -- by Amine Chaieb;
wenzelm
parents:
diff
changeset
|
818 |
end |