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 rewrites ***********************************************************)
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 rewrites ********************************************************)
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_2 … m n) -m -n //
58 (*** associative_max *)
59 lemma nmax_assoc: associative … nmax.
61 #n1 #IH #n2 elim n2 -n2 //
62 #n2 #_ #n3 elim n3 -n3 //
65 (* Basic inversions *********************************************************)
68 lemma nmax_inv_zero (n1) (n2): 𝟎 = (n1 ∨ n2) → ∧∧ 𝟎 = n1 & 𝟎 = n2.
69 #n1 elim n1 -n1 [ /2 width=1 by conj/ ]
70 #n1 #_ #n2 elim n2 -n2 [ /2 width=1 by conj/ ]
71 #n2 #_ <nmax_succ_bi #H
72 elim (eq_inv_nzero_succ … H)