55From Coq Require Import Utf8 Program .
66From MetaCoq.Utils Require Import utils.
77From MetaCoq.Common Require Import config Kernames EnvMap BasicAst.
8- From MetaCoq.Erasure Require Import EAst EAstUtils EInduction EGlobalEnv EExtends EWellformed ELiftSubst ESpineView ECSubst EWcbvEval EWcbvEvalInd EProgram.
8+ From MetaCoq.Erasure Require Import EPrimitive EAst EAstUtils EInduction EGlobalEnv EExtends EWellformed ELiftSubst ESpineView ECSubst EWcbvEval EWcbvEvalInd EProgram.
99
1010Local Open Scope string_scope.
1111Set Asymmetric Patterns.
@@ -75,7 +75,7 @@ Section isEtaExp.
7575 | tBox => true
7676 | tVar _ => true
7777 | tConst _ => true
78- | tPrim _ => true
78+ | tPrim p => test_primIn p ( fun x H => isEtaExp x)
7979 | tConstruct ind i block_args => isEtaExp_app ind i 0 && is_nil block_args }.
8080 Proof .
8181 all:try lia.
@@ -92,11 +92,15 @@ Section isEtaExp.
9292 change (fun x => size x) with size in H.
9393 pose proof (size_mkApps_l napp nnil). lia.
9494 - eapply (In_size snd size) in H. cbn in H; lia.
95+ - destruct p as [? []]; cbn in *; intuition eauto.
96+ subst. lia.
97+ eapply (In_size id size) in H0. unfold id in H0.
98+ change (fun x => size x) with size in H0. lia.
9599 Qed .
96100
97101End isEtaExp.
98102
99- Global Hint Rewrite @forallb_InP_spec : isEtaExp.
103+ Global Hint Rewrite @test_primIn_spec @ forallb_InP_spec : isEtaExp.
100104Tactic Notation "simp_eta" "in " hyp(H) := simp isEtaExp in H; rewrite -?isEtaExp_equation_1 in H.
101105Ltac simp_eta := simp isEtaExp; rewrite -?isEtaExp_equation_1.
102106
@@ -276,8 +280,8 @@ Section WeakEtaExp.
276280 eapply a0 => //.
277281 - move/andP: H0 => [] etaexp h.
278282 rewrite csubst_mkApps /=.
279- rewrite isEtaExp_Constructor. solve_all.
280- rewrite map_length. rtoProp; solve_all. solve_all.
283+ rewrite isEtaExp_Constructor; solve_all.
284+ rtoProp; solve_all. solve_all.
281285 now destruct block_args.
282286 - rewrite csubst_mkApps /=.
283287 move/andP: H1 => [] eu ev.
@@ -417,6 +421,7 @@ Proof.
417421 - eapply In_All in H; solve_all.
418422 move/andP: b => [] -> /=. eauto.
419423 - eapply In_All in H; solve_all.
424+ - solve_all.
420425 - eapply In_All in H; solve_all.
421426 rewrite isEtaExp_Constructor //. rtoProp; intuition auto.
422427 eapply isEtaExp_app_extends; tea.
@@ -471,7 +476,7 @@ Inductive expanded : term -> Prop :=
471476 #|args| >= cstr_arity mind cdecl ->
472477 Forall expanded args ->
473478 expanded (mkApps (tConstruct ind idx []) args)
474- | expanded_tPrim p : expanded (tPrim p)
479+ | expanded_tPrim p : primProp expanded p -> expanded (tPrim p)
475480| expanded_tBox : expanded tBox.
476481
477482End expanded.
@@ -510,7 +515,7 @@ forall (Σ : global_declarations) (P : term -> Prop),
510515 (args : list term),
511516 declared_constructor Σ (ind, idx) mind idecl cdecl ->
512517 #|args| >= cstr_arity mind cdecl -> Forall (expanded Σ) args -> Forall P args -> P (mkApps (tConstruct ind idx []) args)) ->
513- (forall p, P (tPrim p)) ->
518+ (forall p, primProp (expanded Σ) p -> primProp P p -> P (tPrim p)) ->
514519(P tBox) ->
515520forall t : term, expanded Σ t -> P t.
516521Proof .
@@ -523,6 +528,9 @@ Proof.
523528 - eapply H8; eauto. induction H13; econstructor; cbn in *; intuition eauto.
524529 - eapply H9; eauto. induction H13; econstructor; cbn in *; eauto.
525530 - eapply H10; eauto. clear - H15 f. induction H15; econstructor; cbn in *; eauto.
531+ - eapply H11; eauto.
532+ depelim X; constructor. destruct p; split; eauto.
533+ eapply (make_All_All f a0).
526534Qed .
527535
528536Local Hint Constructors expanded : core.
@@ -595,6 +603,7 @@ Proof.
595603 intuition auto.
596604 - econstructor. rewrite forallb_InP_spec in H0. eapply forallb_Forall in H0.
597605 eapply In_All in H. solve_all.
606+ - econstructor. rewrite test_primIn_spec in H0. solve_all.
598607 - rtoProp. eapply In_All in H.
599608 rewrite forallb_InP_spec in H2. eapply forallb_Forall in H2.
600609 eapply isEtaExp_app_expanded in H0 as (? & ? & ? & ? & ?).
@@ -621,6 +630,7 @@ Proof.
621630 - rewrite isEtaExp_Constructor. rtoProp; repeat split.
622631 2: eapply forallb_Forall.
623632 2: solve_all. eapply expanded_isEtaExp_app_; eauto.
633+ - solve_all.
624634Qed .
625635
626636Lemma expanded_global_env_isEtaExp_env {Σ} : expanded_global_env Σ -> isEtaExp_env Σ.
@@ -695,6 +705,7 @@ Proof.
695705 - simp_eta. rtoProp; intuition auto.
696706 eapply In_All in H0; solve_all.
697707 - eapply In_All in H. simp_eta; rtoProp; intuition auto. solve_all.
708+ - simp_eta. solve_all_k 7. primProp. solve_all.
698709 - eapply In_All in H. simp_eta; rtoProp; intuition auto.
699710 rewrite EEtaExpanded.isEtaExp_Constructor. rtoProp; repeat split. eauto.
700711 solve_all. destruct block_args; cbn in *; eauto.
0 commit comments