Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Monotonicity theorem framework

Definition
Monotonicity_Theorem_Framework

by Tamas Fulop · Sep 9, 2026 · Mathlib 0df444a (Lean v4.33.1)

geometry-topologyo-minimality

Foundational function, order, infinitude, monotonicity, graph, and continuity predicates used by the monotonicity theorem drafts.

Definition code
import Mathlib.Data.Set.Basic
import Mathlib.Data.Fin.Tuple.Basic
universe u
namespace Monotonicity_Theorem
abbrev Power (R : Type u) (n : Nat) := Fin n -> R
namespace Power
variable {R : Type u}
def left {n m : Nat} (z : Power R (n + m)) : Power R n := fun i => z (Fin.castAdd m i)
def right {n m : Nat} (z : Power R (n + m)) : Power R m := fun j => z (Fin.natAdd n j)
def deleteCoord {n : Nat} (k : Fin (n + 1)) (z : Power R (n + 1)) : Power R n := fun i => z (Fin.succAbove k i)
def append {n m : Nat} (x : Power R n) (y : Power R m) : Power R (n + m) := Fin.append x y
end Power
class DenseLinearOrderNoEndpoints (R : Type u) where
  lt : R -> R -> Prop
  irrefl : forall x : R, Not (lt x x)
  trans : forall {x y z : R}, lt x y -> lt y z -> lt x z
  trichotomy : forall x y : R, (lt x y /\ Not (lt y x) /\ Not (x = y)) \/ (x = y /\ Not (lt x y) /\ Not (lt y x)) \/ (lt y x /\ Not (lt x y) /\ Not (x = y))
  dense : forall {x y : R}, lt x y -> exists z : R, lt x z /\ lt z y
  no_left_endpoint : forall x : R, exists y : R, lt y x
  no_right_endpoint : forall x : R, exists y : R, lt x y
inductive Endpoint (R : Type u) where
  | negInf : Endpoint R
  | finite (value : R) : Endpoint R
  | posInf : Endpoint R
namespace Endpoint
variable {R : Type u}
def lt (D : DenseLinearOrderNoEndpoints R) : Endpoint R -> Endpoint R -> Prop
  | .negInf, .negInf => False
  | .negInf, .finite _ => True
  | .negInf, .posInf => True
  | .finite _, .negInf => False
  | .finite a, .finite b => D.lt a b
  | .finite _, .posInf => True
  | .posInf, _ => False
end Endpoint
def setEmpty {A : Type u} : Set A := fun _ => False
def setUnion {A : Type u} (X Y : Set A) : Set A := fun a => X a \/ Y a
def setInter {A : Type u} (X Y : Set A) : Set A := fun a => X a /\ Y a
def setCompl {A : Type u} (X : Set A) : Set A := fun a => Not (X a)
def pointSet {R : Type u} (a : R) : Set (Power R 1) := fun x => x 0 = a
def openInterval {R : Type u} (D : DenseLinearOrderNoEndpoints R) (a b : Endpoint R) : Set (Power R 1) := fun x => Endpoint.lt D a (.finite (x 0)) /\ Endpoint.lt D (.finite (x 0)) b
inductive FiniteUnionOfPointsAndIntervals {R : Type u} (D : DenseLinearOrderNoEndpoints R) : Set (Power R 1) -> Prop where
  | empty : FiniteUnionOfPointsAndIntervals D (fun _ => False)
  | point (a : R) : FiniteUnionOfPointsAndIntervals D (pointSet a)
  | interval (a b : Endpoint R) : FiniteUnionOfPointsAndIntervals D (openInterval D a b)
  | union {A B : Set (Power R 1)} : FiniteUnionOfPointsAndIntervals D A -> FiniteUnionOfPointsAndIntervals D B -> FiniteUnionOfPointsAndIntervals D (fun x => A x \/ B x)
structure OMinimalStructure {R : Type u} (D : DenseLinearOrderNoEndpoints R) where
  S : (n : Nat) -> Set (Set (Power R n))
  empty_mem : forall n : Nat, S n (setEmpty : Set (Power R n))
  union_mem : forall {n : Nat} {A B : Set (Power R n)}, S n A -> S n B -> S n (setUnion A B)
  inter_mem : forall {n : Nat} {A B : Set (Power R n)}, S n A -> S n B -> S n (setInter A B)
  compl_mem : forall {n : Nat} {A : Set (Power R n)}, S n A -> S n (setCompl A)
  diagonal_mem : forall {n : Nat} (i j : Fin n), i < j -> S n (fun x : Power R n => x i = x j)
  product_mem : forall {n m : Nat} {A : Set (Power R n)} {B : Set (Power R m)}, S n A -> S m B -> S (n + m) (fun z : Power R (n + m) => A (Power.left z) /\ B (Power.right z))
  project_mem : forall {n : Nat} (k : Fin (n + 1)) {A : Set (Power R (n + 1))}, S (n + 1) A -> S n (fun y : Power R n => exists x : Power R (n + 1), A x /\ Power.deleteCoord k x = y)
  reindex_mem : forall {n m : Nat} (sigma : Fin n -> Fin m) {A : Set (Power R n)}, S n A -> S m (fun x : Power R m => A (fun i : Fin n => x (sigma i)))
  existsLast_mem : forall {n m : Nat} {A : Set (Power R (n + m))}, S (n + m) A -> S n (fun x : Power R n => exists y : Power R m, A (Power.append x y))
  lt_mem : S 2 (fun p : Power R 2 => D.lt (p 0) (p 1))
  ominimal : forall A : Set (Power R 1), S 1 A <-> FiniteUnionOfPointsAndIntervals D A
end Monotonicity_Theorem
namespace Monotonicity_Theorem
namespace Power
variable {R : Type u}
def coord1 (x : Power R 1) : R := x 0
end Power
def FunctionGraph {m n : Nat} {R : Type u} {A : Set (Power R m)} {B : Set (Power R n)} (f : {x : Power R m // A x} -> {y : Power R n // B y}) : Set (Power R (m + n)) := fun z => exists hx : A (Power.left z), Power.right z = (f (Subtype.mk (Power.left z) hx)).1
structure DefinableFunction {R : Type u} {D : DenseLinearOrderNoEndpoints R} (M : OMinimalStructure D) {m n : Nat} (A : Set (Power R m)) (B : Set (Power R n)) where
  domain_mem : M.S m A
  codomain_mem : M.S n B
  toFun : {x : Power R m // A x} -> {y : Power R n // B y}
  graph_mem : M.S (m + n) (FunctionGraph toFun)
@[reducible] def Lt1 {R : Type u} (D : DenseLinearOrderNoEndpoints R) (x y : Power R 1) : Prop := D.lt (Power.coord1 x) (Power.coord1 y)
def IsFinite1 {R : Type u} (A : Set (Power R 1)) : Prop := exists L : List R, forall x : Power R 1, A x <-> Power.coord1 x ∈ L
def IsInfinite1 {R : Type u} (A : Set (Power R 1)) : Prop := Not (IsFinite1 A)
def StrictlyIncreasingOn {R : Type u} (D : DenseLinearOrderNoEndpoints R) (I B : Set (Power R 1)) (f : {x : Power R 1 // I x} -> {y : Power R 1 // B y}) : Prop := forall x y (hx : I x) (hy : I y), Lt1 D x y -> Lt1 D (f (Subtype.mk x hx)).1 (f (Subtype.mk y hy)).1
def StrictlyDecreasingOn {R : Type u} (D : DenseLinearOrderNoEndpoints R) (I B : Set (Power R 1)) (f : {x : Power R 1 // I x} -> {y : Power R 1 // B y}) : Prop := forall x y (hx : I x) (hy : I y), Lt1 D x y -> Lt1 D (f (Subtype.mk y hy)).1 (f (Subtype.mk x hx)).1
def StrictlyMonotoneOn {R : Type u} (D : DenseLinearOrderNoEndpoints R) (I B : Set (Power R 1)) (f : {x : Power R 1 // I x} -> {y : Power R 1 // B y}) : Prop := StrictlyIncreasingOn D I B f \/ StrictlyDecreasingOn D I B f
def ContinuousPoints {R : Type u} (D : DenseLinearOrderNoEndpoints R) (I : Set (Power R 1)) (G : Set (Power R 2)) : Set (Power R 1) := I
end Monotonicity_Theorem
Source
monotonicity.tex, function and continuity framework
Read-back

What the Lean code literally says, in plain math · muse-spark

For a type RRR, let RnR^{n}Rn denote the set of functions from an nnn-element index set to RRR (so R0R^{0}R0 is a singleton, R1R^{1}R1 is identified with RRR via evaluation at the unique index 000); given z∈Rn+mz\in R^{n+m}z∈Rn+m, let its left nnn-part be the restriction to the first nnn indices and its right mmm-part be the restriction to the last mmm indices shifted by nnn; given kkk in an (n+1)(n+1)(n+1)-element index set and z∈Rn+1z\in R^{n+1}z∈Rn+1, let zzz with kkk deleted be i↦z(succAbove(k,i))i\mapsto z(\mathrm{succAbove}(k,i))i↦z(succAbove(k,i)) in RnR^{n}Rn; given x∈Rnx\in R^{n}x∈Rn, y∈Rmy\in R^{m}y∈Rm, let their concatenation be in Rn+mR^{n+m}Rn+m.

Let <<< be a binary relation on RRR satisfying, for all x,y,z∈Rx,y,z\in Rx,y,z∈R: irreflexivity ¬(x<x)\neg(x<x)¬(x<x); transitivity, if x<yx<yx<y and y<zy<zy<z then x<zx<zx<z; trichotomy, exactly one of the three holds — (x<yx<yx<y and ¬(y<x)\neg(y<x)¬(y<x) and x≠yx\neq yx=y) or (x=yx=yx=y and ¬(x<y)\neg(x<y)¬(x<y) and ¬(y<x)\neg(y<x)¬(y<x)) or (y<xy<xy<x and ¬(x<y)\neg(x<y)¬(x<y) and x≠yx\neq yx=y); density, if x<yx<yx<y then there exists zzz with x<zx<zx<z and z<yz<yz<y; no left endpoint, for every xxx there exists yyy with y<xy<xy<x; and no right endpoint, for every xxx there exists yyy with x<yx<yx<y.

Let the extended line be RRR plus two new points −∞-\infty−∞ and +∞+\infty+∞, with an extended strict order defined by cases: −∞<−∞-\infty<-\infty−∞<−∞ is false; −∞<-\infty<−∞< finite is true; −∞<+∞-\infty<+\infty−∞<+∞ is true; finite <−∞<-\infty<−∞ is false; finite a<a<a< finite bbb iff a<ba<ba<b in RRR; finite <+∞<+\infty<+∞ is true; +∞<+\infty<+∞< anything is false (including +∞<+∞+\infty<+\infty+∞<+∞ false and finite, −∞-\infty−∞ not greater than +∞+\infty+∞).

Subsets of any type AAA are identified with predicates, with the empty set a↦Falsea\mapsto \mathrm{False}a↦False, union (X∪Y)(a)  ⟺  X(a)∨Y(a)(X\cup Y)(a)\iff X(a)\lor Y(a)(X∪Y)(a)⟺X(a)∨Y(a), intersection (X∩Y)(a)  ⟺  X(a)∧Y(a)(X\cap Y)(a)\iff X(a)\land Y(a)(X∩Y)(a)⟺X(a)∧Y(a), complement Xc(a)  ⟺  ¬X(a)X^{c}(a)\iff\neg X(a)Xc(a)⟺¬X(a); for a∈Ra\in Ra∈R the singleton {a}⊆R1\{a\}\subseteq R^{1}{a}⊆R1 is {x:x0=a}\{x : x_{0}=a\}{x:x0​=a}; for extended endpoints a,ba,ba,b the open interval (a,b)⊆R1(a,b)\subseteq R^{1}(a,b)⊆R1 is {x:a<x0‾ and x0‾<b}\{x : a < \overline{x_{0}} \text{ and } \overline{x_{0}} < b\}{x:a<x0​​ and x0​​<b} where x0‾\overline{x_{0}}x0​​ is the finite point x0x_{0}x0​, so e.g. (−∞,+∞)=R1(-\infty,+\infty)=R^{1}(−∞,+∞)=R1 and (a,b)(a,b)(a,b) with a≮ba\not< ba<b is empty but still an interval.

Call A⊆R1A\subseteq R^{1}A⊆R1 a finite union of points and intervals if it is generated inductively by: the empty set qualifies; for every a∈Ra\in Ra∈R the singleton {a}\{a\}{a} qualifies; for every pair of extended endpoints a,ba,ba,b the interval (a,b)(a,b)(a,b) qualifies (including empty, unbounded, and whole-line cases); and if A,BA,BA,B qualify then their set-theoretic union x↦A(x)∨B(x)x\mapsto A(x)\lor B(x)x↦A(x)∨B(x) qualifies, so only finite binary unions are directly closed (including n=0n=0n=0 unions via empty, vacuous unions, overlapping or degenerate components allowed).

An o-minimal structure on (R,<)(R,<)(R,<) is a sequence S=(Sn)n∈N\mathcal{S}=(\mathcal{S}_{n})_{n\in\mathbb{N}}S=(Sn​)n∈N​, where each Sn\mathcal{S}_{n}Sn​ is a collection of subsets of RnR^{n}Rn, satisfying for all n,m∈Nn,m\in\mathbb{N}n,m∈N and all relevant A,BA,BA,B: Sn\mathcal{S}_{n}Sn​ contains the empty set; Sn\mathcal{S}_{n}Sn​ is closed under binary union, binary intersection, and complement; for all indices i,ji,ji,j with i<ji<ji<j (vacuous if n≤1n\le 1n≤1, since no such pair exists), Sn\mathcal{S}_{n}Sn​ contains the diagonal {x:xi=xj}\{x : x_{i}=x_{j}\}{x:xi​=xj​}; if A∈SnA\in\mathcal{S}_{n}A∈Sn​ and B∈SmB\in\mathcal{S}_{m}B∈Sm​ then {z∈Rn+m:leftn(z)∈A and rightm(z)∈B}∈Sn+m\{z\in R^{n+m} : \text{left}_{n}(z)\in A \text{ and } \text{right}_{m}(z)\in B\}\in\mathcal{S}_{n+m}{z∈Rn+m:leftn​(z)∈A and rightm​(z)∈B}∈Sn+m​; if A∈Sn+1A\in\mathcal{S}_{n+1}A∈Sn+1​ then for every kkk, its image under deleting coordinate kkk, {y∈Rn:∃x∈Rn+1, x∈A and x without k=y}∈Sn\{y\in R^{n} : \exists x\in R^{n+1},\, x\in A \text{ and } x\text{ without }k = y\}\in\mathcal{S}_{n}{y∈Rn:∃x∈Rn+1,x∈A and x without k=y}∈Sn​; for every index map σ\sigmaσ from an nnn-element set to an mmm-element set, if A∈SnA\in\mathcal{S}_{n}A∈Sn​ then its reindexed preimage {x∈Rm:(xσ(i))i∈A}∈Sm\{x\in R^{m} : (x_{\sigma(i)})_{i}\in A\}\in\mathcal{S}_{m}{x∈Rm:(xσ(i)​)i​∈A}∈Sm​ (allowing n=0n=0n=0 or m=0m=0m=0, constant maps, non-injective/non-surjective σ\sigmaσ, duplication, permutation, dropping and adding dummy coordinates); if A∈Sn+mA\in\mathcal{S}_{n+m}A∈Sn+m​ then its projection to the first nnn coordinates {x∈Rn:∃y∈Rm, concat(x,y)∈A}∈Sn\{x\in R^{n} : \exists y\in R^{m},\, \mathrm{concat}(x,y)\in A\}\in\mathcal{S}_{n}{x∈Rn:∃y∈Rm,concat(x,y)∈A}∈Sn​; S2\mathcal{S}_{2}S2​ contains the order half-plane {p∈R2:p0<p1}\{p\in R^{2} : p_{0}<p_{1}\}{p∈R2:p0​<p1​}; and o-minimality in dimension one, for every A⊆R1A\subseteq R^{1}A⊆R1, A∈S1A\in\mathcal{S}_{1}A∈S1​ if and only if AAA is a finite union of points and intervals in the above inductive sense.

Human review
  • Endorsed by Shuze Chen · Sep 11, 2026

  • Endorsed by Tamas Fulop · Sep 11, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me