author | Christian Urban <urbanc@in.tum.de> |
Fri, 07 Jan 2011 02:30:00 +0000 | |
changeset 2650 | e5fa8de0e4bd |
parent 2649 | a8ebcb368a15 |
child 2651 | 4aa72a88b2c1 |
permissions | -rw-r--r-- |
2649
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1 |
theory LamTest |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
2 |
imports "../Nominal2" |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
3 |
begin |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
4 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
5 |
atom_decl name |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
6 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
7 |
nominal_datatype lam = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
8 |
Var "name" |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
9 |
| App "lam" "lam" |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
10 |
| Lam x::"name" l::"lam" bind x in l |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
11 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
12 |
definition |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
13 |
"eqvt x \<equiv> \<forall>p. p \<bullet> x = x" |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
14 |
|
2650
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
15 |
lemma eqvtI: |
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
16 |
"(\<And>p. p \<bullet> x \<equiv> x) \<Longrightarrow> eqvt x" |
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
17 |
apply(auto simp add: eqvt_def) |
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
18 |
done |
2649
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
19 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
20 |
ML {* |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
21 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
22 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
23 |
val trace = Unsynchronized.ref false |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
24 |
fun trace_msg msg = if ! trace then tracing (msg ()) else () |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
25 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
26 |
val boolT = HOLogic.boolT |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
27 |
val mk_eq = HOLogic.mk_eq |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
28 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
29 |
open Function_Lib |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
30 |
open Function_Common |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
31 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
32 |
datatype globals = Globals of |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
33 |
{fvar: term, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
34 |
domT: typ, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
35 |
ranT: typ, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
36 |
h: term, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
37 |
y: term, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
38 |
x: term, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
39 |
z: term, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
40 |
a: term, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
41 |
P: term, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
42 |
D: term, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
43 |
Pbool:term} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
44 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
45 |
datatype rec_call_info = RCInfo of |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
46 |
{RIvs: (string * typ) list, (* Call context: fixes and assumes *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
47 |
CCas: thm list, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
48 |
rcarg: term, (* The recursive argument *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
49 |
llRI: thm, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
50 |
h_assum: term} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
51 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
52 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
53 |
datatype clause_context = ClauseContext of |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
54 |
{ctxt : Proof.context, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
55 |
qs : term list, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
56 |
gs : term list, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
57 |
lhs: term, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
58 |
rhs: term, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
59 |
cqs: cterm list, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
60 |
ags: thm list, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
61 |
case_hyp : thm} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
62 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
63 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
64 |
fun transfer_clause_ctx thy (ClauseContext { ctxt, qs, gs, lhs, rhs, cqs, ags, case_hyp }) = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
65 |
ClauseContext { ctxt = ProofContext.transfer thy ctxt, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
66 |
qs = qs, gs = gs, lhs = lhs, rhs = rhs, cqs = cqs, ags = ags, case_hyp = case_hyp } |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
67 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
68 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
69 |
datatype clause_info = ClauseInfo of |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
70 |
{no: int, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
71 |
qglr : ((string * typ) list * term list * term * term), |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
72 |
cdata : clause_context, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
73 |
tree: Function_Ctx_Tree.ctx_tree, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
74 |
lGI: thm, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
75 |
RCs: rec_call_info list} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
76 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
77 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
78 |
(* Theory dependencies. *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
79 |
val acc_induct_rule = @{thm accp_induct_rule} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
80 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
81 |
val ex1_implies_ex = @{thm FunDef.fundef_ex1_existence} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
82 |
val ex1_implies_un = @{thm FunDef.fundef_ex1_uniqueness} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
83 |
val ex1_implies_iff = @{thm FunDef.fundef_ex1_iff} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
84 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
85 |
val acc_downward = @{thm accp_downward} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
86 |
val accI = @{thm accp.accI} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
87 |
val case_split = @{thm HOL.case_split} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
88 |
val fundef_default_value = @{thm FunDef.fundef_default_value} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
89 |
val not_acc_down = @{thm not_accp_down} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
90 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
91 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
92 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
93 |
fun find_calls tree = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
94 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
95 |
fun add_Ri (fixes,assumes) (_ $ arg) _ (_, xs) = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
96 |
([], (fixes, assumes, arg) :: xs) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
97 |
| add_Ri _ _ _ _ = raise Match |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
98 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
99 |
rev (Function_Ctx_Tree.traverse_tree add_Ri tree []) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
100 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
101 |
*} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
102 |
|
2650
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
103 |
ML {* |
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
104 |
fun mk_eqvt trm = |
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
105 |
let |
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
106 |
val ty = fastype_of trm |
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
107 |
in |
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
108 |
Const (@{const_name eqvt}, ty --> @{typ bool}) $ trm |
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
109 |
|> HOLogic.mk_Trueprop |
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
110 |
end |
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
111 |
*} |
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
112 |
|
2649
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
113 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
114 |
ML {* |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
115 |
(** building proof obligations *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
116 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
117 |
fun mk_compat_proof_obligations domT ranT fvar f glrs = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
118 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
119 |
val _ = tracing ("domT: " ^ @{make_string} domT) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
120 |
val _ = tracing ("ranT: " ^ @{make_string} ranT) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
121 |
val _ = tracing ("fvar: " ^ @{make_string} fvar) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
122 |
val _ = tracing ("f: " ^ @{make_string} f) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
123 |
fun mk_impl ((qs, gs, lhs, rhs),(qs', gs', lhs', rhs')) = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
124 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
125 |
val shift = incr_boundvars (length qs') |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
126 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
127 |
Logic.mk_implies |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
128 |
(HOLogic.mk_Trueprop (HOLogic.eq_const domT $ shift lhs $ lhs'), |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
129 |
HOLogic.mk_Trueprop (HOLogic.eq_const ranT $ shift rhs $ rhs')) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
130 |
|> fold_rev (curry Logic.mk_implies) (map shift gs @ gs') |
2650
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
131 |
(* HERE |> (curry Logic.mk_implies) (mk_eqvt fvar) *) |
2649
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
132 |
|> (curry Logic.mk_implies) @{term "Trueprop True"} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
133 |
|> fold_rev (fn (n,T) => fn b => Term.all T $ Abs(n,T,b)) (qs @ qs') |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
134 |
|> curry abstract_over fvar |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
135 |
|> curry subst_bound f |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
136 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
137 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
138 |
map mk_impl (unordered_pairs glrs) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
139 |
|> tap (fn ts => tracing ("compat_trms:\n" ^ cat_lines (map (Syntax.string_of_term @{context}) ts))) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
140 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
141 |
*} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
142 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
143 |
ML {* |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
144 |
fun mk_completeness (Globals {x, Pbool, ...}) clauses qglrs = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
145 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
146 |
fun mk_case (ClauseContext {qs, gs, lhs, ...}, (oqs, _, _, _)) = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
147 |
HOLogic.mk_Trueprop Pbool |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
148 |
|> curry Logic.mk_implies (HOLogic.mk_Trueprop (mk_eq (x, lhs))) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
149 |
|> fold_rev (curry Logic.mk_implies) gs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
150 |
|> fold_rev mk_forall_rename (map fst oqs ~~ qs) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
151 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
152 |
HOLogic.mk_Trueprop Pbool |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
153 |
|> fold_rev (curry Logic.mk_implies o mk_case) (clauses ~~ qglrs) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
154 |
|> mk_forall_rename ("x", x) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
155 |
|> mk_forall_rename ("P", Pbool) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
156 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
157 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
158 |
(** making a context with it's own local bindings **) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
159 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
160 |
fun mk_clause_context x ctxt (pre_qs,pre_gs,pre_lhs,pre_rhs) = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
161 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
162 |
val (qs, ctxt') = Variable.variant_fixes (map fst pre_qs) ctxt |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
163 |
|>> map2 (fn (_, T) => fn n => Free (n, T)) pre_qs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
164 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
165 |
val thy = ProofContext.theory_of ctxt' |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
166 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
167 |
fun inst t = subst_bounds (rev qs, t) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
168 |
val gs = map inst pre_gs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
169 |
val lhs = inst pre_lhs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
170 |
val rhs = inst pre_rhs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
171 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
172 |
val cqs = map (cterm_of thy) qs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
173 |
val ags = map (Thm.assume o cterm_of thy) gs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
174 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
175 |
val case_hyp = Thm.assume (cterm_of thy (HOLogic.mk_Trueprop (mk_eq (x, lhs)))) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
176 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
177 |
ClauseContext { ctxt = ctxt', qs = qs, gs = gs, lhs = lhs, rhs = rhs, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
178 |
cqs = cqs, ags = ags, case_hyp = case_hyp } |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
179 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
180 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
181 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
182 |
(* lowlevel term function. FIXME: remove *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
183 |
fun abstract_over_list vs body = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
184 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
185 |
fun abs lev v tm = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
186 |
if v aconv tm then Bound lev |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
187 |
else |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
188 |
(case tm of |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
189 |
Abs (a, T, t) => Abs (a, T, abs (lev + 1) v t) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
190 |
| t $ u => abs lev v t $ abs lev v u |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
191 |
| t => t) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
192 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
193 |
fold_index (fn (i, v) => fn t => abs i v t) vs body |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
194 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
195 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
196 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
197 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
198 |
fun mk_clause_info globals G f no cdata qglr tree RCs GIntro_thm RIntro_thms = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
199 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
200 |
val Globals {h, ...} = globals |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
201 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
202 |
val ClauseContext { ctxt, qs, cqs, ags, ... } = cdata |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
203 |
val cert = Thm.cterm_of (ProofContext.theory_of ctxt) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
204 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
205 |
(* Instantiate the GIntro thm with "f" and import into the clause context. *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
206 |
val lGI = GIntro_thm |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
207 |
|> Thm.forall_elim (cert f) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
208 |
|> fold Thm.forall_elim cqs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
209 |
|> fold Thm.elim_implies ags |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
210 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
211 |
fun mk_call_info (rcfix, rcassm, rcarg) RI = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
212 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
213 |
val llRI = RI |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
214 |
|> fold Thm.forall_elim cqs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
215 |
|> fold (Thm.forall_elim o cert o Free) rcfix |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
216 |
|> fold Thm.elim_implies ags |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
217 |
|> fold Thm.elim_implies rcassm |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
218 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
219 |
val h_assum = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
220 |
HOLogic.mk_Trueprop (G $ rcarg $ (h $ rcarg)) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
221 |
|> fold_rev (curry Logic.mk_implies o prop_of) rcassm |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
222 |
|> fold_rev (Logic.all o Free) rcfix |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
223 |
|> Pattern.rewrite_term (ProofContext.theory_of ctxt) [(f, h)] [] |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
224 |
|> abstract_over_list (rev qs) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
225 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
226 |
RCInfo {RIvs=rcfix, rcarg=rcarg, CCas=rcassm, llRI=llRI, h_assum=h_assum} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
227 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
228 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
229 |
val RC_infos = map2 mk_call_info RCs RIntro_thms |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
230 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
231 |
ClauseInfo {no=no, cdata=cdata, qglr=qglr, lGI=lGI, RCs=RC_infos, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
232 |
tree=tree} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
233 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
234 |
*} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
235 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
236 |
ML {* |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
237 |
fun store_compat_thms 0 thms = [] |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
238 |
| store_compat_thms n thms = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
239 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
240 |
val (thms1, thms2) = chop n thms |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
241 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
242 |
(thms1 :: store_compat_thms (n - 1) thms2) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
243 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
244 |
*} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
245 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
246 |
ML {* |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
247 |
(* expects i <= j *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
248 |
fun lookup_compat_thm i j cts = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
249 |
nth (nth cts (i - 1)) (j - i) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
250 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
251 |
(* Returns "Gsi, Gsj, lhs_i = lhs_j |-- rhs_j_f = rhs_i_f" *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
252 |
(* if j < i, then turn around *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
253 |
fun get_compat_thm thy cts i j ctxi ctxj = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
254 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
255 |
val ClauseContext {cqs=cqsi,ags=agsi,lhs=lhsi,...} = ctxi |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
256 |
val ClauseContext {cqs=cqsj,ags=agsj,lhs=lhsj,...} = ctxj |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
257 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
258 |
val lhsi_eq_lhsj = cterm_of thy (HOLogic.mk_Trueprop (mk_eq (lhsi, lhsj))) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
259 |
in if j < i then |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
260 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
261 |
val compat = lookup_compat_thm j i cts |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
262 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
263 |
compat (* "!!qj qi. Gsj => Gsi => lhsj = lhsi ==> rhsj = rhsi" *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
264 |
|> fold Thm.forall_elim (cqsj @ cqsi) (* "Gsj => Gsi => lhsj = lhsi ==> rhsj = rhsi" *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
265 |
|> Thm.elim_implies @{thm TrueI} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
266 |
|> fold Thm.elim_implies agsj |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
267 |
|> fold Thm.elim_implies agsi |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
268 |
|> Thm.elim_implies ((Thm.assume lhsi_eq_lhsj) RS sym) (* "Gsj, Gsi, lhsi = lhsj |-- rhsj = rhsi" *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
269 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
270 |
else |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
271 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
272 |
val compat = lookup_compat_thm i j cts |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
273 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
274 |
compat (* "!!qi qj. Gsi => Gsj => lhsi = lhsj ==> rhsi = rhsj" *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
275 |
|> fold Thm.forall_elim (cqsi @ cqsj) (* "Gsi => Gsj => lhsi = lhsj ==> rhsi = rhsj" *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
276 |
|> Thm.elim_implies @{thm TrueI} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
277 |
|> fold Thm.elim_implies agsi |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
278 |
|> fold Thm.elim_implies agsj |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
279 |
|> Thm.elim_implies (Thm.assume lhsi_eq_lhsj) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
280 |
|> (fn thm => thm RS sym) (* "Gsi, Gsj, lhsi = lhsj |-- rhsj = rhsi" *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
281 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
282 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
283 |
*} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
284 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
285 |
(* WASS *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
286 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
287 |
ML {* |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
288 |
(* Generates the replacement lemma in fully quantified form. *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
289 |
fun mk_replacement_lemma thy h ih_elim clause = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
290 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
291 |
val ClauseInfo {cdata=ClauseContext {qs, lhs, cqs, ags, case_hyp, ...}, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
292 |
RCs, tree, ...} = clause |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
293 |
local open Conv in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
294 |
val ih_conv = arg1_conv o arg_conv o arg_conv |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
295 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
296 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
297 |
val ih_elim_case = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
298 |
Conv.fconv_rule (ih_conv (K (case_hyp RS eq_reflection))) ih_elim |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
299 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
300 |
val Ris = map (fn RCInfo {llRI, ...} => llRI) RCs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
301 |
val h_assums = map (fn RCInfo {h_assum, ...} => |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
302 |
Thm.assume (cterm_of thy (subst_bounds (rev qs, h_assum)))) RCs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
303 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
304 |
val (eql, _) = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
305 |
Function_Ctx_Tree.rewrite_by_tree thy h ih_elim_case (Ris ~~ h_assums) tree |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
306 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
307 |
val replace_lemma = (eql RS meta_eq_to_obj_eq) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
308 |
|> Thm.implies_intr (cprop_of case_hyp) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
309 |
|> fold_rev (Thm.implies_intr o cprop_of) h_assums |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
310 |
|> fold_rev (Thm.implies_intr o cprop_of) ags |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
311 |
|> fold_rev Thm.forall_intr cqs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
312 |
|> Thm.close_derivation |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
313 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
314 |
replace_lemma |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
315 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
316 |
*} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
317 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
318 |
ML {* |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
319 |
fun mk_uniqueness_clause thy globals compat_store clausei clausej RLj = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
320 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
321 |
val Globals {h, y, x, fvar, ...} = globals |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
322 |
val ClauseInfo {no=i, cdata=cctxi as ClauseContext {ctxt=ctxti, lhs=lhsi, case_hyp, ...}, ...} = clausei |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
323 |
val ClauseInfo {no=j, qglr=cdescj, RCs=RCsj, ...} = clausej |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
324 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
325 |
val cctxj as ClauseContext {ags = agsj', lhs = lhsj', rhs = rhsj', qs = qsj', cqs = cqsj', ...} = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
326 |
mk_clause_context x ctxti cdescj |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
327 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
328 |
val rhsj'h = Pattern.rewrite_term thy [(fvar,h)] [] rhsj' |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
329 |
val compat = get_compat_thm thy compat_store i j cctxi cctxj |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
330 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
331 |
val Ghsj' = map |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
332 |
(fn RCInfo {h_assum, ...} => Thm.assume (cterm_of thy (subst_bounds (rev qsj', h_assum)))) RCsj |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
333 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
334 |
val RLj_import = RLj |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
335 |
|> fold Thm.forall_elim cqsj' |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
336 |
|> fold Thm.elim_implies agsj' |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
337 |
|> fold Thm.elim_implies Ghsj' |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
338 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
339 |
val y_eq_rhsj'h = Thm.assume (cterm_of thy (HOLogic.mk_Trueprop (mk_eq (y, rhsj'h)))) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
340 |
val lhsi_eq_lhsj' = Thm.assume (cterm_of thy (HOLogic.mk_Trueprop (mk_eq (lhsi, lhsj')))) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
341 |
(* lhs_i = lhs_j' |-- lhs_i = lhs_j' *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
342 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
343 |
(trans OF [case_hyp, lhsi_eq_lhsj']) (* lhs_i = lhs_j' |-- x = lhs_j' *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
344 |
|> Thm.implies_elim RLj_import |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
345 |
(* Rj1' ... Rjk', lhs_i = lhs_j' |-- rhs_j'_h = rhs_j'_f *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
346 |
|> (fn it => trans OF [it, compat]) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
347 |
(* lhs_i = lhs_j', Gj', Rj1' ... Rjk' |-- rhs_j'_h = rhs_i_f *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
348 |
|> (fn it => trans OF [y_eq_rhsj'h, it]) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
349 |
(* lhs_i = lhs_j', Gj', Rj1' ... Rjk', y = rhs_j_h' |-- y = rhs_i_f *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
350 |
|> fold_rev (Thm.implies_intr o cprop_of) Ghsj' |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
351 |
|> fold_rev (Thm.implies_intr o cprop_of) agsj' |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
352 |
(* lhs_i = lhs_j' , y = rhs_j_h' |-- Gj', Rj1'...Rjk' ==> y = rhs_i_f *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
353 |
|> Thm.implies_intr (cprop_of y_eq_rhsj'h) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
354 |
|> Thm.implies_intr (cprop_of lhsi_eq_lhsj') |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
355 |
|> fold_rev Thm.forall_intr (cterm_of thy h :: cqsj') |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
356 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
357 |
*} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
358 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
359 |
(* HERE *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
360 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
361 |
ML {* |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
362 |
fun mk_uniqueness_case thy globals G f ihyp ih_intro G_cases compat_store clauses rep_lemmas clausei = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
363 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
364 |
val Globals {x, y, ranT, fvar, ...} = globals |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
365 |
val ClauseInfo {cdata = ClauseContext {lhs, rhs, cqs, ags, case_hyp, ...}, lGI, RCs, ...} = clausei |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
366 |
val rhsC = Pattern.rewrite_term thy [(fvar, f)] [] rhs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
367 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
368 |
val ih_intro_case = full_simplify (HOL_basic_ss addsimps [case_hyp]) ih_intro |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
369 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
370 |
fun prep_RC (RCInfo {llRI, RIvs, CCas, ...}) = (llRI RS ih_intro_case) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
371 |
|> fold_rev (Thm.implies_intr o cprop_of) CCas |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
372 |
|> fold_rev (Thm.forall_intr o cterm_of thy o Free) RIvs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
373 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
374 |
val existence = fold (curry op COMP o prep_RC) RCs lGI |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
375 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
376 |
val P = cterm_of thy (mk_eq (y, rhsC)) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
377 |
val G_lhs_y = Thm.assume (cterm_of thy (HOLogic.mk_Trueprop (G $ lhs $ y))) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
378 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
379 |
val unique_clauses = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
380 |
map2 (mk_uniqueness_clause thy globals compat_store clausei) clauses rep_lemmas |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
381 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
382 |
fun elim_implies_eta A AB = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
383 |
Thm.compose_no_flatten true (A, 0) 1 AB |> Seq.list_of |> the_single |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
384 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
385 |
val uniqueness = G_cases |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
386 |
|> Thm.forall_elim (cterm_of thy lhs) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
387 |
|> Thm.forall_elim (cterm_of thy y) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
388 |
|> Thm.forall_elim P |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
389 |
|> Thm.elim_implies G_lhs_y |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
390 |
|> fold elim_implies_eta unique_clauses |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
391 |
|> Thm.implies_intr (cprop_of G_lhs_y) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
392 |
|> Thm.forall_intr (cterm_of thy y) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
393 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
394 |
val P2 = cterm_of thy (lambda y (G $ lhs $ y)) (* P2 y := (lhs, y): G *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
395 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
396 |
val exactly_one = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
397 |
ex1I |> instantiate' [SOME (ctyp_of thy ranT)] [SOME P2, SOME (cterm_of thy rhsC)] |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
398 |
|> curry (op COMP) existence |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
399 |
|> curry (op COMP) uniqueness |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
400 |
|> simplify (HOL_basic_ss addsimps [case_hyp RS sym]) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
401 |
|> Thm.implies_intr (cprop_of case_hyp) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
402 |
|> fold_rev (Thm.implies_intr o cprop_of) ags |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
403 |
|> fold_rev Thm.forall_intr cqs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
404 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
405 |
val function_value = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
406 |
existence |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
407 |
|> Thm.implies_intr ihyp |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
408 |
|> Thm.implies_intr (cprop_of case_hyp) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
409 |
|> Thm.forall_intr (cterm_of thy x) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
410 |
|> Thm.forall_elim (cterm_of thy lhs) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
411 |
|> curry (op RS) refl |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
412 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
413 |
(exactly_one, function_value) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
414 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
415 |
*} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
416 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
417 |
ML {* |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
418 |
fun prove_stuff ctxt globals G f R clauses complete compat compat_store G_elim f_def = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
419 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
420 |
val Globals {h, domT, ranT, x, ...} = globals |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
421 |
val thy = ProofContext.theory_of ctxt |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
422 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
423 |
(* Inductive Hypothesis: !!z. (z,x):R ==> EX!y. (z,y):G *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
424 |
val ihyp = Term.all domT $ Abs ("z", domT, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
425 |
Logic.mk_implies (HOLogic.mk_Trueprop (R $ Bound 0 $ x), |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
426 |
HOLogic.mk_Trueprop (Const (@{const_name Ex1}, (ranT --> boolT) --> boolT) $ |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
427 |
Abs ("y", ranT, G $ Bound 1 $ Bound 0)))) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
428 |
|> cterm_of thy |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
429 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
430 |
val ihyp_thm = Thm.assume ihyp |> Thm.forall_elim_vars 0 |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
431 |
val ih_intro = ihyp_thm RS (f_def RS ex1_implies_ex) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
432 |
val ih_elim = ihyp_thm RS (f_def RS ex1_implies_un) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
433 |
|> instantiate' [] [NONE, SOME (cterm_of thy h)] |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
434 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
435 |
val _ = trace_msg (K "Proving Replacement lemmas...") |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
436 |
val repLemmas = map (mk_replacement_lemma thy h ih_elim) clauses |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
437 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
438 |
val _ = trace_msg (K "Proving cases for unique existence...") |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
439 |
val (ex1s, values) = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
440 |
split_list (map (mk_uniqueness_case thy globals G f |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
441 |
ihyp ih_intro G_elim compat_store clauses repLemmas) clauses) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
442 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
443 |
val _ = trace_msg (K "Proving: Graph is a function") |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
444 |
val graph_is_function = complete |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
445 |
|> Thm.forall_elim_vars 0 |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
446 |
|> fold (curry op COMP) ex1s |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
447 |
|> Thm.implies_intr (ihyp) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
448 |
|> Thm.implies_intr (cterm_of thy (HOLogic.mk_Trueprop (mk_acc domT R $ x))) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
449 |
|> Thm.forall_intr (cterm_of thy x) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
450 |
|> (fn it => Drule.compose_single (it, 2, acc_induct_rule)) (* "EX! y. (?x,y):G" *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
451 |
|> (fn it => fold (Thm.forall_intr o cterm_of thy o Var) (Term.add_vars (prop_of it) []) it) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
452 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
453 |
val goalstate = Conjunction.intr graph_is_function complete |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
454 |
|> Thm.close_derivation |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
455 |
|> Goal.protect |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
456 |
|> fold_rev (Thm.implies_intr o cprop_of) compat |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
457 |
|> Thm.implies_intr (cprop_of complete) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
458 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
459 |
(goalstate, values) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
460 |
end |
2650
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
461 |
*} |
2649
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
462 |
|
2650
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
463 |
ML {* |
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
464 |
Inductive.add_inductive_i; |
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
465 |
Local_Theory.conceal |
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
466 |
*} |
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
467 |
|
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
468 |
ML {* |
2649
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
469 |
(* wrapper -- restores quantifiers in rule specifications *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
470 |
fun inductive_def (binding as ((R, T), _)) intrs lthy = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
471 |
let |
2650
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
472 |
val ({intrs = intrs_gen, elims = [elim_gen], preds = [ Rdef ], induct, raw_induct, ...}, lthy) = |
2649
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
473 |
lthy |
2650
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
474 |
|> Local_Theory.conceal |
2649
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
475 |
|> Inductive.add_inductive_i |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
476 |
{quiet_mode = true, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
477 |
verbose = ! trace, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
478 |
alt_name = Binding.empty, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
479 |
coind = false, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
480 |
no_elim = false, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
481 |
no_ind = false, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
482 |
skip_mono = true, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
483 |
fork_mono = false} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
484 |
[binding] (* relation *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
485 |
[] (* no parameters *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
486 |
(map (fn t => (Attrib.empty_binding, t)) intrs) (* intro rules *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
487 |
[] (* no special monos *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
488 |
||> Local_Theory.restore_naming lthy |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
489 |
|
2650
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
490 |
val ([eqvt_thm], lthy) = Nominal_Eqvt.raw_equivariance false [Rdef] raw_induct intrs_gen lthy |
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
491 |
val eqvt_thm' = (Nominal_ThmDecls.eqvt_transform lthy eqvt_thm) RS @{thm eqvtI} |
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
492 |
|
2649
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
493 |
val cert = cterm_of (ProofContext.theory_of lthy) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
494 |
fun requantify orig_intro thm = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
495 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
496 |
val (qs, t) = dest_all_all orig_intro |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
497 |
val frees = frees_in_term lthy t |> remove (op =) (Binding.name_of R, T) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
498 |
val vars = Term.add_vars (prop_of thm) [] |> rev |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
499 |
val varmap = AList.lookup (op =) (frees ~~ map fst vars) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
500 |
#> the_default ("",0) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
501 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
502 |
fold_rev (fn Free (n, T) => |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
503 |
forall_intr_rename (n, cert (Var (varmap (n, T), T)))) qs thm |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
504 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
505 |
in |
2650
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
506 |
((Rdef, map2 requantify intrs intrs_gen, forall_intr_vars elim_gen, induct, eqvt_thm'), lthy) |
2649
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
507 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
508 |
*} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
509 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
510 |
ML {* |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
511 |
fun define_graph Gname fvar domT ranT clauses RCss lthy = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
512 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
513 |
val GT = domT --> ranT --> boolT |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
514 |
val (Gvar as (n, T)) = singleton (Variable.variant_frees lthy []) (Gname, GT) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
515 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
516 |
fun mk_GIntro (ClauseContext {qs, gs, lhs, rhs, ...}) RCs = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
517 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
518 |
fun mk_h_assm (rcfix, rcassm, rcarg) = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
519 |
HOLogic.mk_Trueprop (Free Gvar $ rcarg $ (fvar $ rcarg)) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
520 |
|> fold_rev (curry Logic.mk_implies o prop_of) rcassm |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
521 |
|> fold_rev (Logic.all o Free) rcfix |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
522 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
523 |
HOLogic.mk_Trueprop (Free Gvar $ lhs $ rhs) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
524 |
|> fold_rev (curry Logic.mk_implies o mk_h_assm) RCs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
525 |
|> fold_rev (curry Logic.mk_implies) gs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
526 |
|> fold_rev Logic.all (fvar :: qs) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
527 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
528 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
529 |
val G_intros = map2 mk_GIntro clauses RCss |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
530 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
531 |
inductive_def ((Binding.name n, T), NoSyn) G_intros lthy |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
532 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
533 |
*} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
534 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
535 |
ML {* |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
536 |
fun define_function fdefname (fname, mixfix) domT ranT G default lthy = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
537 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
538 |
val f_def = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
539 |
Abs ("x", domT, Const (@{const_name FunDef.THE_default}, ranT --> (ranT --> boolT) --> ranT) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
540 |
$ (default $ Bound 0) $ Abs ("y", ranT, G $ Bound 1 $ Bound 0)) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
541 |
|> Syntax.check_term lthy |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
542 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
543 |
Local_Theory.define |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
544 |
((Binding.name (function_name fname), mixfix), |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
545 |
((Binding.conceal (Binding.name fdefname), []), f_def)) lthy |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
546 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
547 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
548 |
fun define_recursion_relation Rname domT qglrs clauses RCss lthy = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
549 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
550 |
val RT = domT --> domT --> boolT |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
551 |
val (Rvar as (n, T)) = singleton (Variable.variant_frees lthy []) (Rname, RT) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
552 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
553 |
fun mk_RIntro (ClauseContext {qs, gs, lhs, ...}, (oqs, _, _, _)) (rcfix, rcassm, rcarg) = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
554 |
HOLogic.mk_Trueprop (Free Rvar $ rcarg $ lhs) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
555 |
|> fold_rev (curry Logic.mk_implies o prop_of) rcassm |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
556 |
|> fold_rev (curry Logic.mk_implies) gs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
557 |
|> fold_rev (Logic.all o Free) rcfix |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
558 |
|> fold_rev mk_forall_rename (map fst oqs ~~ qs) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
559 |
(* "!!qs xs. CS ==> G => (r, lhs) : R" *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
560 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
561 |
val R_intross = map2 (map o mk_RIntro) (clauses ~~ qglrs) RCss |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
562 |
|
2650
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
563 |
val ((R, RIntro_thms, R_elim, _, R_eqvt), lthy) = |
2649
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
564 |
inductive_def ((Binding.name n, T), NoSyn) (flat R_intross) lthy |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
565 |
in |
2650
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
566 |
((R, Library.unflat R_intross RIntro_thms, R_elim, R_eqvt), lthy) |
2649
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
567 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
568 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
569 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
570 |
fun fix_globals domT ranT fvar ctxt = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
571 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
572 |
val ([h, y, x, z, a, D, P, Pbool],ctxt') = Variable.variant_fixes |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
573 |
["h_fd", "y_fd", "x_fd", "z_fd", "a_fd", "D_fd", "P_fd", "Pb_fd"] ctxt |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
574 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
575 |
(Globals {h = Free (h, domT --> ranT), |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
576 |
y = Free (y, ranT), |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
577 |
x = Free (x, domT), |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
578 |
z = Free (z, domT), |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
579 |
a = Free (a, domT), |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
580 |
D = Free (D, domT --> boolT), |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
581 |
P = Free (P, domT --> boolT), |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
582 |
Pbool = Free (Pbool, boolT), |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
583 |
fvar = fvar, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
584 |
domT = domT, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
585 |
ranT = ranT}, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
586 |
ctxt') |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
587 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
588 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
589 |
fun inst_RC thy fvar f (rcfix, rcassm, rcarg) = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
590 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
591 |
fun inst_term t = subst_bound(f, abstract_over (fvar, t)) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
592 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
593 |
(rcfix, map (Thm.assume o cterm_of thy o inst_term o prop_of) rcassm, inst_term rcarg) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
594 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
595 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
596 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
597 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
598 |
(********************************************************** |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
599 |
* PROVING THE RULES |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
600 |
**********************************************************) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
601 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
602 |
fun mk_psimps thy globals R clauses valthms f_iff graph_is_function = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
603 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
604 |
val Globals {domT, z, ...} = globals |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
605 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
606 |
fun mk_psimp (ClauseInfo {qglr = (oqs, _, _, _), cdata = ClauseContext {cqs, lhs, ags, ...}, ...}) valthm = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
607 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
608 |
val lhs_acc = cterm_of thy (HOLogic.mk_Trueprop (mk_acc domT R $ lhs)) (* "acc R lhs" *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
609 |
val z_smaller = cterm_of thy (HOLogic.mk_Trueprop (R $ z $ lhs)) (* "R z lhs" *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
610 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
611 |
((Thm.assume z_smaller) RS ((Thm.assume lhs_acc) RS acc_downward)) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
612 |
|> (fn it => it COMP graph_is_function) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
613 |
|> Thm.implies_intr z_smaller |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
614 |
|> Thm.forall_intr (cterm_of thy z) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
615 |
|> (fn it => it COMP valthm) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
616 |
|> Thm.implies_intr lhs_acc |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
617 |
|> asm_simplify (HOL_basic_ss addsimps [f_iff]) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
618 |
|> fold_rev (Thm.implies_intr o cprop_of) ags |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
619 |
|> fold_rev forall_intr_rename (map fst oqs ~~ cqs) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
620 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
621 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
622 |
map2 mk_psimp clauses valthms |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
623 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
624 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
625 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
626 |
(** Induction rule **) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
627 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
628 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
629 |
val acc_subset_induct = @{thm predicate1I} RS @{thm accp_subset_induct} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
630 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
631 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
632 |
fun mk_partial_induct_rule thy globals R complete_thm clauses = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
633 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
634 |
val Globals {domT, x, z, a, P, D, ...} = globals |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
635 |
val acc_R = mk_acc domT R |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
636 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
637 |
val x_D = Thm.assume (cterm_of thy (HOLogic.mk_Trueprop (D $ x))) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
638 |
val a_D = cterm_of thy (HOLogic.mk_Trueprop (D $ a)) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
639 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
640 |
val D_subset = cterm_of thy (Logic.all x |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
641 |
(Logic.mk_implies (HOLogic.mk_Trueprop (D $ x), HOLogic.mk_Trueprop (acc_R $ x)))) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
642 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
643 |
val D_dcl = (* "!!x z. [| x: D; (z,x):R |] ==> z:D" *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
644 |
Logic.all x (Logic.all z (Logic.mk_implies (HOLogic.mk_Trueprop (D $ x), |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
645 |
Logic.mk_implies (HOLogic.mk_Trueprop (R $ z $ x), |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
646 |
HOLogic.mk_Trueprop (D $ z))))) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
647 |
|> cterm_of thy |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
648 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
649 |
(* Inductive Hypothesis: !!z. (z,x):R ==> P z *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
650 |
val ihyp = Term.all domT $ Abs ("z", domT, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
651 |
Logic.mk_implies (HOLogic.mk_Trueprop (R $ Bound 0 $ x), |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
652 |
HOLogic.mk_Trueprop (P $ Bound 0))) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
653 |
|> cterm_of thy |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
654 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
655 |
val aihyp = Thm.assume ihyp |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
656 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
657 |
fun prove_case clause = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
658 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
659 |
val ClauseInfo {cdata = ClauseContext {ctxt, qs, cqs, ags, gs, lhs, case_hyp, ...}, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
660 |
RCs, qglr = (oqs, _, _, _), ...} = clause |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
661 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
662 |
val case_hyp_conv = K (case_hyp RS eq_reflection) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
663 |
local open Conv in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
664 |
val lhs_D = fconv_rule (arg_conv (arg_conv (case_hyp_conv))) x_D |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
665 |
val sih = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
666 |
fconv_rule (Conv.binder_conv |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
667 |
(K (arg1_conv (arg_conv (arg_conv case_hyp_conv)))) ctxt) aihyp |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
668 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
669 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
670 |
fun mk_Prec (RCInfo {llRI, RIvs, CCas, rcarg, ...}) = sih |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
671 |
|> Thm.forall_elim (cterm_of thy rcarg) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
672 |
|> Thm.elim_implies llRI |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
673 |
|> fold_rev (Thm.implies_intr o cprop_of) CCas |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
674 |
|> fold_rev (Thm.forall_intr o cterm_of thy o Free) RIvs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
675 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
676 |
val P_recs = map mk_Prec RCs (* [P rec1, P rec2, ... ] *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
677 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
678 |
val step = HOLogic.mk_Trueprop (P $ lhs) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
679 |
|> fold_rev (curry Logic.mk_implies o prop_of) P_recs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
680 |
|> fold_rev (curry Logic.mk_implies) gs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
681 |
|> curry Logic.mk_implies (HOLogic.mk_Trueprop (D $ lhs)) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
682 |
|> fold_rev mk_forall_rename (map fst oqs ~~ qs) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
683 |
|> cterm_of thy |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
684 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
685 |
val P_lhs = Thm.assume step |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
686 |
|> fold Thm.forall_elim cqs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
687 |
|> Thm.elim_implies lhs_D |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
688 |
|> fold Thm.elim_implies ags |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
689 |
|> fold Thm.elim_implies P_recs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
690 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
691 |
val res = cterm_of thy (HOLogic.mk_Trueprop (P $ x)) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
692 |
|> Conv.arg_conv (Conv.arg_conv case_hyp_conv) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
693 |
|> Thm.symmetric (* P lhs == P x *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
694 |
|> (fn eql => Thm.equal_elim eql P_lhs) (* "P x" *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
695 |
|> Thm.implies_intr (cprop_of case_hyp) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
696 |
|> fold_rev (Thm.implies_intr o cprop_of) ags |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
697 |
|> fold_rev Thm.forall_intr cqs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
698 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
699 |
(res, step) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
700 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
701 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
702 |
val (cases, steps) = split_list (map prove_case clauses) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
703 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
704 |
val istep = complete_thm |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
705 |
|> Thm.forall_elim_vars 0 |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
706 |
|> fold (curry op COMP) cases (* P x *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
707 |
|> Thm.implies_intr ihyp |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
708 |
|> Thm.implies_intr (cprop_of x_D) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
709 |
|> Thm.forall_intr (cterm_of thy x) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
710 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
711 |
val subset_induct_rule = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
712 |
acc_subset_induct |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
713 |
|> (curry op COMP) (Thm.assume D_subset) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
714 |
|> (curry op COMP) (Thm.assume D_dcl) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
715 |
|> (curry op COMP) (Thm.assume a_D) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
716 |
|> (curry op COMP) istep |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
717 |
|> fold_rev Thm.implies_intr steps |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
718 |
|> Thm.implies_intr a_D |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
719 |
|> Thm.implies_intr D_dcl |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
720 |
|> Thm.implies_intr D_subset |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
721 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
722 |
val simple_induct_rule = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
723 |
subset_induct_rule |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
724 |
|> Thm.forall_intr (cterm_of thy D) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
725 |
|> Thm.forall_elim (cterm_of thy acc_R) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
726 |
|> assume_tac 1 |> Seq.hd |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
727 |
|> (curry op COMP) (acc_downward |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
728 |
|> (instantiate' [SOME (ctyp_of thy domT)] |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
729 |
(map (SOME o cterm_of thy) [R, x, z])) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
730 |
|> Thm.forall_intr (cterm_of thy z) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
731 |
|> Thm.forall_intr (cterm_of thy x)) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
732 |
|> Thm.forall_intr (cterm_of thy a) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
733 |
|> Thm.forall_intr (cterm_of thy P) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
734 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
735 |
simple_induct_rule |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
736 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
737 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
738 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
739 |
(* FIXME: broken by design *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
740 |
fun mk_domain_intro ctxt (Globals {domT, ...}) R R_cases clause = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
741 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
742 |
val thy = ProofContext.theory_of ctxt |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
743 |
val ClauseInfo {cdata = ClauseContext {gs, lhs, cqs, ...}, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
744 |
qglr = (oqs, _, _, _), ...} = clause |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
745 |
val goal = HOLogic.mk_Trueprop (mk_acc domT R $ lhs) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
746 |
|> fold_rev (curry Logic.mk_implies) gs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
747 |
|> cterm_of thy |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
748 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
749 |
Goal.init goal |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
750 |
|> (SINGLE (resolve_tac [accI] 1)) |> the |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
751 |
|> (SINGLE (eresolve_tac [Thm.forall_elim_vars 0 R_cases] 1)) |> the |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
752 |
|> (SINGLE (auto_tac (clasimpset_of ctxt))) |> the |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
753 |
|> Goal.conclude |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
754 |
|> fold_rev forall_intr_rename (map fst oqs ~~ cqs) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
755 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
756 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
757 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
758 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
759 |
(** Termination rule **) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
760 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
761 |
val wf_induct_rule = @{thm Wellfounded.wfP_induct_rule} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
762 |
val wf_in_rel = @{thm FunDef.wf_in_rel} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
763 |
val in_rel_def = @{thm FunDef.in_rel_def} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
764 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
765 |
fun mk_nest_term_case thy globals R' ihyp clause = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
766 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
767 |
val Globals {z, ...} = globals |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
768 |
val ClauseInfo {cdata = ClauseContext {qs, cqs, ags, lhs, case_hyp, ...}, tree, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
769 |
qglr=(oqs, _, _, _), ...} = clause |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
770 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
771 |
val ih_case = full_simplify (HOL_basic_ss addsimps [case_hyp]) ihyp |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
772 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
773 |
fun step (fixes, assumes) (_ $ arg) u (sub,(hyps,thms)) = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
774 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
775 |
val used = (u @ sub) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
776 |
|> map (fn (ctx,thm) => Function_Ctx_Tree.export_thm thy ctx thm) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
777 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
778 |
val hyp = HOLogic.mk_Trueprop (R' $ arg $ lhs) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
779 |
|> fold_rev (curry Logic.mk_implies o prop_of) used (* additional hyps *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
780 |
|> Function_Ctx_Tree.export_term (fixes, assumes) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
781 |
|> fold_rev (curry Logic.mk_implies o prop_of) ags |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
782 |
|> fold_rev mk_forall_rename (map fst oqs ~~ qs) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
783 |
|> cterm_of thy |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
784 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
785 |
val thm = Thm.assume hyp |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
786 |
|> fold Thm.forall_elim cqs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
787 |
|> fold Thm.elim_implies ags |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
788 |
|> Function_Ctx_Tree.import_thm thy (fixes, assumes) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
789 |
|> fold Thm.elim_implies used (* "(arg, lhs) : R'" *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
790 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
791 |
val z_eq_arg = HOLogic.mk_Trueprop (mk_eq (z, arg)) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
792 |
|> cterm_of thy |> Thm.assume |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
793 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
794 |
val acc = thm COMP ih_case |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
795 |
val z_acc_local = acc |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
796 |
|> Conv.fconv_rule |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
797 |
(Conv.arg_conv (Conv.arg_conv (K (Thm.symmetric (z_eq_arg RS eq_reflection))))) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
798 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
799 |
val ethm = z_acc_local |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
800 |
|> Function_Ctx_Tree.export_thm thy (fixes, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
801 |
z_eq_arg :: case_hyp :: ags @ assumes) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
802 |
|> fold_rev forall_intr_rename (map fst oqs ~~ cqs) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
803 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
804 |
val sub' = sub @ [(([],[]), acc)] |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
805 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
806 |
(sub', (hyp :: hyps, ethm :: thms)) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
807 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
808 |
| step _ _ _ _ = raise Match |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
809 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
810 |
Function_Ctx_Tree.traverse_tree step tree |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
811 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
812 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
813 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
814 |
fun mk_nest_term_rule thy globals R R_cases clauses = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
815 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
816 |
val Globals { domT, x, z, ... } = globals |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
817 |
val acc_R = mk_acc domT R |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
818 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
819 |
val R' = Free ("R", fastype_of R) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
820 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
821 |
val Rrel = Free ("R", HOLogic.mk_setT (HOLogic.mk_prodT (domT, domT))) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
822 |
val inrel_R = Const (@{const_name FunDef.in_rel}, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
823 |
HOLogic.mk_setT (HOLogic.mk_prodT (domT, domT)) --> fastype_of R) $ Rrel |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
824 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
825 |
val wfR' = HOLogic.mk_Trueprop (Const (@{const_name Wellfounded.wfP}, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
826 |
(domT --> domT --> boolT) --> boolT) $ R') |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
827 |
|> cterm_of thy (* "wf R'" *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
828 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
829 |
(* Inductive Hypothesis: !!z. (z,x):R' ==> z : acc R *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
830 |
val ihyp = Term.all domT $ Abs ("z", domT, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
831 |
Logic.mk_implies (HOLogic.mk_Trueprop (R' $ Bound 0 $ x), |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
832 |
HOLogic.mk_Trueprop (acc_R $ Bound 0))) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
833 |
|> cterm_of thy |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
834 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
835 |
val ihyp_a = Thm.assume ihyp |> Thm.forall_elim_vars 0 |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
836 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
837 |
val R_z_x = cterm_of thy (HOLogic.mk_Trueprop (R $ z $ x)) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
838 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
839 |
val (hyps, cases) = fold (mk_nest_term_case thy globals R' ihyp_a) clauses ([], []) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
840 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
841 |
R_cases |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
842 |
|> Thm.forall_elim (cterm_of thy z) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
843 |
|> Thm.forall_elim (cterm_of thy x) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
844 |
|> Thm.forall_elim (cterm_of thy (acc_R $ z)) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
845 |
|> curry op COMP (Thm.assume R_z_x) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
846 |
|> fold_rev (curry op COMP) cases |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
847 |
|> Thm.implies_intr R_z_x |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
848 |
|> Thm.forall_intr (cterm_of thy z) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
849 |
|> (fn it => it COMP accI) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
850 |
|> Thm.implies_intr ihyp |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
851 |
|> Thm.forall_intr (cterm_of thy x) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
852 |
|> (fn it => Drule.compose_single(it,2,wf_induct_rule)) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
853 |
|> curry op RS (Thm.assume wfR') |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
854 |
|> forall_intr_vars |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
855 |
|> (fn it => it COMP allI) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
856 |
|> fold Thm.implies_intr hyps |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
857 |
|> Thm.implies_intr wfR' |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
858 |
|> Thm.forall_intr (cterm_of thy R') |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
859 |
|> Thm.forall_elim (cterm_of thy (inrel_R)) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
860 |
|> curry op RS wf_in_rel |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
861 |
|> full_simplify (HOL_basic_ss addsimps [in_rel_def]) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
862 |
|> Thm.forall_intr (cterm_of thy Rrel) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
863 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
864 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
865 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
866 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
867 |
(* Tail recursion (probably very fragile) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
868 |
* |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
869 |
* FIXME: |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
870 |
* - Need to do forall_elim_vars on psimps: Unneccesary, if psimps would be taken from the same context. |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
871 |
* - Must we really replace the fvar by f here? |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
872 |
* - Splitting is not configured automatically: Problems with case? |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
873 |
*) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
874 |
fun mk_trsimps octxt globals f G R f_def R_cases G_induct clauses psimps = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
875 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
876 |
val Globals {domT, ranT, fvar, ...} = globals |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
877 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
878 |
val R_cases = Thm.forall_elim_vars 0 R_cases (* FIXME: Should be already in standard form. *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
879 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
880 |
val graph_implies_dom = (* "G ?x ?y ==> dom ?x" *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
881 |
Goal.prove octxt ["x", "y"] [HOLogic.mk_Trueprop (G $ Free ("x", domT) $ Free ("y", ranT))] |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
882 |
(HOLogic.mk_Trueprop (mk_acc domT R $ Free ("x", domT))) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
883 |
(fn {prems=[a], ...} => |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
884 |
((rtac (G_induct OF [a])) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
885 |
THEN_ALL_NEW rtac accI |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
886 |
THEN_ALL_NEW etac R_cases |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
887 |
THEN_ALL_NEW asm_full_simp_tac (simpset_of octxt)) 1) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
888 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
889 |
val default_thm = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
890 |
forall_intr_vars graph_implies_dom COMP (f_def COMP fundef_default_value) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
891 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
892 |
fun mk_trsimp clause psimp = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
893 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
894 |
val ClauseInfo {qglr = (oqs, _, _, _), cdata = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
895 |
ClauseContext {ctxt, cqs, gs, lhs, rhs, ...}, ...} = clause |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
896 |
val thy = ProofContext.theory_of ctxt |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
897 |
val rhs_f = Pattern.rewrite_term thy [(fvar, f)] [] rhs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
898 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
899 |
val trsimp = Logic.list_implies(gs, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
900 |
HOLogic.mk_Trueprop (HOLogic.mk_eq(f $ lhs, rhs_f))) (* "f lhs = rhs" *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
901 |
val lhs_acc = (mk_acc domT R $ lhs) (* "acc R lhs" *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
902 |
fun simp_default_tac ss = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
903 |
asm_full_simp_tac (ss addsimps [default_thm, Let_def]) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
904 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
905 |
Goal.prove ctxt [] [] trsimp (fn _ => |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
906 |
rtac (instantiate' [] [SOME (cterm_of thy lhs_acc)] case_split) 1 |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
907 |
THEN (rtac (Thm.forall_elim_vars 0 psimp) THEN_ALL_NEW assume_tac) 1 |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
908 |
THEN (simp_default_tac (simpset_of ctxt) 1) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
909 |
THEN TRY ((etac not_acc_down 1) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
910 |
THEN ((etac R_cases) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
911 |
THEN_ALL_NEW (simp_default_tac (simpset_of ctxt))) 1)) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
912 |
|> fold_rev forall_intr_rename (map fst oqs ~~ cqs) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
913 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
914 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
915 |
map2 mk_trsimp clauses psimps |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
916 |
end |
2650
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
917 |
*} |
2649
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
918 |
|
2650
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
919 |
ML {* |
2649
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
920 |
fun prepare_function config defname [((fname, fT), mixfix)] abstract_qglrs lthy = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
921 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
922 |
val FunctionConfig {domintros, tailrec, default=default_opt, ...} = config |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
923 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
924 |
val default_str = the_default "%x. undefined" default_opt (*FIXME dynamic scoping*) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
925 |
val fvar = Free (fname, fT) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
926 |
val domT = domain_type fT |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
927 |
val ranT = range_type fT |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
928 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
929 |
val default = Syntax.parse_term lthy default_str |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
930 |
|> Type.constraint fT |> Syntax.check_term lthy |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
931 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
932 |
val (globals, ctxt') = fix_globals domT ranT fvar lthy |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
933 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
934 |
val Globals { x, h, ... } = globals |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
935 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
936 |
val clauses = map (mk_clause_context x ctxt') abstract_qglrs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
937 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
938 |
val n = length abstract_qglrs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
939 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
940 |
fun build_tree (ClauseContext { ctxt, rhs, ...}) = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
941 |
Function_Ctx_Tree.mk_tree (fname, fT) h ctxt rhs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
942 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
943 |
val trees = map build_tree clauses |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
944 |
val RCss = map find_calls trees |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
945 |
|
2650
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
946 |
val ((G, GIntro_thms, G_elim, G_induct, G_eqvt), lthy) = |
2649
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
947 |
PROFILE "def_graph" (define_graph (graph_name defname) fvar domT ranT clauses RCss) lthy |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
948 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
949 |
val _ = tracing ("Graph - name: " ^ @{make_string} G) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
950 |
val _ = tracing ("Graph intros:\n" ^ cat_lines (map @{make_string} GIntro_thms)) |
2650
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
951 |
val _ = tracing ("Graph Equivariance" ^ @{make_string} G_eqvt) |
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
952 |
|
2649
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
953 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
954 |
val ((f, (_, f_defthm)), lthy) = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
955 |
PROFILE "def_fun" (define_function (defname ^ "_sumC_def") (fname, mixfix) domT ranT G default) lthy |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
956 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
957 |
val _ = tracing ("f - name: " ^ @{make_string} f) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
958 |
val _ = tracing ("f_defthm:\n" ^ @{make_string} f_defthm) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
959 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
960 |
val RCss = map (map (inst_RC (ProofContext.theory_of lthy) fvar f)) RCss |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
961 |
val trees = map (Function_Ctx_Tree.inst_tree (ProofContext.theory_of lthy) fvar f) trees |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
962 |
|
2650
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
963 |
val ((R, RIntro_thmss, R_elim, R_eqvt), lthy) = |
2649
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
964 |
PROFILE "def_rel" (define_recursion_relation (rel_name defname) domT abstract_qglrs clauses RCss) lthy |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
965 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
966 |
val _ = tracing ("Relation - name: " ^ @{make_string} R) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
967 |
val _ = tracing ("Relation intros:\n" ^ cat_lines (map @{make_string} RIntro_thmss)) |
2650
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
968 |
val _ = tracing ("Relation Equivariance" ^ @{make_string} R_eqvt) |
2649
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
969 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
970 |
val (_, lthy) = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
971 |
Local_Theory.abbrev Syntax.mode_default ((Binding.name (dom_name defname), NoSyn), mk_acc domT R) lthy |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
972 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
973 |
val newthy = ProofContext.theory_of lthy |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
974 |
val clauses = map (transfer_clause_ctx newthy) clauses |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
975 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
976 |
val cert = cterm_of (ProofContext.theory_of lthy) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
977 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
978 |
val xclauses = PROFILE "xclauses" |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
979 |
(map7 (mk_clause_info globals G f) (1 upto n) clauses abstract_qglrs trees |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
980 |
RCss GIntro_thms) RIntro_thmss |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
981 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
982 |
val complete = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
983 |
mk_completeness globals clauses abstract_qglrs |> cert |> Thm.assume |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
984 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
985 |
val compat = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
986 |
mk_compat_proof_obligations domT ranT fvar f abstract_qglrs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
987 |
|> map (cert #> Thm.assume) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
988 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
989 |
val compat_store = store_compat_thms n compat |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
990 |
|
2650
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
991 |
(* |
2649
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
992 |
val _ = tracing ("globals:\n" ^ @{make_string} globals) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
993 |
val _ = tracing ("complete:\n" ^ @{make_string} complete) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
994 |
val _ = tracing ("compat:\n" ^ @{make_string} compat) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
995 |
val _ = tracing ("compat_store:\n" ^ @{make_string} compat_store) |
2650
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
996 |
*) |
2649
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
997 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
998 |
val (goalstate, values) = PROFILE "prove_stuff" |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
999 |
(prove_stuff lthy globals G f R xclauses complete compat |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1000 |
compat_store G_elim) f_defthm |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1001 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1002 |
val _ = tracing ("goalstate prove_stuff thm:\n" ^ @{make_string} goalstate) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1003 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1004 |
val mk_trsimps = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1005 |
mk_trsimps lthy globals f G R f_defthm R_elim G_induct xclauses |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1006 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1007 |
fun mk_partial_rules provedgoal = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1008 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1009 |
val newthy = theory_of_thm provedgoal (*FIXME*) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1010 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1011 |
val (graph_is_function, complete_thm) = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1012 |
provedgoal |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1013 |
|> Conjunction.elim |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1014 |
|> apfst (Thm.forall_elim_vars 0) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1015 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1016 |
val f_iff = graph_is_function RS (f_defthm RS ex1_implies_iff) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1017 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1018 |
val psimps = PROFILE "Proving simplification rules" |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1019 |
(mk_psimps newthy globals R xclauses values f_iff) graph_is_function |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1020 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1021 |
val simple_pinduct = PROFILE "Proving partial induction rule" |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1022 |
(mk_partial_induct_rule newthy globals R complete_thm) xclauses |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1023 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1024 |
val total_intro = PROFILE "Proving nested termination rule" |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1025 |
(mk_nest_term_rule newthy globals R R_elim) xclauses |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1026 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1027 |
val dom_intros = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1028 |
if domintros then SOME (PROFILE "Proving domain introduction rules" |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1029 |
(map (mk_domain_intro lthy globals R R_elim)) xclauses) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1030 |
else NONE |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1031 |
val trsimps = if tailrec then SOME (mk_trsimps psimps) else NONE |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1032 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1033 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1034 |
FunctionResult {fs=[f], G=G, R=R, cases=complete_thm, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1035 |
psimps=psimps, simple_pinducts=[simple_pinduct], |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1036 |
termination=total_intro, trsimps=trsimps, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1037 |
domintros=dom_intros} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1038 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1039 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1040 |
((f, goalstate, mk_partial_rules), lthy) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1041 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1042 |
*} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1043 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1044 |
ML {* |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1045 |
open Function_Lib |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1046 |
open Function_Common |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1047 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1048 |
type qgar = string * (string * typ) list * term list * term list * term |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1049 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1050 |
datatype mutual_part = MutualPart of |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1051 |
{i : int, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1052 |
i' : int, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1053 |
fvar : string * typ, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1054 |
cargTs: typ list, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1055 |
f_def: term, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1056 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1057 |
f: term option, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1058 |
f_defthm : thm option} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1059 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1060 |
datatype mutual_info = Mutual of |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1061 |
{n : int, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1062 |
n' : int, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1063 |
fsum_var : string * typ, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1064 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1065 |
ST: typ, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1066 |
RST: typ, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1067 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1068 |
parts: mutual_part list, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1069 |
fqgars: qgar list, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1070 |
qglrs: ((string * typ) list * term list * term * term) list, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1071 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1072 |
fsum : term option} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1073 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1074 |
fun mutual_induct_Pnames n = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1075 |
if n < 5 then fst (chop n ["P","Q","R","S"]) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1076 |
else map (fn i => "P" ^ string_of_int i) (1 upto n) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1077 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1078 |
fun get_part fname = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1079 |
the o find_first (fn (MutualPart {fvar=(n,_), ...}) => n = fname) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1080 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1081 |
(* FIXME *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1082 |
fun mk_prod_abs e (t1, t2) = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1083 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1084 |
val bTs = rev (map snd e) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1085 |
val T1 = fastype_of1 (bTs, t1) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1086 |
val T2 = fastype_of1 (bTs, t2) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1087 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1088 |
HOLogic.pair_const T1 T2 $ t1 $ t2 |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1089 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1090 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1091 |
fun analyze_eqs ctxt defname fs eqs = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1092 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1093 |
val num = length fs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1094 |
val fqgars = map (split_def ctxt (K true)) eqs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1095 |
val arity_of = map (fn (fname,_,_,args,_) => (fname, length args)) fqgars |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1096 |
|> AList.lookup (op =) #> the |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1097 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1098 |
fun curried_types (fname, fT) = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1099 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1100 |
val (caTs, uaTs) = chop (arity_of fname) (binder_types fT) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1101 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1102 |
(caTs, uaTs ---> body_type fT) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1103 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1104 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1105 |
val (caTss, resultTs) = split_list (map curried_types fs) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1106 |
val argTs = map (foldr1 HOLogic.mk_prodT) caTss |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1107 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1108 |
val dresultTs = distinct (op =) resultTs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1109 |
val n' = length dresultTs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1110 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1111 |
val RST = Balanced_Tree.make (uncurry SumTree.mk_sumT) dresultTs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1112 |
val ST = Balanced_Tree.make (uncurry SumTree.mk_sumT) argTs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1113 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1114 |
val fsum_type = ST --> RST |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1115 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1116 |
val ([fsum_var_name], _) = Variable.add_fixes [ defname ^ "_sum" ] ctxt |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1117 |
val fsum_var = (fsum_var_name, fsum_type) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1118 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1119 |
fun define (fvar as (n, _)) caTs resultT i = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1120 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1121 |
val vars = map_index (fn (j,T) => Free ("x" ^ string_of_int j, T)) caTs (* FIXME: Bind xs properly *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1122 |
val i' = find_index (fn Ta => Ta = resultT) dresultTs + 1 |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1123 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1124 |
val f_exp = SumTree.mk_proj RST n' i' (Free fsum_var $ SumTree.mk_inj ST num i (foldr1 HOLogic.mk_prod vars)) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1125 |
val def = Term.abstract_over (Free fsum_var, fold_rev lambda vars f_exp) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1126 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1127 |
val rew = (n, fold_rev lambda vars f_exp) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1128 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1129 |
(MutualPart {i=i, i'=i', fvar=fvar,cargTs=caTs,f_def=def,f=NONE,f_defthm=NONE}, rew) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1130 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1131 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1132 |
val (parts, rews) = split_list (map4 define fs caTss resultTs (1 upto num)) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1133 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1134 |
fun convert_eqs (f, qs, gs, args, rhs) = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1135 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1136 |
val MutualPart {i, i', ...} = get_part f parts |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1137 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1138 |
(qs, gs, SumTree.mk_inj ST num i (foldr1 (mk_prod_abs qs) args), |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1139 |
SumTree.mk_inj RST n' i' (replace_frees rews rhs) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1140 |
|> Envir.beta_norm) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1141 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1142 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1143 |
val qglrs = map convert_eqs fqgars |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1144 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1145 |
Mutual {n=num, n'=n', fsum_var=fsum_var, ST=ST, RST=RST, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1146 |
parts=parts, fqgars=fqgars, qglrs=qglrs, fsum=NONE} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1147 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1148 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1149 |
fun define_projections fixes mutual fsum lthy = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1150 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1151 |
fun def ((MutualPart {i=i, i'=i', fvar=(fname, fT), cargTs, f_def, ...}), (_, mixfix)) lthy = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1152 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1153 |
val ((f, (_, f_defthm)), lthy') = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1154 |
Local_Theory.define |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1155 |
((Binding.name fname, mixfix), |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1156 |
((Binding.conceal (Binding.name (fname ^ "_def")), []), |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1157 |
Term.subst_bound (fsum, f_def))) lthy |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1158 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1159 |
(MutualPart {i=i, i'=i', fvar=(fname, fT), cargTs=cargTs, f_def=f_def, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1160 |
f=SOME f, f_defthm=SOME f_defthm }, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1161 |
lthy') |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1162 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1163 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1164 |
val Mutual { n, n', fsum_var, ST, RST, parts, fqgars, qglrs, ... } = mutual |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1165 |
val (parts', lthy') = fold_map def (parts ~~ fixes) lthy |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1166 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1167 |
(Mutual { n=n, n'=n', fsum_var=fsum_var, ST=ST, RST=RST, parts=parts', |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1168 |
fqgars=fqgars, qglrs=qglrs, fsum=SOME fsum }, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1169 |
lthy') |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1170 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1171 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1172 |
fun in_context ctxt (f, pre_qs, pre_gs, pre_args, pre_rhs) F = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1173 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1174 |
val thy = ProofContext.theory_of ctxt |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1175 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1176 |
val oqnames = map fst pre_qs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1177 |
val (qs, _) = Variable.variant_fixes oqnames ctxt |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1178 |
|>> map2 (fn (_, T) => fn n => Free (n, T)) pre_qs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1179 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1180 |
fun inst t = subst_bounds (rev qs, t) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1181 |
val gs = map inst pre_gs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1182 |
val args = map inst pre_args |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1183 |
val rhs = inst pre_rhs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1184 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1185 |
val cqs = map (cterm_of thy) qs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1186 |
val ags = map (Thm.assume o cterm_of thy) gs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1187 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1188 |
val import = fold Thm.forall_elim cqs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1189 |
#> fold Thm.elim_implies ags |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1190 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1191 |
val export = fold_rev (Thm.implies_intr o cprop_of) ags |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1192 |
#> fold_rev forall_intr_rename (oqnames ~~ cqs) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1193 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1194 |
F ctxt (f, qs, gs, args, rhs) import export |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1195 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1196 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1197 |
fun recover_mutual_psimp all_orig_fdefs parts ctxt (fname, _, _, args, rhs) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1198 |
import (export : thm -> thm) sum_psimp_eq = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1199 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1200 |
val (MutualPart {f=SOME f, ...}) = get_part fname parts |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1201 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1202 |
val psimp = import sum_psimp_eq |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1203 |
val (simp, restore_cond) = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1204 |
case cprems_of psimp of |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1205 |
[] => (psimp, I) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1206 |
| [cond] => (Thm.implies_elim psimp (Thm.assume cond), Thm.implies_intr cond) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1207 |
| _ => raise General.Fail "Too many conditions" |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1208 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1209 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1210 |
Goal.prove ctxt [] [] |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1211 |
(HOLogic.Trueprop $ HOLogic.mk_eq (list_comb (f, args), rhs)) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1212 |
(fn _ => (Local_Defs.unfold_tac ctxt all_orig_fdefs) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1213 |
THEN EqSubst.eqsubst_tac ctxt [0] [simp] 1 |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1214 |
THEN (simp_tac (simpset_of ctxt)) 1) (* FIXME: global simpset?!! *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1215 |
|> restore_cond |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1216 |
|> export |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1217 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1218 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1219 |
fun mk_applied_form ctxt caTs thm = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1220 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1221 |
val thy = ProofContext.theory_of ctxt |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1222 |
val xs = map_index (fn (i,T) => cterm_of thy (Free ("x" ^ string_of_int i, T))) caTs (* FIXME: Bind xs properly *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1223 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1224 |
fold (fn x => fn thm => Thm.combination thm (Thm.reflexive x)) xs thm |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1225 |
|> Conv.fconv_rule (Thm.beta_conversion true) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1226 |
|> fold_rev Thm.forall_intr xs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1227 |
|> Thm.forall_elim_vars 0 |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1228 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1229 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1230 |
fun mutual_induct_rules lthy induct all_f_defs (Mutual {n, ST, parts, ...}) = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1231 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1232 |
val cert = cterm_of (ProofContext.theory_of lthy) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1233 |
val newPs = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1234 |
map2 (fn Pname => fn MutualPart {cargTs, ...} => |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1235 |
Free (Pname, cargTs ---> HOLogic.boolT)) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1236 |
(mutual_induct_Pnames (length parts)) parts |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1237 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1238 |
fun mk_P (MutualPart {cargTs, ...}) P = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1239 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1240 |
val avars = map_index (fn (i,T) => Var (("a", i), T)) cargTs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1241 |
val atup = foldr1 HOLogic.mk_prod avars |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1242 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1243 |
HOLogic.tupled_lambda atup (list_comb (P, avars)) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1244 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1245 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1246 |
val Ps = map2 mk_P parts newPs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1247 |
val case_exp = SumTree.mk_sumcases HOLogic.boolT Ps |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1248 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1249 |
val induct_inst = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1250 |
Thm.forall_elim (cert case_exp) induct |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1251 |
|> full_simplify SumTree.sumcase_split_ss |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1252 |
|> full_simplify (HOL_basic_ss addsimps all_f_defs) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1253 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1254 |
fun project rule (MutualPart {cargTs, i, ...}) k = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1255 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1256 |
val afs = map_index (fn (j,T) => Free ("a" ^ string_of_int (j + k), T)) cargTs (* FIXME! *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1257 |
val inj = SumTree.mk_inj ST n i (foldr1 HOLogic.mk_prod afs) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1258 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1259 |
(rule |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1260 |
|> Thm.forall_elim (cert inj) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1261 |
|> full_simplify SumTree.sumcase_split_ss |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1262 |
|> fold_rev (Thm.forall_intr o cert) (afs @ newPs), |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1263 |
k + length cargTs) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1264 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1265 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1266 |
fst (fold_map (project induct_inst) parts 0) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1267 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1268 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1269 |
fun mk_partial_rules_mutual lthy inner_cont (m as Mutual {parts, fqgars, ...}) proof = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1270 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1271 |
val result = inner_cont proof |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1272 |
val FunctionResult {G, R, cases, psimps, trsimps, simple_pinducts=[simple_pinduct], |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1273 |
termination, domintros, ...} = result |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1274 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1275 |
val (all_f_defs, fs) = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1276 |
map (fn MutualPart {f_defthm = SOME f_def, f = SOME f, cargTs, ...} => |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1277 |
(mk_applied_form lthy cargTs (Thm.symmetric f_def), f)) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1278 |
parts |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1279 |
|> split_list |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1280 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1281 |
val all_orig_fdefs = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1282 |
map (fn MutualPart {f_defthm = SOME f_def, ...} => f_def) parts |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1283 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1284 |
fun mk_mpsimp fqgar sum_psimp = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1285 |
in_context lthy fqgar (recover_mutual_psimp all_orig_fdefs parts) sum_psimp |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1286 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1287 |
val rew_ss = HOL_basic_ss addsimps all_f_defs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1288 |
val mpsimps = map2 mk_mpsimp fqgars psimps |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1289 |
val mtrsimps = Option.map (map2 mk_mpsimp fqgars) trsimps |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1290 |
val minducts = mutual_induct_rules lthy simple_pinduct all_f_defs m |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1291 |
val mtermination = full_simplify rew_ss termination |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1292 |
val mdomintros = Option.map (map (full_simplify rew_ss)) domintros |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1293 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1294 |
FunctionResult { fs=fs, G=G, R=R, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1295 |
psimps=mpsimps, simple_pinducts=minducts, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1296 |
cases=cases, termination=mtermination, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1297 |
domintros=mdomintros, trsimps=mtrsimps} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1298 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1299 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1300 |
fun prepare_function_mutual config defname fixes eqss lthy = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1301 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1302 |
val mutual as Mutual {fsum_var=(n, T), qglrs, ...} = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1303 |
analyze_eqs lthy defname (map fst fixes) (map Envir.beta_eta_contract eqss) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1304 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1305 |
val ((fsum, goalstate, cont), lthy') = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1306 |
prepare_function config defname [((n, T), NoSyn)] qglrs lthy |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1307 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1308 |
val (mutual', lthy'') = define_projections fixes mutual fsum lthy' |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1309 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1310 |
val mutual_cont = mk_partial_rules_mutual lthy'' cont mutual' |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1311 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1312 |
((goalstate, mutual_cont), lthy'') |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1313 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1314 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1315 |
*} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1316 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1317 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1318 |
ML {* |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1319 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1320 |
open Function_Lib |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1321 |
open Function_Common |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1322 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1323 |
val simp_attribs = map (Attrib.internal o K) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1324 |
[Simplifier.simp_add, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1325 |
Code.add_default_eqn_attribute, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1326 |
Nitpick_Simps.add] |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1327 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1328 |
val psimp_attribs = map (Attrib.internal o K) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1329 |
[Nitpick_Psimps.add] |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1330 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1331 |
fun mk_defname fixes = fixes |> map (fst o fst) |> space_implode "_" |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1332 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1333 |
fun add_simps fnames post sort extra_qualify label mod_binding moreatts |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1334 |
simps lthy = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1335 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1336 |
val spec = post simps |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1337 |
|> map (apfst (apsnd (fn ats => moreatts @ ats))) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1338 |
|> map (apfst (apfst extra_qualify)) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1339 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1340 |
val (saved_spec_simps, lthy) = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1341 |
fold_map Local_Theory.note spec lthy |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1342 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1343 |
val saved_simps = maps snd saved_spec_simps |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1344 |
val simps_by_f = sort saved_simps |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1345 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1346 |
fun add_for_f fname simps = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1347 |
Local_Theory.note |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1348 |
((mod_binding (Binding.qualify true fname (Binding.name label)), []), simps) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1349 |
#> snd |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1350 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1351 |
(saved_simps, fold2 add_for_f fnames simps_by_f lthy) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1352 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1353 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1354 |
fun prepare_function is_external prep default_constraint fixspec eqns config lthy = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1355 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1356 |
val constrn_fxs = map (fn (b, T, mx) => (b, SOME (the_default default_constraint T), mx)) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1357 |
val ((fixes0, spec0), ctxt') = prep (constrn_fxs fixspec) eqns lthy |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1358 |
val fixes = map (apfst (apfst Binding.name_of)) fixes0; |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1359 |
val spec = map (fn (bnd, prop) => (bnd, [prop])) spec0; |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1360 |
val (eqs, post, sort_cont, cnames) = get_preproc lthy config ctxt' fixes spec |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1361 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1362 |
val defname = mk_defname fixes |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1363 |
val FunctionConfig {partials, tailrec, default, ...} = config |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1364 |
val _ = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1365 |
if tailrec then Output.legacy_feature |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1366 |
"'function (tailrec)' command. Use 'partial_function (tailrec)'." |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1367 |
else () |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1368 |
val _ = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1369 |
if is_some default then Output.legacy_feature |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1370 |
"'function (default)'. Use 'partial_function'." |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1371 |
else () |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1372 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1373 |
val ((goal_state, cont), lthy') = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1374 |
prepare_function_mutual config defname fixes eqs lthy |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1375 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1376 |
fun afterqed [[proof]] lthy = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1377 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1378 |
val FunctionResult {fs, R, psimps, trsimps, simple_pinducts, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1379 |
termination, domintros, cases, ...} = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1380 |
cont (Thm.close_derivation proof) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1381 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1382 |
val fnames = map (fst o fst) fixes |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1383 |
fun qualify n = Binding.name n |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1384 |
|> Binding.qualify true defname |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1385 |
val conceal_partial = if partials then I else Binding.conceal |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1386 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1387 |
val addsmps = add_simps fnames post sort_cont |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1388 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1389 |
val (((psimps', pinducts'), (_, [termination'])), lthy) = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1390 |
lthy |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1391 |
|> addsmps (conceal_partial o Binding.qualify false "partial") |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1392 |
"psimps" conceal_partial psimp_attribs psimps |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1393 |
||> (case trsimps of NONE => I | SOME thms => |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1394 |
addsmps I "simps" I simp_attribs thms #> snd |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1395 |
#> Spec_Rules.add Spec_Rules.Equational (fs, thms)) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1396 |
||>> Local_Theory.note ((conceal_partial (qualify "pinduct"), |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1397 |
[Attrib.internal (K (Rule_Cases.case_names cnames)), |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1398 |
Attrib.internal (K (Rule_Cases.consumes 1)), |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1399 |
Attrib.internal (K (Induct.induct_pred ""))]), simple_pinducts) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1400 |
||>> Local_Theory.note ((Binding.conceal (qualify "termination"), []), [termination]) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1401 |
||> (snd o Local_Theory.note ((qualify "cases", |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1402 |
[Attrib.internal (K (Rule_Cases.case_names cnames))]), [cases])) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1403 |
||> (case domintros of NONE => I | SOME thms => |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1404 |
Local_Theory.note ((qualify "domintros", []), thms) #> snd) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1405 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1406 |
val info = { add_simps=addsmps, case_names=cnames, psimps=psimps', |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1407 |
pinducts=snd pinducts', simps=NONE, inducts=NONE, termination=termination', |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1408 |
fs=fs, R=R, defname=defname, is_partial=true } |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1409 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1410 |
val _ = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1411 |
if not is_external then () |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1412 |
else Specification.print_consts lthy (K false) (map fst fixes) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1413 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1414 |
(info, |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1415 |
lthy |> Local_Theory.declaration false (add_function_data o morph_function_data info)) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1416 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1417 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1418 |
((goal_state, afterqed), lthy') |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1419 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1420 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1421 |
*} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1422 |
ML {* |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1423 |
Proof.theorem; |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1424 |
Proof.refine |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1425 |
*} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1426 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1427 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1428 |
ML {* |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1429 |
fun gen_function is_external prep default_constraint fixspec eqns config lthy = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1430 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1431 |
val ((goal_state, afterqed), lthy') = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1432 |
prepare_function is_external prep default_constraint fixspec eqns config lthy |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1433 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1434 |
val _ = tracing ("goal state:\n" ^ @{make_string} goal_state) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1435 |
val _ = tracing ("concl of goal state:\n" ^ Syntax.string_of_term lthy' (concl_of goal_state)) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1436 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1437 |
lthy' |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1438 |
|> Proof.theorem NONE (snd oo afterqed) [[(Logic.unprotect (concl_of goal_state), [])]] |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1439 |
(*|> tap (fn x => tracing ("after thm:\n" ^ Pretty.string_of (Pretty.chunks (Proof.pretty_goals true x))))*) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1440 |
|> Proof.refine (Method.primitive_text (K goal_state)) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1441 |
|> Seq.hd |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1442 |
(*|> tap (fn x => tracing ("after ref:\n" ^ Pretty.string_of (Pretty.chunks (Proof.pretty_goals true x))))*) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1443 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1444 |
*} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1445 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1446 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1447 |
ML {* |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1448 |
val function = gen_function false Specification.check_spec (Type_Infer.anyT HOLogic.typeS) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1449 |
val function_cmd = gen_function true Specification.read_spec "_::type" |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1450 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1451 |
fun add_case_cong n thy = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1452 |
let |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1453 |
val cong = #case_cong (Datatype.the_info thy n) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1454 |
|> safe_mk_meta_eq |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1455 |
in |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1456 |
Context.theory_map |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1457 |
(Function_Ctx_Tree.map_function_congs (Thm.add_thm cong)) thy |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1458 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1459 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1460 |
val setup_case_cong = Datatype.interpretation (K (fold add_case_cong)) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1461 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1462 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1463 |
(* setup *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1464 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1465 |
val setup = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1466 |
Attrib.setup @{binding fundef_cong} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1467 |
(Attrib.add_del Function_Ctx_Tree.cong_add Function_Ctx_Tree.cong_del) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1468 |
"declaration of congruence rule for function definitions" |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1469 |
#> setup_case_cong |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1470 |
#> Function_Relation.setup |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1471 |
#> Function_Common.Termination_Simps.setup |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1472 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1473 |
val get_congs = Function_Ctx_Tree.get_function_congs |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1474 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1475 |
fun get_info ctxt t = Item_Net.retrieve (get_function ctxt) t |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1476 |
|> the_single |> snd |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1477 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1478 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1479 |
(* outer syntax *) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1480 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1481 |
val _ = |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1482 |
Outer_Syntax.local_theory_to_proof "nominal_primrec" "define recursive functions for nominal types" |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1483 |
Keyword.thy_goal |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1484 |
(function_parser default_config |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1485 |
>> (fn ((config, fixes), statements) => function_cmd fixes statements config)) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1486 |
*} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1487 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1488 |
ML {* trace := true *} |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1489 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1490 |
nominal_primrec |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1491 |
depth :: "lam \<Rightarrow> nat" |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1492 |
where |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1493 |
"depth (Var x) = 1" |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1494 |
| "depth (App t1 t2) = (max (depth t1) (depth t2)) + 1" |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1495 |
| "depth (Lam x t) = (depth t) + 1" |
2650
e5fa8de0e4bd
derived equivariance for the function graph and function relation
Christian Urban <urbanc@in.tum.de>
parents:
2649
diff
changeset
|
1496 |
thm depth_graph.intros |
2649
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1497 |
apply(rule_tac y="x" in lam.exhaust) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1498 |
apply(simp_all)[3] |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1499 |
apply(simp_all only: lam.distinct) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1500 |
apply(simp add: lam.eq_iff) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1501 |
apply(simp add: lam.eq_iff) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1502 |
sorry |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1503 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1504 |
nominal_primrec |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1505 |
frees :: "lam \<Rightarrow> name set" |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1506 |
where |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1507 |
"frees (Var x) = {x}" |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1508 |
| "frees (App t1 t2) = (frees t1) \<union> (frees t2)" |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1509 |
| "frees (Lam x t) = (frees t) - {x}" |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1510 |
apply(rule_tac y="x" in lam.exhaust) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1511 |
apply(simp_all)[3] |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1512 |
apply(simp_all only: lam.distinct) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1513 |
apply(simp add: lam.eq_iff) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1514 |
apply(simp add: lam.eq_iff) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1515 |
apply(simp add: lam.eq_iff) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1516 |
sorry |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1517 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1518 |
nominal_primrec |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1519 |
subst :: "lam \<Rightarrow> name \<Rightarrow> lam \<Rightarrow> lam" ("_ [_ ::= _]" [100,100,100] 100) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1520 |
where |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1521 |
"(Var x)[y ::= s] = (if x=y then s else (Var x))" |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1522 |
| "(App t\<^isub>1 t\<^isub>2)[y ::= s] = App (t\<^isub>1[y ::= s]) (t\<^isub>2[y ::= s])" |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1523 |
| "atom x \<sharp> (y, s) \<Longrightarrow> (Lam x t)[y ::= s] = Lam x (t[y ::= s])" |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1524 |
apply(case_tac x) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1525 |
apply(simp) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1526 |
apply(rule_tac y="a" and c="(b, c)" in lam.strong_exhaust) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1527 |
apply(simp_all add: lam.distinct)[3] |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1528 |
apply(auto)[1] |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1529 |
apply(auto)[1] |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1530 |
apply(simp add: fresh_star_def) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1531 |
apply(simp_all add: lam.distinct)[5] |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1532 |
apply(simp add: lam.eq_iff) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1533 |
apply(simp add: lam.eq_iff) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1534 |
apply(simp add: lam.eq_iff) |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1535 |
sorry |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1536 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1537 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1538 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1539 |
end |
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1540 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1541 |
|
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1542 |