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/nat_succ_tri.ma".
17 (* MAXIMUM FOR NON-NEGATIVE INTEGERS ****************************************)
20 definition nmax: nat → nat → nat ≝
21 λm,n. ntri … m n n n m.
24 "maximum (non-negative integers)"
27 (* Basic constructions ******************************************************)
30 lemma nmax_zero_sn (n2): n2 = (𝟎 ∨ n2).
35 lemma nmax_zero_dx (n1): n1 = (n1 ∨ 𝟎).
40 lemma nmax_succ_bi (n1) (n2): ↑(n1 ∨ n2) = (↑n1 ∨ ↑n2).
42 @trans_eq [3: @ntri_succ_bi | skip ] (* * rewrite fails because δ-expansion gets in the way *)
46 (* Advanced constructions ***************************************************)
48 (*** idempotent_max *)
49 lemma nmax_idem (n): n = (n ∨ n).
50 /2 width=1 by ntri_eq/ qed.
52 (*** commutative_max *)
53 lemma nmax_comm: commutative … nmax.
54 #m #n @(nat_ind_2_succ … m n) -m -n //
57 (*** associative_max *)
58 lemma nmax_assoc: associative … nmax.
59 #n1 #n2 @(nat_ind_2_succ … n1 n2) -n1 -n2 //
60 #n1 #n2 #IH #n3 @(nat_ind_succ … n3) -n3 //
63 lemma nmax_max_comm_23 (o:nat) (m) (n): (o ∨ m ∨ n) = (o ∨ n ∨ m).
64 #o #m #n >nmax_assoc >nmax_assoc <nmax_comm in ⊢ (??(??%)?); //
67 (* Basic inversions *********************************************************)
69 lemma eq_inv_zero_nmax (n1) (n2): 𝟎 = (n1 ∨ n2) → ∧∧ 𝟎 = n1 & 𝟎 = n2.
70 #n1 #n2 @(nat_ind_2_succ … n1 n2) -n1 -n2 /2 width=1 by conj/
71 #n1 #n2 #_ <nmax_succ_bi #H
72 elim (eq_inv_zero_nsucc … H)
76 lemma eq_inv_nmax_zero (n1) (n2): (n1 ∨ n2) = 𝟎 → ∧∧ 𝟎 = n1 & 𝟎 = n2.
77 /2 width=1 by eq_inv_zero_nmax/ qed-.