2454
+ − 1
theory Nominal2
2435
+ − 2
imports
2943
+ − 3
Nominal2_Base Nominal2_Abs Nominal2_FCB
2598
+ − 4
uses ("nominal_dt_rawfuns.ML")
2435
+ − 5
("nominal_dt_alpha.ML")
+ − 6
("nominal_dt_quot.ML")
2631
e73bd379e839
removed local fix for bug in induction_schema; added setup method for strong inductions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 7
("nominal_induct.ML")
2819
+ − 8
("nominal_inductive.ML")
2822
23befefc6e73
cleaned ups a bit the examples with the invariant framework; exported nominal_function_config datatype into separate structure and file
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 9
("nominal_function_common.ML")
2665
+ − 10
("nominal_function_core.ML")
+ − 11
("nominal_mutual.ML")
+ − 12
("nominal_function.ML")
2973
d1038e67923a
added a flag (eqvt) to termination proofs arising fron nominal_primrecs
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 13
("nominal_termination.ML")
2885
1264f2a21ea9
some rudimentary infrastructure for storing data about nominal datatypes
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 14
("nominal_dt_data.ML")
1941
+ − 15
begin
+ − 16
2885
1264f2a21ea9
some rudimentary infrastructure for storing data about nominal datatypes
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 17
use "nominal_dt_data.ML"
1264f2a21ea9
some rudimentary infrastructure for storing data about nominal datatypes
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 18
ML {* open Nominal_Dt_Data *}
1264f2a21ea9
some rudimentary infrastructure for storing data about nominal datatypes
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 19
2435
+ − 20
use "nominal_dt_rawfuns.ML"
+ − 21
ML {* open Nominal_Dt_RawFuns *}
+ − 22
+ − 23
use "nominal_dt_alpha.ML"
+ − 24
ML {* open Nominal_Dt_Alpha *}
+ − 25
+ − 26
use "nominal_dt_quot.ML"
+ − 27
ML {* open Nominal_Dt_Quot *}
+ − 28
2631
e73bd379e839
removed local fix for bug in induction_schema; added setup method for strong inductions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 29
(*****************************************)
e73bd379e839
removed local fix for bug in induction_schema; added setup method for strong inductions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 30
(* setup for induction principles method *)
e73bd379e839
removed local fix for bug in induction_schema; added setup method for strong inductions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 31
use "nominal_induct.ML"
e73bd379e839
removed local fix for bug in induction_schema; added setup method for strong inductions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 32
method_setup nominal_induct =
e73bd379e839
removed local fix for bug in induction_schema; added setup method for strong inductions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 33
{* NominalInduct.nominal_induct_method *}
e73bd379e839
removed local fix for bug in induction_schema; added setup method for strong inductions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 34
{* nominal induction *}
2609
666ffc8a92a9
freshness theorem in strong exhausts; (temporarily includes a cheat_tac to make all tests go through)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 35
2639
+ − 36
(****************************************************)
+ − 37
(* inductive definition involving nominal datatypes *)
+ − 38
use "nominal_inductive.ML"
+ − 39
+ − 40
2665
+ − 41
(***************************************)
+ − 42
(* forked code of the function package *)
+ − 43
(* for defining nominal functions *)
2822
23befefc6e73
cleaned ups a bit the examples with the invariant framework; exported nominal_function_config datatype into separate structure and file
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 44
use "nominal_function_common.ML"
2665
+ − 45
use "nominal_function_core.ML"
+ − 46
use "nominal_mutual.ML"
+ − 47
use "nominal_function.ML"
2973
d1038e67923a
added a flag (eqvt) to termination proofs arising fron nominal_primrecs
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 48
use "nominal_termination.ML"
2665
+ − 49
2603
+ − 50
ML {*
+ − 51
val eqvt_attr = Attrib.internal (K Nominal_ThmDecls.eqvt_add)
+ − 52
val rsp_attr = Attrib.internal (K Quotient_Info.rsp_rules_add)
+ − 53
val simp_attr = Attrib.internal (K Simplifier.simp_add)
2787
1a6593bc494d
added eq_iff and distinct lemmas of nominal datatypes to the simplifier
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 54
val induct_attr = Attrib.internal (K Induct.induct_simp_add)
2603
+ − 55
*}
2288
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 56
1941
+ − 57
section{* Interface for nominal_datatype *}
+ − 58
2424
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 59
ML {* print_depth 50 *}
1941
+ − 60
+ − 61
ML {*
+ − 62
fun get_cnstrs dts =
+ − 63
map (fn (_, _, _, constrs) => constrs) dts
+ − 64
+ − 65
fun get_typed_cnstrs dts =
+ − 66
flat (map (fn (_, bn, _, constrs) =>
+ − 67
(map (fn (bn', _, _) => (Binding.name_of bn, Binding.name_of bn')) constrs)) dts)
+ − 68
+ − 69
fun get_cnstr_strs dts =
+ − 70
map (fn (bn, _, _) => Binding.name_of bn) (flat (get_cnstrs dts))
+ − 71
+ − 72
fun get_bn_fun_strs bn_funs =
+ − 73
map (fn (bn_fun, _, _) => Binding.name_of bn_fun) bn_funs
+ − 74
*}
+ − 75
2106
+ − 76
1944
+ − 77
text {* Infrastructure for adding "_raw" to types and terms *}
+ − 78
1941
+ − 79
ML {*
+ − 80
fun add_raw s = s ^ "_raw"
+ − 81
fun add_raws ss = map add_raw ss
+ − 82
fun raw_bind bn = Binding.suffix_name "_raw" bn
+ − 83
+ − 84
fun replace_str ss s =
+ − 85
case (AList.lookup (op=) ss s) of
+ − 86
SOME s' => s'
+ − 87
| NONE => s
+ − 88
+ − 89
fun replace_typ ty_ss (Type (a, Ts)) = Type (replace_str ty_ss a, map (replace_typ ty_ss) Ts)
+ − 90
| replace_typ ty_ss T = T
+ − 91
+ − 92
fun raw_dts ty_ss dts =
+ − 93
let
2640
75d353e8e60e
made sure the raw datatypes and raw functions do not get any mixfix syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 94
fun raw_dts_aux1 (bind, tys, _) =
75d353e8e60e
made sure the raw datatypes and raw functions do not get any mixfix syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 95
(raw_bind bind, map (replace_typ ty_ss) tys, NoSyn)
1941
+ − 96
2640
75d353e8e60e
made sure the raw datatypes and raw functions do not get any mixfix syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 97
fun raw_dts_aux2 (ty_args, bind, _, constrs) =
75d353e8e60e
made sure the raw datatypes and raw functions do not get any mixfix syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 98
(ty_args, raw_bind bind, NoSyn, map raw_dts_aux1 constrs)
1941
+ − 99
in
+ − 100
map raw_dts_aux2 dts
+ − 101
end
+ − 102
+ − 103
fun replace_aterm trm_ss (Const (a, T)) = Const (replace_str trm_ss a, T)
+ − 104
| replace_aterm trm_ss (Free (a, T)) = Free (replace_str trm_ss a, T)
+ − 105
| replace_aterm trm_ss trm = trm
+ − 106
+ − 107
fun replace_term trm_ss ty_ss trm =
+ − 108
trm |> Term.map_aterms (replace_aterm trm_ss) |> map_types (replace_typ ty_ss)
+ − 109
*}
+ − 110
+ − 111
ML {*
+ − 112
fun rawify_dts dt_names dts dts_env =
+ − 113
let
+ − 114
val raw_dts = raw_dts dts_env dts
+ − 115
val raw_dt_names = add_raws dt_names
+ − 116
in
+ − 117
(raw_dt_names, raw_dts)
+ − 118
end
+ − 119
*}
+ − 120
+ − 121
ML {*
+ − 122
fun rawify_bn_funs dts_env cnstrs_env bn_fun_env bn_funs bn_eqs =
+ − 123
let
2640
75d353e8e60e
made sure the raw datatypes and raw functions do not get any mixfix syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 124
val bn_funs' = map (fn (bn, ty, _) =>
75d353e8e60e
made sure the raw datatypes and raw functions do not get any mixfix syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 125
(raw_bind bn, SOME (replace_typ dts_env ty), NoSyn)) bn_funs
1941
+ − 126
+ − 127
val bn_eqs' = map (fn (attr, trm) =>
+ − 128
(attr, replace_term (cnstrs_env @ bn_fun_env) dts_env trm)) bn_eqs
+ − 129
in
+ − 130
(bn_funs', bn_eqs')
+ − 131
end
+ − 132
*}
+ − 133
+ − 134
ML {*
+ − 135
fun rawify_bclauses dts_env cnstrs_env bn_fun_env bclauses =
+ − 136
let
+ − 137
fun rawify_bnds bnds =
+ − 138
map (apfst (Option.map (replace_term (cnstrs_env @ bn_fun_env) dts_env))) bnds
+ − 139
2288
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 140
fun rawify_bclause (BC (mode, bnds, bdys)) = BC (mode, rawify_bnds bnds, bdys)
1941
+ − 141
in
2612
+ − 142
(map o map o map) rawify_bclause bclauses
1941
+ − 143
end
+ − 144
*}
+ − 145
+ − 146
+ − 147
ML {*
2885
1264f2a21ea9
some rudimentary infrastructure for storing data about nominal datatypes
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 148
(* definition of the raw datatype *)
1264f2a21ea9
some rudimentary infrastructure for storing data about nominal datatypes
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 149
2957
+ − 150
fun define_raw_dts dts cnstr_names cnstr_tys bn_funs bn_eqs bclauses lthy =
1941
+ − 151
let
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 152
val thy = Local_Theory.exit_global lthy
1941
+ − 153
val thy_name = Context.theory_name thy
+ − 154
+ − 155
val dt_names = map (fn (_, s, _, _) => Binding.name_of s) dts
+ − 156
val dt_full_names = map (Long_Name.qualify thy_name) dt_names
+ − 157
val dt_full_names' = add_raws dt_full_names
+ − 158
val dts_env = dt_full_names ~~ dt_full_names'
+ − 159
2633
+ − 160
val cnstr_full_names = map (Long_Name.qualify thy_name) cnstr_names
+ − 161
val cnstr_full_names' = map (fn (x, y) => Long_Name.qualify thy_name
+ − 162
(Long_Name.qualify (add_raw x) (add_raw y))) cnstr_tys
+ − 163
val cnstrs_env = cnstr_full_names ~~ cnstr_full_names'
1941
+ − 164
+ − 165
val bn_fun_strs = get_bn_fun_strs bn_funs
+ − 166
val bn_fun_strs' = add_raws bn_fun_strs
+ − 167
val bn_fun_env = bn_fun_strs ~~ bn_fun_strs'
+ − 168
val bn_fun_full_env = map (pairself (Long_Name.qualify thy_name))
+ − 169
(bn_fun_strs ~~ bn_fun_strs')
+ − 170
2957
+ − 171
val (raw_full_dt_names, raw_dts) = rawify_dts dt_names dts dts_env
1941
+ − 172
val (raw_bn_funs, raw_bn_eqs) = rawify_bn_funs dts_env cnstrs_env bn_fun_env bn_funs bn_eqs
2600
ca6b4bc7a871
kept the nested structure of constructors (belonging to one datatype)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 173
val raw_bclauses = rawify_bclauses dts_env cnstrs_env bn_fun_full_env bclauses
1941
+ − 174
2957
+ − 175
val (raw_full_dt_names', thy1) =
+ − 176
Datatype.add_datatype Datatype.default_config raw_full_dt_names raw_dts thy
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 177
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 178
val lthy1 = Named_Target.theory_init thy1
2957
+ − 179
+ − 180
val dtinfos = map (Datatype.the_info (ProofContext.theory_of lthy1)) raw_full_dt_names'
+ − 181
val {descr, sorts, ...} = hd dtinfos
+ − 182
+ − 183
val raw_tys = Datatype_Aux.get_rec_types descr sorts
+ − 184
val raw_ty_args = hd raw_tys
+ − 185
|> snd o dest_Type
+ − 186
|> map dest_TFree
+ − 187
+ − 188
val raw_cns_info = all_dtyp_constrs_types descr sorts
+ − 189
val raw_all_cns = (map o map) (fn (c, _, _, _) => c) raw_cns_info
+ − 190
+ − 191
val raw_inject_thms = flat (map #inject dtinfos)
+ − 192
val raw_distinct_thms = flat (map #distinct dtinfos)
+ − 193
val raw_induct_thm = #induct (hd dtinfos)
+ − 194
val raw_induct_thms = #inducts (hd dtinfos)
+ − 195
val raw_exhaust_thms = map #exhaust dtinfos
+ − 196
val raw_size_trms = map HOLogic.size_const raw_tys
+ − 197
val raw_size_thms = Size.size_thms (ProofContext.theory_of lthy1) (hd raw_full_dt_names')
+ − 198
|> `(fn thms => (length thms) div 2)
+ − 199
|> uncurry drop
+ − 200
+ − 201
val raw_result = RawDtInfo
+ − 202
{raw_dt_names = raw_full_dt_names',
+ − 203
raw_dts = raw_dts,
+ − 204
raw_tys = raw_tys,
+ − 205
raw_ty_args = raw_ty_args,
+ − 206
raw_cns_info = raw_cns_info,
+ − 207
raw_all_cns = raw_all_cns,
+ − 208
raw_inject_thms = raw_inject_thms,
+ − 209
raw_distinct_thms = raw_distinct_thms,
+ − 210
raw_induct_thm = raw_induct_thm,
+ − 211
raw_induct_thms = raw_induct_thms,
+ − 212
raw_exhaust_thms = raw_exhaust_thms,
+ − 213
raw_size_trms = raw_size_trms,
+ − 214
raw_size_thms = raw_size_thms}
2304
+ − 215
in
2957
+ − 216
(raw_bclauses, raw_bn_funs, raw_bn_eqs, raw_result, lthy1)
2304
+ − 217
end
+ − 218
*}
+ − 219
2125
60ee289a8c63
made out of STEPS a configuration value so that it can be set individually in each file
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 220
1941
+ − 221
ML {*
2436
+ − 222
fun nominal_datatype2 opt_thms_name dts bn_funs bn_eqs bclauses lthy =
1941
+ − 223
let
2957
+ − 224
val cnstr_names = get_cnstr_strs dts
+ − 225
val cnstr_tys = get_typed_cnstrs dts
1941
+ − 226
2957
+ − 227
val _ = trace_msg (K "Defining raw datatypes...")
+ − 228
val (raw_bclauses, raw_bn_funs, raw_bn_eqs, raw_dt_info, lthy0) =
+ − 229
define_raw_dts dts cnstr_names cnstr_tys bn_funs bn_eqs bclauses lthy
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 230
2957
+ − 231
val RawDtInfo
+ − 232
{raw_dt_names,
+ − 233
raw_tys,
+ − 234
raw_ty_args,
+ − 235
raw_all_cns,
+ − 236
raw_inject_thms,
+ − 237
raw_distinct_thms,
+ − 238
raw_induct_thm,
+ − 239
raw_induct_thms,
+ − 240
raw_exhaust_thms,
+ − 241
raw_size_trms,
+ − 242
raw_size_thms, ...} = raw_dt_info
2388
+ − 243
2647
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 244
val _ = trace_msg (K "Defining raw permutations...")
2957
+ − 245
val ((raw_perm_funs, raw_perm_simps, raw_perm_laws), lthy2a) = define_raw_perms raw_dt_info lthy0
2144
+ − 246
+ − 247
(* noting the raw permutations as eqvt theorems *)
2959
+ − 248
val lthy3 = snd (Local_Theory.note ((Binding.empty, [eqvt_attr]), raw_perm_simps) lthy2a)
2011
12ce87b55f97
tried to add some comments in the huge(!) nominal2_cmd function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 249
2647
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 250
val _ = trace_msg (K "Defining raw fv- and bn-functions...")
2922
+ − 251
val (raw_bns, raw_bn_defs, raw_bn_info, raw_bn_inducts, lthy3a) =
2957
+ − 252
define_raw_bns raw_dt_info raw_bn_funs raw_bn_eqs lthy3
2647
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 253
2560
+ − 254
(* defining the permute_bn functions *)
2561
+ − 255
val (raw_perm_bns, raw_perm_bn_simps, lthy3b) =
2957
+ − 256
define_raw_bn_perms raw_dt_info raw_bn_info lthy3a
2647
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 257
2560
+ − 258
val (raw_fvs, raw_fv_bns, raw_fv_defs, raw_fv_bns_induct, lthy3c) =
2957
+ − 259
define_raw_fvs raw_dt_info raw_bn_info raw_bclauses lthy3b
2647
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 260
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 261
val _ = trace_msg (K "Defining alpha relations...")
2928
+ − 262
val (alpha_result, lthy4) =
2957
+ − 263
define_raw_alpha raw_dt_info raw_bn_info raw_bclauses raw_fvs lthy3c
2647
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 264
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 265
val _ = trace_msg (K "Proving distinct theorems...")
2957
+ − 266
val alpha_distincts = raw_prove_alpha_distincts lthy4 alpha_result raw_dt_info
2300
+ − 267
2647
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 268
val _ = trace_msg (K "Proving eq-iff theorems...")
2957
+ − 269
val alpha_eq_iff = raw_prove_alpha_eq_iff lthy4 alpha_result raw_dt_info
2647
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 270
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 271
val _ = trace_msg (K "Proving equivariance of bns, fvs, size and alpha...")
2406
428d9cb9a243
can also lift the various eqvt lemmas for bn, fv, fv_bn and size
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 272
val raw_bn_eqvt =
2922
+ − 273
raw_prove_eqvt raw_bns raw_bn_inducts (raw_bn_defs @ raw_perm_simps) lthy4
2647
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 274
2406
428d9cb9a243
can also lift the various eqvt lemmas for bn, fv, fv_bn and size
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 275
(* noting the raw_bn_eqvt lemmas in a temprorary theory *)
2448
+ − 276
val lthy_tmp = snd (Local_Theory.note ((Binding.empty, [eqvt_attr]), raw_bn_eqvt) lthy4)
2305
+ − 277
2406
428d9cb9a243
can also lift the various eqvt lemmas for bn, fv, fv_bn and size
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 278
val raw_fv_eqvt =
2647
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 279
raw_prove_eqvt (raw_fvs @ raw_fv_bns) raw_fv_bns_induct (raw_fv_defs @ raw_perm_simps)
2388
+ − 280
(Local_Theory.restore lthy_tmp)
2647
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 281
2957
+ − 282
val raw_size_eqvt =
+ − 283
let
+ − 284
val RawDtInfo {raw_size_trms, raw_size_thms, raw_induct_thms, ...} = raw_dt_info
+ − 285
in
+ − 286
raw_prove_eqvt raw_size_trms raw_induct_thms (raw_size_thms @ raw_perm_simps)
+ − 287
(Local_Theory.restore lthy_tmp)
+ − 288
|> map (rewrite_rule @{thms permute_nat_def[THEN eq_reflection]})
+ − 289
|> map (fn thm => thm RS @{thm sym})
+ − 290
end
2647
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 291
2448
+ − 292
val lthy5 = snd (Local_Theory.note ((Binding.empty, [eqvt_attr]), raw_fv_eqvt) lthy_tmp)
2306
+ − 293
2868
+ − 294
val alpha_eqvt =
2928
+ − 295
let
+ − 296
val AlphaResult {alpha_trms, alpha_bn_trms, alpha_raw_induct, alpha_intros, ...} = alpha_result
+ − 297
in
+ − 298
Nominal_Eqvt.raw_equivariance (alpha_trms @ alpha_bn_trms) alpha_raw_induct alpha_intros lthy5
+ − 299
end
2868
+ − 300
+ − 301
val alpha_eqvt_norm = map (Nominal_ThmDecls.eqvt_transform lthy5) alpha_eqvt
2311
+ − 302
2647
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 303
val _ = trace_msg (K "Proving equivalence of alpha...")
2927
116f9ba4f59f
combined distributed data for alpha in alpha_result (partially done)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 304
val alpha_refl_thms = raw_prove_refl lthy5 alpha_result raw_induct_thm
116f9ba4f59f
combined distributed data for alpha in alpha_result (partially done)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 305
val alpha_sym_thms = raw_prove_sym lthy5 alpha_result alpha_eqvt_norm
116f9ba4f59f
combined distributed data for alpha in alpha_result (partially done)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 306
val alpha_trans_thms =
116f9ba4f59f
combined distributed data for alpha in alpha_result (partially done)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 307
raw_prove_trans lthy5 alpha_result (raw_distinct_thms @ raw_inject_thms) alpha_eqvt_norm
2311
+ − 308
2404
+ − 309
val (alpha_equivp_thms, alpha_bn_equivp_thms) =
2927
116f9ba4f59f
combined distributed data for alpha in alpha_result (partially done)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 310
raw_prove_equivp lthy5 alpha_result alpha_refl_thms alpha_sym_thms alpha_trans_thms
2322
+ − 311
2647
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 312
val _ = trace_msg (K "Proving alpha implies bn...")
2928
+ − 313
val alpha_bn_imp_thms = raw_prove_bn_imp lthy5 alpha_result
2922
+ − 314
2647
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 315
val _ = trace_msg (K "Proving respectfulness...")
2438
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 316
val raw_funs_rsp_aux =
2928
+ − 317
raw_fv_bn_rsp_aux lthy5 alpha_result raw_fvs raw_bns raw_fv_bns (raw_bn_defs @ raw_fv_defs)
2438
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 318
2647
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 319
val raw_funs_rsp = map mk_funs_rsp raw_funs_rsp_aux
2388
+ − 320
2438
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 321
val raw_size_rsp =
2928
+ − 322
raw_size_rsp_aux lthy5 alpha_result (raw_size_thms @ raw_size_eqvt)
2438
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 323
|> map mk_funs_rsp
2392
+ − 324
2438
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 325
val raw_constrs_rsp =
2957
+ − 326
raw_constrs_rsp lthy5 alpha_result (flat raw_all_cns) (alpha_bn_imp_thms @ raw_funs_rsp_aux)
2647
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 327
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 328
val alpha_permute_rsp = map mk_alpha_permute_rsp alpha_eqvt
2384
+ − 329
2438
abafea9b39bb
corrected bug with fv-function generation (that was the problem with recursive binders)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 330
val alpha_bn_rsp =
2928
+ − 331
raw_alpha_bn_rsp alpha_result alpha_bn_equivp_thms alpha_bn_imp_thms
2404
+ − 332
2966
+ − 333
val raw_perm_bn_rsp = raw_perm_bn_rsp lthy5 alpha_result raw_perm_bns raw_perm_bn_simps
2561
+ − 334
2398
+ − 335
(* noting the quot_respects lemmas *)
2868
+ − 336
val (_, lthy6) =
2647
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 337
Local_Theory.note ((Binding.empty, [rsp_attr]),
2561
+ − 338
raw_constrs_rsp @ raw_funs_rsp @ raw_size_rsp @ alpha_permute_rsp @
2868
+ − 339
alpha_bn_rsp @ raw_perm_bn_rsp) lthy5
2398
+ − 340
2647
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 341
val _ = trace_msg (K "Defining the quotient types...")
2336
+ − 342
val qty_descr = map (fn (vs, bind, mx, _) => (vs, bind, mx)) dts
2400
+ − 343
2336
+ − 344
val (qty_infos, lthy7) =
2928
+ − 345
let
+ − 346
val AlphaResult {alpha_trms, alpha_tys, ...} = alpha_result
+ − 347
in
+ − 348
define_qtypes qty_descr alpha_tys alpha_trms alpha_equivp_thms lthy6
+ − 349
end
2336
+ − 350
+ − 351
val qtys = map #qtyp qty_infos
2400
+ − 352
val qty_full_names = map (fst o dest_Type) qtys
+ − 353
val qty_names = map Long_Name.base_name qty_full_names
+ − 354
2647
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 355
val _ = trace_msg (K "Defining the quotient constants...")
2600
ca6b4bc7a871
kept the nested structure of constructors (belonging to one datatype)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 356
val qconstrs_descrs =
2957
+ − 357
(map2 o map2) (fn (b, _, mx) => fn t => (Variable.check_name b, t, mx)) (get_cnstrs dts) raw_all_cns
2338
+ − 358
2339
+ − 359
val qbns_descr =
2781
+ − 360
map2 (fn (b, _, mx) => fn t => (Variable.check_name b, t, mx)) bn_funs raw_bns
2339
+ − 361
+ − 362
val qfvs_descr =
2346
+ − 363
map2 (fn n => fn t => ("fv_" ^ n, t, NoSyn)) qty_names raw_fvs
2339
+ − 364
2346
+ − 365
val qfv_bns_descr =
2781
+ − 366
map2 (fn (b, _, _) => fn t => ("fv_" ^ Variable.check_name b, t, NoSyn)) bn_funs raw_fv_bns
2339
+ − 367
2384
+ − 368
val qalpha_bns_descr =
2928
+ − 369
let
+ − 370
val AlphaResult {alpha_bn_trms, ...} = alpha_result
+ − 371
in
+ − 372
map2 (fn (b, _, _) => fn t => ("alpha_" ^ Variable.check_name b, t, NoSyn)) bn_funs alpha_bn_trms
+ − 373
end
2384
+ − 374
2398
+ − 375
val qperm_descr =
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 376
map2 (fn n => fn t => ("permute_" ^ n, Type.legacy_freeze t, NoSyn)) qty_names raw_perm_funs
2398
+ − 377
2400
+ − 378
val qsize_descr =
+ − 379
map2 (fn n => fn t => ("size_" ^ n, t, NoSyn)) qty_names raw_size_trms
+ − 380
2562
+ − 381
val qperm_bn_descr =
2781
+ − 382
map2 (fn (b, _, _) => fn t => ("permute_" ^ Variable.check_name b, t, NoSyn)) bn_funs raw_perm_bns
2562
+ − 383
2600
ca6b4bc7a871
kept the nested structure of constructors (belonging to one datatype)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 384
val ((((((qconstrs_infos, qbns_info), qfvs_info), qfv_bns_info), qalpha_bns_info), qperm_bns_info),
ca6b4bc7a871
kept the nested structure of constructors (belonging to one datatype)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 385
lthy8) =
2346
+ − 386
lthy7
2600
ca6b4bc7a871
kept the nested structure of constructors (belonging to one datatype)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 387
|> fold_map (define_qconsts qtys) qconstrs_descrs
2400
+ − 388
||>> define_qconsts qtys qbns_descr
+ − 389
||>> define_qconsts qtys qfvs_descr
+ − 390
||>> define_qconsts qtys qfv_bns_descr
+ − 391
||>> define_qconsts qtys qalpha_bns_descr
2562
+ − 392
||>> define_qconsts qtys qperm_bn_descr
2338
+ − 393
2400
+ − 394
val lthy9 =
2957
+ − 395
define_qperms qtys qty_full_names raw_ty_args qperm_descr raw_perm_laws lthy8
2400
+ − 396
2401
7645e18e8b19
modified the code for class instantiations (with help from Florian)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 397
val lthy9a =
2957
+ − 398
define_qsizes qtys qty_full_names raw_ty_args qsize_descr lthy9
2398
+ − 399
2612
+ − 400
val qtrms = (map o map) #qconst qconstrs_infos
2346
+ − 401
val qbns = map #qconst qbns_info
+ − 402
val qfvs = map #qconst qfvs_info
+ − 403
val qfv_bns = map #qconst qfv_bns_info
2384
+ − 404
val qalpha_bns = map #qconst qalpha_bns_info
2593
25dcb2b1329e
ordered raw_bn_info to agree with the order of the raw_bn_functions; started alpha_bn proof
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 405
val qperm_bns = map #qconst qperm_bns_info
2434
+ − 406
2649
a8ebcb368a15
a modified function package where, as a test, True has been injected into the compatibility condictions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 407
val _ = trace_msg (K "Lifting of theorems...")
2559
add799cf0817
adapted to changes by Florian on the quotient package and removed local fix for function package
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 408
val eq_iff_simps = @{thms alphas permute_prod.simps prod_fv.simps prod_alpha_def prod_rel_def
2434
+ − 409
prod.cases}
+ − 410
2959
+ − 411
val ([ qdistincts, qeq_iffs, qfv_defs, qbn_defs, qperm_simps, qfv_qbn_eqvts,
+ − 412
qbn_inducts, qsize_eqvt, [qinduct], qexhausts, qsize_simps, qperm_bn_simps,
2966
+ − 413
qalpha_refl_thms, qalpha_sym_thms, qalpha_trans_thms ], lthyB) =
2647
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 414
lthy9a
2959
+ − 415
|>>> lift_thms qtys [] alpha_distincts
+ − 416
||>>> lift_thms qtys eq_iff_simps alpha_eq_iff
+ − 417
||>>> lift_thms qtys [] raw_fv_defs
+ − 418
||>>> lift_thms qtys [] raw_bn_defs
+ − 419
||>>> lift_thms qtys [] raw_perm_simps
+ − 420
||>>> lift_thms qtys [] (raw_fv_eqvt @ raw_bn_eqvt)
+ − 421
||>>> lift_thms qtys [] raw_bn_inducts
+ − 422
||>>> lift_thms qtys [] raw_size_eqvt
+ − 423
||>>> lift_thms qtys [] [raw_induct_thm]
+ − 424
||>>> lift_thms qtys [] raw_exhaust_thms
+ − 425
||>>> lift_thms qtys [] raw_size_thms
+ − 426
||>>> lift_thms qtys [] raw_perm_bn_simps
+ − 427
||>>> lift_thms qtys [] alpha_refl_thms
2966
+ − 428
||>>> lift_thms qtys [] alpha_sym_thms
+ − 429
||>>> lift_thms qtys [] alpha_trans_thms
2434
+ − 430
2922
+ − 431
val qinducts = Project_Rule.projections lthyB qinduct
2474
+ − 432
2647
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 433
val _ = trace_msg (K "Proving supp lemmas and fs-instances...")
2959
+ − 434
val qsupports_thms = prove_supports lthyB qperm_simps (flat qtrms)
2448
+ − 435
2451
+ − 436
(* finite supp lemmas *)
2647
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 437
val qfsupp_thms = prove_fsupp lthyB qtys qinduct qsupports_thms
2450
+ − 438
2451
+ − 439
(* fs instances *)
2957
+ − 440
val lthyC = fs_instance qtys qty_full_names raw_ty_args qfsupp_thms lthyB
2448
+ − 441
2647
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 442
val _ = trace_msg (K "Proving equality between fv and supp...")
2475
486d4647bb37
supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 443
val qfv_supp_thms =
2647
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 444
prove_fv_supp qtys (flat qtrms) qfvs qfv_bns qalpha_bns qfv_defs qeq_iffs
2481
3a5ebb2fcdbf
made supp proofs more robust by not using the standard induction; renamed some example files
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 445
qperm_simps qfv_qbn_eqvts qinduct (flat raw_bclauses) lthyC
2475
486d4647bb37
supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 446
2492
5ac9a74d22fd
post-processed eq_iff and supp threormes according to the fv-supp equality
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 447
(* postprocessing of eq and fv theorems *)
5ac9a74d22fd
post-processed eq_iff and supp threormes according to the fv-supp equality
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 448
val qeq_iffs' = qeq_iffs
2493
+ − 449
|> map (simplify (HOL_basic_ss addsimps qfv_supp_thms))
+ − 450
|> map (simplify (HOL_basic_ss addsimps @{thms prod_fv_supp prod_alpha_eq Abs_eq_iff[symmetric]}))
2492
5ac9a74d22fd
post-processed eq_iff and supp threormes according to the fv-supp equality
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 451
5ac9a74d22fd
post-processed eq_iff and supp threormes according to the fv-supp equality
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 452
val qsupp_constrs = qfv_defs
5ac9a74d22fd
post-processed eq_iff and supp threormes according to the fv-supp equality
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 453
|> map (simplify (HOL_basic_ss addsimps (take (length qfvs) qfv_supp_thms)))
5ac9a74d22fd
post-processed eq_iff and supp threormes according to the fv-supp equality
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 454
2493
+ − 455
val transform_thm = @{lemma "x = y \<Longrightarrow> a \<notin> x \<longleftrightarrow> a \<notin> y" by simp}
+ − 456
val transform_thms =
+ − 457
[ @{lemma "a \<notin> (S \<union> T) \<longleftrightarrow> a \<notin> S \<and> a \<notin> T" by simp},
+ − 458
@{lemma "a \<notin> (S - T) \<longleftrightarrow> a \<notin> S \<or> a \<in> T" by simp},
+ − 459
@{lemma "(lhs = (a \<notin> {})) \<longleftrightarrow> lhs" by simp},
+ − 460
@{thm fresh_def[symmetric]}]
+ − 461
+ − 462
val qfresh_constrs = qsupp_constrs
+ − 463
|> map (fn thm => thm RS transform_thm)
+ − 464
|> map (simplify (HOL_basic_ss addsimps transform_thms))
+ − 465
2593
25dcb2b1329e
ordered raw_bn_info to agree with the order of the raw_bn_functions; started alpha_bn proof
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 466
(* proving that the qbn result is finite *)
2647
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 467
val qbn_finite_thms = prove_bns_finite qtys qbns qinduct qbn_defs lthyC
2593
25dcb2b1329e
ordered raw_bn_info to agree with the order of the raw_bn_functions; started alpha_bn proof
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 468
25dcb2b1329e
ordered raw_bn_info to agree with the order of the raw_bn_functions; started alpha_bn proof
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 469
(* proving that perm_bns preserve alpha *)
2594
+ − 470
val qperm_bn_alpha_thms =
2647
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 471
prove_perm_bn_alpha_thms qtys qperm_bns qalpha_bns qinduct qperm_bn_simps qeq_iffs'
2594
+ − 472
qalpha_refl_thms lthyC
2493
+ − 473
2598
+ − 474
(* proving the relationship of bn and permute_bn *)
+ − 475
val qpermute_bn_thms =
2647
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 476
prove_permute_bn_thms qtys qbns qperm_bns qinduct qperm_bn_simps qbn_defs qfv_qbn_eqvts lthyC
2598
+ − 477
2647
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 478
val _ = trace_msg (K "Proving strong exhaust lemmas...")
2619
+ − 479
val qstrong_exhaust_thms = prove_strong_exhausts lthyC qexhausts bclauses qbn_finite_thms qeq_iffs'
2616
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 480
qfv_qbn_eqvts qpermute_bn_thms qperm_bn_alpha_thms
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 481
2647
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 482
val _ = trace_msg (K "Proving strong induct lemmas...")
2633
+ − 483
val qstrong_induct_thms = prove_strong_induct lthyC qinduct qstrong_exhaust_thms qsize_simps bclauses
2628
+ − 484
2436
+ − 485
(* noting the theorems *)
+ − 486
+ − 487
(* generating the prefix for the theorem names *)
+ − 488
val thms_name =
+ − 489
the_default (Binding.name (space_implode "_" qty_names)) opt_thms_name
+ − 490
fun thms_suffix s = Binding.qualified true s thms_name
2633
+ − 491
val case_names_attr = Attrib.internal (K (Rule_Cases.case_names cnstr_names))
2436
+ − 492
2885
1264f2a21ea9
some rudimentary infrastructure for storing data about nominal datatypes
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 493
val infos = mk_infos qty_full_names qeq_iffs' qdistincts qstrong_exhaust_thms qstrong_induct_thms
1264f2a21ea9
some rudimentary infrastructure for storing data about nominal datatypes
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 494
2451
+ − 495
val (_, lthy9') = lthyC
2885
1264f2a21ea9
some rudimentary infrastructure for storing data about nominal datatypes
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 496
|> Local_Theory.declaration false (K (fold register_info infos))
2787
1a6593bc494d
added eq_iff and distinct lemmas of nominal datatypes to the simplifier
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 497
|> Local_Theory.note ((thms_suffix "distinct", [induct_attr, simp_attr]), qdistincts)
1a6593bc494d
added eq_iff and distinct lemmas of nominal datatypes to the simplifier
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 498
||>> Local_Theory.note ((thms_suffix "eq_iff", [induct_attr, simp_attr]), qeq_iffs')
2436
+ − 499
||>> Local_Theory.note ((thms_suffix "fv_defs", []), qfv_defs)
+ − 500
||>> Local_Theory.note ((thms_suffix "bn_defs", []), qbn_defs)
2922
+ − 501
||>> Local_Theory.note ((thms_suffix "bn_inducts", []), qbn_inducts)
2448
+ − 502
||>> Local_Theory.note ((thms_suffix "perm_simps", [eqvt_attr, simp_attr]), qperm_simps)
2922
+ − 503
||>> Local_Theory.note ((thms_suffix "fv_bn_eqvt", [eqvt_attr]), qfv_qbn_eqvts)
2858
de6b601c8d3d
added size-lemmas to simplifier; as a result termination can be proved by the standard lexicographic_order method
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 504
||>> Local_Theory.note ((thms_suffix "size", [simp_attr]), qsize_simps)
2436
+ − 505
||>> Local_Theory.note ((thms_suffix "size_eqvt", []), qsize_eqvt)
2633
+ − 506
||>> Local_Theory.note ((thms_suffix "induct", [case_names_attr]), [qinduct])
+ − 507
||>> Local_Theory.note ((thms_suffix "inducts", [case_names_attr]), qinducts)
+ − 508
||>> Local_Theory.note ((thms_suffix "exhaust", [case_names_attr]), qexhausts)
+ − 509
||>> Local_Theory.note ((thms_suffix "strong_exhaust", [case_names_attr]), qstrong_exhaust_thms)
+ − 510
||>> Local_Theory.note ((thms_suffix "strong_induct", [case_names_attr]), qstrong_induct_thms)
2448
+ − 511
||>> Local_Theory.note ((thms_suffix "supports", []), qsupports_thms)
2450
+ − 512
||>> Local_Theory.note ((thms_suffix "fsupp", []), qfsupp_thms)
2492
5ac9a74d22fd
post-processed eq_iff and supp threormes according to the fv-supp equality
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 513
||>> Local_Theory.note ((thms_suffix "supp", []), qsupp_constrs)
2493
+ − 514
||>> Local_Theory.note ((thms_suffix "fresh", []), qfresh_constrs)
2563
+ − 515
||>> Local_Theory.note ((thms_suffix "perm_bn_simps", []), qperm_bn_simps)
2571
+ − 516
||>> Local_Theory.note ((thms_suffix "bn_finite", []), qbn_finite_thms)
2593
25dcb2b1329e
ordered raw_bn_info to agree with the order of the raw_bn_functions; started alpha_bn proof
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 517
||>> Local_Theory.note ((thms_suffix "perm_bn_alpha", []), qperm_bn_alpha_thms)
2598
+ − 518
||>> Local_Theory.note ((thms_suffix "permute_bn", []), qpermute_bn_thms)
2966
+ − 519
||>> Local_Theory.note ((thms_suffix "alpha_refl", []), qalpha_refl_thms)
+ − 520
||>> Local_Theory.note ((thms_suffix "alpha_sym", []), qalpha_sym_thms)
+ − 521
||>> Local_Theory.note ((thms_suffix "alpha_trans", []), qalpha_trans_thms)
+ − 522
1941
+ − 523
in
2601
+ − 524
lthy9'
2647
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 525
end
1941
+ − 526
*}
+ − 527
2475
486d4647bb37
supp-proofs work except for CoreHaskell and Modules (induct is probably not finding the correct instance)
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 528
1941
+ − 529
section {* Preparing and parsing of the specification *}
+ − 530
+ − 531
ML {*
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 532
(* generates the parsed datatypes and
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 533
declares the constructors
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 534
*)
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 535
fun prepare_dts dt_strs thy =
1941
+ − 536
let
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 537
fun inter_fs_sort thy (a, S) =
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 538
(a, Type.inter_sort (Sign.tsig_of thy) (@{sort fs}, S))
1941
+ − 539
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 540
fun mk_type tname sorts (cname, cargs, mx) =
1941
+ − 541
let
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 542
val full_tname = Sign.full_name thy tname
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 543
val ty = Type (full_tname, map (TFree o inter_fs_sort thy) sorts)
1941
+ − 544
in
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 545
(cname, cargs ---> ty, mx)
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 546
end
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 547
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 548
fun prep_constr (cname, cargs, mx, _) (constrs, sorts) =
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 549
let
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 550
val (cargs', sorts') =
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 551
fold_map (Datatype.read_typ thy) (map snd cargs) sorts
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 552
|>> map (map_type_tfree (TFree o inter_fs_sort thy))
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 553
in
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 554
(constrs @ [(cname, cargs', mx)], sorts')
1941
+ − 555
end
+ − 556
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 557
fun prep_dts (tvs, tname, mx, constrs) (constr_trms, dts, sorts) =
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 558
let
2959
+ − 559
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 560
val (constrs', sorts') =
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 561
fold prep_constr constrs ([], sorts)
1941
+ − 562
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 563
val constr_trms' =
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 564
map (mk_type tname (rev sorts')) constrs'
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 565
in
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 566
(constr_trms @ constr_trms', dts @ [(tvs, tname, mx, constrs')], sorts')
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 567
end
2425
+ − 568
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 569
val (constr_trms, dts, sorts) = fold prep_dts dt_strs ([], [], []);
1941
+ − 570
in
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 571
thy
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 572
|> Sign.add_consts_i constr_trms
1941
+ − 573
|> pair dts
+ − 574
end
+ − 575
*}
+ − 576
+ − 577
ML {*
+ − 578
(* parsing the binding function specification and *)
+ − 579
(* declaring the functions in the local theory *)
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 580
fun prepare_bn_funs bn_fun_strs bn_eq_strs thy =
1941
+ − 581
let
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 582
val lthy = Named_Target.theory_init thy
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 583
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 584
val ((bn_funs, bn_eqs), lthy') =
1941
+ − 585
Specification.read_spec bn_fun_strs bn_eq_strs lthy
+ − 586
+ − 587
fun prep_bn_fun ((bn, T), mx) = (bn, T, mx)
+ − 588
+ − 589
val bn_funs' = map prep_bn_fun bn_funs
+ − 590
in
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 591
(Local_Theory.exit_global lthy')
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 592
|> Sign.add_consts_i bn_funs'
1941
+ − 593
|> pair (bn_funs', bn_eqs)
+ − 594
end
+ − 595
*}
+ − 596
+ − 597
text {* associates every SOME with the index in the list; drops NONEs *}
+ − 598
ML {*
+ − 599
fun indexify xs =
+ − 600
let
+ − 601
fun mapp _ [] = []
+ − 602
| mapp i (NONE :: xs) = mapp (i + 1) xs
+ − 603
| mapp i (SOME x :: xs) = (x, i) :: mapp (i + 1) xs
+ − 604
in
+ − 605
mapp 0 xs
+ − 606
end
+ − 607
+ − 608
fun index_lookup xs x =
+ − 609
case AList.lookup (op=) xs x of
+ − 610
SOME x => x
+ − 611
| NONE => error ("Cannot find " ^ x ^ " as argument annotation.");
+ − 612
*}
+ − 613
+ − 614
ML {*
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 615
fun prepare_bclauses dt_strs thy =
1941
+ − 616
let
+ − 617
val annos_bclauses =
+ − 618
get_cnstrs dt_strs
2612
+ − 619
|> (map o map) (fn (_, antys, _, bns) => (map fst antys, bns))
1941
+ − 620
+ − 621
fun prep_binder env bn_str =
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 622
case (Syntax.read_term_global thy bn_str) of
1941
+ − 623
Free (x, _) => (NONE, index_lookup env x)
+ − 624
| Const (a, T) $ Free (x, _) => (SOME (Const (a, T)), index_lookup env x)
+ − 625
| _ => error ("The term " ^ bn_str ^ " is not allowed as binding function.")
+ − 626
+ − 627
fun prep_body env bn_str = index_lookup env bn_str
+ − 628
+ − 629
fun prep_bclause env (mode, binders, bodies) =
+ − 630
let
+ − 631
val binders' = map (prep_binder env) binders
+ − 632
val bodies' = map (prep_body env) bodies
+ − 633
in
2424
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 634
BC (mode, binders', bodies')
1941
+ − 635
end
+ − 636
+ − 637
fun prep_bclauses (annos, bclause_strs) =
+ − 638
let
+ − 639
val env = indexify annos (* for every label, associate the index *)
+ − 640
in
+ − 641
map (prep_bclause env) bclause_strs
+ − 642
end
+ − 643
in
2612
+ − 644
((map o map) prep_bclauses annos_bclauses, thy)
1941
+ − 645
end
+ − 646
*}
+ − 647
1943
+ − 648
text {*
+ − 649
adds an empty binding clause for every argument
+ − 650
that is not already part of a binding clause
+ − 651
*}
+ − 652
1941
+ − 653
ML {*
+ − 654
fun included i bcs =
+ − 655
let
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 656
fun incl (BC (_, bns, bds)) =
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 657
member (op =) (map snd bns) i orelse member (op =) bds i
1941
+ − 658
in
+ − 659
exists incl bcs
+ − 660
end
+ − 661
*}
+ − 662
+ − 663
ML {*
+ − 664
fun complete dt_strs bclauses =
+ − 665
let
+ − 666
val args =
+ − 667
get_cnstrs dt_strs
2612
+ − 668
|> (map o map) (fn (_, antys, _, _) => length antys)
1941
+ − 669
+ − 670
fun complt n bcs =
+ − 671
let
2288
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 672
fun add bcs i = (if included i bcs then [] else [BC (Lst, [], [i])])
1941
+ − 673
in
+ − 674
bcs @ (flat (map_range (add bcs) n))
+ − 675
end
+ − 676
in
2616
dd7490fdd998
all examples for strong exhausts work; recursive binders need to be treated differently; still unclean version with lots of diagnostic code
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 677
(map2 o map2) complt args bclauses
1941
+ − 678
end
+ − 679
*}
+ − 680
+ − 681
ML {*
2436
+ − 682
fun nominal_datatype2_cmd (opt_thms_name, dt_strs, bn_fun_strs, bn_eq_strs) lthy =
1941
+ − 683
let
2436
+ − 684
val pre_typs =
+ − 685
map (fn (tvs, tname, mx, _) => (tname, length tvs, mx)) dt_strs
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 686
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 687
(* this theory is used just for parsing *)
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 688
val thy = ProofContext.theory_of lthy
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 689
val tmp_thy = Theory.copy thy
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 690
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 691
val (((dts, (bn_funs, bn_eqs)), bclauses), tmp_thy') =
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 692
tmp_thy
2770
+ − 693
|> Sign.add_types_global pre_typs
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 694
|> prepare_dts dt_strs
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 695
||>> prepare_bn_funs bn_fun_strs bn_eq_strs
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 696
||>> prepare_bclauses dt_strs
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 697
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 698
val bclauses' = complete dt_strs bclauses
1941
+ − 699
in
2679
+ − 700
nominal_datatype2 opt_thms_name dts bn_funs bn_eqs bclauses' lthy
1941
+ − 701
end
2424
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 702
*}
1941
+ − 703
2424
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 704
ML {*
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 705
(* nominal datatype parser *)
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 706
local
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 707
structure P = Parse;
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 708
structure S = Scan
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 709
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 710
fun triple ((x, y), z) = (x, y, z)
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 711
fun tuple1 ((x, y, z), u) = (x, y, z, u)
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 712
fun tuple2 (((x, y), z), u) = (x, y, u, z)
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 713
fun tuple3 ((x, y), (z, u)) = (x, y, z, u)
2424
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 714
in
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 715
2950
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 716
val _ = Keyword.keyword "binds"
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 717
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 718
val opt_name = Scan.option (P.binding --| Args.colon)
2424
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 719
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 720
val anno_typ = S.option (P.name --| P.$$$ "::") -- P.typ
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 721
2950
0911cb7bf696
changed bind to binds in specifications; bind will cause trouble with Monad_Syntax
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 722
val bind_mode = P.$$$ "binds" |--
2424
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 723
S.optional (Args.parens
2634
3ce1089cdbf3
changed res keyword to set+ for restrictions; comment by a referee
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 724
(Args.$$$ "list" >> K Lst || (Args.$$$ "set" -- Args.$$$ "+") >> K Res || Args.$$$ "set" >> K Set)) Lst
2424
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 725
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 726
val bind_clauses =
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 727
P.enum "," (bind_mode -- S.repeat1 P.term -- (P.$$$ "in" |-- S.repeat1 P.name) >> triple)
2424
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 728
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 729
val cnstr_parser =
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 730
P.binding -- S.repeat anno_typ -- bind_clauses -- P.opt_mixfix >> tuple2
2424
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 731
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 732
(* datatype parser *)
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 733
val dt_parser =
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 734
(P.type_args -- P.binding -- P.opt_mixfix >> triple) --
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 735
(P.$$$ "=" |-- P.enum1 "|" cnstr_parser) >> tuple1
2424
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 736
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 737
(* binding function parser *)
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 738
val bnfun_parser =
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 739
S.optional (P.$$$ "binder" |-- P.fixes -- Parse_Spec.where_alt_specs) ([], [])
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 740
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 741
(* main parser *)
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 742
val main_parser =
2431
331873ebc5cd
can now deal with type variables in nominal datatype definitions
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 743
opt_name -- P.and_list1 dt_parser -- bnfun_parser >> tuple3
2424
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 744
621ebd8b13c4
changed parser so that the binding mode is indicated as "bind (list)", "bind (set)" or "bind (res)"; if only "bind" is given, then bind (list) is assumed as default
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 745
end
1941
+ − 746
+ − 747
(* Command Keyword *)
2168
+ − 748
val _ = Outer_Syntax.local_theory "nominal_datatype" "test" Keyword.thy_decl
1941
+ − 749
(main_parser >> nominal_datatype2_cmd)
+ − 750
*}
+ − 751
2679
+ − 752
(*
2647
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 753
ML {*
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 754
trace := true
5e95387bef45
removed debugging code abd introduced a guarded tracing function
Christian Urban <urbanc@in.tum.de>
diff
changeset
+ − 755
*}
2679
+ − 756
*)
2292
+ − 757
1941
+ − 758
end
+ − 759
+ − 760
+ − 761