author | Christian Urban <urbanc@in.tum.de> |
Sun, 05 Jun 2011 21:14:23 +0100 | |
changeset 2819 | 4bd584ff4fab |
parent 2781 | 542ff50555f5 |
child 2821 | c7d4bd9e89e0 |
permissions | -rw-r--r-- |
2665
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1 |
(* Nominal Mutual Functions |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
2 |
Author: Christian Urban |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
3 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
4 |
heavily based on the code of Alexander Krauss |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
5 |
(code forked on 14 January 2011) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
6 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
7 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
8 |
Mutual recursive nominal function definitions. |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
9 |
*) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
10 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
11 |
signature NOMINAL_FUNCTION_MUTUAL = |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
12 |
sig |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
13 |
|
2819
4bd584ff4fab
added an option for an invariant (at the moment only a stub)
Christian Urban <urbanc@in.tum.de>
parents:
2781
diff
changeset
|
14 |
val prepare_nominal_function_mutual : Nominal_Function_Common.nominal_function_config |
2665
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
15 |
-> string (* defname *) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
16 |
-> ((string * typ) * mixfix) list |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
17 |
-> term list |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
18 |
-> local_theory |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
19 |
-> ((thm (* goalstate *) |
2819
4bd584ff4fab
added an option for an invariant (at the moment only a stub)
Christian Urban <urbanc@in.tum.de>
parents:
2781
diff
changeset
|
20 |
* (thm -> Nominal_Function_Common.function_result) (* proof continuation *) |
2665
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
21 |
) * local_theory) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
22 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
23 |
end |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
24 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
25 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
26 |
structure Nominal_Function_Mutual: NOMINAL_FUNCTION_MUTUAL = |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
27 |
struct |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
28 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
29 |
open Function_Lib |
2819
4bd584ff4fab
added an option for an invariant (at the moment only a stub)
Christian Urban <urbanc@in.tum.de>
parents:
2781
diff
changeset
|
30 |
open Nominal_Function_Common |
2665
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
31 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
32 |
type qgar = string * (string * typ) list * term list * term list * term |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
33 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
34 |
datatype mutual_part = MutualPart of |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
35 |
{i : int, |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
36 |
i' : int, |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
37 |
fvar : string * typ, |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
38 |
cargTs: typ list, |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
39 |
f_def: term, |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
40 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
41 |
f: term option, |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
42 |
f_defthm : thm option} |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
43 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
44 |
datatype mutual_info = Mutual of |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
45 |
{n : int, |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
46 |
n' : int, |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
47 |
fsum_var : string * typ, |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
48 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
49 |
ST: typ, |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
50 |
RST: typ, |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
51 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
52 |
parts: mutual_part list, |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
53 |
fqgars: qgar list, |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
54 |
qglrs: ((string * typ) list * term list * term * term) list, |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
55 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
56 |
fsum : term option} |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
57 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
58 |
fun mutual_induct_Pnames n = |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
59 |
if n < 5 then fst (chop n ["P","Q","R","S"]) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
60 |
else map (fn i => "P" ^ string_of_int i) (1 upto n) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
61 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
62 |
fun get_part fname = |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
63 |
the o find_first (fn (MutualPart {fvar=(n,_), ...}) => n = fname) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
64 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
65 |
(* FIXME *) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
66 |
fun mk_prod_abs e (t1, t2) = |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
67 |
let |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
68 |
val bTs = rev (map snd e) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
69 |
val T1 = fastype_of1 (bTs, t1) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
70 |
val T2 = fastype_of1 (bTs, t2) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
71 |
in |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
72 |
HOLogic.pair_const T1 T2 $ t1 $ t2 |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
73 |
end |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
74 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
75 |
fun analyze_eqs ctxt defname fs eqs = |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
76 |
let |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
77 |
val num = length fs |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
78 |
val fqgars = map (split_def ctxt (K true)) eqs |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
79 |
val arity_of = map (fn (fname,_,_,args,_) => (fname, length args)) fqgars |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
80 |
|> AList.lookup (op =) #> the |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
81 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
82 |
fun curried_types (fname, fT) = |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
83 |
let |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
84 |
val (caTs, uaTs) = chop (arity_of fname) (binder_types fT) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
85 |
in |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
86 |
(caTs, uaTs ---> body_type fT) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
87 |
end |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
88 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
89 |
val (caTss, resultTs) = split_list (map curried_types fs) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
90 |
val argTs = map (foldr1 HOLogic.mk_prodT) caTss |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
91 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
92 |
val dresultTs = distinct (op =) resultTs |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
93 |
val n' = length dresultTs |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
94 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
95 |
val RST = Balanced_Tree.make (uncurry SumTree.mk_sumT) dresultTs |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
96 |
val ST = Balanced_Tree.make (uncurry SumTree.mk_sumT) argTs |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
97 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
98 |
val fsum_type = ST --> RST |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
99 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
100 |
val ([fsum_var_name], _) = Variable.add_fixes [ defname ^ "_sum" ] ctxt |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
101 |
val fsum_var = (fsum_var_name, fsum_type) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
102 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
103 |
fun define (fvar as (n, _)) caTs resultT i = |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
104 |
let |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
105 |
val vars = map_index (fn (j,T) => Free ("x" ^ string_of_int j, T)) caTs (* FIXME: Bind xs properly *) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
106 |
val i' = find_index (fn Ta => Ta = resultT) dresultTs + 1 |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
107 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
108 |
val f_exp = SumTree.mk_proj RST n' i' (Free fsum_var $ SumTree.mk_inj ST num i (foldr1 HOLogic.mk_prod vars)) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
109 |
val def = Term.abstract_over (Free fsum_var, fold_rev lambda vars f_exp) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
110 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
111 |
val rew = (n, fold_rev lambda vars f_exp) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
112 |
in |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
113 |
(MutualPart {i=i, i'=i', fvar=fvar,cargTs=caTs,f_def=def,f=NONE,f_defthm=NONE}, rew) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
114 |
end |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
115 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
116 |
val (parts, rews) = split_list (map4 define fs caTss resultTs (1 upto num)) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
117 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
118 |
fun convert_eqs (f, qs, gs, args, rhs) = |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
119 |
let |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
120 |
val MutualPart {i, i', ...} = get_part f parts |
2781
542ff50555f5
updated to new Isabelle (> 9 May)
Christian Urban <urbanc@in.tum.de>
parents:
2745
diff
changeset
|
121 |
val rhs' = rhs |
542ff50555f5
updated to new Isabelle (> 9 May)
Christian Urban <urbanc@in.tum.de>
parents:
2745
diff
changeset
|
122 |
|> map_aterms (fn t as Free (n, _) => the_default t (AList.lookup (op =) rews n) | t => t) |
2665
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
123 |
in |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
124 |
(qs, gs, SumTree.mk_inj ST num i (foldr1 (mk_prod_abs qs) args), |
2781
542ff50555f5
updated to new Isabelle (> 9 May)
Christian Urban <urbanc@in.tum.de>
parents:
2745
diff
changeset
|
125 |
Envir.beta_norm (SumTree.mk_inj RST n' i' rhs')) |
2665
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
126 |
end |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
127 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
128 |
val qglrs = map convert_eqs fqgars |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
129 |
in |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
130 |
Mutual {n=num, n'=n', fsum_var=fsum_var, ST=ST, RST=RST, |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
131 |
parts=parts, fqgars=fqgars, qglrs=qglrs, fsum=NONE} |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
132 |
end |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
133 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
134 |
fun define_projections fixes mutual fsum lthy = |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
135 |
let |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
136 |
fun def ((MutualPart {i=i, i'=i', fvar=(fname, fT), cargTs, f_def, ...}), (_, mixfix)) lthy = |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
137 |
let |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
138 |
val ((f, (_, f_defthm)), lthy') = |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
139 |
Local_Theory.define |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
140 |
((Binding.name fname, mixfix), |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
141 |
((Binding.conceal (Binding.name (fname ^ "_def")), []), |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
142 |
Term.subst_bound (fsum, f_def))) lthy |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
143 |
in |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
144 |
(MutualPart {i=i, i'=i', fvar=(fname, fT), cargTs=cargTs, f_def=f_def, |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
145 |
f=SOME f, f_defthm=SOME f_defthm }, |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
146 |
lthy') |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
147 |
end |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
148 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
149 |
val Mutual { n, n', fsum_var, ST, RST, parts, fqgars, qglrs, ... } = mutual |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
150 |
val (parts', lthy') = fold_map def (parts ~~ fixes) lthy |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
151 |
in |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
152 |
(Mutual { n=n, n'=n', fsum_var=fsum_var, ST=ST, RST=RST, parts=parts', |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
153 |
fqgars=fqgars, qglrs=qglrs, fsum=SOME fsum }, |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
154 |
lthy') |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
155 |
end |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
156 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
157 |
fun in_context ctxt (f, pre_qs, pre_gs, pre_args, pre_rhs) F = |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
158 |
let |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
159 |
val thy = ProofContext.theory_of ctxt |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
160 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
161 |
val oqnames = map fst pre_qs |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
162 |
val (qs, _) = Variable.variant_fixes oqnames ctxt |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
163 |
|>> map2 (fn (_, T) => fn n => Free (n, T)) pre_qs |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
164 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
165 |
fun inst t = subst_bounds (rev qs, t) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
166 |
val gs = map inst pre_gs |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
167 |
val args = map inst pre_args |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
168 |
val rhs = inst pre_rhs |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
169 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
170 |
val cqs = map (cterm_of thy) qs |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
171 |
val ags = map (Thm.assume o cterm_of thy) gs |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
172 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
173 |
val import = fold Thm.forall_elim cqs |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
174 |
#> fold Thm.elim_implies ags |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
175 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
176 |
val export = fold_rev (Thm.implies_intr o cprop_of) ags |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
177 |
#> fold_rev forall_intr_rename (oqnames ~~ cqs) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
178 |
in |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
179 |
F ctxt (f, qs, gs, args, rhs) import export |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
180 |
end |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
181 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
182 |
fun recover_mutual_psimp all_orig_fdefs parts ctxt (fname, _, _, args, rhs) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
183 |
import (export : thm -> thm) sum_psimp_eq = |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
184 |
let |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
185 |
val (MutualPart {f=SOME f, ...}) = get_part fname parts |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
186 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
187 |
val psimp = import sum_psimp_eq |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
188 |
val (simp, restore_cond) = |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
189 |
case cprems_of psimp of |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
190 |
[] => (psimp, I) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
191 |
| [cond] => (Thm.implies_elim psimp (Thm.assume cond), Thm.implies_intr cond) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
192 |
| _ => raise General.Fail "Too many conditions" |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
193 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
194 |
in |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
195 |
Goal.prove ctxt [] [] |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
196 |
(HOLogic.Trueprop $ HOLogic.mk_eq (list_comb (f, args), rhs)) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
197 |
(fn _ => (Local_Defs.unfold_tac ctxt all_orig_fdefs) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
198 |
THEN EqSubst.eqsubst_tac ctxt [0] [simp] 1 |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
199 |
THEN (simp_tac (simpset_of ctxt)) 1) (* FIXME: global simpset?!! *) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
200 |
|> restore_cond |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
201 |
|> export |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
202 |
end |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
203 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
204 |
fun mk_applied_form ctxt caTs thm = |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
205 |
let |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
206 |
val thy = ProofContext.theory_of ctxt |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
207 |
val xs = map_index (fn (i,T) => cterm_of thy (Free ("x" ^ string_of_int i, T))) caTs (* FIXME: Bind xs properly *) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
208 |
in |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
209 |
fold (fn x => fn thm => Thm.combination thm (Thm.reflexive x)) xs thm |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
210 |
|> Conv.fconv_rule (Thm.beta_conversion true) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
211 |
|> fold_rev Thm.forall_intr xs |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
212 |
|> Thm.forall_elim_vars 0 |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
213 |
end |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
214 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
215 |
fun mutual_induct_rules lthy induct all_f_defs (Mutual {n, ST, parts, ...}) = |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
216 |
let |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
217 |
val cert = cterm_of (ProofContext.theory_of lthy) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
218 |
val newPs = |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
219 |
map2 (fn Pname => fn MutualPart {cargTs, ...} => |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
220 |
Free (Pname, cargTs ---> HOLogic.boolT)) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
221 |
(mutual_induct_Pnames (length parts)) parts |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
222 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
223 |
fun mk_P (MutualPart {cargTs, ...}) P = |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
224 |
let |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
225 |
val avars = map_index (fn (i,T) => Var (("a", i), T)) cargTs |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
226 |
val atup = foldr1 HOLogic.mk_prod avars |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
227 |
in |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
228 |
HOLogic.tupled_lambda atup (list_comb (P, avars)) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
229 |
end |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
230 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
231 |
val Ps = map2 mk_P parts newPs |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
232 |
val case_exp = SumTree.mk_sumcases HOLogic.boolT Ps |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
233 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
234 |
val induct_inst = |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
235 |
Thm.forall_elim (cert case_exp) induct |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
236 |
|> full_simplify SumTree.sumcase_split_ss |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
237 |
|> full_simplify (HOL_basic_ss addsimps all_f_defs) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
238 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
239 |
fun project rule (MutualPart {cargTs, i, ...}) k = |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
240 |
let |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
241 |
val afs = map_index (fn (j,T) => Free ("a" ^ string_of_int (j + k), T)) cargTs (* FIXME! *) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
242 |
val inj = SumTree.mk_inj ST n i (foldr1 HOLogic.mk_prod afs) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
243 |
in |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
244 |
(rule |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
245 |
|> Thm.forall_elim (cert inj) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
246 |
|> full_simplify SumTree.sumcase_split_ss |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
247 |
|> fold_rev (Thm.forall_intr o cert) (afs @ newPs), |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
248 |
k + length cargTs) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
249 |
end |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
250 |
in |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
251 |
fst (fold_map (project induct_inst) parts 0) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
252 |
end |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
253 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
254 |
fun mk_partial_rules_mutual lthy inner_cont (m as Mutual {parts, fqgars, ...}) proof = |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
255 |
let |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
256 |
val result = inner_cont proof |
2745
34df2cffe259
ported changes from function package....needs Isabelle 16 March or above
Christian Urban <urbanc@in.tum.de>
parents:
2665
diff
changeset
|
257 |
val FunctionResult {G, R, cases, psimps, simple_pinducts=[simple_pinduct], |
2665
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
258 |
termination, domintros, ...} = result |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
259 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
260 |
val (all_f_defs, fs) = |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
261 |
map (fn MutualPart {f_defthm = SOME f_def, f = SOME f, cargTs, ...} => |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
262 |
(mk_applied_form lthy cargTs (Thm.symmetric f_def), f)) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
263 |
parts |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
264 |
|> split_list |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
265 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
266 |
val all_orig_fdefs = |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
267 |
map (fn MutualPart {f_defthm = SOME f_def, ...} => f_def) parts |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
268 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
269 |
fun mk_mpsimp fqgar sum_psimp = |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
270 |
in_context lthy fqgar (recover_mutual_psimp all_orig_fdefs parts) sum_psimp |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
271 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
272 |
val rew_ss = HOL_basic_ss addsimps all_f_defs |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
273 |
val mpsimps = map2 mk_mpsimp fqgars psimps |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
274 |
val minducts = mutual_induct_rules lthy simple_pinduct all_f_defs m |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
275 |
val mtermination = full_simplify rew_ss termination |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
276 |
val mdomintros = Option.map (map (full_simplify rew_ss)) domintros |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
277 |
in |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
278 |
FunctionResult { fs=fs, G=G, R=R, |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
279 |
psimps=mpsimps, simple_pinducts=minducts, |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
280 |
cases=cases, termination=mtermination, |
2745
34df2cffe259
ported changes from function package....needs Isabelle 16 March or above
Christian Urban <urbanc@in.tum.de>
parents:
2665
diff
changeset
|
281 |
domintros=mdomintros} |
2665
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
282 |
end |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
283 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
284 |
(* nominal *) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
285 |
fun prepare_nominal_function_mutual config defname fixes eqss lthy = |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
286 |
let |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
287 |
val mutual as Mutual {fsum_var=(n, T), qglrs, ...} = |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
288 |
analyze_eqs lthy defname (map fst fixes) (map Envir.beta_eta_contract eqss) |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
289 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
290 |
val ((fsum, goalstate, cont), lthy') = |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
291 |
Nominal_Function_Core.prepare_nominal_function config defname [((n, T), NoSyn)] qglrs lthy |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
292 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
293 |
val (mutual', lthy'') = define_projections fixes mutual fsum lthy' |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
294 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
295 |
val mutual_cont = mk_partial_rules_mutual lthy'' cont mutual' |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
296 |
in |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
297 |
((goalstate, mutual_cont), lthy'') |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
298 |
end |
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
299 |
|
16b5a67ee279
exported nominal function code to external file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
300 |
end |