Skip to content

Commit 8d576c7

Browse files
authored
Merge pull request #538 from jakobbotsch/eval-no-axioms
Remove evaluation of axioms from wcbv and add proof of consistency using safe reduction + canonicity
2 parents 18d18e0 + f1655e7 commit 8d576c7

File tree

10 files changed

+368
-460
lines changed

10 files changed

+368
-460
lines changed

erasure/theories/EArities.v

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,6 @@ Qed.
548548

549549
Lemma Is_type_eval (Σ : global_env_ext) t v:
550550
wf Σ ->
551-
axiom_free Σ ->
552551
eval Σ t v ->
553552
isErasable Σ [] t ->
554553
isErasable Σ [] v.
@@ -563,13 +562,12 @@ Qed.
563562

564563
Lemma Is_type_eval_inv (Σ : global_env_ext) t v:
565564
wf_ext Σ ->
566-
axiom_free Σ ->
567565
PCUICSafeLemmata.welltyped Σ [] t ->
568566
PCUICWcbvEval.eval Σ t v ->
569567
isErasable Σ [] v ->
570568
∥ isErasable Σ [] t ∥.
571569
Proof.
572-
intros wfΣ axfree [T HT] ev [vt [Ht Hp]].
570+
intros wfΣ [T HT] ev [vt [Ht Hp]].
573571
eapply wcbeval_red in ev; eauto.
574572
pose proof (subject_reduction _ _ _ _ _ wfΣ.1 HT ev).
575573
pose proof (common_typing _ wfΣ Ht X) as [P [Pvt [Pt vP]]].

erasure/theories/EOptimizePropDiscr.v

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -232,27 +232,25 @@ Proof.
232232
Qed.
233233

234234
Lemma erasable_tBox_value (wfl := Ee.default_wcbv_flags) (Σ : global_env_ext) (wfΣ : wf_ext Σ) t T v :
235-
axiom_free Σ.1 ->
236235
forall wt : Σ ;;; [] |- t : T,
237236
Σ |-p t ▷ v -> erases Σ [] v tBox -> ∥ isErasable Σ [] t ∥.
238237
Proof.
239238
intros.
240-
depind H0.
239+
depind H.
241240
eapply Is_type_eval_inv; eauto. eexists; eauto.
242241
Qed.
243242

244243
Lemma erase_eval_to_box (wfl := Ee.default_wcbv_flags) {Σ : global_env_ext} {wfΣ : wf_ext Σ} {t v Σ' t' deps} :
245-
axiom_free Σ.1 ->
246244
forall wt : welltyped Σ [] t,
247245
erase Σ (sq wfΣ) [] t wt = t' ->
248246
KernameSet.subset (term_global_deps t') deps ->
249247
erase_global deps Σ (sq wfΣ.1) = Σ' ->
250248
PCUICWcbvEval.eval Σ t v ->
251249
@Ee.eval Ee.default_wcbv_flags Σ' t' tBox -> ∥ isErasable Σ [] t ∥.
252250
Proof.
253-
intros axiomfree [T wt].
251+
intros [T wt].
254252
intros.
255-
destruct (erase_correct Σ wfΣ _ _ _ _ _ axiomfree _ H H0 H1 X) as [ev [eg [eg']]].
253+
destruct (erase_correct Σ wfΣ _ _ _ _ _ _ H H0 H1 X) as [ev [eg [eg']]].
256254
pose proof (Ee.eval_deterministic H2 eg'). subst.
257255
eapply erasable_tBox_value; eauto.
258256
Qed.
@@ -457,18 +455,16 @@ Proof.
457455
Qed.
458456

459457
Lemma erase_opt_correct (wfl := Ee.default_wcbv_flags) (Σ : global_env_ext) (wfΣ : wf_ext Σ) t v Σ' t' :
460-
axiom_free Σ.1 ->
461458
forall wt : welltyped Σ [] t,
462459
erase Σ (sq wfΣ) [] t wt = t' ->
463460
erase_global (term_global_deps t') Σ (sq wfΣ.1) = Σ' ->
464461
PCUICWcbvEval.eval Σ t v ->
465462
∃ v' : term, Σ;;; [] |- v ⇝ℇ v' ∧
466463
∥ @Ee.eval Ee.opt_wcbv_flags (optimize_env Σ') (optimize Σ' t') (optimize Σ' v') ∥.
467464
Proof.
468-
intros axiomfree wt.
465+
intros wt.
469466
generalize (sq wfΣ.1) as swfΣ.
470467
intros swfΣ HΣ' Ht' ev.
471-
assert (extraction_pre Σ) by now constructor.
472468
pose proof (erases_erase (wfΣ := sq wfΣ) wt); eauto.
473469
rewrite HΣ' in H.
474470
destruct wt as [T wt].
@@ -485,5 +481,3 @@ Proof.
485481
eapply KernameSet.subset_spec.
486482
intros x hin; auto.
487483
Qed.
488-
489-
Print Assumptions erase_opt_correct.

erasure/theories/ErasureCorrectness.v

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -429,14 +429,7 @@ Qed.
429429

430430
(** ** The correctness proof *)
431431

432-
Record extraction_pre (Σ : global_env_ext) : Type
433-
:= Build_extraction_pre
434-
{ extr_env_axiom_free' : axiom_free (fst Σ);
435-
extr_env_wf' : wf_ext Σ }.
436-
437432
Hint Constructors PCUICWcbvEval.eval erases : core.
438-
Arguments extr_env_wf' {Σ}.
439-
Arguments extr_env_axiom_free' {Σ}.
440433

441434
Definition EisConstruct_app :=
442435
fun t => match (EAstUtils.decompose_app t).1 with
@@ -682,16 +675,16 @@ Proof.
682675
Qed.
683676

684677
Lemma erases_correct (wfl := default_wcbv_flags) Σ t T t' v Σ' :
685-
extraction_pre Σ ->
678+
wf_ext Σ ->
686679
Σ;;; [] |- t : T ->
687680
Σ;;; [] |- t ⇝ℇ t' ->
688681
erases_deps Σ Σ' t' ->
689682
Σ |-p t ▷ v ->
690683
exists v', Σ;;; [] |- v ⇝ℇ v' /\ ∥ Σ' ⊢ t' ▷ v' ∥.
691684
Proof.
692-
intros pre Hty He Hed H.
685+
intros wfΣ Hty He Hed H.
693686
revert T Hty t' He Hed.
694-
induction H; intros T Hty t' He Hed; destruct pre as [axfree wfΣ].
687+
induction H; intros T Hty t' He Hed.
695688
- assert (Hty' := Hty).
696689
assert (eval Σ (PCUICAst.tApp f a) res) by eauto.
697690
eapply inversion_App in Hty as (? & ? & ? & ? & ? & ?).
@@ -805,10 +798,6 @@ Proof.
805798
+ exists EAst.tBox. split. econstructor.
806799
eapply Is_type_eval. 3: eassumption. eauto. eauto. eauto. constructor. econstructor. eauto.
807800

808-
- destruct Σ as (Σ, univs).
809-
cbn in *.
810-
eapply axfree in isdecl. congruence.
811-
812801
- assert (Hty' := Hty).
813802
assert (Σ |-p tCase (ind, pars) p discr brs ▷ res) by eauto.
814803
eapply inversion_Case in Hty' as [u' [args' [mdecl [idecl [ps [pty [btys
@@ -906,7 +895,7 @@ Proof.
906895
eapply subject_reduction. eauto. exact Hty.
907896
etransitivity.
908897
eapply PCUICReduction.red_case_c. eapply wcbeval_red. eauto.
909-
now eapply PCUICClosed.subject_closed in t0. eauto. eauto.
898+
eauto. eauto.
910899

911900
etransitivity. constructor. constructor.
912901
unfold iota_red. rewrite <- nth_default_eq. unfold nth_default.
@@ -949,7 +938,7 @@ Proof.
949938
eapply subject_reduction. eauto. exact Hty.
950939
etransitivity.
951940
eapply PCUICReduction.red_case_c. eapply wcbeval_red. eauto.
952-
now eapply PCUICClosed.subject_closed in t0; eauto. eauto. eauto.
941+
eauto. eauto.
953942
etransitivity. constructor. constructor.
954943
unfold iota_red. rewrite <- nth_default_eq. reflexivity.
955944

@@ -1062,7 +1051,7 @@ Proof.
10621051
eapply erases_deps_mkApps_inv in Hty_vc' as (? & ?).
10631052
now eapply nth_error_forall in H1; eauto.
10641053
+ exists EAst.tBox. split. econstructor.
1065-
eapply Is_type_eval. 4: eassumption. all:eauto. constructor. econstructor. eauto.
1054+
eapply Is_type_eval. 3: eassumption. all:eauto. constructor. econstructor. eauto.
10661055

10671056
- assert (Hty' := Hty).
10681057
assert (Hunf := H).
@@ -1080,7 +1069,7 @@ Proof.
10801069

10811070
+ exists EAst.tBox. split; [|now constructor; constructor].
10821071
econstructor.
1083-
eapply Is_type_eval. 4:eapply X. eauto. eauto.
1072+
eapply Is_type_eval. 3:eapply X. eauto.
10841073
eapply eval_fix; eauto.
10851074
rewrite /cunfold_fix e0 //. congruence.
10861075
+ depelim Hed.
@@ -1151,10 +1140,11 @@ Proof.
11511140
assert(Σ ;;; [] |- mkApps (tFix mfix idx) (argsv ++ [av]) : PCUICLiftSubst.subst [av] 0 x1).
11521141
{ rewrite -mkApps_nested. eapply PCUICValidity.type_App'; eauto.
11531142
eapply subject_reduction_eval; eauto. }
1154-
epose proof (fix_app_is_constructor Σ (args:=argsv ++ [av]) axfree X).
1143+
epose proof (fix_app_is_constructor Σ (args:=argsv ++ [av]) X).
11551144
rewrite /unfold_fix e0 in X0.
11561145
specialize (X0 eq_refl). simpl in X0.
11571146
rewrite nth_error_snoc in X0. auto. apply X0.
1147+
eapply value_axiom_free, eval_to_value; eauto.
11581148
eapply value_whnf; eauto.
11591149
eapply eval_closed; eauto. now eapply PCUICClosed.subject_closed in t0.
11601150
eapply eval_to_value; eauto. }
@@ -1214,7 +1204,7 @@ Proof.
12141204
-- exists EAst.tBox.
12151205
split.
12161206
++ econstructor.
1217-
eapply Is_type_eval. 4:eauto. all:eauto.
1207+
eapply Is_type_eval. 3:eauto. all:eauto.
12181208
rewrite -mkApps_nested.
12191209
eapply eval_fix; eauto.
12201210
1-2:eapply value_final, eval_to_value; eauto.
@@ -1232,7 +1222,7 @@ Proof.
12321222
destruct Hty' as (? & ? & ? & ? & ? & ?).
12331223

12341224
eapply subject_reduction in t as typ_stuck_fix; [|eauto|]; first last.
1235-
{ eapply wcbeval_red. 4:eauto. all:eauto. }
1225+
{ eapply wcbeval_red. 3:eauto. all:eauto. }
12361226

12371227
eapply erases_App in He as He'; [|eauto].
12381228
destruct He' as [(-> & [])|(? & ? & -> & ? & ?)].
@@ -1242,12 +1232,12 @@ Proof.
12421232
eapply Is_type_red.
12431233
* eauto.
12441234
* eapply PCUICReduction.red_app.
1245-
-- eapply wcbeval_red; [eauto|eauto| |eauto]. eauto.
1246-
-- eapply wcbeval_red; [eauto|eauto| |eauto]. eauto.
1235+
-- eapply wcbeval_red; [eauto| |eauto]. eauto.
1236+
-- eapply wcbeval_red; [eauto| |eauto]. eauto.
12471237
* eauto.
12481238
+ depelim Hed.
12491239
eapply subject_reduction in t0 as typ_arg; [|eauto|]; first last.
1250-
{ eapply wcbeval_red; [eauto|eauto| |eauto]. eauto. }
1240+
{ eapply wcbeval_red; [eauto| |eauto]. eauto. }
12511241

12521242
eapply IHeval1 in H1 as (? & ? & [?]); [|now eauto|now eauto].
12531243
eapply IHeval2 in H2 as (? & ? & [?]); [|now eauto|now eauto].

erasure/theories/ErasureFunction.v

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,18 +1187,16 @@ Proof.
11871187
Qed.
11881188

11891189
Lemma erase_correct (wfl := Ee.default_wcbv_flags) (Σ : global_env_ext) (wfΣ : wf_ext Σ) t v Σ' t' deps :
1190-
axiom_free Σ.1 ->
11911190
forall wt : welltyped Σ [] t,
11921191
erase Σ (sq wfΣ) [] t wt = t' ->
11931192
KernameSet.subset (term_global_deps t') deps ->
11941193
erase_global deps Σ (sq (wfΣ.1)) = Σ' ->
11951194
Σ |-p t ▷ v ->
11961195
exists v', Σ;;; [] |- v ⇝ℇ v' /\ ∥ Σ' ⊢ t' ▷ v' ∥.
11971196
Proof.
1198-
intros axiomfree wt.
1197+
intros wt.
11991198
generalize (sq wfΣ.1) as swfΣ.
12001199
intros swfΣ HΣ' Hsub Ht' ev.
1201-
assert (extraction_pre Σ) by now constructor.
12021200
pose proof (erases_erase (wfΣ := sq wfΣ) wt); eauto.
12031201
rewrite HΣ' in H.
12041202
destruct wt as [T wt].

erasure/theories/Prelim.v

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ Module P := PCUICWcbvEval.
1616

1717
Ltac inv H := inversion H; subst; clear H.
1818

19-
Existing Class axiom_free.
20-
2119
Lemma nth_error_app_inv X (x : X) n l1 l2 :
2220
nth_error (l1 ++ l2) n = Some x -> (n < #|l1| /\ nth_error l1 n = Some x) \/ (n >= #|l1| /\ nth_error l2 (n - List.length l1) = Some x).
2321
Proof.
@@ -121,7 +119,7 @@ Proof.
121119
now exists A.
122120
Qed.
123121

124-
Theorem subject_reduction_eval {Σ :global_env_ext} {t u T} {wfΣ : wf Σ} {axfree : axiom_free Σ} :
122+
Theorem subject_reduction_eval {Σ :global_env_ext} {t u T} {wfΣ : wf Σ} :
125123
Σ ;;; [] |- t : T -> PCUICWcbvEval.eval Σ t u -> Σ ;;; [] |- u : T.
126124
Proof.
127125
intros Hty Hred.
@@ -133,7 +131,7 @@ Lemma typing_spine_eval:
133131
(X : All2 (PCUICWcbvEval.eval Σ) args args') (bla : wf Σ)
134132
(T x x0 : PCUICAst.term) (t0 : typing_spine Σ [] x args x0)
135133
(c : Σ;;; [] |- x0 <= T) (x1 : PCUICAst.term)
136-
(c0 : Σ;;; [] |- x1 <= x), axiom_free Σ -> isType Σ [] T -> typing_spine Σ [] x1 args' T.
134+
(c0 : Σ;;; [] |- x1 <= x), isType Σ [] T -> typing_spine Σ [] x1 args' T.
137135
Proof.
138136
intros. eapply typing_spine_red; eauto.
139137
eapply typing_spine_wt in t0; auto.

0 commit comments

Comments
 (0)