Debian Codegraph @

src/Util/Sigma/Associativity.v

raw
1 (** * Reassociation of [sig] *)
2 Definition sig_sig_assoc {A} {P : A -> Prop} {Q}
3 : { a : A | P a /\ Q a } -> { ap : { a : A | P a } | Q (proj1_sig ap) }
4 := fun apq => exist _ (exist _ (proj1_sig apq) (proj1 (proj2_sig apq))) (proj2 (proj2_sig apq)).
5 Ltac sig_sig_assoc :=
6 lazymatch goal with
7 | [ |- { a : ?A | ?P } ]
8 => let P'' := fresh a in
9 let P' := fresh P'' in
10 let P' := fresh P' in
11 let term := constr:(fun a : A => match P with
12 | P' => ltac:(let v := (eval cbv [P'] in P') in
13 let proj := lazymatch v with context[@proj1_sig ?A ?P a] => constr:(@proj1_sig A P a) end in
14 lazymatch eval pattern proj in v with
15 | ?P _ => exact P
16 end)
17 end) in
18 let Q := lazymatch (eval cbv beta in term) with fun _ => ?term => term end in
19 apply (@sig_sig_assoc _ _ Q)
20 end.