Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move some general utility lemmas from TypingWf to All_Forall #913

Draft
wants to merge 1 commit into
base: coq-8.16
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 0 additions & 48 deletions template-coq/theories/TypingWf.v
Original file line number Diff line number Diff line change
Expand Up @@ -139,32 +139,6 @@ Proof.
induction 1 using red1_ind_all; simpl; try discriminate; auto.
Qed.

Lemma OnOne2_All_All {A} {P Q} {l l' : list A} :
OnOne2 P l l' ->
(forall x y, P x y -> Q x -> Q y) ->
All Q l -> All Q l'.
Proof. intros Hl H. induction Hl; intros H'; inv H'; constructor; eauto. Qed.

Lemma All_mapi {A B} (P : B -> Type) (l : list A) (f : nat -> A -> B) :
Alli (fun i x => P (f i x)) 0 l -> All P (mapi f l).
Proof.
unfold mapi. generalize 0.
induction 1; constructor; auto.
Qed.

Lemma Alli_id {A} (P : nat -> A -> Type) n (l : list A) :
(forall n x, P n x) -> Alli P n l.
Proof.
intros H. induction l in n |- *; constructor; auto.
Qed.


Lemma All_Alli {A} {P : A -> Type} {Q : nat -> A -> Type} {l n} :
All P l ->
(forall n x, P x -> Q n x) ->
Alli Q n l.
Proof. intro H. revert n. induction H; constructor; eauto. Qed.


Ltac wf := intuition try (eauto with wf || congruence || solve [constructor]).
#[global]
Expand Down Expand Up @@ -726,20 +700,6 @@ Section WfLookup.

End WfLookup.

Lemma OnOne2All_All2_All2 (A B C : Type) (P : B -> A -> A -> Type) (Q : C -> A -> Type)
(i : list B) (j : list C) (R : B -> Type) (l l' : list A) :
OnOne2All P i l l' ->
All2 Q j l ->
All R i ->
(forall x y a b, R x -> P x a b -> Q y a -> Q y b) ->
All2 Q j l'.
Proof.
induction 1 in j |- *; intros.
depelim X. depelim X0. constructor; eauto.
depelim X0. depelim X1.
constructor; auto.
Qed.

Section WfRed.
Context {cf:checker_flags}.
Context {Σ : global_env}.
Expand Down Expand Up @@ -937,14 +897,6 @@ End WfRed.
#[global]
Hint Resolve wf_extends strictly_extends_decls_extends_decls strictly_extends_decls_extends_strictly_on_decls extends_decls_extends extends_strictly_on_decls_extends : wf.

Lemma All2i_All2 {A B} {P : nat -> A -> B -> Type} {Q : A -> B -> Type} n l l' :
All2i P n l l' ->
(forall i x y, P i x y -> Q x y) ->
All2 Q l l'.
Proof.
induction 1; constructor; eauto.
Qed.

Lemma cstr_branch_context_length ind mdecl cdecl :
#|cstr_branch_context ind mdecl cdecl| = #|cdecl.(cstr_args)|.
Proof. rewrite /cstr_branch_context. now len. Qed.
Expand Down
48 changes: 48 additions & 0 deletions utils/theories/All_Forall.v
Original file line number Diff line number Diff line change
Expand Up @@ -3716,3 +3716,51 @@ Proof.
move=> + h; elim: h=> [n|n x y xs ys r rs ih] q; depelim q; constructor=> //.
by apply: ih.
Qed.

Lemma OnOne2_All_All {A} {P Q} {l l' : list A} :
OnOne2 P l l' ->
(forall x y, P x y -> Q x -> Q y) ->
All Q l -> All Q l'.
Proof. intros Hl H. induction Hl; intros H'; inv H'; constructor; eauto. Qed.

Lemma All_mapi {A B} (P : B -> Type) (l : list A) (f : nat -> A -> B) :
Alli (fun i x => P (f i x)) 0 l -> All P (mapi f l).
Proof.
unfold mapi. generalize 0.
induction 1; constructor; auto.
Qed.

Lemma Alli_id {A} (P : nat -> A -> Type) n (l : list A) :
(forall n x, P n x) -> Alli P n l.
Proof.
intros H. induction l in n |- *; constructor; auto.
Qed.


Lemma All_Alli {A} {P : A -> Type} {Q : nat -> A -> Type} {l n} :
All P l ->
(forall n x, P x -> Q n x) ->
Alli Q n l.
Proof. intro H. revert n. induction H; constructor; eauto. Qed.

Lemma All2i_All2 {A B} {P : nat -> A -> B -> Type} {Q : A -> B -> Type} n l l' :
All2i P n l l' ->
(forall i x y, P i x y -> Q x y) ->
All2 Q l l'.
Proof.
induction 1; constructor; eauto.
Qed.

Lemma OnOne2All_All2_All2 (A B C : Type) (P : B -> A -> A -> Type) (Q : C -> A -> Type)
(i : list B) (j : list C) (R : B -> Type) (l l' : list A) :
OnOne2All P i l l' ->
All2 Q j l ->
All R i ->
(forall x y a b, R x -> P x a b -> Q y a -> Q y b) ->
All2 Q j l'.
Proof.
induction 1 in j |- *; intros.
depelim X. depelim X0. constructor; eauto.
depelim X0. depelim X1.
constructor; auto.
Qed.