1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| The HELM team. *)
8 (* ||A|| http://helm.cs.unibo.it *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU General Public License Version 2 *)
13 (**************************************************************************)
15 include "logic/equality.ma".
16 include "logic/coimplication.ma".
17 include "logic/cprop_connectives.ma".
18 include "datatypes/constructors.ma".
19 include "nat/orders.ma".
22 axiom choose : ∀A:Type.∀P:A → Prop.(∃x.P x) → exP ? P.
23 alias symbol "plus" = "Disjoint union".
24 axiom decide : ∀A,B.A ∨ B → A + B.
31 axiom Rplus : R → R → R.
32 axiom Rtimes : R → R → R.
35 axiom Rlt : R → R → Prop.
36 definition Rle : R → R → Prop ≝ λx,y:R.Rlt x y ∨ x = y.
38 interpretation "real numbers" 'R = R.
40 interpretation "real numbers plus" 'plus x y = (Rplus x y).
41 interpretation "real numbers times" 'times x y = (Rtimes x y).
42 interpretation "real numbers opposite" 'uminus x = (Ropp x).
43 interpretation "real numbers reciprocal" 'invert x = (Rinv x).
44 interpretation "real numbers less than" 'lt x y = (Rlt x y).
45 interpretation "real numbers less eq" 'leq x y = (Rle x y).
47 axiom not_eq_R0_R1 : ¬ R0 = R1.
49 (* commutative ring with unity *)
51 axiom sym_Rplus : ∀x,y:R. x + y = y + x.
52 axiom assoc_Rplus : ∀x,y,z:R.(x+y)+z = x+(y+z).
53 axiom Rplus_x_R0 : ∀x.x + R0 = x.
54 axiom Rplus_Ropp : ∀x.x + (-x) = R0.
56 axiom sym_Rtimes : ∀x,y:R. x * y = y * x.
57 axiom assoc_Rtimes : ∀x,y,z:R.(x*y)*z = x*(y*z).
58 axiom Rtimes_x_R1 : ∀x.x * R1 = x.
59 axiom distr_Rtimes_Rplus_l : ∀x,y,z:R.x*(y+z) = x*y + x*z.
61 lemma distr_Rtimes_Rplus_r : ∀x,y,z:R.(x+y)*z = x*z + y*z.
62 intros;autobatch paramodulation;
65 (* commutative field *)
67 axiom Rinv_Rtimes_l : ∀x. ¬ x = R0 → x * (Rinv x) = R1.
69 (* ordered commutative field *)
71 axiom irrefl_Rlt : ∀x:R.¬ x < x.
72 axiom asym_Rlt : ∀x,y:R. x < y → ¬ y < x.
73 axiom trans_Rlt : ∀x,y,z:R.x < y → y < z → x < z.
74 axiom trichotomy_Rlt : ∀x,y.x < y ∨ y < x ∨ x = y.
76 lemma trans_Rle : ∀x,y,z:R.x ≤ y → y ≤ z → x ≤ z.
80 |rewrite < H3;assumption]
81 |rewrite > H2;assumption]
84 axiom Rlt_plus_l : ∀x,y,z:R.x < y → z + x < z + y.
85 axiom Rlt_times_l : ∀x,y,z:R.x < y → R0 < z → z*x < z*y.
87 (* FIXME: these should be lemmata *)
88 axiom Rle_plus_l : ∀x,y,z:R.x ≤ y → z + x ≤ z + y.
89 axiom Rle_times_l : ∀x,y,z:R.x ≤ y → R0 < z → z*x ≤ z*y.
91 lemma Rle_plus_r : ∀x,y,z:R.x ≤ y → x + z ≤ y + z.
93 rewrite > sym_Rplus;rewrite > sym_Rplus in ⊢ (??%);
97 lemma Rle_times_r : ∀x,y,z:R.x ≤ y → R0 < z → x*z ≤ y*z.
99 rewrite > sym_Rtimes;rewrite > sym_Rtimes in ⊢ (??%);
103 (* Dedekind-completeness *)
105 definition ub ≝ λS: R → Prop.λx:R.∀y.S y → y ≤ x.
106 definition lub ≝ λS: R → Prop.λx:R.ub S x ∧ ∀y. ub S y → x ≤ y.
108 axiom R_dedekind : ∀S:R → Prop.(∃x.S x) → (∃x.ub S x) → ∃x.lub S x.
112 definition R_of_nat : nat → R ≝
115 | S p ⇒ let rec aux m ≝
118 | S q ⇒ (aux q) + R1] in aux p].
122 [ pos n ⇒ R_of_nat (S n)
123 | neg n ⇒ Ropp (R_of_nat (S n))
126 (* FIXME!!! coercion clash! *)
129 (*coercion R_of_nat.*)
131 (* archimedean property *)
133 axiom R_archimedean : ∀x,y:R.R0 < x → ∃n:nat.y < n*x.
135 (*definition Rminus : R → R → R ≝
138 interpretation "real numbers minus" 'minus x y = (Rplus x (Ropp y)).
139 interpretation "real numbers divide" 'divide x y = (Rtimes x (Rinv y)).
141 (* basic properties *)
146 lemma Rplus_eq_l : ∀x,y,z.x = y → z + x= z + y.
150 lemma Rplus_eq_r Rtimes_eq_l Rtimes_eq_r analogamente *)
152 lemma eq_Rplus_l_to_r : ∀a,b,c:R.a+b=c → a = c-b.
153 intros;lapply (eq_f ? ? (λx:R.x-b) ? ? H);
154 rewrite > assoc_Rplus in Hletin;rewrite > Rplus_Ropp in Hletin;
155 rewrite > Rplus_x_R0 in Hletin;assumption;
158 lemma eq_Rplus_r_to_l : ∀a,b,c:R.a=b+c → a-c = b.
159 intros;symmetry;apply eq_Rplus_l_to_r;symmetry;assumption;
162 lemma eq_Rminus_l_to_r : ∀a,b,c:R.a-b=c → a = c+b.
163 intros;lapply (eq_f ? ? (λx:R.x+b) ? ? H);
164 rewrite > assoc_Rplus in Hletin;rewrite > sym_Rplus in Hletin:(??(??%)?);
165 rewrite > Rplus_Ropp in Hletin;rewrite > Rplus_x_R0 in Hletin;assumption;
168 lemma eq_Rminus_r_to_l : ∀a,b,c:R.a=b-c → a+c = b.
169 intros;symmetry;apply eq_Rminus_l_to_r;autobatch paramodulation;
172 lemma eq_Rtimes_l_to_r : ∀a,b,c:R.b ≠ R0 → a*b=c → a = c/b.
173 intros;lapply (eq_f ? ? (λx:R.x/b) ? ? H1);
174 rewrite > assoc_Rtimes in Hletin;rewrite > Rinv_Rtimes_l in Hletin
175 [rewrite > Rtimes_x_R1 in Hletin;assumption
179 lemma eq_Rtimes_r_to_l : ∀a,b,c:R.c ≠ R0 → a=b*c → a/c = b.
180 intros;symmetry;apply eq_Rtimes_l_to_r
182 |symmetry;assumption]
185 lemma eq_Rdiv_l_to_r : ∀a,b,c:R.b ≠ R0 → a/b=c → a = c*b.
186 intros;lapply (eq_f ? ? (λx:R.x*b) ? ? H1);
187 rewrite > assoc_Rtimes in Hletin;rewrite > sym_Rtimes in Hletin:(??(??%)?);
188 rewrite > Rinv_Rtimes_l in Hletin
189 [rewrite > Rtimes_x_R1 in Hletin;assumption
193 lemma eq_Rdiv_r_to_l : ∀a,b,c:R.c ≠ R0 → a=b/c → a*c = b.
194 intros;symmetry;apply eq_Rdiv_l_to_r
196 |symmetry;assumption]
199 (* lemma unique_Ropp : ∀x,y.x + y = R0 → y = -x.
200 intros;autobatch paramodulation;
203 lemma Rtimes_x_R0 : ∀x.x * R0 = R0.
205 rewrite < Rplus_x_R0 in ⊢ (? ? % ?);
206 rewrite < (Rplus_Ropp (x*R0)) in ⊢ (? ? (? ? %) %);
207 rewrite < assoc_Rplus;
208 apply eq_f2;autobatch paramodulation;
211 lemma eq_Rtimes_Ropp_R1_Ropp : ∀x.x*(-R1) = -x.
213 rewrite < Rplus_x_R0 in ⊢ (? ? % ?);
214 rewrite < Rplus_x_R0 in ⊢ (? ? ? %);
215 rewrite < (Rplus_Ropp x) in ⊢ (? ? % ?);
216 rewrite < assoc_Rplus;
217 rewrite < sym_Rplus in ⊢ (? ? % ?);
218 rewrite < sym_Rplus in ⊢ (? ? (? ? %) ?);
219 apply eq_f2 [reflexivity]
220 rewrite < Rtimes_x_R1 in ⊢ (? ? (? % ?) ?);
221 rewrite < distr_Rtimes_Rplus_l;autobatch paramodulation;
224 lemma Ropp_inv : ∀x.x = Ropp (Ropp x).
228 lemma Rinv_inv : ∀x.x ≠ R0 → x = Rinv (Rinv x).
229 intros;rewrite < Rtimes_x_R1 in ⊢ (???%);rewrite > sym_Rtimes;
230 apply eq_Rtimes_l_to_r
231 [intro;lapply (eq_f ? ? (λy:R.x*y) ? ? H1);
232 rewrite > Rinv_Rtimes_l in Hletin
233 [rewrite > Rtimes_x_R0 in Hletin;apply not_eq_R0_R1;symmetry;assumption
235 |apply Rinv_Rtimes_l;assumption]
238 lemma Ropp_R0 : R0 = - R0.
239 rewrite < eq_Rtimes_Ropp_R1_Ropp;autobatch paramodulation;
242 lemma distr_Ropp_Rplus : ∀x,y:R.-(x + y) = -x -y.
243 intros;rewrite < eq_Rtimes_Ropp_R1_Ropp;
244 rewrite > sym_Rtimes;rewrite > distr_Rtimes_Rplus_l;
245 autobatch paramodulation;
248 lemma Ropp_Rtimes_l : ∀x,y:R.-(x*y) = -x*y.
249 intros;rewrite < eq_Rtimes_Ropp_R1_Ropp;
250 rewrite > sym_Rtimes;rewrite < assoc_Rtimes;autobatch paramodulation;
253 lemma Ropp_Rtimes_r : ∀x,y:R.-(x*y) = x*-y.
254 intros;rewrite > sym_Rtimes;rewrite > sym_Rtimes in ⊢ (???%);
260 lemma Rlt_to_Rlt_Ropp_Ropp : ∀x,y.x < y → -y < -x.
261 intros;rewrite < Rplus_x_R0 in ⊢ (??%);
262 rewrite < (Rplus_Ropp y);rewrite < Rplus_x_R0 in ⊢ (?%?);
263 rewrite < assoc_Rplus;rewrite < sym_Rplus in ⊢ (??%);
265 rewrite < (Rplus_Ropp x);rewrite < sym_Rplus in ⊢ (?%?);autobatch;
268 lemma lt_R0_R1 : R0 < R1.
269 elim (trichotomy_Rlt R0 R1) [|elim (not_eq_R0_R1 H)]
271 rewrite > Ropp_inv in ⊢ (??%);rewrite < eq_Rtimes_Ropp_R1_Ropp;
272 rewrite < (Rtimes_x_R0 (-R1));
273 apply Rlt_times_l;rewrite < (Rtimes_x_R0 (-R1));
274 rewrite > sym_Rtimes;rewrite > eq_Rtimes_Ropp_R1_Ropp;autobatch;
277 lemma pos_z_to_lt_Rtimes_Rtimes_to_lt : ∀x,y,z.R0 < z → z*x < z*y → x < y.
278 intros;elim (trichotomy_Rlt x y)
279 [elim H2 [assumption]
280 elim (asym_Rlt (z*y) (z*x));autobatch
281 |rewrite > H2 in H1;elim (irrefl_Rlt ? H1)]
284 lemma pos_z_to_le_Rtimes_Rtimes_to_lt : ∀x,y,z.R0 < z → z*x ≤ z*y → x ≤ y.
287 |right;rewrite < Rtimes_x_R1;rewrite < Rtimes_x_R1 in ⊢ (???%);
288 rewrite < sym_Rtimes;rewrite < sym_Rtimes in ⊢ (???%);
289 rewrite < (Rinv_Rtimes_l z)
290 [rewrite < sym_Rtimes in ⊢ (??(?%?)?);rewrite < sym_Rtimes in ⊢ (???(?%?));
291 autobatch paramodulation
292 |intro;rewrite > H3 in H;apply (irrefl_Rlt R0);assumption]]
295 lemma neg_z_to_lt_Rtimes_Rtimes_to_lt : ∀x,y,z.z < R0 → z*x < z*y → y < x.
296 intros;rewrite > Ropp_inv in ⊢ (?%?);
297 rewrite > Ropp_inv in ⊢ (??%);
298 apply Rlt_to_Rlt_Ropp_Ropp;apply (pos_z_to_lt_Rtimes_Rtimes_to_lt ?? (-z))
299 [rewrite > Ropp_R0;autobatch
300 |rewrite < (eq_Rtimes_Ropp_R1_Ropp) in ⊢ (?(??%)?);
301 rewrite < (eq_Rtimes_Ropp_R1_Ropp) in ⊢ (??(??%));
302 do 2 rewrite < assoc_Rtimes;
303 rewrite > eq_Rtimes_Ropp_R1_Ropp;
304 rewrite > eq_Rtimes_Ropp_R1_Ropp in ⊢ (??%);
305 rewrite > sym_Rtimes;rewrite > sym_Rtimes in ⊢ (??%);
306 rewrite < (eq_Rtimes_Ropp_R1_Ropp) in ⊢ (?%?);
307 rewrite < (eq_Rtimes_Ropp_R1_Ropp) in ⊢ (??%);
308 do 2 rewrite > assoc_Rtimes;
309 rewrite > eq_Rtimes_Ropp_R1_Ropp;
311 rewrite > sym_Rtimes;rewrite > sym_Rtimes in ⊢ (??%);
315 lemma lt_R0_Rinv : ∀x.R0 < x → R0 < Rinv x.
316 intros;apply (pos_z_to_lt_Rtimes_Rtimes_to_lt ?? x H);rewrite > Rinv_Rtimes_l;
317 [rewrite > Rtimes_x_R0;autobatch
318 |intro;apply (irrefl_Rlt x);rewrite < H1 in H;assumption]
321 lemma pos_times_pos_pos : ∀x,y.R0 < x → R0 < y → R0 < x*y.
322 intros;rewrite < (Rtimes_x_R0 x);autobatch;
325 lemma pos_plus_pos_pos : ∀x,y.R0 < x → R0 < y → R0 < x+y.
326 intros;rewrite < (Rplus_Ropp x);apply Rlt_plus_l;
327 apply (trans_Rlt ???? H1);rewrite > Ropp_R0;
328 apply Rlt_to_Rlt_Ropp_Ropp;assumption;
331 lemma Rlt_to_neq : ∀x,y:R.x < y → x ≠ y.
332 intros;intro;rewrite > H1 in H;apply (irrefl_Rlt ? H);
335 lemma lt_Rinv : ∀x,y.R0 < x → x < y → Rinv y < Rinv x.
337 lapply (Rlt_times_l ? ? (Rinv x * Rinv y) H1)
338 [rewrite > sym_Rtimes in Hletin;rewrite < assoc_Rtimes in Hletin;
339 rewrite > assoc_Rtimes in Hletin:(??%);
340 rewrite > sym_Rtimes in Hletin:(??(??%));
341 rewrite > Rinv_Rtimes_l in Hletin
342 [rewrite > Rinv_Rtimes_l in Hletin
343 [rewrite > Rtimes_x_R1 in Hletin;rewrite > sym_Rtimes in Hletin;
344 rewrite > Rtimes_x_R1 in Hletin;assumption
345 |intro;rewrite > H2 in H1;apply (asym_Rlt ? ? H H1)]
346 |intro;rewrite > H2 in H;apply (irrefl_Rlt ? H)]
347 |apply pos_times_pos_pos;apply lt_R0_Rinv;autobatch]
350 lemma Rlt_plus_l_to_r : ∀a,b,c.a + b < c → a < c - b.
351 intros;rewrite < Rplus_x_R0;rewrite < (Rplus_Ropp b);
352 rewrite < assoc_Rplus;
353 rewrite < sym_Rplus;rewrite < sym_Rplus in ⊢ (??%);
354 apply Rlt_plus_l;assumption;
357 lemma Rlt_plus_r_to_l : ∀a,b,c.a < b + c → a - c < b.
358 intros;rewrite > Ropp_inv;rewrite > Ropp_inv in ⊢ (??%);
359 apply Rlt_to_Rlt_Ropp_Ropp;rewrite > distr_Ropp_Rplus;
360 apply Rlt_plus_l_to_r;rewrite < distr_Ropp_Rplus;apply Rlt_to_Rlt_Ropp_Ropp;
364 lemma Rlt_minus_l_to_r : ∀a,b,c.a - b < c → a < c + b.
365 intros;rewrite > (Ropp_inv b);apply Rlt_plus_l_to_r;assumption;
368 lemma Rlt_minus_r_to_l : ∀a,b,c.a < b - c → a + c < b.
369 intros;rewrite > (Ropp_inv c);apply Rlt_plus_r_to_l;assumption;
372 lemma Rlt_div_r_to_l : ∀a,b,c.R0 < c → a < b/c → a*c < b.
373 intros;rewrite < sym_Rtimes;
374 rewrite < Rtimes_x_R1 in ⊢ (??%);rewrite < sym_Rtimes in ⊢ (??%);
375 rewrite < (Rinv_Rtimes_l c)
376 [rewrite > assoc_Rtimes;apply Rlt_times_l
377 [rewrite > sym_Rtimes;assumption
379 |intro;elim (Rlt_to_neq ?? H);symmetry;assumption]
382 lemma Rlt_times_l_to_r : ∀a,b,c.R0 < b → a*b < c → a < c/b.
383 intros;rewrite < sym_Rtimes;
384 rewrite < Rtimes_x_R1;rewrite < sym_Rtimes;
385 rewrite < (Rinv_Rtimes_l b)
386 [rewrite < sym_Rtimes in ⊢ (? (? % ?) ?);
387 rewrite > assoc_Rtimes;apply Rlt_times_l
388 [rewrite > sym_Rtimes;assumption
390 |intro;elim (Rlt_to_neq ?? H);symmetry;assumption]
393 lemma Rle_plus_l_to_r : ∀a,b,c.a + b ≤ c → a ≤ c - b.
399 lemma Rle_plus_r_to_l : ∀a,b,c.a ≤ b + c → a - c ≤ b.
405 lemma Rle_minus_l_to_r : ∀a,b,c.a - b ≤ c → a ≤ c + b.
411 lemma Rle_minus_r_to_l : ∀a,b,c.a ≤ b - c → a + c ≤ b.
417 lemma R_OF_nat_S : ∀n.R_OF_nat (S n) = R_OF_nat n + R1.
418 intros;elim n;simplify
419 [autobatch paramodulation
423 lemma nat_lt_to_R_lt : ∀m,n:nat.m < n → R_OF_nat m < R_OF_nat n.
427 |rewrite < Rplus_x_R0 in ⊢ (?%?);apply Rlt_plus_l;autobatch]
428 |apply (trans_Rlt ??? H2);cases n1;simplify
430 |rewrite < Rplus_x_R0 in ⊢ (?%?);apply Rlt_plus_l;autobatch]]