| 1 |
Require Export Crypto.Util.FixCoqMistakes. |
| 2 |
|
| 3 |
(* Coq's build in tactics don't work so well with things like [iff] |
| 4 |
so split them up into multiple hypotheses *) |
| 5 |
Ltac split_in_context_by ident funl funr tac := |
| 6 |
repeat match goal with |
| 7 |
| [ H : context p [ident] |- _ ] => |
| 8 |
let H0 := context p[funl] in |
| 9 |
let H1 := context p[funr] in |
| 10 |
let H0' := (eval cbv beta in H0) in |
| 11 |
let H1' := (eval cbv beta in H1) in |
| 12 |
assert H0' by (tac H); |
| 13 |
assert H1' by (tac H); |
| 14 |
clear H |
| 15 |
end. |
| 16 |
Ltac split_in_context ident funl funr := |
| 17 |
split_in_context_by ident funl funr ltac:(fun H => apply H). |
| 18 |
|
| 19 |
Ltac split_iff := split_in_context iff (fun a b : Prop => a -> b) (fun a b : Prop => b -> a). |
| 20 |
|
| 21 |
Ltac split_contravariant_or := split_in_context_by or (fun A B : Prop => A) (fun A B : Prop => B) ltac:(fun H => intros; eauto 100 using H, or_introl, or_intror, ex_intro, exist, existT with nocore). |
| 22 |
|
| 23 |
Ltac split_and' := |
| 24 |
repeat match goal with |
| 25 |
| [ H : ?a /\ ?b |- _ ] => let H0 := fresh in let H1 := fresh in |
| 26 |
assert (H0 := proj1 H); assert (H1 := proj2 H); clear H |
| 27 |
end. |
| 28 |
Ltac split_prod' := |
| 29 |
repeat match goal with |
| 30 |
| [ H : prod ?a ?b |- _ ] => let H0 := fresh in let H1 := fresh in |
| 31 |
assert (H0 := fst H); assert (H1 := snd H); clear H |
| 32 |
end. |
| 33 |
Ltac split_and := split_and'; split_in_context and (fun a b : Type => a) (fun a b : Type => b). |
| 34 |
Ltac split_prod := split_and'; split_in_context prod (fun a b : Type => a) (fun a b : Type => b). |