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 (**************************************************************************)
16 include "list/list.ma".
17 include "cprop_connectives.ma".
19 notation "\rationals" non associative with precedence 99 for @{'q}.
20 interpretation "Q" 'q = Q.
24 bars: list (ℚ × ℚ) (* base, height *)
29 interpretation "Q plus" 'plus x y = (qp x y).
33 interpretation "Q minus" 'minus x y = (qm x y).
35 axiom qlt : ℚ → ℚ → CProp.
37 interpretation "Q less than" 'lt x y = (qlt x y).
39 inductive q_comparison (a,b:ℚ) : CProp ≝
40 | q_eq : a = b → q_comparison a b
41 | q_lt : a < b → q_comparison a b
42 | q_gt : b < a → q_comparison a b.
44 axiom q_cmp:∀a,b:ℚ.q_comparison a b.
46 definition qle ≝ λa,b:ℚ.a = b ∨ a < b.
48 interpretation "Q less or equal than" 'le x y = (qle x y).
50 notation "'nth'" left associative with precedence 70 for @{'nth}.
51 notation < "\nth \nbsp l \nbsp d \nbsp i" left associative with precedence 70 for @{'nth_appl $l $d $i}.
52 interpretation "list nth" 'nth = (cic:/matita/list/list/nth.con _).
53 interpretation "list nth" 'nth_appl l d i = (cic:/matita/list/list/nth.con _ l d i).
55 notation < "\rationals \sup 2" non associative with precedence 40 for @{'q2}.
56 interpretation "Q x Q" 'q2 = (product Q Q).
58 let rec mk_list (A:Type) (def:nat→A) (n:nat) on n ≝
61 | S m ⇒ def m :: mk_list A def m].
63 interpretation "mk_list appl" 'mk_list f n = (mk_list f n).
64 interpretation "mk_list" 'mk_list = mk_list.
65 notation < "\mk_list \nbsp f \nbsp n" left associative with precedence 70 for @{'mk_list_appl $f $n}.
66 notation "'mk_list'" left associative with precedence 70 for @{'mk_list}.
68 alias symbol "pair" = "pair".
69 definition q00 : ℚ × ℚ ≝ 〈OQ,OQ〉.
71 alias symbol "pi2" = "pair pi2".
72 alias symbol "pi1" = "pair pi1".
73 alias symbol "pair" = "pair".
77 fst (nth (bars (fst p)) q00 i) =
78 fst (nth (bars (snd p)) q00 i).
79 intros (f1 f2); cases f1 (s1 l1); cases f2 (s2 l2); clear f1 f2;
81 let rec aux (l1,l2:list (ℚ × ℚ)) on l1 : (list (ℚ × ℚ)) × (list (ℚ × ℚ)) ≝
83 [ nil ⇒ 〈mk_list (λi.〈fst (nth l2 q00 i),OQ〉) (length ? l2),l2〉
84 | cons he tl ⇒ 〈[],[]〉] in aux);
87 [1: apply (mk_q_f s1);
88 |2: apply (mk_q_f s1); cases l2;
90 [1: (* offset: the smallest one *)