]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambda/preamble.ma
3d5efb8f2acf300c1107057d1e5b50d7a5ca0073
[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/list.ma".
17 include "arithmetics/nat.ma".
18
19 include "xoa_notation.ma".
20 include "xoa.ma".
21
22 (* Note: notation for nil not involving brackets *)
23 notation > "◊"
24   non associative with precedence 90
25   for @{'nil}.
26
27 (* Note: For some reason this cannot be in the standard library *) 
28 interpretation "logical false" 'false = False.
29
30 notation "⊥"
31   non associative with precedence 90
32   for @{'false}.
33
34 lemma lt_refl_false: ∀n. n < n → ⊥.
35 #n #H elim (lt_to_not_eq … H) -H /2 width=1/
36 qed-.
37
38 lemma lt_zero_false: ∀n. n < 0 → ⊥.
39 #n #H elim (lt_to_not_le … H) -H /2 width=1/
40 qed-.
41
42 lemma plus_lt_false: ∀m,n. m + n < m → ⊥.
43 #m #n #H elim (lt_to_not_le … H) -H /2 width=1/
44 qed-.
45
46 lemma lt_or_eq_or_gt: ∀m,n. ∨∨ m < n | n = m | n < m.
47 #m #n elim (lt_or_ge m n) /2 width=1/
48 #H elim H -m /2 width=1/
49 #m #Hm * #H /2 width=1/ /3 width=1/
50 qed-.
51
52 (* trichotomy operator *)
53
54 (* Note: this is "if eqb n1 n2 then a2 else if leb n1 n2 then a1 else a3" *)
55 let rec tri (A:Type[0]) n1 n2 a1 a2 a3 on n1 : A ≝
56   match n1 with 
57   [ O    ⇒ match n2 with [ O ⇒ a2 | S n2 ⇒ a1 ]
58   | S n1 ⇒ match n2 with [ O ⇒ a3 | S n2 ⇒ tri A n1 n2 a1 a2 a3 ]
59   ].
60
61 lemma tri_lt: ∀A,a1,a2,a3,n2,n1. n1 < n2 → tri A n1 n2 a1 a2 a3 = a1.
62 #A #a1 #a2 #a3 #n2 elim n2 -n2
63 [ #n1 #H elim (lt_zero_false … H)
64 | #n2 #IH #n1 elim n1 -n1 // /3 width=1/
65 ]
66 qed.
67
68 lemma tri_eq: ∀A,a1,a2,a3,n. tri A n n a1 a2 a3 = a2.
69 #A #a1 #a2 #a3 #n elim n -n normalize //
70 qed.
71
72 lemma tri_gt: ∀A,a1,a2,a3,n1,n2. n2 < n1 → tri A n1 n2 a1 a2 a3 = a3.
73 #A #a1 #a2 #a3 #n1 elim n1 -n1
74 [ #n2 #H elim (lt_zero_false … H)
75 | #n1 #IH #n2 elim n2 -n2 // /3 width=1/
76 ]
77 qed.