1-- Archimedean boundary approximation for Dedekind cuts2-- Part of Cumulus, the Grace17 mathematics library.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.Cumulus.Real.Archimedean8import Core910-- Natural indices whose points on a fixed rational grid belong to A.11-- This helper is local to the construction; the public boundary theorem12-- below speaks only the language of rational addition.13def cutGridIndices (A : Set) (a b n D : Nat) : Set:=14 { k ∈ ℕ | rationalGrid(a, b, n, D, k) ∈ A }1516-- A Dedekind cut has a member within every positive rational distance of its17-- complement. This is the endpoint-free boundary principle used throughout18-- the algebra and, later, in epsilon arguments for real analysis.19theorem DedekindCut.exists_boundary_within (A : Set, ε : Rational)20requires cut : DedekindCut(A)21requires positive : rationalZero < ε22shows∃ p, Rational(p) ∧ p ∈ A ∧¬(rationalAddValue(p, ε) ∈ A)23proof24obtain⟨a0, a0InA⟩:= DedekindCut.nonempty with cut25have subsetA := DedekindCut.subset_rationals with cut26have a0Rational : Rational(a0)27unfoldRational28exact subsetA with a0, a0InA29obtain⟨a, aNatural, b, bNatural, n, nNatural, nNonzero, a0Shape⟩:=Rational.coordinates with a0Rational3031have properA := DedekindCut.proper with cut32obtain⟨u, uInQ, uMissing⟩:= ProperSubset.missing with properA33have uRational : Rational(u) byexact uInQ3435obtain⟨D, DNatural, DNonzero, stepPositive, stepSmall⟩:= rationalLess.exists_positive_unit_fraction with36 positive37have stepRational := rationalClass.rational at1, 0, D with DNonzero3839have gapRational := rationalSubValue.rational with uRational, a0Rational40obtain⟨N, NNatural, gapBelowN⟩:=Rational.below_natural with gapRational41have oneNatural : Nat(1) bytypecheck42have oneNonzero : 1≠043intro oneZero44arith45have naturalRational := rationalClass.rational with46 NNatural, Naturals.constructor.zero, oneNatural, oneNonzero47have uBelowFar := rationalLess.add_left_of_sub_left with uRational, a0Rational, gapBelowN4849have zeroInIndices : 0∈ cutGridIndices(A, a, b, n, D)50have zeroMembership := cutGridIndices.membership at A, a, b, n, D, 051apply zeroMembership.backward52constructor53 . exact Naturals.constructor.zero54 . have gridZero := rationalGrid.zero at a, b, n, D with55 nNonzero, DNonzero56 rwa [gridZero, ← a0Shape]5758have farMissing : ¬(D * N ∈ cutGridIndices(A, a, b, n, D))59intro farInIndices60have farMembership := cutGridIndices.membership at61 A, a, b, n, D, D * N62obtain⟨farNatural, farInA⟩:= farMembership.forward with farInIndices63have farShape := rationalGrid.natural_step at a, b, n, D, N with64 nNonzero, DNonzero65rw [a0Shape, rationalAddValue.notation, ← farShape] at uBelowFar66have uInA := DedekindCut.downward with cut, farInA, uInQ, uBelowFar67exact uMissing with uInA6869have endpointNatural : Nat(D * N) bytypecheck70obtain⟨k, kNatural, kInIndices, successorMissing⟩:= natural.exists_boundary with71 endpointNatural, zeroInIndices, farMissing72have kMembership := cutGridIndices.membership at73 A, a, b, n, D, k74obtain⟨kNaturalAgain, gridInA⟩:= kMembership.forward with kInIndices7576witness rationalGrid(a, b, n, D, k)77constructor78 . exact rationalGrid.rational with nNonzero, DNonzero79constructor80 . exact gridInA81 . intro shiftedInA82have gridRational := rationalGrid.rational at a, b, n, D, k with83 nNonzero, DNonzero84have shiftedLess := rationalLess.add_left at85 rationalClass(1, 0, D), ε, rationalGrid(a, b, n, D, k) with86 stepRational, assumption, gridRational, stepSmall87rw [rationalAddValue.notation, rationalAddValue.notation] at shiftedLess88have shiftedRational := rationalAddValue.rational_raw at89 rationalGrid(a, b, n, D, k), ε with gridRational, assumption90have smallShiftRational := rationalAddValue.rational_raw with gridRational, stepRational91have smallShiftInA := DedekindCut.downward at92 A,93 rationalAddValue(rationalGrid(a, b, n, D, k), rationalClass(1, 0, D)),94 rationalAddValue(rationalGrid(a, b, n, D, k), ε) with95 cut, shiftedInA, smallShiftRational,96 shiftedLess97have successorInIndices : succ(k) ∈ cutGridIndices(A, a, b, n, D)98have successorMembership := cutGridIndices.membership at99 A, a, b, n, D, succ(k)100apply successorMembership.backward101constructor102 . exact Naturals.constructor.succ at k with kNatural103 . have successorShape := rationalGrid.successor at104 a, b, n, D, k with nNonzero, DNonzero105 rwa successorShape106exact successorMissing with successorInIndices107