Debian Codegraph @

test-suite/success/definition_using.v

raw
1 Axiom bogus : Type.
2
3 Section A.
4 Variable x : bogus.
5
6 #[using="All"]
7 Definition c1 : bool := true.
8
9 #[using="All"]
10 Fixpoint c2 n : bool :=
11 match n with
12 | O => true
13 | S p => c3 p
14 end
15 with c3 n : bool :=
16 match n with
17 | O => true
18 | S p => c2 p
19 end.
20
21 #[using="All"]
22 Definition c4 : bool. Proof. exact true. Qed.
23
24 #[using="All"]
25 Fixpoint c5 (n : nat) {struct n} : bool. Proof. destruct n as [|p]. exact true. exact (c5 p). Qed.
26
27 #[using="All"]
28 Definition c6 : bool. Proof. exact true. Qed.
29
30 #[using="All"]
31 Fixpoint c7 (n : nat) {struct n} : bool :=
32 match n with
33 | O => true
34 | S p => c7 p
35 end.
36
37 Fail #[using="dummy", program]
38 Fixpoint c7' (n : nat) {struct n} : bool :=
39 match n with
40 | O => true
41 | S p => c7' p
42 end.
43
44 Fail #[using="c7'", program]
45 Fixpoint c7' (n : nat) {struct n} : bool :=
46 match n with
47 | O => true
48 | S p => c7' p
49 end.
50
51 End A.
52
53 Check c1 : bogus -> bool.
54 Check c2 : bogus -> nat -> bool.
55 Check c3 : bogus -> nat -> bool.
56 Check c4 : bogus -> bool.
57 Check c5 : bogus -> nat -> bool.
58 Check c6 : bogus -> bool.
59 Check c7 : bogus -> nat -> bool.
60
61 Section B.
62
63 Variable a : bogus.
64 Variable h : c1 a = true.
65
66 #[using="a*"]
67 Definition c8 : bogus := a.
68
69 Collection ccc := a h.
70
71 #[using="ccc"]
72 Definition c9 : bogus := a.
73
74 #[using="ccc - h"]
75 Definition c10 : bogus := a.
76
77 End B.
78
79 Check c8 : forall a, c1 a = true -> bogus.
80 Check c9 : forall a, c1 a = true -> bogus.
81 Check c10: bogus -> bogus.
82
83 Module TypeBehavior.
84
85 Section S.
86 Variables a : nat.
87 #[using="Type", warning="-non-recursive"]
88 Program Fixpoint b1 (n:nat) : nat := (fun _ => 0) a.
89 Program Fixpoint b2 (n:nat) : (fun X _ => X) nat a := 0.
90 Program Fixpoint b3 (n:nat) : (fun X _ => X) nat a := (fun _ => 0) a.
91 Program Definition c1 : nat := (fun _ => 0) a.
92 Program Definition c2 : (fun X _ => X) nat a := 0.
93 Program Definition c3 : (fun X _ => X) nat a := (fun _ => 0) a.
94 Fixpoint d1 (n:nat) : nat := (fun _ => 0) a.
95 Fixpoint d2 (n:nat) : (fun X _ => X) nat a := 0.
96 Fixpoint d3 (n:nat) : (fun X _ => X) nat a := (fun _ => 0) a.
97 Definition e1 : nat := (fun _ => 0) a.
98 Definition e2 : (fun X _ => X) nat a := 0.
99 Definition e3 : (fun X _ => X) nat a := (fun _ => 0) a.
100 End S.
101 (* Not clear what is most expected below... *)
102
103 (* Dependency in a with Program Fixpoint: the body is not reduced. *)
104 (* As of now, we don't seem to have such a case. *)
105 (* No dependency in a with Program Fixpoint, because both body and type are beta-reduced *)
106 Check b1 0 : nat.
107 Check b2 0 : nat.
108 Check b3 0 : nat.
109 (* With Program Definition, type is beta-reduced but not the body *)
110 Check c1 0 : nat.
111 Check c2 : nat.
112 Check c3 0 : nat.
113 (* With Definition/Fixpoint, neither body nor type are beta-reduced *)
114 Check d1 0 0 : nat.
115 Check d2 0 0 : nat.
116 Check d3 0 0 : nat.
117 Check e1 0 : nat.
118 Check e2 0 : nat.
119 Check e3 0 : nat.
120
121 End TypeBehavior.