aboutsummaryrefslogtreecommitdiff
path: root/contrib/dp/tests.v
blob: 6209d453909a141c564102aa083908dcfb69b09d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
Reset Initial.

Require Import ZArith.
Require Import Classical.


(* Premier exemple avec traduction de l'galit et du 0 *)

Goal 0 = 0.

simplify.
Qed.


(* Exemples dans le calcul propositionnel *)

Parameter A C : Prop.

Goal A -> A.

simplify.
Qed.


Goal A -> (A \/ C).

zenon.
Qed.


(* Arithmtique de base *)

Parameter x y z : Z.

Goal x = y -> y = z -> x = z.

zenon.
Qed.

(* Ajot de quantificateurs universels *)

Goal (forall (x y : Z), x = y) -> 0 = 1.

simplify.
Qed.


(* Dfinition de fonctions *) 

Definition fst (x y : Z) : Z := x.

Goal forall (g : Z -> Z) (x y : Z), g (fst x y) = g x.

simplify.
Qed.

(* Exemple d'ta-expansion *)

Definition snd_of_3 (x y z : Z) : Z := y.

Definition f : Z -> Z -> Z := snd_of_3 0.

Goal forall (x y z z1 : Z), snd_of_3 x y z = f y z1.

simplify.
Qed.


(* Dfinition de types inductifs - appel de la fonction injection *)

Inductive new : Set :=
| B : new
| N : new -> new.

Inductive even_p : new -> Prop :=
| even_p_B : even_p B
| even_p_N : forall n : new, even_p n -> even_p (N (N n)).

Goal even_p (N (N (N (N B)))).

simplify.
Qed.

Goal even_p (N (N (N (N B)))).

zenon.
Qed.


(* A noter que simplify ne parvient pas  rsoudre ce problme
   avant le timemout au contraire de zenon *)

Definition skip_z (z : Z) (n : new) := n.

Definition skip_z1 := skip_z.

Goal forall (z : Z) (n : new), skip_z z n = skip_z1 z n.

zenon.
Qed.


(* Dfinition d'axiomes et ajot de dp_hint *)

Parameter add : new -> new -> new.
Axiom add_B : forall (n : new), add B n = n.
Axiom add_N : forall (n1 n2 : new), add (N n1) n2 = N (add n1 n2).

Dp add_B.
Dp add_N.

(* Encore un exemple que simplify ne rsout pas avant le timeout *)

Goal forall n : new, add n B = n.

induction n ; zenon.
Qed.


Definition newPred (n : new) : new := match n with
  | B => B
  | N n' => n'
end.

Goal forall n : new, n <> B -> newPred (N n) <> B.

zenon.
Qed.


Fixpoint newPlus (n m : new) {struct n} : new :=
  match n with
  | B => m
  | N n' => N (newPlus n' m)
end.

Goal forall n : new, newPlus n B = n.

induction n; zenon.
Qed.


Definition h (n : new) (z : Z) : Z := match n with
  | B => z + 1
  | N n' => z - 1
end.



(* mutually recursive functions *)

Fixpoint even (n:nat) : bool := match n with
  | O => true
  | S m => odd m
end
with odd (n:nat) : bool := match n with
  | O => false
  | S m => even m
end.

Goal even (S (S O)) = true.
zenon.

(* anonymous mutually recursive functions : no equations are produced *)

Definition f := 
  fix even (n:nat) : bool := match n with
  | O => true
  | S m => odd m
  end
  with odd (n:nat) : bool := match n with
  | O => false
  | S m => even m
  end for even.

Goal f (S (S O)) = true.
zenon.