Skip to content

Commit 6c5946d

Browse files
committed
Allow to disable automatic equivariance proof
1 parent 60c5b35 commit 6c5946d

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

Tools/binder_inductive.ML

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ fun collapse (Inl x) = x
2121
fun mk_insert x S =
2222
Const (@{const_name Set.insert}, fastype_of x --> fastype_of S --> fastype_of S) $ x $ S;
2323

24-
fun binder_inductive_cmd ((pred_name, binds_opt), perms_supps) no_defs_lthy =
24+
datatype options = No_Equiv | No_Refresh
25+
26+
fun binder_inductive_cmd (((options, pred_name), binds_opt), perms_supps) no_defs_lthy =
2527
let
2628
val binds = the_default [] binds_opt;
2729
val ({names, ...}, { def, preds, mono, induct, intrs, ... }) = Inductive.the_inductive_global no_defs_lthy (long_name no_defs_lthy pred_name);
@@ -370,12 +372,14 @@ fun binder_inductive_cmd ((pred_name, binds_opt), perms_supps) no_defs_lthy =
370372
fun keep_both xs = cond_keep xs one_specified;
371373
fun keep_binders xs = cond_keep xs binders_specified;
372374

375+
fun option x t f = if member (op=) options x then t else f;
376+
373377
val defs = map snd (perms @ supps);
374378

375379
val goals = map (single o rpair []) (
376380
keep_perm perm_id0_goals @ keep_perm perm_comp_goals @ keep_both supp_seminat_goals
377381
@ keep_both perm_support_goals @ keep_supp supp_small_goals @ flat (keep_binders B_small_goals)
378-
@ [G_refresh_goal]
382+
@ option No_Equiv [G_equiv_goal] [] @ [G_refresh_goal]
379383
);
380384
fun after_qed thmss lthy =
381385
let
@@ -426,13 +430,14 @@ fun binder_inductive_cmd ((pred_name, binds_opt), perms_supps) no_defs_lthy =
426430
val m2 = length (filter not one_specified);
427431
val m3 = length (filter not supps_specified);
428432
val m4 = length (filter not binders_specified);
429-
val ((((((perm_id0s, perm_comps), supp_seminats), perm_supports), supp_smalls), B_smalls), G_refresh) = map hd thmss
433+
val (((((((perm_id0s, perm_comps), supp_seminats), perm_supports), supp_smalls), B_smalls), G_equivs), G_refresh) = map hd thmss
430434
|> chop (n - m)
431435
||>> chop (n - m)
432436
||>> chop (n - m2)
433437
||>> chop (n - m2)
434438
||>> chop (num_vars * (n - m3))
435439
||>> chop (length bind_ts - m4)
440+
||>> chop (option No_Equiv 1 0)
436441
||> hd;
437442

438443
fun map_id0_of_mr_bnf (Inl mrbnf) = [MRBNF_Def.map_id0_of_mrbnf mrbnf]
@@ -582,7 +587,7 @@ fun binder_inductive_cmd ((pred_name, binds_opt), perms_supps) no_defs_lthy =
582587
val perm_ids = map (fn thm => thm RS fun_cong RS @{thm trans[OF _ id_apply]}) perm_id0s;
583588

584589
val _ = @{print} (map snd perms)
585-
val G_equiv =
590+
val G_equiv = if member (op=) options No_Equiv then hd G_equivs else
586591
Goal.prove_sorry lthy [] [] G_equiv_goal (fn {context=ctxt, ...} => EVERY1 [
587592
K (Local_Defs.unfold0_tac ctxt [snd G]),
588593
REPEAT_DETERM o EVERY' [
@@ -1082,7 +1087,14 @@ val parse_perm_supps =
10821087
>> (fn ps => fold extract_perm_supp ps (NONE, NONE))
10831088
|| Scan.succeed (NONE, NONE);
10841089

1085-
val binder_inductive_parser = Parse.name -- Scan.option (
1090+
val options_parser = Parse.group (fn () => "option")
1091+
((Parse.reserved "no_auto_equiv" >> K No_Equiv)
1092+
|| (Parse.reserved "no_auto_refresh" >> K No_Refresh))
1093+
1094+
val config_parser = Scan.optional (@{keyword "("} |--
1095+
Parse.!!! (Parse.list1 options_parser) --| @{keyword ")"}) []
1096+
1097+
val binder_inductive_parser = config_parser -- Parse.name -- Scan.option (
10861098
@{keyword where} |-- Parse.enum1 "|" (Parse.name --| @{keyword binds} -- Parse.and_list Parse.term)
10871099
) -- parse_perm_supps
10881100

0 commit comments

Comments
 (0)