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 "preamble.ma".
17 (* TRICHOTOMY OPERATOR ******************************************************)
19 (* Note: this is "if eqb n1 n2 then a2 else if leb n1 n2 then a1 else a3" *)
20 let rec tri (A:Type[0]) n1 n2 a1 a2 a3 on n1 : A ≝
22 [ O ⇒ match n2 with [ O ⇒ a2 | S n2 ⇒ a1 ]
23 | S n1 ⇒ match n2 with [ O ⇒ a3 | S n2 ⇒ tri A n1 n2 a1 a2 a3 ]
26 lemma tri_lt: ∀A,a1,a2,a3,n2,n1. n1 < n2 → tri A n1 n2 a1 a2 a3 = a1.
27 #A #a1 #a2 #a3 #n2 elim n2 -n2
28 [ #n1 #H elim (lt_zero_false … H)
29 | #n2 #IH #n1 elim n1 -n1 // /3 width=1/
33 lemma tri_eq: ∀A,a1,a2,a3,n. tri A n n a1 a2 a3 = a2.
34 #A #a1 #a2 #a3 #n elim n -n normalize //
37 lemma tri_gt: ∀A,a1,a2,a3,n1,n2. n2 < n1 → tri A n1 n2 a1 a2 a3 = a3.
38 #A #a1 #a2 #a3 #n1 elim n1 -n1
39 [ #n2 #H elim (lt_zero_false … H)
40 | #n1 #IH #n2 elim n2 -n2 // /3 width=1/