Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
5cf9e6f
Add basic axiomatization for BMV monads
jvanbruegge Dec 10, 2024
7ea31c3
Do not seperate between own/other injections, use types instead
jvanbruegge Dec 12, 2024
36882fd
Add var class and bound to bmv monad
jvanbruegge Dec 12, 2024
912eb6e
Have one Vrs operator per injection and (optionally) var type
jvanbruegge Dec 12, 2024
70a5a1a
Add vars_bd theorems to BMV Monad
jvanbruegge Dec 12, 2024
49636dc
Prove supported functor structure
jvanbruegge Dec 15, 2024
c690d1c
Generate composed constants
jvanbruegge Dec 24, 2024
0792e36
Implement proofs for bmv composition
jvanbruegge Dec 25, 2024
35ce942
Introduce definitions if terms get too big
jvanbruegge Dec 26, 2024
d275cd8
Add function to convert bnf to pbmv monad
jvanbruegge Dec 26, 2024
2ef45eb
Allow to register pbmv monads
jvanbruegge Dec 26, 2024
86ecdd3
Add command to register pbmv monads
jvanbruegge Jan 1, 2025
35f9e93
Add command to print registered pbmv monads
jvanbruegge Jan 1, 2025
5759609
Add bmv_monad_of_typ function
jvanbruegge Jan 4, 2025
8a869e3
Automatically infer/fix types in pbmv_monad command
jvanbruegge Jan 6, 2025
b52796e
Fix composition for types that have lives and frees
jvanbruegge Jan 9, 2025
fe1a95f
Make composed Sb_cong tactic more robust
jvanbruegge Feb 18, 2025
796ed4d
Allow to blacklist positions for bmv structure
jvanbruegge Feb 19, 2025
43203af
Improve printing of bmv monads
jvanbruegge Feb 19, 2025
6f3f00b
Add initial BMV fixpoint operations theory
jvanbruegge Feb 19, 2025
bb956cc
Obtain fixpoint substitution with recursor
jvanbruegge Feb 22, 2025
788b363
Allow BMV monads to carry predefined SSupp operators
jvanbruegge Mar 3, 2025
eee8eb4
Rewrite bmv composition to be easier to understand
jvanbruegge Mar 9, 2025
7333300
Add initial bmv_monad facts (ie derived theorems)
jvanbruegge Mar 10, 2025
e2b7b93
Add initial mrsbnf axiomatization
jvanbruegge Mar 11, 2025
cad2531
Fix mrsbnf tactics when mrbnf has more than just frees
jvanbruegge Mar 12, 2025
76409ca
Save vars per op in bmv monad, add set_Vrs to mrsbnf axioms
jvanbruegge Mar 12, 2025
0fad0a5
Add more complex lambda calculus example with second source of frees
jvanbruegge Apr 28, 2025
d83bf56
Introduce RVrs to BMV Monads
jvanbruegge May 3, 2025
946d611
Make use of free vars in mrbnf when constructing mrsbnf/bmv from them
jvanbruegge May 5, 2025
c4fc4a4
Add complicated example proof for composition and demotion
jvanbruegge May 26, 2025
a66f05a
Automate demoting of bmv monads
jvanbruegge Jun 3, 2025
94ceff1
Automate the new BMV composition
jvanbruegge Jun 5, 2025
0bd6edb
Fix Supp_Sb axiom and Vrs_Sb goal generation
jvanbruegge Jun 7, 2025
1e90ead
Fix last errors in BMV_Monad operations theory
jvanbruegge Jun 7, 2025
7bf857e
Fix several issues in MRSBNF axiomatization
jvanbruegge Jun 16, 2025
73c499f
Prove MRSBNF composition for complex example
jvanbruegge Jun 18, 2025
b422ebd
Make sure MRSBNF composition can handle bound positions
jvanbruegge Jun 22, 2025
26968a7
Get mrsbnf composition to work
jvanbruegge Jun 23, 2025
6bb424b
Implement sealing of bmvs and mrsbnfs
jvanbruegge Jun 27, 2025
085b69a
Adjust BMV_Fixpoint operations theory for sealed mrsbnf
jvanbruegge Jun 27, 2025
bdfe1b6
Adjust bmv composition operations theory for minimum UNIV bound
jvanbruegge Jul 1, 2025
f664777
Fix types with no frees
jvanbruegge Jul 3, 2025
7e3ac6d
Use IImsupp everywhere
jvanbruegge Jul 7, 2025
3b8fb84
more
dtraytel Jul 10, 2025
8832417
Fix remaining fixpoint proofs
jvanbruegge Jul 10, 2025
414b5a1
Fix duplicate simp rule assumption
jvanbruegge Jul 10, 2025
d068809
Automate obtaining new substitutions
jvanbruegge Jul 10, 2025
9187737
Prove most of the bmv axioms
jvanbruegge Jul 11, 2025
1fc5062
Automate proofs of recursive BMV
jvanbruegge Jul 11, 2025
f7c188c
Automate recursive mrsbnf
jvanbruegge Jul 11, 2025
219af31
Package resulting theorems in tvsubst_result
jvanbruegge Jul 11, 2025
d3c43ec
Add theories to ROOT file
jvanbruegge Jul 11, 2025
23f6c7f
Fix Pi_Calculus theories
jvanbruegge Jul 11, 2025
e550b9a
Fix POPLmark theories
jvanbruegge Jul 11, 2025
3b41e3a
Fix Composition operations theory
jvanbruegge Jul 11, 2025
9650587
Fix map simp rules
jvanbruegge Jul 11, 2025
4e486ed
Fix duplicate IImsupp and SSupp constants in LC
jvanbruegge Jul 11, 2025
bfa06be
Fix ILC theories
jvanbruegge Jul 11, 2025
9e48baa
Fix Greatest_Fixpoint operations theory
jvanbruegge Jul 11, 2025
fbbac94
Fix Least_Fixpoint2 theory
jvanbruegge Jul 11, 2025
a9bbc63
Fix Least_Fixpoint theory
jvanbruegge Jul 11, 2025
b33068c
Fix Sugar operations theory
jvanbruegge Jul 11, 2025
8bd4063
Do not generate a substitution if there are extra free vars
jvanbruegge Jul 11, 2025
1e247a4
Use mrsbnf composition for binder_datatypes
jvanbruegge Jul 11, 2025
9aa2a89
Use class registry also for BMV monads
jvanbruegge Aug 5, 2025
17ff165
Fix handling of deads in seal_mrsbnf
jvanbruegge Aug 5, 2025
0c44127
Fix map_is_Sb for simple sealing
jvanbruegge Aug 5, 2025
6e310eb
Fix lingering issues of mrsbnf composition
jvanbruegge Aug 8, 2025
45370de
Clamp var types in fast compose path
jvanbruegge Aug 8, 2025
5d4139c
First working integration of bmv-based substitution
jvanbruegge Aug 10, 2025
67f7c8d
Prove SSupp_natural, IImsupp_natural and tvsubst_permute again
jvanbruegge Aug 10, 2025
954de77
Remove tvsubst simps from sugar operations
jvanbruegge Aug 10, 2025
7018929
Fix errors in Mazza case study
jvanbruegge Aug 10, 2025
b16a0f9
Fix Pi calculus and POPLmark 1B
jvanbruegge Aug 10, 2025
3ff4caa
Fix POPLmark 2B
jvanbruegge Aug 13, 2025
8539fbe
Fix STLC and add it to ROOT
jvanbruegge Aug 13, 2025
ba8c580
Fix classes proofs
jvanbruegge Oct 2, 2025
626d0d0
Simplify POPLmark proofs
jvanbruegge Oct 2, 2025
2ec8d3f
Use antiquotations for proofs
jvanbruegge Oct 2, 2025
615e8fb
Fix ILC proof
jvanbruegge Oct 2, 2025
67771cd
Fix operations theories
jvanbruegge Oct 2, 2025
b7a774a
Split internal definitions from user-facing ones
jvanbruegge Oct 3, 2025
6bcd55d
Fix errors from rebase
jvanbruegge Oct 20, 2025
97f6a2b
Add support for passive free variables
jvanbruegge Nov 15, 2025
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
8 changes: 8 additions & 0 deletions ROOT
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ session Binders in "thys" = Prelim +
MRBNF_Composition
MRBNF_FP
MRBNF_Recursor
Swapping
Support

session Operations in "operations" = Untyped_Lambda_Calculus +
theories
Expand All @@ -36,6 +38,8 @@ session Operations in "operations" = Untyped_Lambda_Calculus +
VVSubst_Corec
TVSubst
Sugar
BMV_Monad
BMV_Fixpoint

session Tests in "tests" = Case_Studies +
sessions
Expand Down Expand Up @@ -116,3 +120,7 @@ session System_Fsub in "case_studies/POPLmark" = Case_Studies +
Pattern
POPLmark_1B
POPLmark_2B

session STLC in "case_studies/STLC" = Binders +
theories
STLC
22 changes: 9 additions & 13 deletions Tools/binder_induction.ML
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,6 @@ fun gen_binder_context_tactic mod_cases simp def_insts arbitrary avoiding taking
| NONE => error "Automatic detection of induction rule is not supported yet, please specify with rule:"
);

fun dest_ordLess t =
let val t' = case HOLogic.dest_mem t of
(t', Const (@{const_name ordLess}, _)) => t'
| _ => raise TERM ("dest_ordLess", [t])
in HOLogic.dest_prod t' end
fun dest_card_of (Const (@{const_name card_of}, _) $ t) = t
| dest_card_of t = raise TERM ("dest_card_of", [t])

fun strip_all (Const (@{const_name HOL.All}, _) $ t) = (case t of
Abs (x, T, t) => let val a = Free (x, T)
in apfst (curry (op::) a) (strip_all (Term.subst_bound (a, t))) end
Expand All @@ -153,8 +145,8 @@ fun gen_binder_context_tactic mod_cases simp def_insts arbitrary avoiding taking
val vars_prems = map (try (
HOLogic.dest_Trueprop
#> snd o strip_all
#> fst o dest_ordLess
#> dest_card_of
#> fst o MRBNF_Util.dest_ordLess
#> MRBNF_Util.dest_card_of
#> fst o Term.strip_comb
#> snd o Term.dest_Var
#> HOLogic.dest_setT o range_type
Expand Down Expand Up @@ -463,6 +455,10 @@ fun gen_binder_context_tactic mod_cases simp def_insts arbitrary avoiding taking
rotate_tac ~1
],
SELECT_GOAL (Local_Defs.unfold0_tac ctxt @{thms de_Morgan_disj singleton_iff Int_Un_distrib Un_empty}),
REPEAT_DETERM o CHANGED o EVERY' [
SELECT_GOAL (Local_Defs.unfold0_tac ctxt @{thms conj_assoc}),
SELECT_GOAL (Local_Defs.unfold0_tac ctxt @{thms conj_assoc[symmetric]})
],
REPEAT_DETERM o EVERY' [
etac ctxt conjE,
rotate_tac ~2
Expand All @@ -471,9 +467,9 @@ fun gen_binder_context_tactic mod_cases simp def_insts arbitrary avoiding taking
Subgoal.FOCUS_PREMS (fn {context=ctxt, prems=inner_prems, ...} => EVERY1 [
DETERM o resolve_tac ctxt (IH :: repeat_mp IH),
IF_UNSOLVED o EVERY' [
SELECT_GOAL (Local_Defs.unfold0_tac ctxt @{thms Un_iff de_Morgan_disj singleton_iff Int_Un_distrib Un_empty}),
K (Local_Defs.unfold0_tac ctxt @{thms notin_Un Un_iff de_Morgan_disj singleton_iff Int_Un_distrib Un_empty}),
EVERY' (map (fn inner_prem => EVERY' (map (fn tac => DETERM o tac) [
TRY o rtac ctxt conjI,
REPEAT_DETERM o rtac ctxt conjI,
let val x = length (fst (Logic.strip_horn (Thm.prop_of inner_prem)));
in REPEAT_DETERM_N x o rtac ctxt @{thm induct_impliesI} end,
REPEAT_DETERM o rtac ctxt @{thm induct_forallI},
Expand All @@ -484,7 +480,7 @@ fun gen_binder_context_tactic mod_cases simp def_insts arbitrary avoiding taking
val simpset = Simplifier.add_cong @{thm imp_cong} (
(BNF_Util.ss_only @{thms
split_paired_All HOL.simp_thms all_simps HOL.induct_forall_def prod.inject induct_implies_equal_eq
disjoint_single trans[OF arg_cong2[OF Int_commute refl, of "(=)"] disjoint_single]
disjoint_single trans[OF arg_cong2[OF Int_commute refl, of "(=)"] disjoint_single] conj_assoc
} ctxt)
addsimprocs [@{simproc HOL.defined_All}, @{simproc HOL.defined_Ex}]
)
Expand Down
10 changes: 6 additions & 4 deletions Tools/binder_inductive.ML
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ fun binder_inductive_cmd (((options, pred_name), binds_opt: (string * string lis
(MRBNF_Util.subst_typ_morphism (snd (dest_Type (MRBNF_Def.T_of_mrbnf mrbnf)) ~~ Ts))
mrbnf))
| collect_params _ = [];

val pot_bind_Ts = foldl1 (fn (xs, ys) => if
subset (op=) (xs, ys) then ys else union (op=) ys xs
) (map collect_params param_Ts);
Expand All @@ -78,7 +79,7 @@ fun binder_inductive_cmd (((options, pred_name), binds_opt: (string * string lis
| collect_binders (Abs (_, _, t)) = collect_binders t
| collect_binders (t as (t1 $ t2)) = case try (dest_Type o Term.body_type o fastype_of) t of
NONE => map2 (curry (op@)) (collect_binders t1) (collect_binders t2)
| SOME (s, _) => (case MRBNF_Sugar.binder_sugar_of no_defs_lthy s of
| SOME (s, _) => (case Binder_Sugar.binder_sugar_of no_defs_lthy s of
NONE => map2 (curry (op@)) (collect_binders t1) (collect_binders t2)
| SOME sugar =>
let
Expand Down Expand Up @@ -115,7 +116,8 @@ fun binder_inductive_cmd (((options, pred_name), binds_opt: (string * string lis
val intro = unvarify_global (Term.subst_TVars subst (Thm.prop_of intro));
val binderss = map (distinct (op=)) (collect_binders intro);
val xs_binders = map (fn binders => fold_rev (fn t => fn (a, b) => case t of
Const (@{const_name insert}, _) $ x $ Const (@{const_name bot}, _) => (x::a, b)
Const (@{const_name insert}, _) $ x $ Const (@{const_name bot}, _) => (case x of
Bound _ => (a, b) | _ => (x::a, b))
| _ => (a, t::b)
) binders ([], [])) binderss;
val binders = map (fn (xs, binders) =>
Expand Down Expand Up @@ -539,7 +541,7 @@ fun binder_inductive_cmd (((options, pred_name), binds_opt: (string * string lis
map_filter (try dest_Type o snd) (fold Term.add_frees (flat bind_ts) [])
);

val bset_bounds = maps (fn Type (s, _) => (case MRBNF_Sugar.binder_sugar_of lthy s of
val bset_bounds = maps (fn Type (s, _) => (case Binder_Sugar.binder_sugar_of lthy s of
SOME sugar => #bset_bounds sugar
| NONE => [])
| _ => []) param_Ts;
Expand All @@ -550,7 +552,7 @@ fun binder_inductive_cmd (((options, pred_name), binds_opt: (string * string lis
REPEAT_DETERM o eresolve_tac ctxt [exE, conjE],
hyp_subst_tac ctxt,
REPEAT_DETERM o resolve_tac ctxt (
@{thms conjI emp_bound iffD2[OF insert_bound] ordLeq_refl}
@{thms conjI emp_bound iffD2[OF insert_bound_UNIV] ordLeq_refl}
@ infinite_UNIVs @ [Un_bound, UN_bound]
@ maps (fn thm => [thm, @{thm ordLess_ordLeq_trans} OF [thm]]) (
maps set_bd_UNIVs_of_mr_bnfs binder_mr_bnfs
Expand Down
88 changes: 88 additions & 0 deletions Tools/binder_sugar.ML
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
signature BINDER_SUGAR = sig

type binder_sugar = {
map_simps: thm list,
set_simpss: thm list list,
permute_simps: thm list,
map_permute: thm option,
subst_simps: thm list option,
IImsupp_permute_commutes: thm list option,
IImsupp_Diffs: thm list option,
tvsubst_permute: thm option,
bsetss: term option list list,
bset_bounds: thm list,
pset_ctors: thm list,
mrbnf: MRBNF_Def.mrbnf,
strong_induct: thm option,
distinct: thm list,
inject: thm list,
ctors: (term * thm) list
};

val morph_binder_sugar: morphism -> binder_sugar -> binder_sugar;

val binder_sugar_of: local_theory -> string -> binder_sugar option
val register_binder_sugar: string -> binder_sugar -> local_theory -> local_theory

end

structure Binder_Sugar : BINDER_SUGAR = struct

type binder_sugar = {
map_simps: thm list,
set_simpss: thm list list,
permute_simps: thm list,
map_permute: thm option,
subst_simps: thm list option,
IImsupp_permute_commutes: thm list option,
IImsupp_Diffs: thm list option,
tvsubst_permute: thm option,
bsetss: term option list list,
bset_bounds: thm list,
pset_ctors: thm list,
mrbnf: MRBNF_Def.mrbnf,
strong_induct: thm option,
distinct: thm list,
inject: thm list,
ctors: (term * thm) list
};

fun morph_binder_sugar phi { map_simps, permute_simps, map_permute, set_simpss, subst_simps, mrbnf,
strong_induct, distinct, inject, ctors, bsetss, bset_bounds, IImsupp_permute_commutes, IImsupp_Diffs,
tvsubst_permute, pset_ctors
} = {
map_simps = map (Morphism.thm phi) map_simps,
permute_simps = map (Morphism.thm phi) permute_simps,
map_permute = Option.map (Morphism.thm phi) map_permute,
set_simpss = map (map (Morphism.thm phi)) set_simpss,
subst_simps = Option.map (map (Morphism.thm phi)) subst_simps,
IImsupp_permute_commutes = Option.map (map (Morphism.thm phi)) IImsupp_permute_commutes,
IImsupp_Diffs = Option.map (map (Morphism.thm phi)) IImsupp_Diffs,
tvsubst_permute = Option.map (Morphism.thm phi) tvsubst_permute,
bsetss = map (map (Option.map (Morphism.term phi))) bsetss,
bset_bounds = map (Morphism.thm phi) bset_bounds,
pset_ctors = map (Morphism.thm phi) pset_ctors,
mrbnf = MRBNF_Def.morph_mrbnf phi mrbnf,
strong_induct = Option.map (Morphism.thm phi) strong_induct,
distinct = map (Morphism.thm phi) distinct,
inject = map (Morphism.thm phi) inject,
ctors = map (MRBNF_Util.map_prod (Morphism.term phi) (Morphism.thm phi)) ctors
} : binder_sugar;

structure Data = Generic_Data (
type T = binder_sugar Symtab.table;
val empty = Symtab.empty;
fun merge data : T = Symtab.merge (K true) data;
);

fun register_binder_sugar name sugar =
Local_Theory.declaration {syntax = false, pervasive = true, pos = Position.none}
(fn phi => Data.map (Symtab.update (name, morph_binder_sugar phi sugar)));

fun binder_sugar_of_generic context =
Option.map (morph_binder_sugar (Morphism.transfer_morphism (Context.theory_of context)))
o Symtab.lookup (Data.get context);

val binder_sugar_of = binder_sugar_of_generic o Context.Proof;

end
Loading
Loading