1
(************************************************************************)
2
(* v * The Coq Proof Assistant / The Coq Development Team *)
3
(* <O___,, * CNRS-Ecole Polytechnique-INRIA Futurs-Universite Paris Sud *)
4
(* \VV/ **************************************************************)
5
(* // * This file is distributed under the terms of the *)
6
(* * GNU Lesser General Public License Version 2.1 *)
7
(************************************************************************)
9
(* Micromega: A reflexive tactic using the Positivstellensatz *)
11
(* Fr�d�ric Besson (Irisa/Inria) 2006-2008 *)
13
(************************************************************************)
15
Require Import ZArith.
16
Require Import Coq.Arith.Max.
18
Set Implicit Arguments.
20
(* I have addded a Leaf constructor to the varmap data structure (/contrib/ring/Quote.v)
21
-- this is harmless and spares a lot of Empty.
22
This means smaller proof-terms.
23
BTW, by dropping the polymorphism, I get small (yet noticeable) speed-up.
33
| Node : t -> A -> t -> t .
35
Fixpoint find (vm : t ) (p:positive) {struct vm} : A :=
39
| Node l e r => match p with
46
(* an off_map (a map with offset) offers the same functionalites as /contrib/setoid_ring/BinList.v - it is used in EnvRing.v *)
48
Definition off_map := (option positive *t )%type.
52
Definition jump (j:positive) (l:off_map ) :=
56
| Some j0 => (Some (j+j0)%positive,m)
59
Definition nth (n:positive) (l: off_map ) :=
61
let idx := match o with
68
Definition hd (l:off_map) := nth xH l.
71
Definition tail (l:off_map ) := jump xH l.
74
Lemma psucc : forall p, (match p with
75
| xI y' => xO (Psucc y')
77
| 1%positive => 2%positive
78
end) = (p+1)%positive.
87
Lemma jump_Pplus : forall i j l,
88
(jump (i + j) l) = (jump i (jump j l)).
98
Lemma jump_simpl : forall p l,
102
| xO p => jump p (jump p l)
103
| xI p => jump p (jump p (tail l))
106
destruct p ; unfold tail ; intros ; repeat rewrite <- jump_Pplus.
107
(* xI p = p + p + 1 *)
110
rewrite <- Pplus_one_succ_r.
121
| |- context [jump xH ?e] => rewrite (jump_simpl xH)
122
| |- context [jump (xO ?p) ?e] => rewrite (jump_simpl (xO p))
123
| |- context [jump (xI ?p) ?e] => rewrite (jump_simpl (xI p))
126
Lemma jump_tl : forall j l, tail (jump j l) = jump j (tail l).
130
repeat rewrite <- jump_Pplus.
135
Lemma jump_Psucc : forall j l,
136
(jump (Psucc j) l) = (jump 1 (jump j l)).
139
rewrite <- jump_Pplus.
140
rewrite Pplus_one_succ_r.
145
Lemma jump_Pdouble_minus_one : forall i l,
146
(jump (Pdouble_minus_one i) (tail l)) = (jump i (jump i l)).
150
repeat rewrite <- jump_Pplus.
151
rewrite <- Pplus_one_succ_r.
152
rewrite Psucc_o_double_minus_one_eq_xO.
157
Lemma jump_x0_tail : forall p l, jump (xO p) (tail l) = jump (xI p) l.
161
repeat rewrite <- jump_Pplus.
166
Lemma nth_spec : forall p l,
170
| xO p => nth p (jump p l)
171
| xI p => nth p (jump p (tail l))
180
replace (p0 + xI p)%positive with ((p + (p0 + 1) + p))%positive.
183
rewrite Pplus_one_succ_r.
184
rewrite <- Pplus_diag.
187
rewrite (Pplus_comm p0).
188
rewrite <- Pplus_assoc.
189
rewrite (Pplus_comm 1)%positive.
190
rewrite <- Pplus_assoc.
193
replace ((p0 + xO p))%positive with (p + p0 + p)%positive.
195
rewrite <- Pplus_diag.
196
rewrite <- Pplus_assoc.
204
rewrite Pplus_one_succ_r.
205
rewrite <- Pplus_diag.
216
Lemma nth_jump : forall p l, nth p (tail l) = hd (jump p l).
226
rewrite <- Pplus_assoc.
227
rewrite (Pplus_comm p0).
233
Lemma nth_Pdouble_minus_one :
234
forall p l, nth (Pdouble_minus_one p) (tail l) = nth p (jump p l).
240
rewrite ((Pplus_comm p)).
241
rewrite <- (Pplus_assoc p0).
243
rewrite <- Psucc_o_double_minus_one_eq_xO.
244
rewrite Pplus_one_succ_r.
245
rewrite (Pplus_comm (Pdouble_minus_one p)).
247
rewrite (Pplus_comm p0).
249
rewrite <- Pplus_one_succ_l.
250
rewrite Psucc_o_double_minus_one_eq_xO.