]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/nlibrary/arithmetics/R.ma
Not is now inductive.
[helm.git] / helm / software / matita / nlibrary / arithmetics / R.ma
1 (**************************************************************************)
2 (*       ___                                                              *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||         The HELM team.                                      *)
8 (*      ||A||         http://helm.cs.unibo.it                             *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU General Public License Version 2                  *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15 include "arithmetics/nat.ma".
16
17 naxiom Q: Type[0].
18 naxiom nat_to_Q: nat → Q.
19 ncoercion nat_to_Q : ∀x:nat.Q ≝ nat_to_Q on _x:nat to Q.
20 naxiom Qplus: Q → Q → Q.
21 naxiom Qtimes: Q → Q → Q.
22 naxiom Qdivides: Q → Q → Q.
23 naxiom Qle : Q → Q → Prop.
24 naxiom Qlt: Q → Q → Prop.
25 interpretation "Q plus" 'plus x y = (Qplus x y).
26 interpretation "Q times" 'times x y = (Qtimes x y).
27 interpretation "Q divides" 'divide x y = (Qdivides x y).
28 interpretation "Q le" 'leq x y = (Qle x y).
29 interpretation "Q lt" 'lt x y = (Qlt x y).
30 naxiom Qtimes_plus: ∀n,m:nat.∀q:Q. (n * q + m * q) = (plus n m) * q.
31 naxiom Qmult_one: ∀q:Q. 1 * q = q.
32 naxiom Qdivides_mult: ∀q1,q2. (q1 * q2) / q1 = q2.
33 naxiom Qtimes_distr: ∀q1,q2,q3:Q.(q3 * q1 + q3 * q2) = q3 * (q1 + q2).
34 naxiom Qdivides_distr: ∀q1,q2,q3:Q.(q1 / q3 + q2 / q3) = (q1 + q2) / q3.
35 naxiom Qplus_comm: ∀q1,q2. q1 + q2 = q2 + q1.
36 naxiom Qplus_assoc: ∀q1,q2,q3. q1 + q2 + q3 = q1 + (q2 + q3).
37 ntheorem Qplus_assoc1: ∀q1,q2,q3. q1 + q2 + q3 = q3 + q2 + q1.
38 #a; #b; #c; //; nqed.
39 naxiom Qle_refl: ∀q1. q1≤q1.
40 naxiom Qle_trans: ∀x,y,z. x≤y → y≤z → x≤z.
41 naxiom Qle_plus_compat: ∀x,y,z,t. x≤y → z≤t → x+z ≤ y+t.
42
43
44 (* naxiom Ndivides_mult: ∀n:nat.∀q. (n * q) / n = q. *)
45
46 ntheorem lem1: ∀n:nat.∀q:Q. (n * q + q) = (S n) * q.
47 #n; #q; ncut (plus n 1 = S n);##[//##]
48 //; nqed.
49
50 ncoinductive locate : Q → Q → Prop ≝
51    L: ∀l,l',u',u. l≤l' → u'≤((2 * l + u) / 3) → locate l' u' → locate l u
52  | H: ∀l,l',u',u. ((l + 2 * u) / 3)≤l' → u'≤ u → locate l' u' → locate l u.
53
54 ndefinition locate_inv_ind':
55  ∀x1,x2:Q.∀P:Q → Q → Prop.
56   ∀H1: ∀l',u'.x1≤l' → u'≤((2 * x1 + x2) / 3) → locate l' u' → P x1 x2. 
57   ∀H2: ∀l',u'. ((x1 + 2 * x2) / 3)≤l' → u'≤ x2 → locate l' u' → P x1 x2.
58    locate x1 x2 → P x1 x2.
59  #x1; #x2; #P; #H1; #H2; #p; ninversion p; #l; #l'; #u'; #u; #Ha; #Hb; #E1;
60  #E2; #E3; ndestruct; /2/ width=5.
61 nqed.
62
63 ndefinition R ≝ ∃l,u:Q. locate l u.
64
65 nlet corec Q_to_locate q : locate q q ≝ L q q q q … (Q_to_locate q).
66   //; nrewrite < (Qdivides_mult 3 q) in ⊢ (? % ?); //.
67 nqed.
68
69 ndefinition Q_to_R : Q → R.
70  #q; @ q; @q; //.
71 nqed.
72
73 (*
74 nlet corec locate_add (l1,u1:?) (r1: locate l1 u1) (l2,u2:?) (r2: locate l2 u2) :
75  locate (l1 + l2) (u1 + u2) ≝ ?.
76  napply (locate_inv_ind' … r1); napply (locate_inv_ind' … r2); #l2'; #u2'; #leq2l; #leq2u; #r2;
77  #l1'; #u1'; #leq1l; #leq1u; #r1
78   [ ##1,4: ##[ @1 ? (l1'+l2') (u1'+u2') | @2 ? (l1'+l2') (u1'+u2') ]
79     ##[ ##1,5: /2/ | napplyS (Qle_plus_compat …leq1u leq2u) |
80         ##4: napplyS (Qle_plus_compat …leq1l leq2l)
81       |##*: /2/ ]
82  ##| ninversion r2; #l2''; #u2''; #leq2l'; #leq2u'; #r2';
83      ninversion r1; #l1''; #u1''; #leq1l'; #leq1u'; #r1';
84       ##[ @1 ? (l1''+l2'') (u1''+u2''); 
85       ##[ napply Qle_plus_compat; /3/;
86         ##| ##3: /2/;
87         ##| napplyS (Qle_plus_compat …leq1u' leq2u');
88       .
89  
90 nlet corec apart (l1,u1) (r1: locate l1 u1) (l2,u2) (r2: locate l2 u2) : CProp[0] ≝
91  match disjoint l1 u1 l2 u2 with
92   [ true ⇒ True
93   | false ⇒ 
94 *)
95
96 include "topology/igft.ma".
97 include "datatypes/pairs.ma".
98 include "datatypes/sums.ma".
99
100 nrecord pre_order (A: Type[0]) : Type[1] ≝
101  { pre_r :2> A → A → CProp[0];
102    pre_sym: reflexive … pre_r;
103    pre_trans: transitive … pre_r
104  }.
105
106 nrecord Ax_pro : Type[1] ≝
107  { AAx :> Ax;
108    Aleq: pre_order AAx
109  }.
110
111 interpretation "Ax_pro leq" 'leq x y = (pre_r ? (Aleq ?) x y).
112
113 (*CSC: per auto per sotto, ma non sembra aiutare *)
114 nlemma And_elim1: ∀A,B. A ∧ B → A.
115  #A; #B; *; //.
116 nqed.
117
118 nlemma And_elim2: ∀A,B. A ∧ B → B.
119  #A; #B; *; //.
120 nqed.
121 (*CSC: /fine per auto per sotto *)
122
123 ndefinition Rax : Ax_pro.
124  @
125   [ @ (Q × Q)
126     [ #p; napply (unit + sigma … (λc. fst … p < fst … c ∧ fst … c < snd … c ∧ snd … c < snd … p))
127     | #c; *
128       [ #_; napply {c' | fst … c < fst … c' ∧ snd … c' < snd … c}
129       | *; #c'; #_; napply {d' | fst … d' = fst … c  ∧ snd … d' = fst … c'
130                                ∨ fst … d' = snd … c' ∧ snd … d' = snd … c } ]##]
131 ##| @ (λc,d. fst … d ≤ fst … c ∧ snd … c ≤ snd … d)
132      [ /2/
133      | nnormalize; #z; #x; #y; *; #H1; #H2; *; /3/; (*CSC: perche' non va? *) ##]
134 nqed.
135
136 ndefinition downarrow: ∀S:Ax_pro. Ω \sup S → Ω \sup S ≝
137  λS:Ax_pro.λU:Ω ^S.{a | ∃b:S. b ∈ U ∧ a ≤ b}.
138
139 interpretation "downarrow" 'downarrow a = (downarrow ? a).
140
141 ndefinition fintersects: ∀S:Ax_pro. Ω \sup S → Ω \sup S → Ω \sup S ≝
142  λS.λU,V. ↓U ∩ ↓V.
143
144 interpretation "fintersects" 'fintersects U V = (fintersects ? U V).
145
146 ndefinition singleton ≝ λA.λa:A.{b | b=a}.
147
148 interpretation "singleton" 'singl a = (singleton ? a).
149
150 ninductive ftcover (A : Ax_pro) (U : Ω^A) : A → CProp[0] ≝
151 | ftreflexivity : ∀a. a ∈ U → ftcover A U a
152 | ftleqinfinity : ∀a,b. a ≤ b → ∀i. (∀x. x ∈ 𝐂 b i ↓ (singleton … a) → ftcover A U x) → ftcover A U a
153 | ftleqleft     : ∀a,b. a ≤ b → ftcover A U b → ftcover A U a.
154
155 interpretation "ftcovers" 'covers a U = (ftcover ? U a).
156
157 ntheorem ftinfinity: ∀A: Ax_pro. ∀U: Ω^A. ∀a. ∀i. (∀x. x ∈ 𝐂 a i → x ◃ U) → a ◃ U.
158  #A; #U; #a; #i; #H;
159  napply (ftleqinfinity … a … i); //;
160  #x; *; *; #b; *; #H1; #H2; #H3; napply (ftleqleft … b); //;
161  napply H; napply H1 (*CSC: auto non va! *).
162 nqed.
163
164 ncoinductive ftfish (A : Ax_pro) (F : Ω^A) : A → CProp[0] ≝
165 | ftfish : ∀a.
166     a ∈ F →
167     (∀b. a ≤ b → ftfish A F b) →
168     (∀b. a ≤ b → ∀i:𝐈 b. ∃x.  x ∈ 𝐂 b i ↓ (singleton … a) ∧ ftfish A F x) →
169     ftfish A F a.
170
171 interpretation "fish" 'fish a U = (ftfish ? U a).
172
173 alias symbol "I" (instance 6) = "I".
174 ntheorem ftcoinfinity: ∀A: Ax_pro. ∀F: Ω^A. ∀a. a ⋉ F → (∀i: 𝐈 a. ∃b. b ∈ 𝐂 a i ∧ b ⋉ F).
175  #A; #F; #a; #H; ncases H; #b; #_; #_; #H2; #i; ncases (H2 … i); //;
176  #x; *; *; *; #y; *; #K2; #K3; #_; #K5; @y; @ K2; ncases K5 in K3; /2/.
177 nqed.