Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revamp fixpoint code #49

Merged
merged 37 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
1ac8a6f
Add operations theory for least fixpoint
jvanbruegge Aug 8, 2024
a80e591
Adapt recursor operations to manual fixpoint theory
jvanbruegge Aug 8, 2024
94fd68c
Add bound free position to fixpoint operation
jvanbruegge Aug 8, 2024
ba4173b
Adapt recursor operations theory for bound free
jvanbruegge Aug 8, 2024
c10476b
Allow to disable noting of mrbnf theorems
jvanbruegge Aug 17, 2024
b2a2c20
Reorder fixpoint operations theory to bundle definitions
jvanbruegge Aug 17, 2024
bbc0f9b
Add @{map_filter n} antiquotation
jvanbruegge Aug 17, 2024
a129e9a
Rename old fixpoint code
jvanbruegge Aug 17, 2024
d070240
Define fixpoint constants from ML
jvanbruegge Aug 17, 2024
834b39e
Automate fixpoint theorems up to and including alpha_trans
jvanbruegge Aug 18, 2024
2295954
Fix equivp subgoals for quotient
jvanbruegge Aug 27, 2024
62e2ade
Add operations theory for two datatype with two binding position for …
jvanbruegge Sep 1, 2024
e3f02a7
Note covar_large theorem properly in covar class
jvanbruegge Sep 8, 2024
d32750b
Add more lemmas about id_on and eq_on
jvanbruegge Sep 8, 2024
71af052
Add operations theory for greatest fixpoint
jvanbruegge Sep 8, 2024
135e793
Use same tactic for alpha_FVars for codatatypes and datatypes
jvanbruegge Sep 10, 2024
90fdbf8
Remove usage of subgoal_tac, hard to use from ML
jvanbruegge Sep 10, 2024
6df6526
Use induction on free vars for alpha_FVars in lfp operations
jvanbruegge Sep 11, 2024
d2413b7
Automate fixpoint proofs until alpha_FVars
jvanbruegge Sep 13, 2024
268e62e
Automate alpha_sym and alpha_trans
jvanbruegge Oct 31, 2024
a2910b8
Automate until permute_simps theorem
jvanbruegge Oct 31, 2024
3ed209e
Automate rest fixpoint theorems for datatypes
jvanbruegge Nov 1, 2024
7ee8f2b
Delete old fp code
jvanbruegge Nov 5, 2024
38a6dd8
Adapt fp_result for new theorems and register fixpoint operation
jvanbruegge Nov 7, 2024
700cfad
Adjust recursor code to deal with bound free positions
jvanbruegge Nov 9, 2024
52da0d3
Fix VVSubst and TVSubst operations theories for bound free positions
jvanbruegge Nov 9, 2024
68c574c
Fix vvsubst automation and sugar operations for bound free positions
jvanbruegge Nov 10, 2024
db01938
Fix tvsubst for bound free positions
jvanbruegge Nov 18, 2024
c78f80d
Add map, subst and permute simps to sugar operations
jvanbruegge Nov 18, 2024
5b1540d
Merge branch 'master' into fixpoint-revamp
jvanbruegge Nov 18, 2024
0a1cea2
Fix renamed theorems in case studies
jvanbruegge Nov 19, 2024
7c8ceec
Fix theorem names in pi calculus
jvanbruegge Nov 19, 2024
add3337
Make induction theorems optional in fixpoint
jvanbruegge Nov 21, 2024
35807c7
Strengthen fresh_cases theorem, do not use unnecessary "avoid" constant
jvanbruegge Nov 21, 2024
2f9551b
Allow bound free positions and non-recursive types
jvanbruegge Nov 21, 2024
a479bcd
Fix usage of fresh_cases theorem
jvanbruegge Nov 21, 2024
3c5ee89
Replace custom ML for commitment type
jvanbruegge Nov 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ROOT
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ session Binders in "thys" = Prelim +
session Operations in "operations" = Untyped_Lambda_Calculus +
theories
Binder_Inductive
Fixpoint
Least_Fixpoint
Least_Fixpoint2
Greatest_Fixpoint
Recursor
VVSubst
TVSubst
Expand Down
2 changes: 1 addition & 1 deletion Tools/binder_induction.ML
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ fun extract_vars ctxt var t =
| NONE => (case BNF_Def.bnf_of ctxt name of
SOME bnf => BNF_Def.sets_of_bnf bnf
| NONE => (case MRBNF_FP_Def_Sugar.fp_result_of ctxt name of
SOME sugar => #FVars (hd (filter (
SOME sugar => #FVarss (hd (filter (
fn quot => fst (dest_Type (#T quot)) = name
) (#quotient_fps sugar)))
| NONE => []
Expand Down
15 changes: 5 additions & 10 deletions Tools/binder_inductive.ML
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,9 @@ fun long_name ctxt name =
Const (s, _) => s
| _ => error ("Undeclared constant: " ^ quote name)

datatype ('a, 'b) either = Inl of 'a | Inr of 'b

fun collapse (Inl x) = x
| collapse (Inr x) = x

fun mk_insert x S =
Const (@{const_name Set.insert}, fastype_of x --> fastype_of S --> fastype_of S) $ x $ S;

fun binder_inductive_cmd ((pred_name, binds_opt), perms_supps) no_defs_lthy =
let
val binds = the_default [] binds_opt;
Expand Down Expand Up @@ -154,7 +149,7 @@ fun binder_inductive_cmd ((pred_name, binds_opt), perms_supps) no_defs_lthy =
val mapx = case mr_bnf of
Inl mrbnf => MRBNF_Def.map_of_mrbnf mrbnf
| Inr (Inl bnf) => BNF_Def.map_of_bnf bnf
| Inr (Inr sugar) => #rename (hd (filter (fn quot =>
| Inr (Inr sugar) => #permute (hd (filter (fn quot =>
fst (dest_Type (#T quot)) = name
) (#quotient_fps sugar)))
val Ts = fst (split_last (Term.binder_types (fastype_of mapx)));
Expand Down Expand Up @@ -434,7 +429,7 @@ fun binder_inductive_cmd ((pred_name, binds_opt), perms_supps) no_defs_lthy =

fun map_id0_of_mr_bnf (Inl mrbnf) = [MRBNF_Def.map_id0_of_mrbnf mrbnf]
| map_id0_of_mr_bnf (Inr (Inl bnf)) = [BNF_Def.map_id0_of_bnf bnf]
| map_id0_of_mr_bnf (Inr (Inr sugar)) = map #rename_id0 (#quotient_fps sugar)
| map_id0_of_mr_bnf (Inr (Inr sugar)) = map #permute_id0 (#quotient_fps sugar)

fun prove_missing goals specified thms tac = fst (@{fold_map 4} (
fn true => (fn _ => fn _ => fn _ => fn acc => (hd acc, tl acc))
Expand All @@ -446,7 +441,7 @@ fun binder_inductive_cmd ((pred_name, binds_opt), perms_supps) no_defs_lthy =
fun map_comp_of_mr_bnf (Inl mrbnf) = [MRBNF_Def.map_comp_of_mrbnf mrbnf, MRBNF_Def.map_comp0_of_mrbnf mrbnf RS sym]
| map_comp_of_mr_bnf (Inr (Inl bnf)) = [BNF_Def.map_comp_of_bnf bnf, BNF_Def.map_comp0_of_bnf bnf RS sym]
| map_comp_of_mr_bnf (Inr (Inr sugar)) = maps (fn quot =>
[#rename_comp quot, #rename_comp0 quot]
[#permute_comp quot, #permute_comp0 quot]
) (#quotient_fps sugar)

val perm_id0s = prove_missing perm_id0_goals perms_specified perm_id0s (fn ctxt => fn mr_bnfs => K (EVERY1 [
Expand All @@ -460,7 +455,7 @@ fun binder_inductive_cmd ((pred_name, binds_opt), perms_supps) no_defs_lthy =

fun set_map_of_mr_bnf (Inl mrbnf) = MRBNF_Def.set_map_of_mrbnf mrbnf
| set_map_of_mr_bnf (Inr (Inl bnf)) = BNF_Def.set_map_of_bnf bnf
| set_map_of_mr_bnf (Inr (Inr sugar)) = maps #FVars_renames (#quotient_fps sugar)
| set_map_of_mr_bnf (Inr (Inr sugar)) = maps #FVars_permutes (#quotient_fps sugar)

val supp_seminats = prove_missing supp_seminat_goals one_specified supp_seminats (fn ctxt => fn mr_bnfs => K (EVERY1 [
K (Local_Defs.unfold0_tac ctxt (
Expand All @@ -470,7 +465,7 @@ fun binder_inductive_cmd ((pred_name, binds_opt), perms_supps) no_defs_lthy =
rtac ctxt @{thm subset_refl}
]));

fun map_cong_id_of_mr_bnf (Inr (Inr sugar)) = map (#rename_cong_id o #inner) (#quotient_fps sugar)
fun map_cong_id_of_mr_bnf (Inr (Inr sugar)) = map (#permute_cong_id o #inner) (#quotient_fps sugar)
| map_cong_id_of_mr_bnf x =
let
val thm1 = case x of
Expand Down
13 changes: 12 additions & 1 deletion Tools/mrbnf_def.ML
Original file line number Diff line number Diff line change
Expand Up @@ -1307,9 +1307,12 @@ datatype inline_policy = Dont_Inline | Hardly_Inline | Smart_Inline | Do_Inline;
datatype fact_policy = Dont_Note | Note_Some | Note_All;

val mrbnf_internals = Attrib.setup_config_bool @{binding mrbnf_internals} (K false);
val mrbnf_notes = Attrib.setup_config_bool @{binding mrbnf_notes} (K true);
val mrbnf_timing = Attrib.setup_config_bool @{binding mrbnf_timing} (K false);

fun user_policy policy ctxt = if Config.get ctxt mrbnf_internals then Note_All else policy;
fun user_policy policy ctxt = if Config.get ctxt mrbnf_notes then
(if Config.get ctxt mrbnf_internals then Note_All else policy)
else Dont_Note;

val smart_max_inline_term_size = 25; (*FUDGE*)

Expand Down Expand Up @@ -2269,6 +2272,14 @@ fun prepare_def const_policy mk_fact_policy internal qualify prep_typ prep_term
|> Thm.close_derivation \<^here>
end;

val lthy = Local_Theory.background_theory (fn thy =>
let
val lthy = Named_Target.init [] (hd coclass) thy;
val lthy = snd (Local_Theory.notes (map (fn (thmN, thm) => ((Binding.name thmN, []), [([thm], [])])) [
("large", covar_large)
]) lthy) handle ERROR _ => lthy;
in Local_Theory.exit_global lthy end
) lthy;
val lthy = Local_Theory.background_theory (fn thy =>
let
val lthy = Named_Target.init [] (hd class) thy;
Expand Down
Loading
Loading