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 (**************************************************************************)
15 include "arithmetics/nat.ma".
17 include "xoa_notation.ma".
20 (* Note: For some reason this cannot be in the standard library *)
21 interpretation "logical false" 'false = False.
24 non associative with precedence 90
27 lemma lt_refl_false: ∀n. n < n → ⊥.
28 #n #H elim (lt_to_not_eq … H) -H /2 width=1/
31 lemma lt_zero_false: ∀n. n < 0 → ⊥.
32 #n #H elim (lt_to_not_le … H) -H /2 width=1/
35 lemma plus_lt_false: ∀m,n. m + n < m → ⊥.
36 #m #n #H elim (lt_to_not_le … H) -H /2 width=1/
39 lemma lt_or_eq_or_gt: ∀m,n. ∨∨ m < n | n = m | n < m.
40 #m #n elim (lt_or_ge m n) /2 width=1/
41 #H elim H -m /2 width=1/
42 #m #Hm * #H /2 width=1/ /3 width=1/
45 (* trichotomy operator *)
47 (* Note: this is "if eqb n1 n2 then a2 else if leb n1 n2 then a1 else a3" *)
48 let rec tri (A:Type[0]) n1 n2 a1 a2 a3 on n1 : A ≝
50 [ O ⇒ match n2 with [ O ⇒ a2 | S n2 ⇒ a1 ]
51 | S n1 ⇒ match n2 with [ O ⇒ a3 | S n2 ⇒ tri A n1 n2 a1 a2 a3 ]
54 lemma tri_lt: ∀A,a1,a2,a3,n2,n1. n1 < n2 → tri A n1 n2 a1 a2 a3 = a1.
55 #A #a1 #a2 #a3 #n2 elim n2 -n2
56 [ #n1 #H elim (lt_zero_false … H)
57 | #n2 #IH #n1 elim n1 -n1 // /3 width=1/
61 lemma tri_eq: ∀A,a1,a2,a3,n. tri A n n a1 a2 a3 = a2.
62 #A #a1 #a2 #a3 #n elim n -n normalize //
65 lemma tri_gt: ∀A,a1,a2,a3,n1,n2. n2 < n1 → tri A n1 n2 a1 a2 a3 = a3.
66 #A #a1 #a2 #a3 #n1 elim n1 -n1
67 [ #n2 #H elim (lt_zero_false … H)
68 | #n1 #IH #n2 elim n2 -n2 // /3 width=1/