]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambda_delta/ground_2/tri.ma
4fc6195650e5c442bbcd1967c83ada21eb750fb9
[helm.git] / matita / matita / contribs / lambda_delta / ground_2 / tri.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 "ground_2/arith.ma".
16
17 (* TRICOTOMY FUNCTION *******************************************************)
18
19 let rec tri (A:Type[0]) m n a b c on m : A ≝
20   match m with 
21   [ O   ⇒ match n with [ O ⇒ b | S n ⇒ a ]
22   | S m ⇒ match n with [ O ⇒ c | S n ⇒ tri A m n a b c ]
23   ]. 
24
25 (* Basic properties *********************************************************)
26
27 lemma tri_lt: ∀A,a,b,c,n,m. m < n → tri A m n a b c = a.
28 #A #a #b #c #n elim n -n
29 [ #m #H elim (lt_zero_false … H)
30 | #n #IH #m elim m -m // /3 width=1/
31 ]
32 qed.
33
34 lemma tri_eq: ∀A,a,b,c,m. tri A m m a b c = b.
35 #A #a #b #c #m elim m -m normalize //
36 qed.
37
38 lemma tri_gt: ∀A,a,b,c,m,n. n < m → tri A m n a b c = c.
39 #A #a #b #c #m elim m -m
40 [ #n #H elim (lt_zero_false … H)
41 | #m #IH #n elim n -n // /3 width=1/
42 ]
43 qed.
44