]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/contribs/dama/dama/models/q_function.ma
- grafiteParser.ml: the callback invocation was displaced
[helm.git] / helm / software / matita / contribs / dama / dama / models / q_function.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 "Q/q/q.ma".
16 include "list/list.ma".
17 include "cprop_connectives.ma". 
18
19 notation "\rationals" non associative with precedence 99 for @{'q}.
20 interpretation "Q" 'q = Q. 
21
22 record q_f : Type ≝ {
23  start : ℚ;
24  bars: list (ℚ × ℚ) (* base, height *)
25 }.
26
27 axiom qp : ℚ → ℚ → ℚ.
28
29 interpretation "Q plus" 'plus x y = (qp x y).
30
31 axiom qm : ℚ → ℚ → ℚ.
32
33 interpretation "Q minus" 'minus x y = (qm x y).
34
35 axiom qlt : ℚ → ℚ → CProp.
36
37 interpretation "Q less than" 'lt x y = (qlt x y).
38
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.
43
44 axiom q_cmp:∀a,b:ℚ.q_comparison a b.
45
46 definition qle ≝ λa,b:ℚ.a = b ∨ a < b.
47
48 interpretation "Q less or equal than" 'le x y = (qle x y).
49
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).
54
55 notation < "\rationals \sup 2" non associative with precedence 40 for @{'q2}.
56 interpretation "Q x Q" 'q2 = (product Q Q).
57
58 let rec mk_list (A:Type) (def:nat→A) (n:nat) on n ≝
59   match n with
60   [ O ⇒ []
61   | S m ⇒ def m :: mk_list A def m].
62
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}.
67
68 alias symbol "pair" = "pair".
69 definition q00 : ℚ × ℚ ≝ 〈OQ,OQ〉.
70
71 alias symbol "pi2" = "pair pi2".
72 alias symbol "pi1" = "pair pi1".
73 alias symbol "pair" = "pair".
74 definition rebase: 
75   q_f → q_f → 
76     ∃p:q_f × q_f.∀i.
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;
80 letin aux ≝ (
81 let rec aux (l1,l2:list (ℚ × ℚ)) on l1 : (list (ℚ × ℚ)) × (list (ℚ × ℚ)) ≝
82   match l1 with
83   [ nil ⇒ 〈mk_list (λi.〈fst (nth l2 q00 i),OQ〉) (length ? l2),l2〉
84   | cons he tl ⇒ 〈[],[]〉] in aux); 
85   
86 cases (q_cmp s1 s2);
87 [1: apply (mk_q_f s1);
88 |2: apply (mk_q_f s1); cases l2;
89     [1: letin l2' ≝ (
90 [1: (* offset: the smallest one *)
91     cases