Debian Codegraph @

src/Util/ListUtil/ForallIn.v

raw
1 From Coq Require Import List.
2 Require Import Crypto.Util.Prod.
3 Require Import Crypto.Util.Tactics.DestructHead.
4
5 Lemma fold_right_impl_Proper {A} {P Q : A -> Prop} ls (concl1 concl2 : Prop)
6 (Hconcl : concl1 -> concl2)
7 (HPQ : forall a, In a ls -> Q a -> P a)
8 : fold_right (fun a (concl : Prop) => P a -> concl) concl1 ls
9 -> fold_right (fun a (concl : Prop) => Q a -> concl) concl2 ls.
10 Proof. induction ls as [|x xs IHxs]; cbn [fold_right In] in *; intuition. Qed.
11
12 Lemma forall_In_existT {A P} {Q : forall a : A, P a -> Prop} ls
13 : fold_right
14 (fun xp (concl : Prop)
15 => Q (projT1 xp) (projT2 xp) -> concl)
16 (forall x p, In (@existT A P x p) ls -> Q x p)
17 ls.
18 Proof.
19 induction ls as [|x xs IHxs]; cbn [fold_right In]; intros;
20 destruct_head' False; destruct_head'_or.
21 eapply fold_right_impl_Proper; [ | | refine IHxs ]; intuition (subst; eauto).
22 Qed.
23
24 Lemma forall_In_pair_existT {A A' P P'} {Q : forall (a : A) (a' : A'), P a -> P' a' -> Prop} ls
25 : fold_right
26 (fun xp_x'p' (concl : Prop)
27 => Q (projT1 (fst xp_x'p')) (projT1 (snd xp_x'p')) (projT2 (fst xp_x'p')) (projT2 (snd xp_x'p')) -> concl)
28 (forall x p x' p', In (@existT A P x p, @existT A' P' x' p') ls -> Q x x' p p')
29 ls.
30 Proof.
31 induction ls as [|x xs IHxs]; cbn [fold_right In]; intros;
32 destruct_head' False; destruct_head'_prod; destruct_head'_or; intros.
33 eapply fold_right_impl_Proper; [ | | refine IHxs ]; intuition (inversion_prod; subst; eauto).
34 Qed.