@@ -606,188 +606,6 @@ Section Spines.
606606
607607End Spines.
608608
609- (*
610- Section Normalization.
611- Context {cf:checker_flags} (Σ : global_env_ext).
612- Context {wfΣ : wf Σ}.
613-
614- Section reducible.
615- Lemma reducible Γ t : sum (∑ t', red1 Σ Γ t t') (forall t', red1 Σ Γ t t' -> False).
616- Proof.
617- Local Ltac lefte := left; eexists; econstructor; eauto.
618- Local Ltac leftes := left; eexists; econstructor; solve [eauto].
619- Local Ltac righte := right; intros t' red; depelim red; solve_discr; eauto 2.
620- induction t in Γ |- * using term_forall_list_ind.
621- (*all:try solve [righte].
622- - destruct (nth_error Γ n) eqn:hnth.
623- destruct c as [na [b|] ty]; [lefte|righte].
624- * rewrite hnth; reflexivity.
625- * rewrite hnth /= // in e.
626- * righte. rewrite hnth /= // in e.
627- - admit.
628- - destruct (IHt1 Γ) as [[? ?]|]; [lefte|].
629- destruct (IHt2 (Γ ,, vass n t1)) as [[? ?]|]; [|righte].
630- leftes.
631- - destruct (IHt1 Γ) as [[? ?]|]; [lefte|].
632- destruct (IHt2 (Γ ,, vass n t1)) as [[? ?]|]; [|righte].
633- leftes.
634- - destruct (IHt1 Γ) as [[? ?]|]; [lefte|].
635- destruct (IHt2 Γ) as [[? ?]|]; [lefte|].
636- destruct (IHt3 (Γ ,, vdef n t1 t2)) as [[? ?]|]; [|].
637- leftes. lefte.
638- - destruct (IHt1 Γ) as [[? ?]|]; [lefte|].
639- destruct (IHt2 Γ) as [[? ?]|]; [leftes|].
640- destruct (PCUICParallelReductionConfluence.view_lambda_fix_app t1 t2).
641- * rewrite [tApp _ _](mkApps_nested _ _ [a]).
642- destruct (unfold_fix mfix i) as [[rarg body]|] eqn:unf.
643- destruct (is_constructor rarg (l ++ [a])) eqn:isc; [leftes|]; eauto.
644- right => t' red; depelim red; solve_discr; eauto.
645- rewrite -mkApps_nested in H. noconf H. eauto.
646- rewrite -mkApps_nested in H. noconf H. eauto.
647- eapply (f_equal (@length _)) in H1. rewrite /= app_length /= // in H1; lia.
648- eapply (f_equal (@length _)) in H1. rewrite /= app_length /= // in H1; lia.
649- righte; try (rewrite -mkApps_nested in H; noconf H); eauto.
650- eapply (f_equal (@length _)) in H1. rewrite /= app_length /= // in H1; lia.
651- eapply (f_equal (@length _)) in H1. rewrite /= app_length /= // in H1; lia.
652- * admit.
653- * righte. destruct args using rev_case; solve_discr; noconf H.
654- rewrite H in i. eapply negb_False; eauto.
655- rewrite -mkApps_nested; eapply isFixLambda_app_mkApps' => //.
656- - admit.
657- - admit.
658- - admit.
659- - admit.
660- - admit. *)
661-
662- Admitted.
663- End reducible.
664-
665- Lemma reducible' Γ t : sum (∑ t', red1 Σ Γ t t') (normal Σ Γ t).
666- Proof.
667- Ltac lefte := left; eexists; econstructor; eauto.
668- Ltac leftes := left; eexists; econstructor; solve [eauto].
669- Ltac righte := right; (solve [repeat (constructor; eauto)])||(repeat constructor).
670- induction t in Γ |- * using term_forall_list_ind.
671- all:try solve [righte].
672- - destruct (nth_error Γ n) eqn:hnth.
673- destruct c as [na [b|] ty]; [lefte|].
674- * rewrite hnth; reflexivity.
675- * right. do 2 constructor; rewrite hnth /= //.
676- * righte. rewrite hnth /= //.
677- - admit.
678- - destruct (IHt1 Γ) as [[? ?]|]; [lefte|].
679- destruct (IHt2 (Γ ,, vass n t1)) as [[? ?]|]; [|].
680- leftes. right; solve[constructor; eauto].
681- - destruct (IHt1 Γ) as [[? ?]|]; [lefte|].
682- destruct (IHt2 (Γ ,, vass n t1)) as [[? ?]|]; [leftes|leftes].
683- - destruct (IHt1 Γ) as [[? ?]|]; [lefte|].
684- destruct (IHt2 Γ) as [[? ?]|]; [leftes|].
685- destruct (PCUICParallelReductionConfluence.view_lambda_fix_app t1 t2).
686- * rewrite [tApp _ _](mkApps_nested _ _ [a]).
687- destruct (unfold_fix mfix i) as [[rarg body]|] eqn:unf.
688- destruct (is_constructor rarg (l ++ [a])) eqn:isc; [leftes|]; eauto.
689- right; constructor. rewrite -mkApps_nested. constructor. admit. admit. admit.
690- * admit.
691- * admit.
692- - admit.
693- - admit.
694- - admit.
695- - admit.
696- - admit.
697- Admitted.
698-
699- Lemma normalizer {Γ t ty} :
700- Σ ;;; Γ |- t : ty ->
701- ∑ nf, (red Σ.1 Γ t nf) * normal Σ Γ nf.
702- Proof.
703- intros Hty.
704- unshelve epose proof (PCUICSN.normalisation Σ Γ t (iswelltyped _ _ _ ty Hty)).
705- clear ty Hty.
706- move: t H. eapply Fix_F.
707- intros x IH.
708- destruct (reducible' Γ x) as [[t' red]|nred].
709- specialize (IH t'). forward IH by (constructor; auto).
710- destruct IH as [nf [rednf norm]].
711- exists nf; split; auto. now transitivity t'.
712- exists x. split; [constructor|assumption].
713- Qed.
714-
715- Derive Signature for neutral normal.
716-
717- Lemma typing_var {Γ n ty} : Σ ;;; Γ |- (tVar n) : ty -> False.
718- Proof. intros Hty; depind Hty; eauto. Qed.
719-
720- Lemma typing_evar {Γ n l ty} : Σ ;;; Γ |- (tEvar n l) : ty -> False.
721- Proof. intros Hty; depind Hty; eauto. Qed.
722-
723- Definition axiom_free Σ :=
724- forall c decl, declared_constant Σ c decl -> cst_body decl <> None.
725-
726- Lemma neutral_empty t ty : axiom_free Σ -> Σ ;;; [] |- t : ty -> neutral Σ [] t -> False.
727- Proof.
728- intros axfree typed ne.
729- pose proof (PCUICClosed.subject_closed wfΣ typed) as cl.
730- depind ne.
731- - now simpl in cl.
732- - now eapply typing_var in typed.
733- - now eapply typing_evar in typed.
734- - eapply inversion_Const in typed as [decl [wfd [declc [cu cum]]]]; eauto.
735- specialize (axfree _ _ declc). specialize (H decl).
736- destruct (cst_body decl); try congruence.
737- now specialize (H t declc eq_refl).
738- - simpl in cl; move/andP: cl => [clf cla].
739- eapply inversion_App in typed as [na [A [B [Hf _]]]]; eauto.
740- - simpl in cl; move/andP: cl => [/andP[_ clc] _].
741- eapply inversion_Case in typed; pcuicfo eauto.
742- - eapply inversion_Proj in typed; pcuicfo auto.
743- Qed.
744-
745- Lemma ind_normal_constructor t i u args :
746- axiom_free Σ ->
747- Σ ;;; [] |- t : mkApps (tInd i u) args -> normal Σ [] t -> construct_cofix_discr (head t).
748- Proof.
749- intros axfree Ht capp. destruct capp.
750- - eapply neutral_empty in H; eauto.
751- - eapply inversion_Sort in Ht as (? & ? & ? & ? & ?); auto.
752- eapply invert_cumul_sort_l in c as (? & ? & ?).
753- eapply red_mkApps_tInd in r as (? & eq & ?); eauto; eauto.
754- solve_discr.
755- - eapply inversion_Prod in Ht as (? & ? & ? & ? & ?); auto.
756- eapply invert_cumul_sort_l in c as (? & ? & ?).
757- eapply red_mkApps_tInd in r as (? & eq & ?); eauto; eauto.
758- solve_discr.
759- - eapply inversion_Lambda in Ht as (? & ? & ? & ? & ?); auto.
760- eapply invert_cumul_prod_l in c as (? & ? & ? & (? & ?) & ?); auto.
761- eapply red_mkApps_tInd in r as (? & eq & ?); eauto; eauto.
762- solve_discr.
763- - now rewrite head_mkApps /= /head /=.
764- - eapply PCUICValidity.inversion_mkApps in Ht as (? & ? & ?); auto.
765- eapply inversion_Ind in t as (? & ? & ? & decli & ? & ?); auto.
766- eapply PCUICSpine.typing_spine_strengthen in t0; eauto.
767- pose proof (on_declared_inductive wfΣ decli) as [onind oib].
768- rewrite oib.(ind_arity_eq) in t0.
769- rewrite !subst_instance_constr_it_mkProd_or_LetIn in t0.
770- eapply typing_spine_arity_mkApps_Ind in t0; eauto.
771- eexists; split; [sq|]; eauto.
772- now do 2 eapply isArity_it_mkProd_or_LetIn.
773- - admit. (* wf of fixpoints *)
774- - now rewrite /head /=.
775- Admitted.
776-
777- Lemma red_normal_constructor t i u args :
778- axiom_free Σ ->
779- Σ ;;; [] |- t : mkApps (tInd i u) args ->
780- ∑ hnf, (red Σ.1 [] t hnf) * construct_cofix_discr (head hnf).
781- Proof.
782- intros axfree Ht. destruct (normalizer Ht) as [nf [rednf capp]].
783- exists nf; split; auto.
784- eapply subject_reduction in Ht; eauto.
785- now eapply ind_normal_constructor.
786- Qed.
787-
788- End Normalization.
789- *)
790-
791609(** Evaluation is a subrelation of reduction: *)
792610
793611Tactic Notation "redt" uconstr(y) := eapply (CRelationClasses.transitivity (R:=red _ _) (y:=y)).
@@ -833,69 +651,12 @@ Section WeakNormalization.
833651 now eapply value_whnf.
834652 Qed .
835653
836- (*
837- Lemma reducible Γ t : sum (∑ t', red1 Σ Γ t t') (wh_normal Σ Γ t).
838- Proof.
839- Ltac lefte := left; eexists; econstructor; eauto.
840- Ltac leftes := left; eexists; econstructor; solve [eauto].
841- Ltac righte := right; (solve [repeat (constructor; eauto)])||(repeat constructor).
842- induction t in Γ |- * using term_forall_list_ind.
843- all:try solve [righte].
844- - destruct (nth_error Γ n) eqn:hnth.
845- destruct c as [na [b|] ty]; [lefte|].
846- * rewrite hnth; reflexivity.
847- * right. do 2 constructor; rewrite hnth /= //.
848- * righte. rewrite hnth /= //. admit.
849- - destruct (IHt1 Γ) as [[? ?]|]; [lefte|].
850- destruct (IHt2 Γ) as [[? ?]|]; [leftes|].
851- destruct (IHt2 (Γ ,, vass n t1)) as [[? ?]|]; [|].
852- leftes. leftes.
853- - destruct (IHt1 Γ) as [[? ?]|]; [lefte|].
854- destruct (IHt2 Γ) as [[? ?]|]; [leftes|].
855- destruct (PCUICParallelReductionConfluence.view_lambda_fix_app t1 t2).
856- * rewrite [tApp _ _](mkApps_nested _ _ [a]).
857- destruct (unfold_fix mfix i) as [[rarg body]|] eqn:unf.
858- + destruct (is_constructor rarg (l ++ [a])) eqn:isc; [leftes|]; eauto.
859- right. rewrite /is_constructor in isc.
860- destruct nth_error eqn:eq.
861- ++ constructor; eapply whne_fixapp; eauto. admit.
862- ++ eapply whnf_fixapp. rewrite unf //.
863- + right. eapply whnf_fixapp. rewrite unf //.
864- * left. induction l; simpl. eexists. constructor.
865- eexists. eapply app_red_l. eapply red1_mkApps_l. constructor.
866- * admit.
867- - admit.
868- - admit.
869- - admit.
870- - admit.
871- - admit.
872- Admitted.
873-
874- Lemma normalizer {Γ t ty} :
875- Σ ;;; Γ |- t : ty ->
876- ∑ nf, (red Σ.1 Γ t nf) * wh_normal Σ Γ nf.
877- Proof.
878- intros Hty.
879- unshelve epose proof (PCUICSN.normalisation Σ Γ t (iswelltyped _ _ _ ty Hty)).
880- clear ty Hty.
881- move: t H. eapply Fix_F.
882- intros x IH.
883- destruct (reducible Γ x) as [[t' red]|nred].
884- specialize (IH t'). forward IH by (constructor; auto).
885- destruct IH as [nf [rednf norm]].
886- exists nf; split; auto. now transitivity t'.
887- exists x. split; [constructor|assumption].
888- Qed. *)
889-
890654 Lemma typing_var {Γ n ty} : Σ ;;; Γ |- (tVar n) : ty -> False.
891655 Proof . intros Hty; depind Hty; eauto. Qed .
892656
893657 Lemma typing_evar {Γ n l ty} : Σ ;;; Γ |- (tEvar n l) : ty -> False.
894658 Proof . intros Hty; depind Hty; eauto. Qed .
895659
896- Definition axiom_free Σ :=
897- forall c decl, declared_constant Σ c decl -> cst_body decl <> None.
898-
899660 Lemma invert_cumul_prod_ind {Γ na dom codom ind u args} :
900661 Σ ;;; Γ |- tProd na dom codom <= mkApps (tInd ind u) args -> False.
901662 Proof .
@@ -1015,8 +776,8 @@ Section WeakNormalization.
1015776 match t with
1016777 | tApp hd arg => axiom_free_value Σ (axiom_free_value Σ [] arg :: args) hd
1017778 | tConst kn _ => match lookup_env Σ kn with
1018- | Some (ConstantDecl {| cst_body := Some _ |}) => true
1019- | _ => false
779+ | Some (ConstantDecl {| cst_body := None |}) => false
780+ | _ => true
1020781 end
1021782 | tCase _ _ discr _ => axiom_free_value Σ [] discr
1022783 | tProj _ t => axiom_free_value Σ [] t
@@ -1119,7 +880,7 @@ Section WeakNormalization.
1119880 axiom_free_value Σ [] t ->
1120881 Σ ;;; [] |- t : mkApps (tInd ind u) indargs ->
1121882 wh_normal Σ [] t ->
1122- check_recursivity_kind Σ (inductive_mind ind) Finite ->
883+ ~ check_recursivity_kind Σ (inductive_mind ind) CoFinite ->
1123884 isConstruct_app t.
1124885 Proof .
1125886 intros axfree typed whnf ck.
@@ -1130,7 +891,7 @@ Section WeakNormalization.
1130891 destruct hd eqn:eqh => //. subst hd.
1131892 eapply decompose_app_inv in da. subst.
1132893 eapply typing_cofix_coind in typed.
1133- now move: (check_recursivity_kind_inj typed ck) .
894+ auto .
1134895 Qed .
1135896
1136897 Lemma fix_app_is_constructor {mfix idx args ty narg fn} :
@@ -1149,11 +910,13 @@ Section WeakNormalization.
1149910 rewrite /unfold_fix in unf. rewrite e in unf.
1150911 noconf unf.
1151912 eapply (wf_fixpoint_spine wfΣ) in t0; eauto.
1152- rewrite /is_constructor. destruct (nth_error args (rarg x0)) eqn:hnth.
913+ rewrite /is_constructor. destruct (nth_error args (rarg x0)) eqn:hnth; [|assumption] .
1153914 destruct_sigma t0. destruct t0.
1154915 intros axfree norm.
1155916 eapply whnf_ind_finite in t0; eauto.
1156- assumption.
917+ intros chk.
918+ pose proof (check_recursivity_kind_inj chk i1).
919+ discriminate.
1157920 Qed .
1158921
1159922 Lemma value_axiom_free Σ' t :
0 commit comments