1-- Natural-number order2-- Part of the Grace17 proof assistant for mathematics based on set theory.3-- Copyright (c) 2026 Grant Passmore.4-- Released under the Apache License 2.0. See LICENSE in the repository root.5-- Authors: Grant Passmore67module Grace.Core.Nat.Order8namespace Grace.Core.Nat.Order9import Grace.Core.Nat.Algebra10exportopen Grace.Core.Nat.Order1112predicate LessEqual (a b : Nat) := exists k, Nat(k) and add(a, k) = b13notationinfix50"≤"=> LessEqual forNat14notationinfix50"<="=> LessEqual forNat15notationinfix50"≥"=> reverse LessEqual forNat16notationinfix50">="=> reverse LessEqual forNat1718predicate Less (a b : Nat) := succ(a) ≤ b19notationinfix50"<"=> Less forNat20notationinfix50">"=> reverse Less2122theorem LessEqual.reflexive (a : Nat)23shows a ≤ a24proof25simp [LessEqual, Naturals.constructor.zero, add.right_unit]2627theorem LessEqual.zero (b : Nat)28shows0≤ b29proof30witness b31simp [add]3233theorem LessEqual.add_right (a k : Nat)34shows a ≤ add(a, k)35proof36witness k37reflexivity3839theorem LessEqual.successor (a : Nat)40shows a ≤ succ(a)41proof42witness143simp [Naturals.constructor.zero, Naturals.constructor.succ]44simp [add.succ_right, add.right_unit]4546theorem LessEqual.transitive (a b c : Nat)47requires hab : a ≤ b48requires hbc : b ≤ c49shows a ≤ c50proof51obtain⟨k, hk⟩:= hab52obtain⟨l, hl⟩:= hbc53witness add(k, l)54simp [add.closed]55simp [add.associative_reverse]5657theorem LessEqual.add_monotone_right (a b c : Nat)58requires hab : a ≤ b59shows add(a, c) ≤ add(b, c)60proof61obtain⟨k, hk⟩:= hab62witness k63simp64simp [add.associative, add.swap, add.commutative]6566theorem Less.implies_LessEqual (a b : Nat)67requires hab : a < b68shows a ≤ b69proof70obtain⟨k, hk⟩:= hab71witness succ(k)72simp [Naturals.constructor.succ]73simp [add.successor_shift]7475-- The right side of a bound whose left side is a natural number is one too:76-- the arithmetic tactics type an opaque bounded term from these.77theorem LessEqual.natural_right (a : Nat, b : Set)78requires hab : a ≤ b79showsNat(b)80proof81obtain⟨k, hk, sum⟩:= hab82rw← sum83exact add.closed at k, a8485theorem Less.natural_right (a : Nat, b : Set)86requires hab : a < b87showsNat(b)88proof89have natSucc : Nat(succ(a)) bysimp [Naturals.constructor.succ]90exact LessEqual.natural_right at succ(a), b with natSucc, hab9192end Grace.Core.Nat.Order93