Debian Codegraph @

test-suite/success/Inversion.v

raw
1 Axiom magic : False.
2
3 (* Submitted by Dachuan Yu (BZ#220) *)
4 Fixpoint T (n : nat) : Type :=
5 match n with
6 | O => nat -> Prop
7 | S n' => T n'
8 end.
9 Inductive R : forall n : nat, T n -> nat -> Prop :=
10 | RO : forall (Psi : T 0) (l : nat), Psi l -> R 0 Psi l
11 | RS :
12 forall (n : nat) (Psi : T (S n)) (l : nat), R n Psi l -> R (S n) Psi l.
13 Definition Psi00 (n : nat) : Prop := False.
14 Definition Psi0 : T 0 := Psi00.
15 Lemma Inversion_RO : forall l : nat, R 0 Psi0 l -> Psi00 l.
16 inversion 1.
17 Abort.
18
19 (* Submitted by Pierre Casteran (BZ#540) *)
20
21 Set Implicit Arguments.
22 Unset Strict Implicit.
23 Parameter rule : Set -> Type.
24
25 Inductive extension (I : Set) : Type :=
26 | NL : extension I
27 | add_rule : rule I -> extension I -> extension I.
28
29
30 Inductive in_extension (I : Set) (r : rule I) : extension I -> Type :=
31 | in_first : forall e, in_extension r (add_rule r e)
32 | in_rest : forall e r', in_extension r e -> in_extension r (add_rule r' e).
33
34 Arguments NL {I}.
35
36 Inductive super_extension (I : Set) (e : extension I) :
37 extension I -> Type :=
38 | super_NL : super_extension e NL
39 | super_add :
40 forall r (e' : extension I),
41 in_extension r e ->
42 super_extension e e' -> super_extension e (add_rule r e').
43
44
45
46 Lemma super_def :
47 forall (I : Set) (e1 e2 : extension I),
48 super_extension e2 e1 -> forall ru, in_extension ru e1 -> in_extension ru e2.
49 Proof.
50 simple induction 1.
51 inversion 1; auto.
52 elim magic.
53 Qed.
54
55 (* Example from Norbert Schirmer on Coq-Club, Sep 2000 *)
56
57 Set Strict Implicit.
58 Unset Implicit Arguments.
59 Definition Q (n m : nat) (prf : n <= m) := True.
60 Goal forall (n m : nat) (H : S n <= m), Q (S n) m H = True.
61 intros.
62 dependent inversion_clear H.
63 elim magic.
64 elim magic.
65 Qed.
66
67 (* Submitted by Boris Yakobowski (BZ#529) *)
68 (* Check that Inversion does not fail due to unnormalized evars *)
69
70 Set Implicit Arguments.
71 Unset Strict Implicit.
72 Require Import TestSuite.vector.
73
74 Inductive I : nat -> Set :=
75 | C1 : I 1
76 | C2 : forall k i : nat, Vector.t (I i) k -> I i.
77
78 Inductive SI : forall k : nat, I k -> Vector.t nat k -> nat -> Prop :=
79 SC2 :
80 forall (k i vf : nat) (v : Vector.t (I i) k) (xi : Vector.t nat i),
81 SI (C2 v) xi vf.
82
83 Theorem SUnique :
84 forall (k : nat) (f : I k) (c : Vector.t nat k) v v',
85 SI f c v -> SI f c v' -> v = v'.
86 Proof.
87 induction 1.
88 intros H; inversion H.
89 Admitted.
90
91 (* Used to failed at some time *)
92
93 Set Strict Implicit.
94 Unset Implicit Arguments.
95 Parameter bar : forall p q : nat, p = q -> Prop.
96 Inductive foo : nat -> nat -> Prop :=
97 C : forall (a b : nat) (Heq : a = b), bar a b Heq -> foo a b.
98 Lemma depinv : forall a b, foo a b -> True.
99 intros a b H.
100 inversion H.
101 Abort.
102
103 (* Check non-regression of BZ#1968 *)
104
105 Inductive foo2 : option nat -> Prop := Foo : forall t, foo2 (Some t).
106 Goal forall o, foo2 o -> 0 = 1.
107 intros.
108 eapply trans_eq.
109 inversion H.
110 Abort.
111
112 (* Check that the part of "injection" that is called by "inversion"
113 does the same number of intros as the number of equations
114 introduced, even in presence of dependent equalities that
115 "injection" renounces to split *)
116
117 Fixpoint prodn (n : nat) :=
118 match n with
119 | O => unit
120 | (S m) => prod (prodn m) nat
121 end.
122
123 Inductive U : forall n : nat, prodn n -> bool -> Prop :=
124 | U_intro : U 0 tt true.
125
126 Lemma foo3 : forall n (t : prodn n), U n t true -> False.
127 Proof.
128 (* used to fail because dEqThen thought there were 2 new equations but
129 inject_at_positions actually introduced only one; leading then to
130 an inconsistent state that disturbed "inversion" *)
131 intros. inversion H.
132 Abort.
133
134 (* BZ#2314 (simplified): check that errors do not show as anomalies *)
135
136 Goal True -> True.
137 intro.
138 Fail inversion H using False.
139 Fail inversion foo using True_ind.
140 Abort.
141
142 (* Was failing at some time between 7 and 10 September 2014 *)
143 (* even though, it is not clear that the resulting context is interesting *)
144
145 Parameter P:nat*nat->Prop.
146 Inductive IND : nat * nat -> { x : nat * nat | P x } * nat -> Prop :=
147 CONSTR a b (H:P (a,b)) c : IND (a,b) (exist _ (a,b) H, c).
148
149 Goal forall x y z t u (H':P (z,t)), IND (x,y) (exist _ (z,t) H', u) -> x = z.
150 intros * Hyp.
151 inversion Hyp.
152 (* By the way, why is "H" removed even in non-clear mode ? *)
153 reflexivity.
154 Qed.
155
156 Goal forall x y z t u (H':P (z,t)), IND (x,y) (exist _ (z,t) H', u) -> x = z.
157 intros * Hyp.
158 inversion Hyp as (a,b,H,c,(H1_1,H1_2),(H2_1,H2_2,H2_3)).
159 reflexivity.
160 Qed.
161
162 (* Up to September 2014, Mapp below was called MApp0 because of a bug
163 in intro_replacing (short version of BZ#2164.v)
164 (example taken from CoLoR) *)
165
166 Parameter Term : Type.
167 Parameter isApp : Term -> Prop.
168 Parameter appBodyL : forall M, isApp M -> Prop.
169 Parameter lower : forall M Mapp, appBodyL M Mapp -> Term.
170
171 Inductive BetaStep : Term -> Term -> Prop :=
172 Beta M Mapp Mabs : BetaStep M (lower M Mapp Mabs).
173
174 Goal forall M N, BetaStep M N -> True.
175 intros M N H.
176 inversion H as (P,Mapp,Mabs,H0,H1).
177 clear Mapp Mabs H0 H1.
178 exact Logic.I.
179 Qed.
180
181 (* Up to September 2014, H0 below was renamed called H1 because of a collision
182 with the automatically generated names for equations.
183 (example taken from CoLoR) *)
184
185 Inductive term := Var | Fun : term -> term -> term.
186 Inductive lt : term -> term -> Prop :=
187 mpo f g ss ts : lt Var (Fun f ts) -> lt (Fun f ss) (Fun g ts).
188
189 Goal forall f g ss ts, lt (Fun f ss) (Fun g ts) -> lt Var (Fun f ts).
190 intros.
191 inversion H as (f',g',ss',ts',H0).
192 exact H0.
193 Qed.