Debian Codegraph @

test-suite/bugs/bug_4198.v

raw
1 (* Check that the subterms of the predicate of a match are taken into account *)
2
3 Require Import TestSuite.list.
4
5 Goal forall A (x x' : A) (xs xs' : list A) (H : cons x xs = cons x' xs'),
6 let k :=
7 (match H in (_ = y) return x = hd x y with
8 | eq_refl => eq_refl
9 end : x = x')
10 in k = k.
11 simpl.
12 intros.
13 match goal with
14 | [ |- context G[@hd] ] => idtac
15 end.
16 Abort.
17
18 (* This second example comes from CFGV where inspecting subterms of a
19 match is expecting to inspect first the term to match (even though
20 it would certainly be better to provide a "match x with _ end"
21 construct for generically matching a "match") *)
22
23 Ltac find_head_of_head_match T :=
24 match T with context [?E] =>
25 match T with
26 | E => fail 1
27 | _ => constr:(E)
28 end
29 end.
30
31 Ltac mydestruct :=
32 match goal with
33 | |- ?T1 = _ => let E := find_head_of_head_match T1 in destruct E
34 end.
35
36 Goal forall x, match x with 0 => 0 | _ => 0 end = 0.
37 intros.
38 mydestruct.
39 Abort.