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/notation/functions/zero_0.ma".
16 include "ground/arith/nat_succ_tri.ma".
18 (* MAXIMUM FOR NON-NEGATIVE INTEGERS ****************************************)
21 definition nmax: nat → nat → nat ≝
22 λm,n. ntri … m n n n m.
25 "maximum (non-negative integers)"
28 (* Basic constructions ******************************************************)
31 lemma nmax_zero_sn (n2): n2 = (𝟎 ∨ n2).
36 lemma nmax_zero_dx (n1): n1 = (n1 ∨ 𝟎).
41 lemma nmax_succ_bi (n1) (n2): ↑(n1 ∨ n2) = (↑n1 ∨ ↑n2).
43 @trans_eq [3: @ntri_succ_bi | skip ] (**) (* rewrite fails because δ-expansion gets in the way *)
47 (* Advanced constructions ***************************************************)
49 (*** idempotent_max *)
50 lemma nmax_idem (n): n = (n ∨ n).
51 /2 width=1 by ntri_eq/ qed.
53 (*** commutative_max *)
54 lemma nmax_comm: commutative … nmax.
55 #m #n @(nat_ind_succ_2 … m n) -m -n //
58 (*** associative_max *)
59 lemma nmax_assoc: associative … nmax.
60 #n1 #n2 @(nat_ind_succ_2 … n1 n2) -n1 -n2 //
61 #n1 #n2 #IH #n3 @(nat_ind_succ … n3) -n3 //
64 (* Basic inversions *********************************************************)
67 lemma nmax_inv_zero (n1) (n2): 𝟎 = (n1 ∨ n2) → ∧∧ 𝟎 = n1 & 𝟎 = n2.
68 #n1 #n2 @(nat_ind_succ_2 … n1 n2) -n1 -n2 /2 width=1 by conj/
69 #n1 #n2 #_ <nmax_succ_bi #H
70 elim (eq_inv_nzero_succ … H)