@@ -30,37 +30,65 @@ Import EWcbvEval.
30
30
31
31
Local Obligation Tactic := program_simpl.
32
32
33
+ Record unsafe_passes :=
34
+ { fix_to_lazy : bool;
35
+ reorder_constructors : bool;
36
+ inlining : bool;
37
+ unboxing : bool;
38
+ betared : bool }.
39
+
33
40
Record erasure_configuration := {
34
- enable_unsafe : bool ;
41
+ enable_unsafe : unsafe_passes ;
35
42
enable_typed_erasure : bool;
36
43
enable_fast_remove_params : bool;
37
44
dearging_config : dearging_config;
38
45
inductives_mapping : EReorderCstrs.inductives_mapping;
39
- inlining : KernameSet.t
46
+ inlined_constants : KernameSet.t
40
47
}.
41
48
42
49
Definition default_dearging_config :=
43
50
{| overridden_masks := fun _ => None;
44
51
do_trim_const_masks := true;
45
52
do_trim_ctor_masks := false |}.
46
53
47
- (* This runs the cofix -> fix translation which is not entirely verified yet *)
54
+
55
+ Definition make_unsafe_passes b :=
56
+ {| fix_to_lazy := b;
57
+ reorder_constructors := b;
58
+ inlining := b;
59
+ unboxing := b;
60
+ betared := b |}.
61
+
62
+ Definition no_unsafe_passes := make_unsafe_passes false.
63
+ Definition all_unsafe_passes := make_unsafe_passes true.
64
+
65
+ (* This runs the cofix -> fix/lazy translation as well as inlining and
66
+ beta-redex simplification, which are not verified. It does not change
67
+ representation by reordering constructors or unboxing. *)
68
+
69
+ Definition default_unsafe_passes :=
70
+ {| fix_to_lazy := true;
71
+ reorder_constructors := false;
72
+ inlining := true;
73
+ unboxing := false;
74
+ betared := true |}.
75
+
48
76
Definition default_erasure_config :=
49
- {| enable_unsafe := true ;
77
+ {| enable_unsafe := default_unsafe_passes ;
50
78
dearging_config := default_dearging_config;
51
79
enable_typed_erasure := true;
52
80
enable_fast_remove_params := true;
53
81
inductives_mapping := [];
54
- inlining := KernameSet.empty |}.
82
+ inlined_constants := KernameSet.empty |}.
55
83
56
84
(* This runs only the verified phases without the typed erasure and "fast" remove params *)
57
85
Definition safe_erasure_config :=
58
- {| enable_unsafe := false ;
86
+ {| enable_unsafe := no_unsafe_passes ;
59
87
enable_typed_erasure := false;
60
88
enable_fast_remove_params := false;
61
89
dearging_config := default_dearging_config;
62
90
inductives_mapping := [];
63
- inlining := KernameSet.empty |}.
91
+ inlined_constants := KernameSet.empty |}.
64
92
65
93
Axiom assume_welltyped_template_program_expansion :
66
94
forall p (wtp : ∥ wt_template_program_env p ∥),
@@ -96,22 +124,40 @@ Definition final_wcbv_flags := {|
96
124
with_constructor_as_block := true |}.
97
125
98
126
Program Definition optional_unsafe_transforms econf :=
127
+ let passes := econf.(enable_unsafe) in
99
128
let efl := EConstructorsAsBlocks.switch_cstr_as_blocks
100
129
(EInlineProjections.disable_projections_env_flag (ERemoveParams.switch_no_params EWellformed.all_env_flags)) in
101
- ETransform.optional_self_transform econf.(enable_unsafe )
130
+ ETransform.optional_self_transform passes.(fix_to_lazy )
102
131
((* Rebuild the efficient lookup table *)
103
132
rebuild_wf_env_transform (efl := efl) false false ▷
104
133
(* Coinductives & cofixpoints are translated to inductive types and thunked fixpoints *)
105
134
coinductive_to_inductive_transformation efl
106
- (has_app := eq_refl) (has_box := eq_refl) (has_rel := eq_refl) (has_pars := eq_refl) (has_cstrblocks := eq_refl) ▷
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
- (* Heuristically do it twice for more beta-normal terms *)
113
- betared_transformation efl final_wcbv_flags ▷
114
- betared_transformation efl final_wcbv_flags).
135
+ (has_app := eq_refl) (has_box := eq_refl) (has_rel := eq_refl) (has_pars := eq_refl) (has_cstrblocks := eq_refl)) ▷
136
+ ETransform.optional_self_transform passes.(reorder_constructors)
137
+ (reorder_cstrs_transformation efl final_wcbv_flags econf.(inductives_mapping)) ▷
138
+ ETransform.optional_self_transform passes.(unboxing)
139
+ (rebuild_wf_env_transform (efl := efl) false false ▷
140
+ unbox_transformation efl final_wcbv_flags) ▷
141
+ ETransform.optional_self_transform passes.(inlining)
142
+ (inline_transformation efl final_wcbv_flags econf.(inlined_constants) ▷
143
+ forget_inlining_info_transformation efl final_wcbv_flags) ▷
144
+ (* Heuristically do it twice for more beta-normal terms *)
145
+ ETransform.optional_self_transform passes.(betared)
146
+ (betared_transformation efl final_wcbv_flags ▷
147
+ betared_transformation efl final_wcbv_flags).
148
+
149
+ Next Obligation .
150
+ destruct (enable_unsafe econf) as [[] [] [] [] []]; cbn in * => //; intuition auto.
151
+ Qed .
152
+ Next Obligation .
153
+ destruct (enable_unsafe econf) as [[] [] [] [] []]; cbn in * => //; intuition auto.
154
+ Qed .
155
+ Next Obligation .
156
+ destruct (enable_unsafe econf) as [[] [] [] [] []]; cbn in * => //; intuition auto.
157
+ Qed .
158
+ Next Obligation .
159
+ destruct (enable_unsafe econf) as [[] [] [] [] []]; cbn in * => //; intuition auto.
160
+ Qed .
115
161
116
162
Program Definition verified_lambdabox_pipeline {guard : abstract_guard_impl}
117
163
(efl := EWellformed.all_env_flags)
266
312
267
313
Next Obligation .
268
314
unfold optional_unsafe_transforms. cbn.
269
- destruct enable_unsafe => //.
315
+ destruct enable_unsafe as [[] ? ? ? ?] => //.
270
316
Qed .
271
317
272
318
Local Obligation Tactic := intros; eauto.
@@ -365,7 +411,9 @@ Next Obligation.
365
411
cbn in H. split; cbn; intuition eauto .
366
412
Qed .
367
413
Next Obligation .
368
- cbn in H. unfold optional_unsafe_transforms. destruct enable_unsafe => //.
414
+ cbn in H. unfold optional_unsafe_transforms.
415
+ cbn.
416
+ destruct enable_unsafe as [[] ? ? ? ?]=> //.
369
417
Qed .
370
418
Next Obligation .
371
419
cbn in H. split; cbn; intuition eauto .
@@ -409,8 +457,8 @@ Program Definition run_erase_program {guard : abstract_guard_impl} econf :=
409
457
else run (erasure_pipeline ▷ (optional_unsafe_transforms econf)).
410
458
Next Obligation .
411
459
Proof .
412
- unfold optional_unsafe_transforms.
413
- destruct enable_unsafe => //.
460
+ unfold optional_unsafe_transforms; cbn .
461
+ destruct enable_unsafe as [[] ? ? ? ?] => //.
414
462
Qed .
415
463
416
464
Program Definition erase_and_print_template_program econf (p : Ast.Env.program) : string :=
@@ -425,23 +473,23 @@ Next Obligation.
425
473
Qed .
426
474
427
475
Definition erasure_fast_config :=
428
- {| enable_unsafe := false ;
476
+ {| enable_unsafe := no_unsafe_passes ;
429
477
dearging_config := default_dearging_config;
430
478
enable_typed_erasure := false;
431
479
enable_fast_remove_params := true;
432
480
inductives_mapping := [];
433
- inlining := KernameSet.empty |}.
481
+ inlined_constants := KernameSet.empty |}.
434
482
435
483
Program Definition erase_fast_and_print_template_program (p : Ast.Env.program) : string :=
436
484
erase_and_print_template_program erasure_fast_config p.
437
485
438
486
Definition typed_erasure_config :=
439
- {| enable_unsafe := false ;
487
+ {| enable_unsafe := no_unsafe_passes ;
440
488
dearging_config := default_dearging_config;
441
489
enable_typed_erasure := true;
442
490
enable_fast_remove_params := true;
443
491
inductives_mapping := [];
444
- inlining := KernameSet.empty |}.
492
+ inlined_constants := KernameSet.empty |}.
445
493
446
494
(* Parameterized by a configuration for dearging, allowing to, e.g., override masks. *)
447
495
Program Definition typed_erase_and_print_template_program (p : Ast.Env.program)
0 commit comments