]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambda/preamble.ma
- lambda: some parts commented out, some refactoring
[helm.git] / matita / matita / contribs / lambda / preamble.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 "basics/star.ma".
16 include "basics/lists/lstar.ma".
17 include "arithmetics/exp.ma".
18
19 include "xoa_notation.ma".
20 include "xoa.ma".
21
22 (* logic *)
23
24 (* Note: For some reason this cannot be in the standard library *) 
25 interpretation "logical false" 'false = False.
26
27 notation "⊥"
28   non associative with precedence 90
29   for @{'false}.
30
31 (* arithmetics *)
32
33 lemma lt_refl_false: ∀n. n < n → ⊥.
34 #n #H elim (lt_to_not_eq … H) -H /2 width=1/
35 qed-.
36
37 lemma lt_zero_false: ∀n. n < 0 → ⊥.
38 #n #H elim (lt_to_not_le … H) -H /2 width=1/
39 qed-.
40
41 lemma plus_lt_false: ∀m,n. m + n < m → ⊥.
42 #m #n #H elim (lt_to_not_le … H) -H /2 width=1/
43 qed-.
44
45 lemma lt_or_eq_or_gt: ∀m,n. ∨∨ m < n | n = m | n < m.
46 #m #n elim (lt_or_ge m n) /2 width=1/
47 #H elim H -m /2 width=1/
48 #m #Hm * #H /2 width=1/ /3 width=1/
49 qed-.
50
51 (* trichotomy operator *)
52
53 (* Note: this is "if eqb n1 n2 then a2 else if leb n1 n2 then a1 else a3" *)
54 let rec tri (A:Type[0]) n1 n2 a1 a2 a3 on n1 : A ≝
55   match n1 with 
56   [ O    ⇒ match n2 with [ O ⇒ a2 | S n2 ⇒ a1 ]
57   | S n1 ⇒ match n2 with [ O ⇒ a3 | S n2 ⇒ tri A n1 n2 a1 a2 a3 ]
58   ].
59
60 lemma tri_lt: ∀A,a1,a2,a3,n2,n1. n1 < n2 → tri A n1 n2 a1 a2 a3 = a1.
61 #A #a1 #a2 #a3 #n2 elim n2 -n2
62 [ #n1 #H elim (lt_zero_false … H)
63 | #n2 #IH #n1 elim n1 -n1 // /3 width=1/
64 ]
65 qed.
66
67 lemma tri_eq: ∀A,a1,a2,a3,n. tri A n n a1 a2 a3 = a2.
68 #A #a1 #a2 #a3 #n elim n -n normalize //
69 qed.
70
71 lemma tri_gt: ∀A,a1,a2,a3,n1,n2. n2 < n1 → tri A n1 n2 a1 a2 a3 = a3.
72 #A #a1 #a2 #a3 #n1 elim n1 -n1
73 [ #n2 #H elim (lt_zero_false … H)
74 | #n1 #IH #n2 elim n2 -n2 // /3 width=1/
75 ]
76 qed.
77
78 (* lists *)
79
80 (* Note: notation for nil not involving brackets *)
81 notation > "◊"
82   non associative with precedence 90
83   for @{'nil}.
84
85 definition map_cons: ∀A. A → list (list A) → list (list A) ≝ λA,a.
86                      map … (cons … a).
87
88 interpretation "map_cons" 'ho_cons a l = (map_cons ? a l).
89
90 notation "hvbox(a ::: break l)"
91   right associative with precedence 47
92   for @{'ho_cons $a $l}.
93
94 (* lstar *)
95
96 (* Note: this cannot be in lib because of the missing xoa quantifier *)
97 lemma lstar_inv_pos: ∀A,B,R,l,b1,b2. lstar A B R l b1 b2 → 0 < |l| →
98                      ∃∃a,ll,b. a::ll = l & R a b1 b & lstar A B R ll b b2.
99 #A #B #R #l #b1 #b2 #H @(lstar_ind_l ????????? H) -b1
100 [ #H elim (lt_refl_false … H) 
101 | #a #ll #b1 #b #Hb1 #Hb2 #_ #_ /2 width=6/ (**) (* auto fail if we do not remove the inductive premise *)
102 ]
103 qed-.