Debian Codegraph @

test-suite/bugs/bug_21053.v

raw
1 Notation "'rew' [ f ] e 'in' x" := (eq_rect _ f x _ e) (at level 10, x at level 10).
2
3 Definition cast {A B : Set} (e : A = B) : A -> B :=
4 rew [fun (T : Set) => T -> B] eq_sym e in fun x => x.
5
6 Definition castP {A B : Prop} (e : A = B) : A -> B :=
7 rew [fun T => T -> B] eq_sym e in fun x => x.
8
9
10 Inductive True2 : Prop := I2 : (False -> True2) -> True2.
11
12 Fail Fixpoint f (e : (False -> True2) = True2) (x : True2) {struct x} : False :=
13 match x with
14 | I2 H => f e (castP e H)
15 end.
16 (* Problematic fixpoint : [castP e f] should not be a subterm of [f] *)
17
18 #[bypass_check(guard)]
19 Fixpoint f (e : (False -> True2) = True2) (x : True2) {struct x} : False :=
20 match x with
21 | I2 H => f e (castP e H)
22 end.
23
24 Section contradiction.
25 Context (prop_ext: forall P Q, (P <-> Q) -> P = Q).
26
27 Theorem e : (False -> True2) = True2.
28 Proof.
29 apply prop_ext. split; auto using I2.
30 Qed.
31
32 Definition contradiction := f e (I2 (False_rect True2)).
33 End contradiction.
34
35
36
37 Fail Fixpoint g (e : nat = nat) (n : nat) {struct n} :=
38 match n with
39 | 0 => 0
40 | S n => S (g e (cast e n))
41 end.
42 (* Problematic fixpoint : [cast e n] should not be a subterm of [n] *)
43
44 #[bypass_check(guard)]
45 Fixpoint g (e : nat = nat) (n : nat) {struct n} :=
46 match n with
47 | 0 => 0
48 | S n => S (g e (cast e n))
49 end.
50
51 Section Issue.
52 Context (e : nat = nat). (* Supposed non-trivial *)
53 Context (e0 : rew [fun (T : Set) => T] e in 0 = 1).
54 (* How the non triviality may appear *)
55
56 Corollary e0' : cast e 0 = 1.
57 Proof.
58 rewrite <- e0. clear e0.
59 unfold cast.
60 generalize 0.
61 destruct e.
62 reflexivity.
63 Defined.
64
65 Theorem Boom : False.
66 enough (g e 1 = S (g e 1)) by now induction (g e 1); auto.
67 change (g e 1) with (S (g e (cast e 0))) at 1.
68 f_equal. f_equal.
69 apply e0'.
70 Qed.
71
72 End Issue.