-- Order properties of natural powers of real numbers -- Part of Cumulus, the Grace17 mathematics library. -- Copyright (c) 2026 Grant Passmore. -- Released under the Apache License 2.0. See LICENSE in the repository root. -- Authors: Grant Passmore, András Salamon module Grace.Cumulus.Real.PowerOrder import Power import Squares import AbsoluteValue import Negation import Natural import RationalEmbedding -- Section: Sign and size theorem realPow.nonnegative (A : Real, n : Nat) requires nonnegative : 0 ≤ A shows 0 ≤ A ^ n proof induction n | zero => rw realPow.zero exact realLess.implies_le with realZero.lt_one | succ(k) using ih => have power := realPow.real at A, k rw realPow.succ exact realMulValue.nonnegative with nonnegative, ih -- Powers are monotone in a nonnegative base. theorem realPow.base_monotone (A B : Real, n : Nat) requires nonnegative : 0 ≤ A requires le : A ≤ B shows A ^ n ≤ B ^ n proof induction n | zero => rw [realPow.zero, realPow.zero] exact realLe.reflexive with realOne.real | succ(k) using ih => have powerA := realPow.real at A, k have powerB := realPow.real at B, k have nonnegativeB : 0 ≤ B by linarith have powerNonnegative := realPow.nonnegative with nonnegative have first := realLe.mul_right_of_nonnegative with le, powerNonnegative have second := realLe.mul_left_of_nonnegative with ih, nonnegativeB rw [realPow.succ, realPow.succ] linarith theorem realPow.le_one (A : Real, n : Nat) requires nonnegative : 0 ≤ A requires bounded : A ≤ 1 shows A ^ n ≤ 1 proof have lowered := realPow.base_monotone at A, (1:R), n with nonnegative, bounded rwa realPow.one at lowered theorem realPow.one_le (A : Real, n : Nat) requires above : 1 ≤ A shows 1 ≤ A ^ n proof have oneNonnegative := realLess.implies_le with realZero.lt_one have lifted := realPow.base_monotone at (1:R), A, n with oneNonnegative, above rwa realPow.one at lifted theorem realPow.abs (A : Real, n : Nat) shows abs(A ^ n) = abs(A) ^ n proof induction n | zero => rw [realPow.zero, realPow.zero] have oneNonnegative := realLess.implies_le with realZero.lt_one exact abs.of_nonnegative with oneNonnegative | succ(k) using ih => have power := realPow.real at A, k have product := abs.mul at A, A ^ k with assumption, power rw [realPow.succ, realPow.succ, product, ih] rfl -- Section: Bernoulli -- Bernoulli's inequality. theorem realPow.bernoulli (H : Real, n : Nat) requires nonnegative : 0 ≤ H shows (1:R) + (realNat(n):R) * H ≤ ((1:R) + H) ^ n proof induction n | zero => rw [realPow.zero, realNat.zero] have zeroProduct : (1:R) + (0:R) * H = (1:R) by ring rw zeroProduct exact realLe.reflexive with realOne.real | succ(k) using ih => have countReal := realNat.real at k have baseReal : (1:R) + H ∈ ℝ by typecheck have one := realZero.lt_one have baseNonnegative : 0 ≤ (1:R) + H by linarith have power := realPow.real at (1:R) + H, k have scaled := realLe.mul_left_of_nonnegative with ih, baseNonnegative have countNonnegative := realNat.zero_le at k have square := realMulValue.square_nonnegative at H have cross := realMulValue.nonnegative with countNonnegative, square have expand : ((1:R) + H) * ((1:R) + (realNat(k):R) * H) = (1:R) + ((realNat(k):R) + 1) * H + (realNat(k):R) * (H * H) by ring rw [realPow.succ, realNat.successor] rw expand at scaled linarith -- For 0 ≤ A < 1 the powers decay at least like 1/(1 + n(1 - A)). theorem realPow.decay_bound (A : Real, n : Nat) requires nonnegative : 0 ≤ A requires below : A < 1 shows A ^ n * ((1:R) + (realNat(n):R) * ((1:R) - A)) ≤ 1 proof have gapReal := realSubValue.real at (1:R), A with realOne.real, assumption have gapPositive := realLess.iff_pos_sub.forward with below have gapNonnegative := realLess.implies_le with gapPositive have countReal := realNat.real at n have power := realPow.real at A, n have powerNonnegative := realPow.nonnegative at A, n with nonnegative have bernoulli := realPow.bernoulli at (1:R) - A, n with gapNonnegative have baseReal : (1:R) + ((1:R) - A) ∈ ℝ by typecheck have basePower := realPow.real at (1:R) + ((1:R) - A), n have factorReal : (1:R) + (realNat(n):R) * ((1:R) - A) ∈ ℝ by typecheck have scaled := realLe.mul_left_of_nonnegative with bernoulli, powerNonnegative have combined := realPow.mul at A, (1:R) + ((1:R) - A), n have productReal : A * ((1:R) + ((1:R) - A)) ∈ ℝ by typecheck have one := realZero.lt_one have baseNonnegative : 0 ≤ (1:R) + ((1:R) - A) by linarith have productNonnegative := realMulValue.nonnegative with nonnegative, baseNonnegative have productBounded : A * ((1:R) + ((1:R) - A)) ≤ 1 have square := realMulValue.square_nonnegative at (1:R) - A have expand : A * ((1:R) + ((1:R) - A)) = (1:R) - ((1:R) - A) * ((1:R) - A) by ring rw expand linarith have small := realPow.le_one at A * ((1:R) + ((1:R) - A)), n with productNonnegative, productBounded rw combined at small exact realLe.transitive with scaled, small