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 "ground/arith/pnat_tri.ma".
16 include "ground/arith/nat.ma".
18 (* TRICHOTOMY OPERATOR FOR NON-NEGATIVE INTEGERS ****************************)
20 (* Note: this is "if eqb n1 n2 then a2 else if leb n1 n2 then a1 else a3" *)
22 definition ntri (A:Type[0]) (n1) (n2) (a1) (a2) (a3): A ≝
24 [ nzero ⇒ match n2 with [ nzero ⇒ a2 | ninj p2 ⇒ a1 ]
25 | ninj p1 ⇒ match n2 with [ nzero ⇒ a3 | ninj p2 ⇒ ptri A p1 p2 a1 a2 a3 ]
28 (* Basic constructions ******************************************************)
30 lemma ntri_zero_bi (A) (a1) (a2) (a3):
31 a2 = ntri A (𝟎) (𝟎) a1 a2 a3.
34 lemma ntri_zero_inj (A) (a1) (a2) (a3) (p):
35 a1 = ntri A (𝟎) (ninj p) a1 a2 a3.
38 lemma ntri_inj_zero (A) (a1) (a2) (a3) (p):
39 a3 = ntri A (ninj p) (𝟎) a1 a2 a3.
42 lemma ntri_inj_bi (A) (a1) (a2) (a3) (p1) (p2):
43 ptri A (p1) (p2) a1 a2 a3 = ntri A (p1) (p2) a1 a2 a3.
46 (* Advanced constructions ***************************************************)
49 lemma ntri_eq (A) (a1) (a2) (a3) (n): a2 = ntri A n n a1 a2 a3.
53 lemma ntri_f_tri (A) (B) (f) (a1) (a2) (a3) (n1) (n2):
54 f (ntri A n1 n2 a1 a2 a3) = ntri B n1 n2 (f a1) (f a2) (f a3).
57 <ntri_inj_bi <ntri_inj_bi //