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.
63 lemma distr_Rtimes_Rplus_r : ∀x,y,z:R.(x+y)*z = x*z + y*z.
64 intros; demodulate all. (*autobatch paramodulation;*)
67 (* commutative field *)
69 axiom Rinv_Rtimes_l : ∀x. ¬ x = R0 → x * (Rinv x) = R1.
71 (* ordered commutative field *)
73 axiom irrefl_Rlt : ∀x:R.¬ x < x.
74 axiom asym_Rlt : ∀x,y:R. x < y → ¬ y < x.
75 axiom trans_Rlt : ∀x,y,z:R.x < y → y < z → x < z.
76 axiom trichotomy_Rlt : ∀x,y.x < y ∨ y < x ∨ x = y.
78 lemma trans_Rle : ∀x,y,z:R.x ≤ y → y ≤ z → x ≤ z.
82 |rewrite < H3;assumption]
83 |rewrite > H2;assumption]
86 axiom Rlt_plus_l : ∀x,y,z:R.x < y → z + x < z + y.
87 axiom Rlt_times_l : ∀x,y,z:R.x < y → R0 < z → z*x < z*y.
89 (* FIXME: these should be lemmata *)
90 axiom Rle_plus_l : ∀x,y,z:R.x ≤ y → z + x ≤ z + y.
91 axiom Rle_times_l : ∀x,y,z:R.x ≤ y → R0 < z → z*x ≤ z*y.
93 lemma Rle_plus_r : ∀x,y,z:R.x ≤ y → x + z ≤ y + z.
95 rewrite > sym_Rplus;rewrite > sym_Rplus in ⊢ (??%);
99 lemma Rle_times_r : ∀x,y,z:R.x ≤ y → R0 < z → x*z ≤ y*z.
101 rewrite > sym_Rtimes;rewrite > sym_Rtimes in ⊢ (??%);
105 (* Dedekind-completeness *)
107 definition ub ≝ λS: R → Prop.λx:R.∀y.S y → y ≤ x.
108 definition lub ≝ λS: R → Prop.λx:R.ub S x ∧ ∀y. ub S y → x ≤ y.
110 axiom R_dedekind : ∀S:R → Prop.(∃x.S x) → (∃x.ub S x) → ∃x.lub S x.
114 definition R_of_nat : nat → R ≝
117 | S p ⇒ let rec aux m ≝
120 | S q ⇒ (aux q) + R1] in aux p].
124 [ pos n ⇒ R_of_nat (S n)
125 | neg n ⇒ Ropp (R_of_nat (S n))
128 (* FIXME!!! coercion clash! *)
131 (*coercion R_of_nat.*)
133 (* archimedean property *)
135 axiom R_archimedean : ∀x,y:R.R0 < x → ∃n:nat.y < n*x.
137 (*definition Rminus : R → R → R ≝
140 interpretation "real numbers minus" 'minus x y = (Rplus x (Ropp y)).
141 interpretation "real numbers divide" 'divide x y = (Rtimes x (Rinv y)).
143 (* basic properties *)
148 lemma Rplus_eq_l : ∀x,y,z.x = y → z + x= z + y.
152 lemma Rplus_eq_r Rtimes_eq_l Rtimes_eq_r analogamente *)
154 lemma eq_Rplus_l_to_r : ∀a,b,c:R.a+b=c → a = c-b.
155 intros;lapply (eq_f ? ? (λx:R.x-b) ? ? H);
156 rewrite > assoc_Rplus in Hletin;rewrite > Rplus_Ropp in Hletin;
157 rewrite > Rplus_x_R0 in Hletin;assumption;
160 lemma eq_Rplus_r_to_l : ∀a,b,c:R.a=b+c → a-c = b.
161 intros;symmetry;apply eq_Rplus_l_to_r;symmetry;assumption;
164 lemma eq_Rminus_l_to_r : ∀a,b,c:R.a-b=c → a = c+b.
165 intros;lapply (eq_f ? ? (λx:R.x+b) ? ? H);
166 rewrite > assoc_Rplus in Hletin;rewrite > sym_Rplus in Hletin:(??(??%)?);
167 rewrite > Rplus_Ropp in Hletin;rewrite > Rplus_x_R0 in Hletin;assumption;
170 lemma eq_Rminus_r_to_l : ∀a,b,c:R.a=b-c → a+c = b.
171 intros;symmetry;apply eq_Rminus_l_to_r;autobatch paramodulation;
174 lemma eq_Rtimes_l_to_r : ∀a,b,c:R.b ≠ R0 → a*b=c → a = c/b.
175 intros;lapply (eq_f ? ? (λx:R.x/b) ? ? H1);
176 rewrite > assoc_Rtimes in Hletin;rewrite > Rinv_Rtimes_l in Hletin
177 [rewrite > Rtimes_x_R1 in Hletin;assumption
181 lemma eq_Rtimes_r_to_l : ∀a,b,c:R.c ≠ R0 → a=b*c → a/c = b.
182 intros;symmetry;apply eq_Rtimes_l_to_r
184 |symmetry;assumption]
187 lemma eq_Rdiv_l_to_r : ∀a,b,c:R.b ≠ R0 → a/b=c → a = c*b.
188 intros;lapply (eq_f ? ? (λx:R.x*b) ? ? H1);
189 rewrite > assoc_Rtimes in Hletin;rewrite > sym_Rtimes in Hletin:(??(??%)?);
190 rewrite > Rinv_Rtimes_l in Hletin
191 [rewrite > Rtimes_x_R1 in Hletin;assumption
195 lemma eq_Rdiv_r_to_l : ∀a,b,c:R.c ≠ R0 → a=b/c → a*c = b.
196 intros;symmetry;apply eq_Rdiv_l_to_r
198 |symmetry;assumption]
201 (* lemma unique_Ropp : ∀x,y.x + y = R0 → y = -x.
202 intros;autobatch paramodulation;
205 lemma Rtimes_x_R0 : ∀x.x * R0 = R0.
206 intro; demodulate all.
208 rewrite < Rplus_x_R0 in ⊢ (? ? % ?);
209 rewrite < (Rplus_Ropp (x*R0)) in ⊢ (? ? (? ? %) %);
210 rewrite < assoc_Rplus;
211 apply eq_f2;autobatch paramodulation;
215 lemma eq_Rtimes_Ropp_R1_Ropp : ∀x.x*(-R1) = -x.
216 intro. demodulate all. (*
218 rewrite < Rplus_x_R0 in ⊢ (? ? % ?);
219 rewrite < Rplus_x_R0 in ⊢ (? ? ? %);
220 rewrite < (Rplus_Ropp x) in ⊢ (? ? % ?);
221 rewrite < assoc_Rplus;
222 rewrite < sym_Rplus in ⊢ (? ? % ?);
223 rewrite < sym_Rplus in ⊢ (? ? (? ? %) ?);
224 apply eq_f2 [reflexivity]
225 rewrite < Rtimes_x_R1 in ⊢ (? ? (? % ?) ?);
226 rewrite < distr_Rtimes_Rplus_l;autobatch paramodulation;
230 lemma Ropp_inv : ∀x.x = Ropp (Ropp x).
234 lemma Rinv_inv : ∀x.x ≠ R0 → x = Rinv (Rinv x).
235 intros;rewrite < Rtimes_x_R1 in ⊢ (???%);rewrite > sym_Rtimes;
236 apply eq_Rtimes_l_to_r
237 [intro;lapply (eq_f ? ? (λy:R.x*y) ? ? H1);
238 rewrite > Rinv_Rtimes_l in Hletin
239 [rewrite > Rtimes_x_R0 in Hletin;apply not_eq_R0_R1;symmetry;assumption
241 |apply Rinv_Rtimes_l;assumption]
244 lemma Ropp_R0 : R0 = - R0. demodulate all. (*
245 rewrite < eq_Rtimes_Ropp_R1_Ropp;autobatch paramodulation; *)
248 lemma distr_Ropp_Rplus : ∀x,y:R.-(x + y) = -x -y.
249 intros; demodulate all; (*rewrite < eq_Rtimes_Ropp_R1_Ropp;
250 rewrite > sym_Rtimes;rewrite > distr_Rtimes_Rplus_l;
251 autobatch paramodulation;*)
254 lemma Ropp_Rtimes_l : ∀x,y:R.-(x*y) = -x*y.
255 intros; demodulate all; (*rewrite < eq_Rtimes_Ropp_R1_Ropp;
256 rewrite > sym_Rtimes;rewrite < assoc_Rtimes;autobatch paramodulation;*)
259 lemma Ropp_Rtimes_r : ∀x,y:R.-(x*y) = x*-y.
260 intros; demodulate all; (*rewrite > sym_Rtimes;rewrite > sym_Rtimes in ⊢ (???%);
266 lemma Rlt_to_Rlt_Ropp_Ropp : ∀x,y.x < y → -y < -x.
267 intros;rewrite < Rplus_x_R0 in ⊢ (??%);
268 rewrite < (Rplus_Ropp y);rewrite < Rplus_x_R0 in ⊢ (?%?);
269 rewrite < assoc_Rplus;rewrite < sym_Rplus in ⊢ (??%);
271 rewrite < (Rplus_Ropp x);rewrite < sym_Rplus in ⊢ (?%?);autobatch;
274 lemma lt_R0_R1 : R0 < R1.
275 elim (trichotomy_Rlt R0 R1) [|elim (not_eq_R0_R1 H)]
277 rewrite > Ropp_inv in ⊢ (??%);rewrite < eq_Rtimes_Ropp_R1_Ropp;
278 rewrite < (Rtimes_x_R0 (-R1));
279 apply Rlt_times_l;rewrite < (Rtimes_x_R0 (-R1));
280 rewrite > sym_Rtimes;rewrite > eq_Rtimes_Ropp_R1_Ropp;autobatch;
283 lemma pos_z_to_lt_Rtimes_Rtimes_to_lt : ∀x,y,z.R0 < z → z*x < z*y → x < y.
284 intros;elim (trichotomy_Rlt x y)
285 [elim H2 [assumption]
286 elim (asym_Rlt (z*y) (z*x));autobatch
287 |rewrite > H2 in H1;elim (irrefl_Rlt ? H1)]
290 lemma pos_z_to_le_Rtimes_Rtimes_to_lt : ∀x,y,z.R0 < z → z*x ≤ z*y → x ≤ y.
293 |right; rewrite < Rtimes_x_R1;rewrite < Rtimes_x_R1 in ⊢ (???%);
294 rewrite < sym_Rtimes;rewrite < sym_Rtimes in ⊢ (???%);
295 rewrite < (Rinv_Rtimes_l z)
296 [demodulate all; (*rewrite < sym_Rtimes in ⊢ (??(?%?)?);rewrite < sym_Rtimes in ⊢ (???(?%?));
297 autobatch paramodulation*)
298 |intro;rewrite > H3 in H;apply (irrefl_Rlt R0);assumption]]
301 lemma neg_z_to_lt_Rtimes_Rtimes_to_lt : ∀x,y,z.z < R0 → z*x < z*y → y < x.
302 intros;rewrite > Ropp_inv in ⊢ (?%?);
303 rewrite > Ropp_inv in ⊢ (??%);
304 apply Rlt_to_Rlt_Ropp_Ropp;apply (pos_z_to_lt_Rtimes_Rtimes_to_lt ?? (-z))
305 [rewrite > Ropp_R0;autobatch
307 rewrite < (eq_Rtimes_Ropp_R1_Ropp) in ⊢ (?(??%)?);
308 rewrite < (eq_Rtimes_Ropp_R1_Ropp) in ⊢ (??(??%));
309 do 2 rewrite < assoc_Rtimes;
310 rewrite > eq_Rtimes_Ropp_R1_Ropp;
311 rewrite > eq_Rtimes_Ropp_R1_Ropp in ⊢ (??%);
312 rewrite > sym_Rtimes;rewrite > sym_Rtimes in ⊢ (??%);
313 rewrite < (eq_Rtimes_Ropp_R1_Ropp) in ⊢ (?%?);
314 rewrite < (eq_Rtimes_Ropp_R1_Ropp) in ⊢ (??%);
315 do 2 rewrite > assoc_Rtimes;
316 rewrite > eq_Rtimes_Ropp_R1_Ropp;
318 rewrite > sym_Rtimes;rewrite > sym_Rtimes in ⊢ (??%);
322 lemma lt_R0_Rinv : ∀x.R0 < x → R0 < Rinv x.
323 intros;apply (pos_z_to_lt_Rtimes_Rtimes_to_lt ?? x H);rewrite > Rinv_Rtimes_l;
324 [rewrite > Rtimes_x_R0;autobatch
325 |intro;apply (irrefl_Rlt x);rewrite < H1 in H;assumption]
328 lemma pos_times_pos_pos : ∀x,y.R0 < x → R0 < y → R0 < x*y.
329 intros;rewrite < (Rtimes_x_R0 x);autobatch;
332 lemma pos_plus_pos_pos : ∀x,y.R0 < x → R0 < y → R0 < x+y.
333 intros;rewrite < (Rplus_Ropp x);apply Rlt_plus_l;
334 apply (trans_Rlt ???? H1);rewrite > Ropp_R0;
335 apply Rlt_to_Rlt_Ropp_Ropp;assumption;
338 lemma Rlt_to_neq : ∀x,y:R.x < y → x ≠ y.
339 intros;intro;rewrite > H1 in H;apply (irrefl_Rlt ? H);
342 lemma lt_Rinv : ∀x,y.R0 < x → x < y → Rinv y < Rinv x.
344 lapply (Rlt_times_l ? ? (Rinv x * Rinv y) H1)
345 [ lapply (Rinv_Rtimes_l x);[2: intro; destruct H2; autobatch;]
346 lapply (Rinv_Rtimes_l y);[2: intro; destruct H2; autobatch;]
347 cut ((x \sup -1/y*x<x \sup -1/y*y) = (y^-1 < x ^-1));[2:
349 rewrite < Hcut; assumption;
351 rewrite > sym_Rtimes in Hletin;rewrite < assoc_Rtimes in Hletin;
352 rewrite > assoc_Rtimes in Hletin:(??%);
353 rewrite > sym_Rtimes in Hletin:(??(??%));
354 rewrite > Rinv_Rtimes_l in Hletin
355 [rewrite > Rinv_Rtimes_l in Hletin
356 [applyS Hletin;(*rewrite > Rtimes_x_R1 in Hletin;rewrite > sym_Rtimes in Hletin;
357 rewrite > Rtimes_x_R1 in Hletin;assumption*)
358 |intro;rewrite > H2 in H1;apply (asym_Rlt ? ? H H1)]
359 |intro;rewrite > H2 in H;apply (irrefl_Rlt ? H)]*)
360 |apply pos_times_pos_pos;apply lt_R0_Rinv;autobatch]
363 lemma Rlt_plus_l_to_r : ∀a,b,c.a + b < c → a < c - b.
364 intros; lapply (Rlt_plus_l ?? (-b) H); applyS Hletin;
366 rewrite < Rplus_x_R0;rewrite < (Rplus_Ropp b);
367 rewrite < assoc_Rplus;
368 rewrite < sym_Rplus;rewrite < sym_Rplus in ⊢ (??%);
369 apply Rlt_plus_l;assumption;
373 lemma Rlt_plus_r_to_l : ∀a,b,c.a < b + c → a - c < b.
375 rewrite > Ropp_inv;rewrite > Ropp_inv in ⊢ (??%);
376 apply Rlt_to_Rlt_Ropp_Ropp;rewrite > distr_Ropp_Rplus;
377 apply Rlt_plus_l_to_r;rewrite < distr_Ropp_Rplus;apply Rlt_to_Rlt_Ropp_Ropp;
381 lemma Rlt_minus_l_to_r : ∀a,b,c.a - b < c → a < c + b.
382 intros;rewrite > (Ropp_inv b);apply Rlt_plus_l_to_r;assumption;
385 lemma Rlt_minus_r_to_l : ∀a,b,c.a < b - c → a + c < b.
386 intros;rewrite > (Ropp_inv c);apply Rlt_plus_r_to_l;assumption;
389 lemma Rlt_div_r_to_l : ∀a,b,c.R0 < c → a < b/c → a*c < b.
390 intros;rewrite < sym_Rtimes;
391 rewrite < Rtimes_x_R1 in ⊢ (??%);rewrite < sym_Rtimes in ⊢ (??%);
392 rewrite < (Rinv_Rtimes_l c)
393 [rewrite > assoc_Rtimes;apply Rlt_times_l
394 [rewrite > sym_Rtimes;assumption
396 |intro;elim (Rlt_to_neq ?? H);symmetry;assumption]
399 lemma Rlt_times_l_to_r : ∀a,b,c.R0 < b → a*b < c → a < c/b.
400 intros;rewrite < sym_Rtimes;
401 rewrite < Rtimes_x_R1;rewrite < sym_Rtimes;
402 rewrite < (Rinv_Rtimes_l b)
403 [rewrite < sym_Rtimes in ⊢ (? (? % ?) ?);
404 rewrite > assoc_Rtimes;apply Rlt_times_l
405 [rewrite > sym_Rtimes;assumption
407 |intro;elim (Rlt_to_neq ?? H);symmetry;assumption]
410 lemma Rle_plus_l_to_r : ∀a,b,c.a + b ≤ c → a ≤ c - b.
416 lemma Rle_plus_r_to_l : ∀a,b,c.a ≤ b + c → a - c ≤ b.
422 lemma Rle_minus_l_to_r : ∀a,b,c.a - b ≤ c → a ≤ c + b.
428 lemma Rle_minus_r_to_l : ∀a,b,c.a ≤ b - c → a + c ≤ b.
434 lemma R_OF_nat_S : ∀n.R_OF_nat (S n) = R_OF_nat n + R1.
435 intros;elim n;simplify
436 [autobatch paramodulation
440 lemma nat_lt_to_R_lt : ∀m,n:nat.m < n → R_OF_nat m < R_OF_nat n.
444 |rewrite < Rplus_x_R0 in ⊢ (?%?);apply Rlt_plus_l;autobatch]
445 |apply (trans_Rlt ??? H2);cases n1;simplify
447 |rewrite < Rplus_x_R0 in ⊢ (?%?);apply Rlt_plus_l;autobatch]]