Debian Codegraph @

test-suite/success/FixStronglyWf.v

raw
1 (* Examples of fixpoints with loops in erasable subterms *)
2
3 (* Loop in erasable local definition *)
4 Fail Fixpoint foo (n : nat) :=
5 let g := foo n in
6 0.
7
8 (* Loop in erasable branch *)
9 Fail Fixpoint foo (n : nat) :=
10 match 0 with
11 | 0 => 0
12 | S x => foo n
13 end.
14
15 (* Loop in inert type *)
16 Fail Fixpoint foo (n : nat) :=
17 forall x : foo n, True.
18
19 (* Loop in erasable (and inert) types *)
20
21 Fail Fixpoint foo (n : nat) :=
22 let _ := fun x : foo n => 0 in True.
23
24 Fail Fixpoint foo (n : nat) :=
25 (fun _ : foo n = foo n => True) eq_refl.
26
27 Fail Fixpoint foo (n : nat) :=
28 0 : id (fun _ => nat) (foo n).
29
30 (* Competition between an internally bound recursive argument and an
31 invalid argument; also checks that it does not depend on order *)
32
33 Fail Fixpoint foo p (n : nat) :=
34 match n with
35 | 0 => 0
36 | S x =>
37 foo p (id (fun y =>
38 match p with
39 | true => y
40 | false => n
41 end) x)
42 end.
43
44 Fail Fixpoint foo p (n : nat) :=
45 match n with
46 | 0 => 0
47 | S x =>
48 foo p (id (fun y =>
49 match p with
50 | true => n
51 | false => y
52 end) x)
53 end.
54
55 (* These one are presumably inoffensive but we continue to reject them *)
56
57 Fail Fixpoint foo1 (n : nat) :=
58 forall x : foo1 = foo1, True.
59
60 Fail Fixpoint foo2 (n : nat) :=
61 eq foo2 foo2.
62
63 (* Should we allow the following? This is practically uninteresting but a priori ok *)
64
65 Fail Fixpoint foo (n : nat) :=
66 forall n, forall x : foo n = foo n, True.
67
68 Fail Fixpoint foo (n : nat) :=
69 forall n, eq (foo n) (foo n).
70
71 (* Loop after one step of reduction *)
72
73 Fail Fixpoint foo (n : nat) :=
74 (fun f p => (fun _ => True) (foo p)) n.
75
76 Fail Fixpoint foo (n : nat) :=
77 (if true then fun p => if true then True else foo n
78 else fun p => True) n.
79
80 (* Loop in dead branch *)
81
82 Fail Fixpoint foo n :=
83 match n with
84 | 0 => 0
85 | S n =>
86 (fix aux n :=
87 match n with
88 | 0 => foo n
89 | S n => aux n
90 end) (S n)
91 end.
92
93 (* Loop in inert erasable subterm *)
94
95 Fail Fixpoint g (n:nat) : Prop :=
96 (fun x : g n -> True => True) (fun y : g n => I).