@@ -34,7 +34,8 @@ Record erasure_configuration := {
3434 enable_cofix_to_fix : bool;
3535 enable_typed_erasure : bool;
3636 enable_fast_remove_params : bool;
37- dearging_config : dearging_config
37+ dearging_config : dearging_config;
38+ inductives_mapping : EReorderCstrs.inductives_mapping
3839 }.
3940
4041Definition default_dearging_config :=
@@ -47,14 +48,16 @@ Definition default_erasure_config :=
4748 {| enable_cofix_to_fix := true;
4849 dearging_config := default_dearging_config;
4950 enable_typed_erasure := true;
50- enable_fast_remove_params := true |}.
51+ enable_fast_remove_params := true;
52+ inductives_mapping := [] |}.
5153
5254(* This runs only the verified phases without the typed erasure and "fast" remove params *)
5355Definition safe_erasure_config :=
5456 {| enable_cofix_to_fix := false;
5557 enable_typed_erasure := false;
5658 enable_fast_remove_params := false;
57- dearging_config := default_dearging_config |}.
59+ dearging_config := default_dearging_config;
60+ inductives_mapping := [] |}.
5861
5962Axiom assume_welltyped_template_program_expansion :
6063 forall p (wtp : ∥ wt_template_program_env p ∥),
@@ -89,7 +92,7 @@ Definition final_wcbv_flags := {|
8992 with_guarded_fix := false;
9093 with_constructor_as_block := true |}.
9194
92- Program Definition optional_cofix_to_fix_transform econf :=
95+ Program Definition optional_unsafe_transforms econf :=
9396 ETransform.optional_self_transform econf.(enable_cofix_to_fix)
9497 ((* Rebuild the efficient lookup table *)
9598 rebuild_wf_env_transform (efl := EConstructorsAsBlocks.switch_cstr_as_blocks
@@ -98,8 +101,8 @@ Program Definition optional_cofix_to_fix_transform econf :=
98101 let efl := EConstructorsAsBlocks.switch_cstr_as_blocks
99102 (EInlineProjections.disable_projections_env_flag (ERemoveParams.switch_no_params EWellformed.all_env_flags)) in
100103 coinductive_to_inductive_transformation efl
101- (has_app := eq_refl) (has_box := eq_refl) (has_rel := eq_refl) (has_pars := eq_refl) (has_cstrblocks := eq_refl))
102- .
104+ (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)) .
103106
104107Program Definition verified_lambdabox_pipeline {guard : abstract_guard_impl}
105108 (efl := EWellformed.all_env_flags)
@@ -237,32 +240,26 @@ Program Definition verified_lambdabox_typed_pipeline {guard : abstract_guard_imp
237240 constructors_as_blocks_transformation
238241 (efl := EInlineProjections.disable_projections_env_flag (ERemoveParams.switch_no_params EWellformed.all_env_flags))
239242 (has_app := eq_refl) (has_pars := eq_refl) (has_rel := eq_refl) (has_box := eq_refl) (has_cstrblocks := eq_refl) ▷
240- ETransform.optional_self_transform econf.(enable_cofix_to_fix)
241- ((* Rebuild the efficient lookup table *)
242- rebuild_wf_env_transform (efl := EConstructorsAsBlocks.switch_cstr_as_blocks
243- (EInlineProjections.disable_projections_env_flag (ERemoveParams.switch_no_params EWellformed.all_env_flags))) false false ▷
244- (* Coinductives & cofixpoints are translated to inductive types and thunked fixpoints *)
245- let efl := EConstructorsAsBlocks.switch_cstr_as_blocks
246- (EInlineProjections.disable_projections_env_flag (ERemoveParams.switch_no_params EWellformed.all_env_flags)) in
247- coinductive_to_inductive_transformation efl
248- (has_app := eq_refl) (has_box := eq_refl) (has_rel := eq_refl) (has_pars := eq_refl) (has_cstrblocks := eq_refl))
249- .
243+ optional_unsafe_transforms econf.
250244
251245 (* At the end of erasure we get a well-formed program (well-scoped globally and localy), without
252246 parameters in inductive declarations. The constructor applications are also transformed to a first-order
253247 "block" application, of the right length, and the evaluation relation does not need to consider guarded
254248 fixpoints or case analyses on propositional content. All fixpoint bodies start with a lambda as well.
255249 Finally, projections are inlined to cases, so no `tProj` remains. *)
256250
257- Import EGlobalEnv EWellformed.
251+ Import EGlobalEnv EWellformed.
252+
253+ Next Obligation .
254+ destruct H. split => //. sq.
255+ now eapply ETransform.expanded_eprogram_env_expanded_eprogram_cstrs.
256+ Qed .
258257
259- Next Obligation .
260- destruct H. split => //. sq.
261- now eapply ETransform.expanded_eprogram_env_expanded_eprogram_cstrs.
262- Qed .
263- Next Obligation .
264- destruct H. destruct enable_cofix_to_fix => //.
265- Qed .
258+ Next Obligation .
259+ unfold optional_unsafe_transforms. cbn.
260+ unfold optional_self_transform. cbn.
261+ destruct enable_cofix_to_fix => //.
262+ Qed .
266263
267264Local Obligation Tactic := intros; eauto.
268265
@@ -340,7 +337,7 @@ Program Definition erasure_pipeline_fast {guard : abstract_guard_impl} (efl := E
340337 let efl := EInlineProjections.disable_projections_env_flag (ERemoveParams.switch_no_params EWellformed.all_env_flags) in
341338 rebuild_wf_env_transform (efl := efl) true false ▷
342339 constructors_as_blocks_transformation (efl := efl) (has_app := eq_refl) (has_pars := eq_refl) (has_rel := eq_refl) (has_box := eq_refl) (has_cstrblocks := eq_refl) ▷
343- optional_cofix_to_fix_transform econf.
340+ optional_unsafe_transforms econf.
344341Next Obligation .
345342 destruct H; split => //. now eapply ETransform.expanded_eprogram_env_expanded_eprogram_cstrs.
346343Qed .
@@ -360,7 +357,7 @@ Next Obligation.
360357 cbn in H. split; cbn; intuition eauto .
361358Qed .
362359Next Obligation .
363- cbn in H. unfold optional_cofix_to_fix_transform . destruct enable_cofix_to_fix => //.
360+ cbn in H. unfold optional_unsafe_transforms . destruct enable_cofix_to_fix => //.
364361Qed .
365362Next Obligation .
366363 cbn in H. split; cbn; intuition eauto .
@@ -401,10 +398,10 @@ Program Definition run_erase_program {guard : abstract_guard_impl} econf :=
401398 if econf.(enable_typed_erasure) then run (typed_erasure_pipeline econf)
402399 else if econf.(enable_fast_remove_params) then
403400 run (erasure_pipeline_fast econf)
404- else run (erasure_pipeline ▷ (optional_cofix_to_fix_transform econf)).
401+ else run (erasure_pipeline ▷ (optional_unsafe_transforms econf)).
405402Next Obligation .
406403Proof .
407- unfold optional_cofix_to_fix_transform .
404+ unfold optional_unsafe_transforms .
408405 destruct enable_cofix_to_fix => //.
409406Qed .
410407
@@ -423,7 +420,8 @@ Definition erasure_fast_config :=
423420 {| enable_cofix_to_fix := false;
424421 dearging_config := default_dearging_config;
425422 enable_typed_erasure := false;
426- enable_fast_remove_params := true |}.
423+ enable_fast_remove_params := true;
424+ inductives_mapping := [] |}.
427425
428426Program Definition erase_fast_and_print_template_program (p : Ast.Env.program) : string :=
429427 erase_and_print_template_program erasure_fast_config p.
@@ -432,7 +430,8 @@ Definition typed_erasure_config :=
432430 {| enable_cofix_to_fix := false;
433431 dearging_config := default_dearging_config;
434432 enable_typed_erasure := true;
435- enable_fast_remove_params := true |}.
433+ enable_fast_remove_params := true;
434+ inductives_mapping := [] |}.
436435
437436(* Parameterized by a configuration for dearging, allowing to, e.g., override masks. *)
438437Program Definition typed_erase_and_print_template_program (p : Ast.Env.program)
0 commit comments