Debian Codegraph @

src/Util/Tactics/ConvoyDestruct.v

raw
1 Require Import Crypto.Util.Tactics.GetGoal.
2
3 (** Destruct the convoy pattern ([match e as x return x = e -> _ with _ => _ end eq_refl] *)
4 Ltac convoy_destruct_gen T change_in :=
5 let e' := fresh in
6 let H' := fresh in
7 match T with
8 | context G[?f eq_refl]
9 => match f with
10 | match ?e with _ => _ end
11 => pose e as e';
12 match f with
13 | context F[e]
14 => let F' := context F[e'] in
15 first [ pose (eq_refl : e = e') as H';
16 let G' := context G[F' H'] in
17 change_in G';
18 clearbody H' e'
19 | pose (eq_refl : e' = e) as H';
20 let G' := context G[F' H'] in
21 change_in G';
22 clearbody H' e' ]
23 end
24 end;
25 destruct e'
26 end.
27
28 Ltac convoy_destruct_in H :=
29 let T := type of H in
30 convoy_destruct_gen T ltac:(fun T' => change T' in H).
31 Ltac convoy_destruct :=
32 let T := get_goal in
33 convoy_destruct_gen T ltac:(fun T' => change T').