@@ -3,15 +3,59 @@ From Coq Require Import Program ssrbool.
33From MetaCoq.Utils Require Import utils.
44From MetaCoq.Common Require Import config Primitive.
55From MetaCoq.PCUIC Require Import PCUICAst PCUICAstUtils PCUICPrimitive PCUICTyping
6- PCUICElimination PCUICWcbvEval PCUICFirstorder.
6+ PCUICElimination PCUICWcbvEval PCUICFirstorder
7+ PCUICWellScopedCumulativity PCUICFirstorder PCUICNormalization PCUICReduction
8+ PCUICConversion PCUICPrincipality PCUICNormal.
9+
710From MetaCoq.Erasure Require EAst EGlobalEnv.
811
912Module E := EAst.
1013
1114Local Existing Instance extraction_checker_flags.
1215
13- Definition isErasable Σ Γ t := ∑ T, Σ ;;; Γ |- t : T × (isArity T + (∑ u, (Σ ;;; Γ |- T : tSort u) *
14- is_propositional u))%type.
16+ (* A term is erasable if it has _a_ type which either:
17+ - is a syntactic arity
18+ - is of propositional type *)
19+ Definition isErasable Σ Γ t :=
20+ ∑ T, Σ ;;; Γ |- t : T ×
21+ (isArity T + (∑ u, (Σ ;;; Γ |- T : tSort u) * is_propositional u))%type.
22+
23+ (* A more positive notion of relevant terms.
24+ Showing that a term is not erasable requires quantification over all its possible typings.
25+ We give a more positive characterization of relevant terms. A term is not erasable if
26+ it has _a_ type in normal form which is not an arity and whose sort is not propositional.
27+ *)
28+ Definition nisErasable Σ Γ t :=
29+ ∑ T u,
30+ [× Σ;;; Γ |- t : T,
31+ nf Σ Γ T,
32+ ~ isArity T,
33+ Σ;;; Γ |- T : tSort u &
34+ ~ is_propositional u].
35+
36+ Lemma nisErasable_spec Σ Γ t :
37+ wf_ext Σ -> wf_local Σ Γ ->
38+ nisErasable Σ Γ t -> ~ ∥ isErasable Σ Γ t ∥.
39+ Proof .
40+ intros wf wf' [T [u []]].
41+ intros []. destruct X as [T' []].
42+ destruct s.
43+ * destruct (common_typing _ _ t0 t2) as (? & e & ? & ?).
44+ eapply PCUICClassification.invert_cumul_arity_l_gen in e. destruct e as [s [[hr] ha]].
45+ eapply (proj2 (nf_red _ _ _ _)) in n. 2:eapply hr. subst. contradiction.
46+ eapply PCUICClassification.invert_cumul_arity_r_gen. 2:exact w.
47+ exists T'. split; auto. sq.
48+ eapply PCUICValidity.validity in t2 as [s Hs].
49+ eapply PCUICClassification.wt_closed_red_refl; eauto.
50+ * destruct (principal_type _ _ t0) as [princ hprinc].
51+ destruct s as [u' [hs isp]].
52+ pose proof (hprinc _ t2) as [].
53+ destruct (PCUICValidity.validity t3).
54+ eapply PCUICElimination.unique_sorting_equality_propositional in hs; tea; eauto.
55+ pose proof (hprinc _ t0) as [].
56+ eapply PCUICElimination.unique_sorting_equality_propositional in t1; tea; eauto.
57+ congruence.
58+ Qed .
1559
1660Fixpoint mkAppBox c n :=
1761 match n with
0 commit comments