Debian Codegraph @

test-suite/bugs/bug_21797.v

raw
1 (* The function Inductive.find_uniform_parameters did not recurse
2 into arguments of Rel applications.
3 A self-call hidden inside a regular function application was invisible
4 to the uniform parameter analysis, causing over-counting. *)
5 Fail Fixpoint naughty (n : nat) : nat :=
6 match n with
7 | 0 => 0
8 | S n' =>
9 (fix G (a : nat) (f : nat -> nat -> nat) (m : nat) {struct m} : nat :=
10 match m with
11 | 0 => S (naughty a)
12 | S m' => f (G n f m') m'
13 end) n' (fun x _ => x) n'
14 end.
15
16 (*
17 Lemma naughty_loop : naughty 2 = S (naughty 2).
18 Proof.
19 remember 0 as n.
20 set (v := naughty (S (S n))) at 2.
21 remember v as ans; unfold v in *; clearbody v.
22 cbn.
23 set (n₀ := n) at 3.
24 replace n₀ with 0.
25 f_equal.
26 now symmetry.
27 Qed.
28
29 Theorem inconsistency : False.
30 Proof.
31 assert (Hn : forall n, n <> S n).
32 { induction n; discriminate + (intro H; apply IHn; now injection H). }
33 exact (Hn _ naughty_loop).
34 Qed.
35
36 Print Assumptions inconsistency.
37 *)
38
39 (** Another variant of the same issue *)
40
41 Fixpoint iter_fg {A} f g (a : A) n :=
42 match n with
43 | 0 => a | S n' => f (iter_fg f g (g a) n')
44 end.
45
46 Fail Fixpoint F (n : nat) :=
47 iter_fg S F n 1.
48
49 (*
50 Theorem wrong : F 0 = S (F 0).
51 Proof.
52 unfold F at 1. change (fix F (n : nat) := _) with F.
53 cbn -[F]. reflexivity.
54 Qed.
55
56 Corollary false : False.
57 Proof.
58 assert (H : forall n, n <> S n).
59 { induction n; eauto. }
60 eapply H, wrong.
61 Qed.
62 *)