@@ -6,7 +6,7 @@ From MetaCoq.Template Require Import EtaExpand TemplateProgram.
66From MetaCoq.PCUIC Require PCUICAst PCUICAstUtils PCUICProgram.
77From MetaCoq.SafeChecker Require Import PCUICErrors PCUICWfEnvImpl.
88From MetaCoq.Erasure Require EAstUtils ErasureFunction ErasureCorrectness EPretty Extract .
9- From MetaCoq.Erasure Require Import EProgram.
9+ From MetaCoq.Erasure Require Import EProgram EInlining EBeta .
1010From MetaCoq.ErasurePlugin Require Import ETransform.
1111
1212Import PCUICProgram.
@@ -31,11 +31,12 @@ Import EWcbvEval.
3131Local Obligation Tactic := program_simpl.
3232
3333Record erasure_configuration := {
34- enable_cofix_to_fix : bool;
34+ enable_unsafe : bool;
3535 enable_typed_erasure : bool;
3636 enable_fast_remove_params : bool;
3737 dearging_config : dearging_config;
38- inductives_mapping : EReorderCstrs.inductives_mapping
38+ inductives_mapping : EReorderCstrs.inductives_mapping;
39+ inlining : KernameSet.t
3940 }.
4041
4142Definition default_dearging_config :=
@@ -45,19 +46,21 @@ Definition default_dearging_config :=
4546
4647(* This runs the cofix -> fix translation which is not entirely verified yet *)
4748Definition default_erasure_config :=
48- {| enable_cofix_to_fix := true;
49+ {| enable_unsafe := true;
4950 dearging_config := default_dearging_config;
5051 enable_typed_erasure := true;
5152 enable_fast_remove_params := true;
52- inductives_mapping := [] |}.
53+ inductives_mapping := [];
54+ inlining := KernameSet.empty |}.
5355
5456(* This runs only the verified phases without the typed erasure and "fast" remove params *)
5557Definition safe_erasure_config :=
56- {| enable_cofix_to_fix := false;
58+ {| enable_unsafe := false;
5759 enable_typed_erasure := false;
5860 enable_fast_remove_params := false;
5961 dearging_config := default_dearging_config;
60- inductives_mapping := [] |}.
62+ inductives_mapping := [];
63+ inlining := KernameSet.empty |}.
6164
6265Axiom assume_welltyped_template_program_expansion :
6366 forall p (wtp : ∥ wt_template_program_env p ∥),
@@ -93,16 +96,20 @@ Definition final_wcbv_flags := {|
9396 with_constructor_as_block := true |}.
9497
9598Program Definition optional_unsafe_transforms econf :=
96- ETransform.optional_self_transform econf.(enable_cofix_to_fix)
99+ let efl := EConstructorsAsBlocks.switch_cstr_as_blocks
100+ (EInlineProjections.disable_projections_env_flag (ERemoveParams.switch_no_params EWellformed.all_env_flags)) in
101+ ETransform.optional_self_transform econf.(enable_unsafe)
97102 ((* Rebuild the efficient lookup table *)
98- rebuild_wf_env_transform (efl := EConstructorsAsBlocks.switch_cstr_as_blocks
99- (EInlineProjections.disable_projections_env_flag (ERemoveParams.switch_no_params EWellformed.all_env_flags))) false false ▷
103+ rebuild_wf_env_transform (efl := efl) false false ▷
100104 (* Coinductives & cofixpoints are translated to inductive types and thunked fixpoints *)
101- let efl := EConstructorsAsBlocks.switch_cstr_as_blocks
102- (EInlineProjections.disable_projections_env_flag (ERemoveParams.switch_no_params EWellformed.all_env_flags)) in
103105 coinductive_to_inductive_transformation efl
104106 (has_app := eq_refl) (has_box := eq_refl) (has_rel := eq_refl) (has_pars := eq_refl) (has_cstrblocks := eq_refl) ▷
105- reorder_cstrs_transformation efl final_wcbv_flags econf.(inductives_mapping)).
107+ reorder_cstrs_transformation efl final_wcbv_flags econf.(inductives_mapping) ▷
108+ rebuild_wf_env_transform (efl := efl) false false ▷
109+ unbox_transformation efl final_wcbv_flags ▷
110+ inline_transformation efl final_wcbv_flags econf.(inlining) ▷
111+ forget_inlining_info_transformation efl final_wcbv_flags ▷
112+ betared_transformation efl final_wcbv_flags).
106113
107114Program Definition verified_lambdabox_pipeline {guard : abstract_guard_impl}
108115 (efl := EWellformed.all_env_flags)
257264
258265Next Obligation .
259266 unfold optional_unsafe_transforms. cbn.
260- unfold optional_self_transform. cbn.
261- destruct enable_cofix_to_fix => //.
267+ destruct enable_unsafe => //.
262268Qed .
263269
264270Local Obligation Tactic := intros; eauto.
@@ -357,7 +363,7 @@ Next Obligation.
357363 cbn in H. split; cbn; intuition eauto .
358364Qed .
359365Next Obligation .
360- cbn in H. unfold optional_unsafe_transforms. destruct enable_cofix_to_fix => //.
366+ cbn in H. unfold optional_unsafe_transforms. destruct enable_unsafe => //.
361367Qed .
362368Next Obligation .
363369 cbn in H. split; cbn; intuition eauto .
@@ -402,7 +408,7 @@ Program Definition run_erase_program {guard : abstract_guard_impl} econf :=
402408Next Obligation .
403409Proof .
404410 unfold optional_unsafe_transforms.
405- destruct enable_cofix_to_fix => //.
411+ destruct enable_unsafe => //.
406412Qed .
407413
408414Program Definition erase_and_print_template_program econf (p : Ast.Env.program) : string :=
@@ -417,21 +423,23 @@ Next Obligation.
417423Qed .
418424
419425Definition erasure_fast_config :=
420- {| enable_cofix_to_fix := false;
426+ {| enable_unsafe := false;
421427 dearging_config := default_dearging_config;
422428 enable_typed_erasure := false;
423429 enable_fast_remove_params := true;
424- inductives_mapping := [] |}.
430+ inductives_mapping := [];
431+ inlining := KernameSet.empty |}.
425432
426433Program Definition erase_fast_and_print_template_program (p : Ast.Env.program) : string :=
427434 erase_and_print_template_program erasure_fast_config p.
428435
429436Definition typed_erasure_config :=
430- {| enable_cofix_to_fix := false;
437+ {| enable_unsafe := false;
431438 dearging_config := default_dearging_config;
432439 enable_typed_erasure := true;
433440 enable_fast_remove_params := true;
434- inductives_mapping := [] |}.
441+ inductives_mapping := [];
442+ inlining := KernameSet.empty |}.
435443
436444(* Parameterized by a configuration for dearging, allowing to, e.g., override masks. *)
437445Program Definition typed_erase_and_print_template_program (p : Ast.Env.program)
0 commit comments