Boundary and marked affine chart programs
DefinitionInfoLossLAR_NativeSparsePrefix_06affine-transportinfo-loss-lar-native-5c3becbstoc-2027
This package defines boundary calibration profiles, boundary spikes, chart parameters, common-denominator arithmetic, finite linear iteration and projection, positive normalization, marked chart data, and conditional paired-output programs.
These interfaces retain the finite local chart data used to calibrate protected source inputs before physical affine completion. They expose mathematical data and the supporting constructor APIs; the subsequent response, approximation, and transport bounds are stated as separate theorems. Recorded native operation charges are not by themselves platform machine-time certificates.
Definition code
import Definitions.Def_InfoLossLAR_NativeSparsePrefix_05
import Definitions.Def_InfoLossLAR_Native_AFT_RationalHeight
section
namespace AFT
end AFT
namespace AFT.BetaReference
end AFT.BetaReference
namespace AFT.BetaReference.density_succ
end AFT.BetaReference.density_succ
namespace AFT.BetaReference.event_mono
end AFT.BetaReference.event_mono
namespace AFT.BetaReference.finiteLaw
end AFT.BetaReference.finiteLaw
namespace AFT.BetaReference.gridLaw
end AFT.BetaReference.gridLaw
namespace AFT.BetaReference.gridTailLaw
end AFT.BetaReference.gridTailLaw
namespace AFT.BetaReference.integerCDFPrefix
end AFT.BetaReference.integerCDFPrefix
namespace AFT.BetaReference.integerCDFTerm
end AFT.BetaReference.integerCDFTerm
namespace AFT.BetaReference.momentCoefficient
end AFT.BetaReference.momentCoefficient
namespace AFT.BetaReference.referenceHistogram
end AFT.BetaReference.referenceHistogram
namespace AFT.BetaReference.safeGridValue
end AFT.BetaReference.safeGridValue
namespace AFT.BinaryCDFSampler
end AFT.BinaryCDFSampler
namespace AFT.BlockDensity
end AFT.BlockDensity
namespace AFT.BlockDensity.attachedMass
end AFT.BlockDensity.attachedMass
namespace AFT.CanonicalMoments
end AFT.CanonicalMoments
namespace AFT.FiniteDist
end AFT.FiniteDist
namespace AFT.FiniteDist.TVBound
end AFT.FiniteDist.TVBound
namespace AFT.FiniteDist.conditionalSource
end AFT.FiniteDist.conditionalSource
namespace AFT.FormalLogarithm
end AFT.FormalLogarithm
namespace AFT.FormalLogarithm.finiteLogarithm
end AFT.FormalLogarithm.finiteLogarithm
namespace AFT.GaussianSource
end AFT.GaussianSource
namespace AFT.GaussianSource.actualBodyChannel
end AFT.GaussianSource.actualBodyChannel
namespace AFT.GaussianSource.actualPairResidualInput
end AFT.GaussianSource.actualPairResidualInput
namespace AFT.GaussianSource.actualPrimaryChannel
end AFT.GaussianSource.actualPrimaryChannel
namespace AFT.GaussianSource.actualResponse
end AFT.GaussianSource.actualResponse
namespace AFT.GaussianSource.actualRootLaw
end AFT.GaussianSource.actualRootLaw
namespace AFT.GaussianSource.compensatorRootShift
end AFT.GaussianSource.compensatorRootShift
namespace AFT.GaussianSource.extraSample
end AFT.GaussianSource.extraSample
namespace AFT.GaussianSource.gaussianKernel
end AFT.GaussianSource.gaussianKernel
namespace AFT.GaussianSource.harmonicWidth
end AFT.GaussianSource.harmonicWidth
namespace AFT.GaussianSource.kernelPower
end AFT.GaussianSource.kernelPower
namespace AFT.GaussianSource.optionalShift
end AFT.GaussianSource.optionalShift
namespace AFT.GaussianSource.optionalShift.match_1
end AFT.GaussianSource.optionalShift.match_1
namespace AFT.GaussianSource.pairCore
end AFT.GaussianSource.pairCore
namespace AFT.GaussianSource.pairCoreDepth
end AFT.GaussianSource.pairCoreDepth
namespace AFT.GaussianSource.pairNeumannConstant
end AFT.GaussianSource.pairNeumannConstant
namespace AFT.GaussianSource.pairSample
end AFT.GaussianSource.pairSample
namespace AFT.GaussianSource.pairSourceLaw
end AFT.GaussianSource.pairSourceLaw
namespace AFT.GaussianSource.pairSourceShift
end AFT.GaussianSource.pairSourceShift
namespace AFT.GaussianSource.powerWidth
end AFT.GaussianSource.powerWidth
namespace AFT.GaussianSource.powerWidth.match_1
end AFT.GaussianSource.powerWidth.match_1
namespace AFT.GaussianSource.ratioError
end AFT.GaussianSource.ratioError
namespace AFT.GaussianSource.rootMarginal
end AFT.GaussianSource.rootMarginal
namespace AFT.GaussianSource.shiftedWeight
end AFT.GaussianSource.shiftedWeight
namespace AFT.GaussianSource.sumWidth
end AFT.GaussianSource.sumWidth
namespace AFT.GaussianSource.theta
end AFT.GaussianSource.theta
namespace AFT.GaussianSource.thetaFourier
end AFT.GaussianSource.thetaFourier
namespace AFT.HistogramGenerating
end AFT.HistogramGenerating
namespace AFT.Hoeffding
end AFT.Hoeffding
namespace AFT.LocalTensors
end AFT.LocalTensors
namespace AFT.MixedKernel
end AFT.MixedKernel
namespace AFT.MixedKernel.columnAverage
end AFT.MixedKernel.columnAverage
namespace AFT.MixedKernel.pairKernel
end AFT.MixedKernel.pairKernel
namespace AFT.MixedKernel.pairReference
end AFT.MixedKernel.pairReference
namespace AFT.MixedKernel.rowAverage
end AFT.MixedKernel.rowAverage
namespace AFT.MixedKernel.singletonKernel
end AFT.MixedKernel.singletonKernel
namespace AFT.MixedKernel.tripleProductKernel
end AFT.MixedKernel.tripleProductKernel
namespace AFT.Negligible
end AFT.Negligible
namespace AFT.ParameterProgram
end AFT.ParameterProgram
namespace AFT.ParameterProgram.beta
end AFT.ParameterProgram.beta
namespace AFT.PhysicalBlockTensors
end AFT.PhysicalBlockTensors
namespace AFT.RepresentedPolynomial
end AFT.RepresentedPolynomial
namespace AFT.RepresentedPolynomial.InputTableCanonical
end AFT.RepresentedPolynomial.InputTableCanonical
namespace AFT.RepresentedPolynomial.backgroundLogarithm
end AFT.RepresentedPolynomial.backgroundLogarithm
namespace AFT.RepresentedPolynomial.bodySingletonInput
end AFT.RepresentedPolynomial.bodySingletonInput
namespace AFT.RepresentedPolynomial.boundaryPolynomial
end AFT.RepresentedPolynomial.boundaryPolynomial
namespace AFT.RepresentedPolynomial.inputRate
end AFT.RepresentedPolynomial.inputRate
namespace AFT.RepresentedPolynomial.inputReference
end AFT.RepresentedPolynomial.inputReference
namespace AFT.RepresentedPolynomial.inversePrimarySeed
end AFT.RepresentedPolynomial.inversePrimarySeed
namespace AFT.RepresentedPolynomial.logarithm
end AFT.RepresentedPolynomial.logarithm
namespace AFT.RepresentedPolynomial.primaryCoordinates
end AFT.RepresentedPolynomial.primaryCoordinates
namespace AFT.RepresentedPolynomial.primaryPairInput
end AFT.RepresentedPolynomial.primaryPairInput
namespace AFT.RepresentedPolynomial.primarySingletonInput
end AFT.RepresentedPolynomial.primarySingletonInput
namespace AFT.RepresentedPolynomial.primaryTripleInput
end AFT.RepresentedPolynomial.primaryTripleInput
namespace AFT.RepresentedPolynomial.profilePolynomialMap
end AFT.RepresentedPolynomial.profilePolynomialMap
namespace AFT.RepresentedPolynomial.seedChannel
end AFT.RepresentedPolynomial.seedChannel
namespace AFT.RootSlice
end AFT.RootSlice
namespace AFT.RootSlice.quadraticExponent
end AFT.RootSlice.quadraticExponent
namespace AFT.RootSlice.reference
end AFT.RootSlice.reference
namespace AFT.SafeConvolution
end AFT.SafeConvolution
namespace AFT.SafeConvolution.RowBound
end AFT.SafeConvolution.RowBound
namespace AFT.SafeConvolution.SupBound
end AFT.SafeConvolution.SupBound
namespace AFT.SafeConvolution.SupportedInBox
end AFT.SafeConvolution.SupportedInBox
namespace AFT.SafeConvolution.uniformCanonical
end AFT.SafeConvolution.uniformCanonical
namespace AFT.SafePair
end AFT.SafePair
namespace AFT.TrimmedSlice
end AFT.TrimmedSlice
namespace AFT.V7Calibration
end AFT.V7Calibration
namespace AFT.V7Calibration.activeCanonicalPairDensity
end AFT.V7Calibration.activeCanonicalPairDensity
namespace AFT.V7Calibration.activeCanonicalPairInput
end AFT.V7Calibration.activeCanonicalPairInput
namespace AFT.V7Calibration.activeEndpointDifference
end AFT.V7Calibration.activeEndpointDifference
namespace AFT.V7Calibration.activeEndpointMarginalDensity
end AFT.V7Calibration.activeEndpointMarginalDensity
namespace AFT.V7Calibration.actualActivatedSource
end AFT.V7Calibration.actualActivatedSource
namespace AFT.V7Calibration.actualActiveMarginalBodyInput
end AFT.V7Calibration.actualActiveMarginalBodyInput
namespace AFT.V7Calibration.actualActiveMarginalBodyKernel
end AFT.V7Calibration.actualActiveMarginalBodyKernel
namespace AFT.V7Calibration.actualActiveTripleInput
end AFT.V7Calibration.actualActiveTripleInput
namespace AFT.V7Calibration.actualActiveTripleKernel
end AFT.V7Calibration.actualActiveTripleKernel
namespace AFT.V7Calibration.actualBasePrimary
end AFT.V7Calibration.actualBasePrimary
namespace AFT.V7Calibration.actualBetaBufferedTail
end AFT.V7Calibration.actualBetaBufferedTail
namespace AFT.V7Calibration.actualBetaGridError
end AFT.V7Calibration.actualBetaGridError
namespace AFT.V7Calibration.actualBodyCenter
end AFT.V7Calibration.actualBodyCenter
namespace AFT.V7Calibration.actualBodyIntegerProfile
end AFT.V7Calibration.actualBodyIntegerProfile
namespace AFT.V7Calibration.actualBodyMean
end AFT.V7Calibration.actualBodyMean
namespace AFT.V7Calibration.actualBoundaryCoefficient
end AFT.V7Calibration.actualBoundaryCoefficient
namespace AFT.V7Calibration.actualBoundaryCoefficientProgram
end AFT.V7Calibration.actualBoundaryCoefficientProgram
namespace AFT.V7Calibration.actualBoundaryProfile
end AFT.V7Calibration.actualBoundaryProfile
namespace AFT.V7Calibration.actualBoundaryUniformProgram
end AFT.V7Calibration.actualBoundaryUniformProgram
namespace AFT.V7Calibration.actualCanonicalPairResidualInput
end AFT.V7Calibration.actualCanonicalPairResidualInput
namespace AFT.V7Calibration.actualCompanionLaw
end AFT.V7Calibration.actualCompanionLaw
namespace AFT.V7Calibration.actualCovarianceSeed
end AFT.V7Calibration.actualCovarianceSeed
namespace AFT.V7Calibration.actualCovarianceTable
end AFT.V7Calibration.actualCovarianceTable
namespace AFT.V7Calibration.actualDimension_positive
end AFT.V7Calibration.actualDimension_positive
namespace AFT.V7Calibration.actualEndpointHigherTable
end AFT.V7Calibration.actualEndpointHigherTable
namespace AFT.V7Calibration.actualEndpointSeed
end AFT.V7Calibration.actualEndpointSeed
namespace AFT.V7Calibration.actualEndpointVector
end AFT.V7Calibration.actualEndpointVector
namespace AFT.V7Calibration.actualEndpointVector.match_1
end AFT.V7Calibration.actualEndpointVector.match_1
namespace AFT.V7Calibration.actualExtraAnchorKernel
end AFT.V7Calibration.actualExtraAnchorKernel
namespace AFT.V7Calibration.actualFixedRootTriple
end AFT.V7Calibration.actualFixedRootTriple
namespace AFT.V7Calibration.actualFixedRootTripleLaw
end AFT.V7Calibration.actualFixedRootTripleLaw
namespace AFT.V7Calibration.actualInactiveBodyPairDensity
end AFT.V7Calibration.actualInactiveBodyPairDensity
namespace AFT.V7Calibration.actualInactiveBodyPairInput
end AFT.V7Calibration.actualInactiveBodyPairInput
namespace AFT.V7Calibration.actualInactiveBodyPairMass
end AFT.V7Calibration.actualInactiveBodyPairMass
namespace AFT.V7Calibration.actualInactiveMarginalBodyInput
end AFT.V7Calibration.actualInactiveMarginalBodyInput
namespace AFT.V7Calibration.actualInactiveMarginalBodyKernel
end AFT.V7Calibration.actualInactiveMarginalBodyKernel
namespace AFT.V7Calibration.actualInactiveResidual
end AFT.V7Calibration.actualInactiveResidual
namespace AFT.V7Calibration.actualInactiveTripleInput
end AFT.V7Calibration.actualInactiveTripleInput
namespace AFT.V7Calibration.actualInactiveTripleKernel
end AFT.V7Calibration.actualInactiveTripleKernel
namespace AFT.V7Calibration.actualInteriorCountProgram
end AFT.V7Calibration.actualInteriorCountProgram
namespace AFT.V7Calibration.actualInteriorProfile
end AFT.V7Calibration.actualInteriorProfile
namespace AFT.V7Calibration.actualInteriorUniformProgram
end AFT.V7Calibration.actualInteriorUniformProgram
namespace AFT.V7Calibration.actualLeadingOutput
end AFT.V7Calibration.actualLeadingOutput
namespace AFT.V7Calibration.actualMarkedFringeInput
end AFT.V7Calibration.actualMarkedFringeInput
namespace AFT.V7Calibration.actualMarkedInput
end AFT.V7Calibration.actualMarkedInput
namespace AFT.V7Calibration.actualMarkedPair
end AFT.V7Calibration.actualMarkedPair
namespace AFT.V7Calibration.actualMarkedSafeDensity
end AFT.V7Calibration.actualMarkedSafeDensity
namespace AFT.V7Calibration.actualMarkedSafeSeed
end AFT.V7Calibration.actualMarkedSafeSeed
namespace AFT.V7Calibration.actualPairCompletionInput
end AFT.V7Calibration.actualPairCompletionInput
namespace AFT.V7Calibration.actualPairReferenceInput
end AFT.V7Calibration.actualPairReferenceInput
namespace AFT.V7Calibration.actualPositiveReferenceLaw
end AFT.V7Calibration.actualPositiveReferenceLaw
namespace AFT.V7Calibration.actualPrimary
end AFT.V7Calibration.actualPrimary
namespace AFT.V7Calibration.actualPrimaryProgram
end AFT.V7Calibration.actualPrimaryProgram
namespace AFT.V7Calibration.actualReferenceMarkedProfile
end AFT.V7Calibration.actualReferenceMarkedProfile
namespace AFT.V7Calibration.actualReferenceMean
end AFT.V7Calibration.actualReferenceMean
namespace AFT.V7Calibration.actualReferenceZeroChargeHistogram
end AFT.V7Calibration.actualReferenceZeroChargeHistogram
namespace AFT.V7Calibration.actualSliceAtSource
end AFT.V7Calibration.actualSliceAtSource
namespace AFT.V7Calibration.actualSliceMean
end AFT.V7Calibration.actualSliceMean
namespace AFT.V7Calibration.actualSourceShift
end AFT.V7Calibration.actualSourceShift
namespace AFT.V7Calibration.actualSourceShift.match_1
end AFT.V7Calibration.actualSourceShift.match_1
namespace AFT.V7Calibration.actualZeroSliceMean
end AFT.V7Calibration.actualZeroSliceMean
namespace AFT.V7Calibration.actual_body_population_expectation
end AFT.V7Calibration.actual_body_population_expectation
namespace AFT.V7Calibration.anchorMean
end AFT.V7Calibration.anchorMean
namespace AFT.V7Calibration.attachedBodyAtSource
end AFT.V7Calibration.attachedBodyAtSource
namespace AFT.V7Calibration.averagedInactiveBody
end AFT.V7Calibration.averagedInactiveBody
namespace AFT.V7Calibration.averagedInactivePair
end AFT.V7Calibration.averagedInactivePair
namespace AFT.V7Calibration.betaGridCutoff
end AFT.V7Calibration.betaGridCutoff
namespace AFT.V7Calibration.betaGridMesh
end AFT.V7Calibration.betaGridMesh
namespace AFT.V7Calibration.betaGridRejectedMass
end AFT.V7Calibration.betaGridRejectedMass
namespace AFT.V7Calibration.betaGridStart
end AFT.V7Calibration.betaGridStart
namespace AFT.V7Calibration.blockBackgroundError
end AFT.V7Calibration.blockBackgroundError
namespace AFT.V7Calibration.blockBackgroundLinear
end AFT.V7Calibration.blockBackgroundLinear
namespace AFT.V7Calibration.blockBackgroundLinear.match_1
end AFT.V7Calibration.blockBackgroundLinear.match_1
namespace AFT.V7Calibration.blockBodyMeanProfile
end AFT.V7Calibration.blockBodyMeanProfile
namespace AFT.V7Calibration.blockBodyMeanProfile.match_1
end AFT.V7Calibration.blockBodyMeanProfile.match_1
namespace AFT.V7Calibration.blockBodyMeanTable
end AFT.V7Calibration.blockBodyMeanTable
namespace AFT.V7Calibration.blockBodyMeanTable.match_1
end AFT.V7Calibration.blockBodyMeanTable.match_1
namespace AFT.V7Calibration.blockPhysicalPolynomial
end AFT.V7Calibration.blockPhysicalPolynomial
namespace AFT.V7Calibration.blurredAnchorKernel
end AFT.V7Calibration.blurredAnchorKernel
namespace AFT.V7Calibration.blurredAnchorMean
end AFT.V7Calibration.blurredAnchorMean
namespace AFT.V7Calibration.bodyCanonicalInput
end AFT.V7Calibration.bodyCanonicalInput
namespace AFT.V7Calibration.bodyCenteredOutside
end AFT.V7Calibration.bodyCenteredOutside
namespace AFT.V7Calibration.bodyInside
end AFT.V7Calibration.bodyInside
namespace AFT.V7Calibration.bodyOutside
end AFT.V7Calibration.bodyOutside
namespace AFT.V7Calibration.coreIntegerProfile
end AFT.V7Calibration.coreIntegerProfile
namespace AFT.V7Calibration.covarianceCoefficient
end AFT.V7Calibration.covarianceCoefficient
namespace AFT.V7Calibration.endpointCoefficient
end AFT.V7Calibration.endpointCoefficient
namespace AFT.V7Calibration.errorLaw
end AFT.V7Calibration.errorLaw
namespace AFT.V7Calibration.errorStarts
end AFT.V7Calibration.errorStarts
namespace AFT.V7Calibration.extraAnchorSeed
end AFT.V7Calibration.extraAnchorSeed
namespace AFT.V7Calibration.globalLinearProfile
end AFT.V7Calibration.globalLinearProfile
namespace AFT.V7Calibration.globalLinearTable
end AFT.V7Calibration.globalLinearTable
namespace AFT.V7Calibration.globalMeanChangeTable
end AFT.V7Calibration.globalMeanChangeTable
namespace AFT.V7Calibration.globalMeanTable
end AFT.V7Calibration.globalMeanTable
namespace AFT.V7Calibration.inactiveAttachedBodyDensity
end AFT.V7Calibration.inactiveAttachedBodyDensity
namespace AFT.V7Calibration.inactiveAttachedBodyDifference
end AFT.V7Calibration.inactiveAttachedBodyDifference
namespace AFT.V7Calibration.inactiveCanonicalPairDensity
end AFT.V7Calibration.inactiveCanonicalPairDensity
namespace AFT.V7Calibration.inactiveCanonicalPairInput
end AFT.V7Calibration.inactiveCanonicalPairInput
namespace AFT.V7Calibration.inactiveEndpointDensity
end AFT.V7Calibration.inactiveEndpointDensity
namespace AFT.V7Calibration.inactiveEndpointDifference
end AFT.V7Calibration.inactiveEndpointDifference
namespace AFT.V7Calibration.inactiveEndpointMarginalDensity
end AFT.V7Calibration.inactiveEndpointMarginalDensity
namespace AFT.V7Calibration.inactivePairAtSource
end AFT.V7Calibration.inactivePairAtSource
namespace AFT.V7Calibration.inactivePairShift
end AFT.V7Calibration.inactivePairShift
namespace AFT.V7Calibration.inactivePairSources
end AFT.V7Calibration.inactivePairSources
namespace AFT.V7Calibration.inactivePairStarts
end AFT.V7Calibration.inactivePairStarts
namespace AFT.V7Calibration.inactiveStart
end AFT.V7Calibration.inactiveStart
namespace AFT.V7Calibration.integerShiftProfile
end AFT.V7Calibration.integerShiftProfile
namespace AFT.V7Calibration.localAttachedMeanInputTable
end AFT.V7Calibration.localAttachedMeanInputTable
namespace AFT.V7Calibration.localBackgroundLinear
end AFT.V7Calibration.localBackgroundLinear
namespace AFT.V7Calibration.localBodyMixture
end AFT.V7Calibration.localBodyMixture
namespace AFT.V7Calibration.localCovarianceInputTable
end AFT.V7Calibration.localCovarianceInputTable
namespace AFT.V7Calibration.localPairMixture
end AFT.V7Calibration.localPairMixture
namespace AFT.V7Calibration.localPrimaryMeanInputTable
end AFT.V7Calibration.localPrimaryMeanInputTable
namespace AFT.V7Calibration.modulus_population_upper
end AFT.V7Calibration.modulus_population_upper
namespace AFT.V7Calibration.primaryPairSeed
end AFT.V7Calibration.primaryPairSeed
namespace AFT.V7Calibration.responseOperator
end AFT.V7Calibration.responseOperator
namespace AFT.positiveKernelMap
end AFT.positiveKernelMap
/-! # Rational entries of the physical body and root-only anchor matrices -/
namespace AFT.V7Calibration
open GaussianSource RationalNumerics Filter
open scoped BigOperators
def publicAnchorStartProgram (modulus width color : ℕ) (coin : Bool) : ℤ :=
if 2*color < modulus-1 then (modulus : ℤ)-color-2*width
else if modulus-1 < 2*color then (modulus : ℤ)-1-color+width
else if coin then (modulus : ℤ)-color-2*width else (modulus : ℤ)-1-color+width
noncomputable section
open scoped Topology
set_option backward.isDefEq.respectTransparency false
local instance anchorProgramFinDecEq (n : ℕ) : DecidableEq (Fin n) := Classical.decEq _
end
end AFT.V7Calibration
end
section
/-!
# Positive repair on the safe affine-chart set
This file formalizes the finite-dimensional Neumann repair in V7's
`accuracy-boundary-chart` proof, including its pointwise positivity constants.
The affine-feature equivalences below supply the exact unrestricted uniform
and pairwise-independence statements used by that construction.
-/
namespace AFT
namespace BoundaryCalibration
open scoped BigOperators
section FiniteRepair
variable {Ω : Type*} [Fintype Ω]
/-- Restrict a chart density to the public safe set. -/
noncomputable def safeMask (safe : Ω → Prop) [DecidablePred safe] :
(Ω → ℝ) →L[ℝ] (Ω → ℝ) :=
ContinuousLinearMap.pi fun x => if safe x then ContinuousLinearMap.proj x else 0
omit [Fintype Ω] in
@[simp] theorem safeMask_apply (safe : Ω → Prop) [DecidablePred safe]
(f : Ω → ℝ) (x : Ω) :
safeMask safe f x = if safe x then f x else 0 := by
simp only [safeMask, ContinuousLinearMap.pi_apply]
split_ifs <;> simp
/-- The actual deletion operator `P(1_{safeᶜ} f)`. -/
noncomputable def deletion (P : (Ω → ℝ) →L[ℝ] (Ω → ℝ))
(safe : Ω → Prop) [DecidablePred safe] : (Ω → ℝ) →L[ℝ] (Ω → ℝ) :=
P * (ContinuousLinearMap.id ℝ (Ω → ℝ) - safeMask safe)
omit [Fintype Ω] in
@[simp] theorem deletion_apply (P : (Ω → ℝ) →L[ℝ] (Ω → ℝ))
(safe : Ω → Prop) [DecidablePred safe] (f : Ω → ℝ) :
deletion P safe f = P (f - safeMask safe f) := rfl
/-- Invert `Id - D` by its norm-convergent geometric series. -/
noncomputable def neumannSolve (D : (Ω → ℝ) →L[ℝ] (Ω → ℝ))
(hD : ‖D‖ < 1) (f : Ω → ℝ) : Ω → ℝ :=
(↑((Units.oneSub D hD)⁻¹) : (Ω → ℝ) →L[ℝ] (Ω → ℝ)) f
/-- The constructed inverse solves the required equation exactly. -/
theorem neumannSolve_equation (D : (Ω → ℝ) →L[ℝ] (Ω → ℝ))
(hD : ‖D‖ < 1) (f : Ω → ℝ) :
neumannSolve D hD f - D (neumannSolve D hD f) = f := by
have h := congrArg (fun T : (Ω → ℝ) →L[ℝ] (Ω → ℝ) => T f)
(Units.val_inv (Units.oneSub D hD))
change ((1 - D) * (↑((Units.oneSub D hD)⁻¹) : (Ω → ℝ) →L[ℝ] (Ω → ℝ))) f = f at h
simpa only [ContinuousLinearMap.mul_apply,
ContinuousLinearMap.sub_apply, ContinuousLinearMap.one_apply, neumannSolve] using h
/-- If `P` is a projection and the desired response is in its range, restricting
the Neumann solution to safe charts has exactly that response. -/
theorem safe_neumann_projection (P : (Ω → ℝ) →L[ℝ] (Ω → ℝ))
(safe : Ω → Prop) [DecidablePred safe] (hP : P * P = P)
(hD : ‖deletion P safe‖ < 1) (f : Ω → ℝ) (hf : P f = f) :
P (safeMask safe (neumannSolve (deletion P safe) hD f)) = f := by
let h := neumannSolve (deletion P safe) hD f
have heq : h - P (h - safeMask safe h) = f :=
neumannSolve_equation (deletion P safe) hD f
have hp := congrArg P heq
have hPid (g : Ω → ℝ) : P (P g) = P g := by
exact congrArg (fun T : (Ω → ℝ) →L[ℝ] (Ω → ℝ) => T g) hP
simp only [map_sub, hPid, hf] at hp
change P (safeMask safe h) = f
convert hp using 1
abel
end FiniteRepair
section FeatureProjections
open scoped Classical
variable {Ω C I : Type*} [Fintype Ω] [Fintype C] [Fintype I]
/-- Exact expectation as a linear functional on finite chart densities. -/
noncomputable def expectation (p : FiniteDist Ω) : (Ω → ℝ) →ₗ[ℝ] ℝ where
toFun f := ∑ x, p.weight x * f x
map_add' f g := by simp [mul_add, Finset.sum_add_distrib]
map_smul' r f := by simp [mul_left_comm, ← Finset.mul_sum]
@[simp] theorem expectation_apply (p : FiniteDist Ω) (f : Ω → ℝ) :
expectation p f = ∑ x, p.weight x * f x := rfl
@[simp] theorem expectation_const (p : FiniteDist Ω) (r : ℝ) :
expectation p (fun _ => r) = r := by
simp [expectation, ← Finset.sum_mul, p.sum_one]
/-- Pushforward is exact at the level of every test function. -/
theorem expectation_map (p : FiniteDist Ω) (feature : Ω → C) (g : C → ℝ) :
expectation (p.map feature) g = expectation p (fun x => g (feature x)) := by
simp only [expectation_apply, FiniteDist.map_weight, Finset.sum_mul]
rw [Finset.sum_comm]
apply Finset.sum_congr rfl
intro x _
simp [ite_mul]
/-- Normalized expectation conditioned on an equidistributed feature value. -/
noncomputable def conditional (p : FiniteDist Ω) (feature : Ω → C) :
(Ω → ℝ) →ₗ[ℝ] (C → ℝ) where
toFun f color := (Fintype.card C : ℝ) *
expectation p (fun x => if feature x = color then f x else 0)
map_add' f g := by
funext color
change (Fintype.card C : ℝ) * expectation p
(fun x => if feature x = color then f x + g x else 0) = _
have he : (fun x => if feature x = color then f x + g x else (0 : ℝ)) =
(fun x => if feature x = color then f x else 0) +
(fun x => if feature x = color then g x else 0) := by
funext x
split_ifs <;> simp_all
rw [he, map_add, mul_add]
rfl
map_smul' r f := by
funext color
change (Fintype.card C : ℝ) * expectation p
(fun x => if feature x = color then r * f x else 0) = _
have he : (fun x => if feature x = color then r * f x else (0 : ℝ)) =
r • (fun x => if feature x = color then f x else 0) := by
funext x
split_ifs <;> simp_all
rw [he, map_smul]
change (Fintype.card C : ℝ) * (r * _) = r * ((Fintype.card C : ℝ) * _)
ring
@[simp] theorem conditional_apply (p : FiniteDist Ω) (feature : Ω → C)
(f : Ω → ℝ) (color : C) :
conditional p feature f color = (Fintype.card C : ℝ) *
expectation p (fun x => if feature x = color then f x else 0) := rfl
/-- Conditioning a feature on itself recovers the exact color profile. -/
theorem conditional_same [Nonempty C] (p : FiniteDist Ω) (feature : Ω → C)
(hfeature : p.map feature = FiniteDist.uniform C) (g : C → ℝ) :
conditional p feature (fun x => g (feature x)) = g := by
funext color
rw [conditional_apply]
have he := expectation_map p feature (fun c => if c = color then g c else 0)
rw [hfeature] at he
rw [← he]
simp [expectation_apply, FiniteDist.uniform_weight, mul_ite,
Fintype.card_ne_zero]
/-- Conditioning on an independent uniform feature gives a constant profile. -/
theorem conditional_other [Nonempty C] (p : FiniteDist Ω) (first second : Ω → C)
(hpair : p.map (fun x => (first x, second x)) =
(FiniteDist.uniform C).prod (FiniteDist.uniform C)) (g : C → ℝ) :
conditional p first (fun x => g (second x)) =
fun _ => expectation (FiniteDist.uniform C) g := by
funext color
rw [conditional_apply]
have he := expectation_map p (fun x => (first x, second x))
(fun pair => if pair.1 = color then g pair.2 else 0)
rw [hpair] at he
rw [← he]
have hC : (Fintype.card C : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr Fintype.card_ne_zero
simp [expectation_apply, FiniteDist.prod_weight, FiniteDist.uniform_weight,
Fintype.sum_prod_type, mul_ite, ← Finset.mul_sum]
field_simp
/-- Keep a color profile on its allowed set and subtract its allowed-set mean. -/
noncomputable def centerAllowed (allowed : Finset C) : (C → ℝ) →ₗ[ℝ] (C → ℝ) where
toFun g c := if c ∈ allowed then g c - (∑ a ∈ allowed, g a) / allowed.card else 0
map_add' f g := by
funext c
simp only [Pi.add_apply]
split_ifs <;> simp [Finset.sum_add_distrib, add_div]
ring
map_smul' r g := by
funext c
simp only [Pi.smul_apply, smul_eq_mul, RingHom.id_apply]
split_ifs <;> simp [← Finset.mul_sum, mul_sub, mul_div_assoc]
omit [Fintype C] in
@[simp] theorem centerAllowed_apply (allowed : Finset C) (g : C → ℝ) (c : C) :
centerAllowed allowed g c =
if c ∈ allowed then g c - (∑ a ∈ allowed, g a) / allowed.card else 0 := rfl
omit [Fintype C] in
@[simp] theorem centerAllowed_const (allowed : Finset C) (r : ℝ) :
centerAllowed allowed (fun _ => r) = 0 := by
funext c
rw [centerAllowed_apply]
by_cases hc : c ∈ allowed
· have hcard : (allowed.card : ℝ) ≠ 0 :=
Nat.cast_ne_zero.mpr (Finset.card_ne_zero.mpr ⟨c, hc⟩)
simp [hc, hcard]
· simp [hc]
/-- Centering on the allowed palette removes all mass. -/
theorem centerAllowed_sum (allowed : Finset C) (g : C → ℝ) :
∑ c, centerAllowed allowed g c = 0 := by
simp only [centerAllowed_apply, ← Finset.sum_filter]
simp only [Finset.filter_univ_mem]
by_cases ha : allowed = ∅
· simp [ha]
· have hcard : (allowed.card : ℝ) ≠ 0 :=
Nat.cast_ne_zero.mpr (Finset.card_ne_zero.mpr (Finset.nonempty_iff_ne_empty.mpr ha))
rw [Finset.sum_sub_distrib]
simp only [Finset.sum_const, nsmul_eq_mul]
field_simp
ring
/-- Centering twice is exactly the same projection. -/
theorem centerAllowed_idempotent (allowed : Finset C) (g : C → ℝ) :
centerAllowed allowed (centerAllowed allowed g) = centerAllowed allowed g := by
have hsum : ∑ a ∈ allowed, centerAllowed allowed g a = 0 := by
rw [← centerAllowed_sum allowed g]
exact Finset.sum_subset (Finset.subset_univ _) (fun c _ hc => by simp [hc])
funext c
rw [centerAllowed_apply, hsum, zero_div, sub_zero]
split_ifs with hc
· rfl
· simp [hc]
/-- Pull a color profile back to the corresponding chart feature. -/
def liftFeature (feature : Ω → C) : (C → ℝ) →ₗ[ℝ] (Ω → ℝ) where
toFun g x := g (feature x)
map_add' _ _ := rfl
map_smul' _ _ := rfl
/-- The actual centered feature projection from the boundary-chart proof. -/
noncomputable def featureProjection (p : FiniteDist Ω) (feature : Ω → C)
(allowed : Finset C) : (Ω → ℝ) →ₗ[ℝ] (Ω → ℝ) :=
(liftFeature feature).comp ((centerAllowed allowed).comp (conditional p feature))
@[simp] theorem featureProjection_apply (p : FiniteDist Ω) (feature : Ω → C)
(allowed : Finset C) (f : Ω → ℝ) (x : Ω) :
featureProjection p feature allowed f x =
centerAllowed allowed (conditional p feature f) (feature x) := rfl
/-- Each feature component is an exact projection. -/
theorem featureProjection_idempotent [Nonempty C] (p : FiniteDist Ω)
(feature : Ω → C) (hfeature : p.map feature = FiniteDist.uniform C)
(allowed : Finset C) :
(featureProjection p feature allowed).comp (featureProjection p feature allowed) =
featureProjection p feature allowed := by
apply LinearMap.ext
intro f
change liftFeature feature (centerAllowed allowed
(conditional p feature (fun x => centerAllowed allowed
(conditional p feature f) (feature x)))) = _
rw [conditional_same p feature hfeature, centerAllowed_idempotent]
rfl
/-- Different feature projections annihilate each other by exact pairwise independence. -/
theorem featureProjection_orthogonal [Nonempty C] (p : FiniteDist Ω)
(first second : Ω → C)
(hpair : p.map (fun x => (first x, second x)) =
(FiniteDist.uniform C).prod (FiniteDist.uniform C)) (A B : Finset C) :
(featureProjection p first A).comp (featureProjection p second B) = 0 := by
apply LinearMap.ext
intro f
change liftFeature first (centerAllowed A
(conditional p first (fun x => centerAllowed B
(conditional p second f) (second x)))) = 0
rw [conditional_other p first second hpair, centerAllowed_const, map_zero]
/-- Projection onto the constant chart densities. -/
noncomputable def constantProjection (p : FiniteDist Ω) : (Ω → ℝ) →ₗ[ℝ] (Ω → ℝ) where
toFun f _ := expectation p f
map_add' _ _ := by funext x; simp only [map_add, Pi.add_apply]
map_smul' _ _ := by funext x; simp only [map_smul, Pi.smul_apply, RingHom.id_apply]
@[simp] theorem constantProjection_apply (p : FiniteDist Ω) (f : Ω → ℝ) (x : Ω) :
constantProjection p f x = expectation p f := rfl
@[simp] theorem constantProjection_idempotent (p : FiniteDist Ω) :
constantProjection p * constantProjection p = constantProjection p := by
apply LinearMap.ext
intro f
funext x
exact expectation_const p (expectation p f)
/-- Feature centering annihilates constants. -/
theorem featureProjection_const [Nonempty C] (p : FiniteDist Ω) (feature : Ω → C)
(hfeature : p.map feature = FiniteDist.uniform C) (allowed : Finset C) (r : ℝ) :
featureProjection p feature allowed (fun _ => r) = 0 := by
change liftFeature feature (centerAllowed allowed
(conditional p feature (fun x => (fun _ : C => r) (feature x)))) = 0
rw [conditional_same p feature hfeature (fun _ : C => r), centerAllowed_const, map_zero]
/-- Each centered feature has zero unrestricted mean. -/
theorem featureProjection_mean [Nonempty C] (p : FiniteDist Ω) (feature : Ω → C)
(hfeature : p.map feature = FiniteDist.uniform C) (allowed : Finset C) (f : Ω → ℝ) :
expectation p (featureProjection p feature allowed f) = 0 := by
change expectation p (fun x =>
centerAllowed allowed (conditional p feature f) (feature x)) = 0
rw [← expectation_map, hfeature]
simp only [expectation_apply, FiniteDist.uniform_weight, ← Finset.mul_sum,
centerAllowed_sum, mul_zero]
theorem featureProjection_constantProjection [Nonempty C] (p : FiniteDist Ω)
(feature : Ω → C) (hfeature : p.map feature = FiniteDist.uniform C) (allowed : Finset C) :
featureProjection p feature allowed * constantProjection p = 0 := by
apply LinearMap.ext
intro f
funext x
exact congrFun (featureProjection_const p feature hfeature allowed (expectation p f)) x
theorem constantProjection_featureProjection [Nonempty C] (p : FiniteDist Ω)
(feature : Ω → C) (hfeature : p.map feature = FiniteDist.uniform C) (allowed : Finset C) :
constantProjection p * featureProjection p feature allowed = 0 := by
apply LinearMap.ext
intro f
funext x
exact featureProjection_mean p feature hfeature allowed f
/-- The paper's projection: constants plus all allowed centered feature components. -/
noncomputable def combinedProjection (p : FiniteDist Ω) (features : I → Ω → C)
(allowed : I → Finset C) : (Ω → ℝ) →ₗ[ℝ] (Ω → ℝ) :=
constantProjection p + ∑ i, featureProjection p (features i) (allowed i)
/-- Pairwise-independent unrestricted features make the concrete sum operator
an exact projection. -/
theorem combinedProjection_idempotent [Nonempty C] (p : FiniteDist Ω)
(features : I → Ω → C) (allowed : I → Finset C)
(hfeature : ∀ i, p.map (features i) = FiniteDist.uniform C)
(hpair : ∀ i j, i ≠ j → p.map (fun x => (features i x, features j x)) =
(FiniteDist.uniform C).prod (FiniteDist.uniform C)) :
combinedProjection p features allowed * combinedProjection p features allowed =
combinedProjection p features allowed := by
have hcomp (i j : I) :
featureProjection p (features i) (allowed i) * featureProjection p (features j) (allowed j) =
if i = j then featureProjection p (features i) (allowed i) else 0 := by
by_cases hij : i = j
· subst j
simpa only [Module.End.mul_eq_comp, if_true] using featureProjection_idempotent p (features i) (hfeature i) (allowed i)
· rw [if_neg hij]
exact featureProjection_orthogonal p (features i) (features j) (hpair i j hij)
(allowed i) (allowed j)
unfold combinedProjection
rw [add_mul, mul_add, mul_add]
simp_rw [Finset.mul_sum, Finset.sum_mul,
constantProjection_idempotent,
constantProjection_featureProjection p _ (hfeature _),
featureProjection_constantProjection p _ (hfeature _), hcomp]
simp
@[simp] theorem combinedProjection_one [Nonempty C] (p : FiniteDist Ω)
(features : I → Ω → C) (allowed : I → Finset C)
(hfeature : ∀ i, p.map (features i) = FiniteDist.uniform C) :
combinedProjection p features allowed 1 = 1 := by
have hc : constantProjection p 1 = (1 : Ω → ℝ) := by
funext x
exact expectation_const p 1
have hf (i : I) : featureProjection p (features i) (allowed i) 1 = 0 :=
featureProjection_const p (features i) (hfeature i) (allowed i) 1
simp [combinedProjection, LinearMap.sum_apply, hc, hf]
/-- Constants are an independent component: the projection preserves mass. -/
theorem combinedProjection_mean [Nonempty C] (p : FiniteDist Ω)
(features : I → Ω → C) (allowed : I → Finset C)
(hfeature : ∀ i, p.map (features i) = FiniteDist.uniform C) (f : Ω → ℝ) :
expectation p (combinedProjection p features allowed f) = expectation p f := by
simp only [combinedProjection, LinearMap.add_apply, LinearMap.sum_apply,
map_add, map_sum]
have hc : expectation p (constantProjection p f) = expectation p f :=
expectation_const p _
rw [hc]
simp_rw [featureProjection_mean p _ (hfeature _)]
simp
/-- The concrete finite feature projection as a bounded operator for Neumann repair. -/
noncomputable def chartProjection (p : FiniteDist Ω) (features : I → Ω → C)
(allowed : I → Finset C) : (Ω → ℝ) →L[ℝ] (Ω → ℝ) :=
(combinedProjection p features allowed).toContinuousLinearMap
@[simp] theorem chartProjection_apply (p : FiniteDist Ω) (features : I → Ω → C)
(allowed : I → Finset C) (f : Ω → ℝ) (x : Ω) :
chartProjection p features allowed f x = expectation p f +
∑ i, centerAllowed (allowed i) (conditional p (features i) f) (features i x) := by
simp [chartProjection, combinedProjection]
/-- Idempotence of the bounded operator used by the actual safe-set deletion. -/
theorem chartProjection_idempotent [Nonempty C] (p : FiniteDist Ω)
(features : I → Ω → C) (allowed : I → Finset C)
(hfeature : ∀ i, p.map (features i) = FiniteDist.uniform C)
(hpair : ∀ i j, i ≠ j → p.map (fun x => (features i x, features j x)) =
(FiniteDist.uniform C).prod (FiniteDist.uniform C)) :
chartProjection p features allowed * chartProjection p features allowed =
chartProjection p features allowed := by
ext f x
exact congrFun (congrArg (fun L : (Ω → ℝ) →ₗ[ℝ] (Ω → ℝ) => L f)
(combinedProjection_idempotent p features allowed hfeature hpair)) x
/-- A nonnegative weighting controls arbitrary signed tests by their sup norm. -/
theorem expectation_abs_mul_le (p : FiniteDist Ω) (weight f : Ω → ℝ)
(hw : ∀ x, 0 ≤ weight x) :
|expectation p (fun x => weight x * f x)| ≤ ‖f‖ * expectation p weight := by
calc
_ ≤ ∑ x, |p.weight x * (weight x * f x)| := Finset.abs_sum_le_sum_abs _ _
_ = ∑ x, p.weight x * weight x * |f x| := by
apply Finset.sum_congr rfl
intro x _
rw [abs_mul, abs_mul, abs_of_nonneg (p.nonneg x), abs_of_nonneg (hw x)]
ring
_ ≤ ∑ x, p.weight x * weight x * ‖f‖ := by
apply Finset.sum_le_sum
intro x _
exact mul_le_mul_of_nonneg_left (norm_le_pi_norm f x)
(mul_nonneg (p.nonneg x) (hw x))
_ = ‖f‖ * expectation p weight := by
rw [← Finset.sum_mul]
unfold expectation
dsimp
ring
/-- The same test bound holds conditionally on each feature value. -/
theorem conditional_abs_mul_le (p : FiniteDist Ω) (feature : Ω → C)
(weight f : Ω → ℝ) (hw : ∀ x, 0 ≤ weight x) (c : C) :
|conditional p feature (fun x => weight x * f x) c| ≤
‖f‖ * conditional p feature weight c := by
have he : (fun x => if feature x = c then weight x * f x else (0 : ℝ)) =
fun x => (if feature x = c then weight x else 0) * f x := by
funext x
split_ifs <;> simp
rw [conditional_apply, conditional_apply, abs_mul, abs_of_nonneg (Nat.cast_nonneg _), he]
have h := expectation_abs_mul_le p (fun x => if feature x = c then weight x else 0) f
(fun x => by split_ifs <;> simp [hw])
calc
_ ≤ (Fintype.card C : ℝ) * (‖f‖ * expectation p
(fun x => if feature x = c then weight x else 0)) :=
mul_le_mul_of_nonneg_left h (Nat.cast_nonneg _)
_ = _ := by ring
omit [Fintype C] in
/-- Centering an allowed-set profile costs at most twice its sup bound. -/
theorem centerAllowed_abs_le (allowed : Finset C) (g : C → ℝ) (M : ℝ)
(hM : 0 ≤ M) (hg : ∀ c ∈ allowed, |g c| ≤ M) (c : C) :
|centerAllowed allowed g c| ≤ 2 * M := by
rw [centerAllowed_apply]
by_cases hc : c ∈ allowed
· rw [if_pos hc]
have hcard : 0 < (allowed.card : ℝ) :=
Nat.cast_pos.mpr (Finset.card_pos.mpr ⟨c, hc⟩)
have havg : |(∑ a ∈ allowed, g a) / allowed.card| ≤ M := by
rw [abs_div, abs_of_nonneg hcard.le, div_le_iff₀ hcard]
calc
_ ≤ ∑ a ∈ allowed, |g a| := Finset.abs_sum_le_sum_abs _ _
_ ≤ ∑ _a ∈ allowed, M := Finset.sum_le_sum (fun a ha => hg a ha)
_ = _ := by simp [mul_comm]
exact (abs_sub _ _).trans (by linarith [hg c hc])
· simp [hc, hM]
/-- The public deletion indicator used in the exact finite probability bounds. -/
noncomputable def badIndicator (safe : Ω → Prop) : Ω → ℝ :=
fun x => if safe x then 0 else 1
/-- The actual `l∞` deletion norm bound, derived from scalar deletion
probabilities. With `m` features this is exactly `(2m+1)ε` in V7. -/
theorem chartDeletion_norm (p : FiniteDist Ω) (features : I → Ω → C)
(allowed : I → Finset C) (safe : Ω → Prop) [DecidablePred safe]
(ε : ℝ) (hε : 0 ≤ ε)
(hglobal : expectation p (badIndicator safe) ≤ ε)
(hconditional : ∀ i c, c ∈ allowed i →
conditional p (features i) (badIndicator safe) c ≤ ε) :
‖deletion (Ω := Ω) (chartProjection (Ω := Ω) (C := C) (I := I) p features allowed) safe‖ ≤
(2 * Fintype.card I + 1) * ε := by
apply ContinuousLinearMap.opNorm_le_bound _ (by positivity)
intro f
apply (pi_norm_le_iff_of_nonneg (by positivity)).mpr
intro x
have hb : ∀ y, 0 ≤ badIndicator safe y := by
intro y
unfold badIndicator
split_ifs <;> norm_num
have heq : f - safeMask safe f = fun y => badIndicator safe y * f y := by
funext y
simp only [Pi.sub_apply, safeMask_apply, badIndicator]
split_ifs <;> simp
have hg : |expectation p (f - safeMask safe f)| ≤ ε * ‖f‖ := by
rw [heq]
exact (expectation_abs_mul_le p (badIndicator safe) f hb).trans
(by nlinarith [mul_le_mul_of_nonneg_left hglobal (norm_nonneg f)])
have hc (i : I) (c : C) (hca : c ∈ allowed i) :
|conditional p (features i) (f - safeMask safe f) c| ≤ ε * ‖f‖ := by
rw [heq]
exact (conditional_abs_mul_le p (features i) (badIndicator safe) f hb c).trans
(by nlinarith [mul_le_mul_of_nonneg_left (hconditional i c hca) (norm_nonneg f)])
change |chartProjection p features allowed (f - safeMask safe f) x| ≤ _
rw [chartProjection_apply]
calc
_ ≤ |expectation p (f - safeMask safe f)| +
|∑ i, centerAllowed (allowed i)
(conditional p (features i) (f - safeMask safe f)) (features i x)| := abs_add_le _ _
_ ≤ ε * ‖f‖ + ∑ i, |centerAllowed (allowed i)
(conditional p (features i) (f - safeMask safe f)) (features i x)| :=
add_le_add hg (Finset.abs_sum_le_sum_abs _ _)
_ ≤ ε * ‖f‖ + ∑ _i : I, 2 * (ε * ‖f‖) := by
apply add_le_add_right
apply Finset.sum_le_sum
intro i _
exact centerAllowed_abs_le (allowed i) _ (ε * ‖f‖)
(mul_nonneg hε (norm_nonneg _)) (hc i) (features i x)
_ = _ := by simp; ring
/-- Expectation is monotone for pointwise ordered tests. -/
theorem expectation_mono (p : FiniteDist Ω) {f g : Ω → ℝ} (h : ∀ x, f x ≤ g x) :
expectation p f ≤ expectation p g :=
Finset.sum_le_sum (fun x _ => mul_le_mul_of_nonneg_left (h x) (p.nonneg x))
theorem conditional_mono (p : FiniteDist Ω) (feature : Ω → C)
{f g : Ω → ℝ} (h : ∀ x, f x ≤ g x) (c : C) :
conditional p feature f c ≤ conditional p feature g c := by
apply mul_le_mul_of_nonneg_left _ (Nat.cast_nonneg _)
apply expectation_mono
intro x
split_ifs <;> simp [h]
/-- Indicator of a forbidden color in one palette. -/
noncomputable def paletteFailure (allowed : Finset C) (c : C) : ℝ :=
if c ∈ allowed then 0 else 1
omit [Fintype C] in
@[simp] theorem paletteFailure_nonneg (allowed : Finset C) (c : C) :
0 ≤ paletteFailure allowed c := by unfold paletteFailure; split_ifs <;> norm_num
/-- Simultaneously enforce nonzero scale (the auxiliary palette) and all
trimmed feature palettes. -/
def legalChart (auxiliary : Ω → C) (auxAllowed : Finset C)
(features : I → Ω → C) (allowed : I → Finset C) (x : Ω) : Prop :=
auxiliary x ∈ auxAllowed ∧ ∀ i, features i x ∈ allowed i
omit [Fintype Ω] [Fintype C] in
/-- The union bound is pointwise before any probability or conditioning. -/
theorem badIndicator_le_palette_sum (auxiliary : Ω → C) (auxAllowed : Finset C)
(features : I → Ω → C) (allowed : I → Finset C) (x : Ω) :
badIndicator (legalChart auxiliary auxAllowed features allowed) x ≤
paletteFailure auxAllowed (auxiliary x) +
∑ i, paletteFailure (allowed i) (features i x) := by
by_cases hs : legalChart auxiliary auxAllowed features allowed x
· simp only [badIndicator, if_pos hs]
exact add_nonneg (paletteFailure_nonneg _ _)
(Finset.sum_nonneg (fun i _ => paletteFailure_nonneg _ _))
· simp only [badIndicator, if_neg hs]
by_cases ha : auxiliary x ∈ auxAllowed
· have he : ∃ i, features i x ∉ allowed i := by
simpa only [legalChart, ha, true_and, not_forall] using hs
obtain ⟨i, hi⟩ := he
have hsum := Finset.single_le_sum (fun j (_ : j ∈ Finset.univ) =>
paletteFailure_nonneg (allowed j) (features j x)) (Finset.mem_univ i)
simpa [paletteFailure, ha, hi] using hsum
· rw [show paletteFailure auxAllowed (auxiliary x) = 1 by simp [paletteFailure, ha]]
exact le_add_of_nonneg_right (Finset.sum_nonneg (fun i _ => paletteFailure_nonneg _ _))
/-- Exact uniform probability of a forbidden palette. -/
theorem uniform_palette_failure [Nonempty C] (allowed : Finset C) :
expectation (FiniteDist.uniform C) (paletteFailure allowed) =
1 - (allowed.card : ℝ) / Fintype.card C := by
have heq : paletteFailure allowed =
(fun _ : C => (1 : ℝ)) - (fun c => if c ∈ allowed then (1 : ℝ) else 0) := by
funext c
unfold paletteFailure
split_ifs <;> simp_all
rw [heq, map_sub, expectation_const]
congr 1
simp only [expectation_apply, FiniteDist.uniform_weight, mul_ite, mul_one, mul_zero,
← Finset.sum_filter, Finset.filter_univ_mem]
simp [div_eq_mul_inv]
/-- Uniform feature laws give the unconditional union deletion budget. -/
theorem legalChart_global_budget [Nonempty C] (p : FiniteDist Ω)
(auxiliary : Ω → C) (auxAllowed : Finset C)
(features : I → Ω → C) (allowed : I → Finset C)
(haux : p.map auxiliary = FiniteDist.uniform C)
(hfeature : ∀ i, p.map (features i) = FiniteDist.uniform C) :
expectation p (badIndicator (legalChart auxiliary auxAllowed features allowed)) ≤
expectation (FiniteDist.uniform C) (paletteFailure auxAllowed) +
∑ i, expectation (FiniteDist.uniform C) (paletteFailure (allowed i)) := by
have h := expectation_mono p (badIndicator_le_palette_sum auxiliary auxAllowed features allowed)
have heq : (fun x => paletteFailure auxAllowed (auxiliary x) +
∑ i, paletteFailure (allowed i) (features i x)) =
(fun x => paletteFailure auxAllowed (auxiliary x)) +
∑ i, (fun x => paletteFailure (allowed i) (features i x)) := by
ext x
simp
rw [heq, map_add, map_sum] at h
rw [← expectation_map p auxiliary (paletteFailure auxAllowed), haux] at h
have hf (i : I) : expectation p (fun x => paletteFailure (allowed i) (features i x)) =
expectation (FiniteDist.uniform C) (paletteFailure (allowed i)) := by
rw [← expectation_map p (features i) (paletteFailure (allowed i)), hfeature i]
simpa only [hf] using h
/-- The same deletion budget remains valid after fixing any allowed feature
value: its own violation disappears and all other violations remain uniform. -/
theorem legalChart_conditional_budget [Nonempty C] (p : FiniteDist Ω)
(auxiliary : Ω → C) (auxAllowed : Finset C)
(features : I → Ω → C) (allowed : I → Finset C)
(hfeature : ∀ i, p.map (features i) = FiniteDist.uniform C)
(hpair : ∀ i j, i ≠ j → p.map (fun x => (features i x, features j x)) =
(FiniteDist.uniform C).prod (FiniteDist.uniform C))
(hauxpair : ∀ i, p.map (fun x => (features i x, auxiliary x)) =
(FiniteDist.uniform C).prod (FiniteDist.uniform C))
(i : I) (c : C) (hc : c ∈ allowed i) :
conditional p (features i)
(badIndicator (legalChart auxiliary auxAllowed features allowed)) c ≤
expectation (FiniteDist.uniform C) (paletteFailure auxAllowed) +
∑ j, expectation (FiniteDist.uniform C) (paletteFailure (allowed j)) := by
have h := conditional_mono p (features i)
(badIndicator_le_palette_sum auxiliary auxAllowed features allowed) c
have heq : (fun x => paletteFailure auxAllowed (auxiliary x) +
∑ j, paletteFailure (allowed j) (features j x)) =
(fun x => paletteFailure auxAllowed (auxiliary x)) +
∑ j, (fun x => paletteFailure (allowed j) (features j x)) := by
ext x
simp
rw [heq, map_add, map_sum] at h
have ha := conditional_other p (features i) auxiliary (hauxpair i) (paletteFailure auxAllowed)
have hj (j : I) : conditional p (features i)
(fun x => paletteFailure (allowed j) (features j x)) c ≤
expectation (FiniteDist.uniform C) (paletteFailure (allowed j)) := by
by_cases hij : i = j
· subst j
rw [conditional_same p (features i) (hfeature i)]
simp only [paletteFailure, if_pos hc]
exact Finset.sum_nonneg (fun x _ => mul_nonneg
((FiniteDist.uniform C).nonneg x) (paletteFailure_nonneg _ _))
· rw [conditional_other p (features i) (features j) (hpair i j hij)]
calc
_ ≤ _ := h
_ ≤ _ := by
simp only [Pi.add_apply, Finset.sum_apply]
rw [ha]
exact add_le_add_right (Finset.sum_le_sum (fun j _ => hj j)) _
/-- A component is unchanged by applying the complete orthogonal projection. -/
theorem featureProjection_combined [Nonempty C] (p : FiniteDist Ω)
(features : I → Ω → C) (allowed : I → Finset C)
(hfeature : ∀ i, p.map (features i) = FiniteDist.uniform C)
(hpair : ∀ i j, i ≠ j → p.map (fun x => (features i x, features j x)) =
(FiniteDist.uniform C).prod (FiniteDist.uniform C)) (i : I) (f : Ω → ℝ) :
featureProjection p (features i) (allowed i) (combinedProjection p features allowed f) =
featureProjection p (features i) (allowed i) f := by
have hcomp (j : I) : featureProjection p (features i) (allowed i)
(featureProjection p (features j) (allowed j) f) =
if i = j then featureProjection p (features i) (allowed i) f else 0 := by
by_cases hij : i = j
· subst j
simpa using congrArg (fun L : (Ω → ℝ) →ₗ[ℝ] (Ω → ℝ) => L f)
(featureProjection_idempotent p (features i) (hfeature i) (allowed i))
· rw [if_neg hij]
exact congrArg (fun L : (Ω → ℝ) →ₗ[ℝ] (Ω → ℝ) => L f)
(featureProjection_orthogonal p (features i) (features j) (hpair i j hij)
(allowed i) (allowed j))
simp only [combinedProjection, LinearMap.add_apply, LinearMap.sum_apply, map_add, map_sum]
have hc : featureProjection p (features i) (allowed i) (constantProjection p f) = 0 :=
featureProjection_const p (features i) (hfeature i) (allowed i) _
rw [hc]
simp only [hcomp, Finset.sum_ite_eq, Finset.mem_univ, if_true, zero_add]
/-- Summing conditional densities restores the unrestricted density mass. -/
theorem conditional_sum (p : FiniteDist Ω) (feature : Ω → C) (f : Ω → ℝ) :
∑ c, conditional p feature f c = (Fintype.card C : ℝ) * expectation p f := by
simp only [conditional_apply, expectation_apply, ← Finset.mul_sum]
congr 1
rw [Finset.sum_comm]
simp [mul_ite]
/-- Zero centered component and palette support determine the entire marginal. -/
theorem centerAllowed_zero_profile (allowed : Finset C) (g : C → ℝ)
(hcenter : centerAllowed allowed g = 0) (hsupport : ∀ c ∉ allowed, g c = 0) (c : C) :
g c = if c ∈ allowed then (∑ a, g a) / allowed.card else 0 := by
have hsum : ∑ a ∈ allowed, g a = ∑ a, g a :=
Finset.sum_subset (Finset.subset_univ _) (fun a _ ha => hsupport a ha)
by_cases hc : c ∈ allowed
· have h := congrFun hcenter c
simp only [centerAllowed_apply, if_pos hc, Pi.zero_apply, hsum] at h
simpa only [if_pos hc] using sub_eq_zero.mp h
· simp [hc, hsupport c hc]
/-- Safe support forces every forbidden feature marginal to vanish exactly. -/
theorem conditional_outside_zero (p : FiniteDist Ω) (feature : Ω → C)
(allowed : Finset C) (safe : Ω → Prop) (f : Ω → ℝ)
(hsupport : ∀ x, ¬ safe x → f x = 0)
(hallowed : ∀ x, safe x → feature x ∈ allowed) (c : C) (hc : c ∉ allowed) :
conditional p feature f c = 0 := by
rw [conditional_apply]
have heq : (fun x => if feature x = c then f x else (0 : ℝ)) = 0 := by
funext x
by_cases hx : feature x = c
· have hn : ¬ safe x := by intro hs; exact hc (hx ▸ hallowed x hs)
simp [hx, hsupport x hn]
· simp [hx]
rw [heq, map_zero, mul_zero]
/-- Turn a nonnegative mean-one chart density into its actual probability law. -/
noncomputable def densityLaw (p : FiniteDist Ω) (w : Ω → ℝ)
(hw : ∀ x, 0 ≤ w x) (hmean : expectation p w = 1) : FiniteDist Ω where
weight x := p.weight x * w x
nonneg x := mul_nonneg (p.nonneg x) (hw x)
sum_one := hmean
/-- Conditional densities and the probability law's marginal have the exact
uniform-reference conversion factor. -/
theorem densityLaw_marginal [Nonempty C] (p : FiniteDist Ω) (w : Ω → ℝ)
(hw : ∀ x, 0 ≤ w x) (hmean : expectation p w = 1)
(feature : Ω → C) (c : C) :
((densityLaw p w hw hmean).map feature).weight c =
conditional p feature w c / Fintype.card C := by
rw [FiniteDist.map_weight, conditional_apply]
have hC : (Fintype.card C : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr Fintype.card_ne_zero
rw [mul_div_cancel_left₀ _ hC]
simp only [expectation_apply, densityLaw, mul_ite, mul_zero]
end FeatureProjections
section AffineFeatures
variable {F : Type*} [Field F]
/-- A chart stores the base, scale, and shear in that order. -/
abbrev Chart (F : Type*) := F × F × F
/-- The exact protected affine feature at source input `(first, second)`. -/
def feature (first second : F) (chart : Chart F) : F :=
chart.1 + chart.2.1 * first + chart.2.2 * second
/-- Every feature is a free uniform coordinate jointly with scale and shear. -/
def featureChartEquiv (first second : F) : Chart F ≃ Chart F where
toFun chart := (feature first second chart, chart.2)
invFun output := (output.1 - output.2.1 * first - output.2.2 * second, output.2)
left_inv chart := by
rcases chart with ⟨base, scale, shear⟩
dsimp [feature]
congr 1
ring
right_inv output := by
rcases output with ⟨color, scale, shear⟩
dsimp [feature]
congr 1
ring
/-- Two features with different first inputs, together with the shear, are
three independent free coordinates. -/
def firstPairChartEquiv (u v u' v' : F) (hfirst : u' - u ≠ 0) : Chart F ≃ Chart F where
toFun chart := (feature u v chart, feature u' v' chart, chart.2.2)
invFun output :=
let scale := (output.2.1 - output.1 - output.2.2 * (v' - v)) / (u' - u)
(output.1 - scale * u - output.2.2 * v, scale, output.2.2)
left_inv chart := by
rcases chart with ⟨base, scale, shear⟩
simp only [feature, Prod.mk.injEq, and_true]
constructor <;> field_simp <;> ring
right_inv output := by
rcases output with ⟨color, other, shear⟩
simp only [feature, Prod.mk.injEq, and_true]
constructor <;> field_simp <;> ring
/-- Two features with different second inputs, together with the scale, are
three independent free coordinates. -/
def secondPairChartEquiv (u v u' v' : F) (hsecond : v' - v ≠ 0) : Chart F ≃ Chart F where
toFun chart := (feature u v chart, feature u' v' chart, chart.2.1)
invFun output :=
let shear := (output.2.1 - output.1 - output.2.2 * (u' - u)) / (v' - v)
(output.1 - output.2.2 * u - shear * v, output.2.2, shear)
left_inv chart := by
rcases chart with ⟨base, scale, shear⟩
simp only [feature, Prod.mk.injEq, true_and]
constructor <;> field_simp <;> ring
right_inv output := by
rcases output with ⟨color, other, scale⟩
simp only [feature, Prod.mk.injEq, and_true]
constructor <;> field_simp <;> ring
/-- For any two distinct source inputs, the ordered feature pair can be
completed to an explicit bijection of unrestricted charts. -/
noncomputable def pairChartEquiv (input other : F × F) (hne : input ≠ other) :
Chart F ≃ Chart F := by
classical
by_cases hfirst : other.1 - input.1 = 0
· have hsecond : other.2 - input.2 ≠ 0 := by
intro h
apply hne
exact Prod.ext (sub_eq_zero.mp hfirst).symm (sub_eq_zero.mp h).symm
exact secondPairChartEquiv input.1 input.2 other.1 other.2 hsecond
· exact firstPairChartEquiv input.1 input.2 other.1 other.2 hfirst
@[simp] theorem pairChartEquiv_first (input other : F × F) (hne : input ≠ other)
(chart : Chart F) :
(pairChartEquiv input other hne chart).1 = feature input.1 input.2 chart := by
classical
unfold pairChartEquiv
split_ifs <;> rfl
@[simp] theorem pairChartEquiv_second (input other : F × F) (hne : input ≠ other)
(chart : Chart F) :
(pairChartEquiv input other hne chart).2.1 = feature other.1 other.2 chart := by
classical
unfold pairChartEquiv
split_ifs <;> rfl
end AffineFeatures
section UniformFeatures
open scoped Classical
variable {F : Type*} [Field F] [Fintype F]
/-- Projecting the first two unrestricted chart coordinates gives independent
uniform colors. -/
theorem uniform_chart_first_two :
(FiniteDist.uniform (Chart F)).map (fun chart => (chart.1, chart.2.1)) =
(FiniteDist.uniform F).prod (FiniteDist.uniform F) := by
ext colors
rcases colors with ⟨first, second⟩
simp only [FiniteDist.map_weight, FiniteDist.uniform_weight, FiniteDist.prod_weight]
rw [Fintype.sum_prod_type]
simp only [Fintype.sum_prod_type, Prod.mk.injEq, Fintype.card_prod, Nat.cast_mul]
have hF : (Fintype.card F : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr Fintype.card_ne_zero
simp [ite_and]
field_simp
/-- Each affine chart feature is independent uniform with the scale. -/
theorem feature_scale_uniform (first second : F) :
(FiniteDist.uniform (Chart F)).map (fun chart => (feature first second chart, chart.2.1)) =
(FiniteDist.uniform F).prod (FiniteDist.uniform F) := by
have h := FiniteDist.uniform_map_equiv (featureChartEquiv first second)
have hh := congrArg (fun p : FiniteDist (Chart F) =>
p.map (fun chart => (chart.1, chart.2.1))) h
rw [FiniteDist.map_map, uniform_chart_first_two] at hh
exact hh
/-- The exact pairwise-independence assertion in V7's boundary-chart proof,
proved from explicit invertible affine coordinate changes. -/
theorem feature_pair_uniform (input other : F × F) (hne : input ≠ other) :
(FiniteDist.uniform (Chart F)).map
(fun chart => (feature input.1 input.2 chart, feature other.1 other.2 chart)) =
(FiniteDist.uniform F).prod (FiniteDist.uniform F) := by
have h := FiniteDist.uniform_map_equiv (pairChartEquiv input other hne)
have hh := congrArg (fun p : FiniteDist (Chart F) =>
p.map (fun chart => (chart.1, chart.2.1))) h
rw [FiniteDist.map_map, uniform_chart_first_two] at hh
simpa only [pairChartEquiv_first, pairChartEquiv_second] using hh
theorem prod_map_first {α β : Type*} [Fintype α] [Fintype β]
(p : FiniteDist α) (q : FiniteDist β) : (p.prod q).map Prod.fst = p := by
ext a
simp only [FiniteDist.map_weight, FiniteDist.prod_weight, Fintype.sum_prod_type]
rw [Finset.sum_comm]
simp [← Finset.mul_sum, q.sum_one]
theorem prod_map_second {α β : Type*} [Fintype α] [Fintype β]
(p : FiniteDist α) (q : FiniteDist β) : (p.prod q).map Prod.snd = q := by
ext b
simp only [FiniteDist.map_weight, FiniteDist.prod_weight, Fintype.sum_prod_type]
simp [← Finset.sum_mul, p.sum_one]
/-- Every unrestricted affine feature is exactly uniform. -/
theorem feature_uniform (first second : F) :
(FiniteDist.uniform (Chart F)).map (feature first second) = FiniteDist.uniform F := by
have h := congrArg (fun p : FiniteDist (F × F) => p.map Prod.fst)
(feature_scale_uniform first second)
rw [FiniteDist.map_map, prod_map_first] at h
exact h
/-- The unrestricted scale is uniform and remains a public chart coordinate. -/
theorem scale_uniform :
(FiniteDist.uniform (Chart F)).map (fun chart => chart.2.1) = FiniteDist.uniform F := by
have h := congrArg (fun p : FiniteDist (F × F) => p.map Prod.snd)
(feature_scale_uniform (0 : F) 0)
rw [FiniteDist.map_map, prod_map_second] at h
exact h
/-- The scale-zero probability contributes exactly one deleted field value. -/
theorem nonzero_palette_failure :
expectation (FiniteDist.uniform F) (paletteFailure (Finset.univ.erase (0 : F))) =
(Fintype.card F : ℝ)⁻¹ := by
simp [expectation_apply, FiniteDist.uniform_weight, paletteFailure, mul_ite, ite_not]
variable {I : Type*} [Fintype I]
/-- The actual deleted-color union budget for unrestricted affine charts. -/
noncomputable def affineDeletionBudget (allowed : I → Finset F) : ℝ :=
(Fintype.card F : ℝ)⁻¹ + ∑ i, (1 - (allowed i).card / (Fintype.card F : ℝ))
end UniformFeatures
end BoundaryCalibration
end AFT
end
section
/-!
# The isolated mark in the positive boundary chart
The spike is a normalized restriction of the genuine unrestricted chart law
onto the surviving marked fiber. Its positive mass and marginal bounds follow
from uniform pairwise-independent features and the public deletion budget.
-/
namespace AFT
namespace BoundaryCalibration
open scoped BigOperators Classical
section RestrictedFiber
variable {Ω C J : Type*} [Fintype Ω] [Fintype C] [Nonempty C] [Fintype J]
/-- An event as a real-valued chart density. -/
noncomputable def eventIndicator (event : Ω → Prop) : Ω → ℝ :=
fun x => if event x then 1 else 0
omit [Fintype Ω] in
@[simp] theorem eventIndicator_nonneg (event : Ω → Prop) (x : Ω) :
0 ≤ eventIndicator event x := by unfold eventIndicator; split_ifs <;> norm_num
/-- Unrestricted probability of a finite chart event. -/
noncomputable def eventMass (p : FiniteDist Ω) (event : Ω → Prop) : ℝ :=
expectation p (eventIndicator event)
theorem eventMass_nonneg (p : FiniteDist Ω) (event : Ω → Prop) :
0 ≤ eventMass p event :=
Finset.sum_nonneg (fun x _ => mul_nonneg (p.nonneg x) (eventIndicator_nonneg event x))
/-- A literal conditioning density relative to the unrestricted chart law. -/
noncomputable def restrictedDensity (p : FiniteDist Ω) (event : Ω → Prop) : Ω → ℝ :=
fun x => eventIndicator event x / eventMass p event
theorem restrictedDensity_nonneg (p : FiniteDist Ω) (event : Ω → Prop) (x : Ω) :
0 ≤ restrictedDensity p event x :=
div_nonneg (eventIndicator_nonneg event x) (eventMass_nonneg p event)
theorem restrictedDensity_mean (p : FiniteDist Ω) (event : Ω → Prop)
(hpos : 0 < eventMass p event) : expectation p (restrictedDensity p event) = 1 := by
simp only [expectation_apply, restrictedDensity, ← mul_div_assoc, ← Finset.sum_div]
exact div_self hpos.ne'
end RestrictedFiber
section SpikeRepair
variable {Ω C I : Type*} [Fintype Ω] [Fintype C] [Nonempty C] [Fintype I]
/-- The complete projection fixes each of its feature components. -/
theorem combinedProjection_feature (p : FiniteDist Ω)
(features : I → Ω → C) (allowed : I → Finset C)
(hfeature : ∀ i, p.map (features i) = FiniteDist.uniform C)
(hpair : ∀ i j, i ≠ j → p.map (fun x => (features i x, features j x)) =
(FiniteDist.uniform C).prod (FiniteDist.uniform C)) (i : I) (f : Ω → ℝ) :
combinedProjection p features allowed (featureProjection p (features i) (allowed i) f) =
featureProjection p (features i) (allowed i) f := by
have hcomp (j : I) : featureProjection p (features j) (allowed j)
(featureProjection p (features i) (allowed i) f) =
if j = i then featureProjection p (features i) (allowed i) f else 0 := by
by_cases hij : j = i
· subst j
simpa using congrArg (fun L : (Ω → ℝ) →ₗ[ℝ] (Ω → ℝ) => L f)
(featureProjection_idempotent p (features i) (hfeature i) (allowed i))
· rw [if_neg hij]
exact congrArg (fun L : (Ω → ℝ) →ₗ[ℝ] (Ω → ℝ) => L f)
(featureProjection_orthogonal p (features j) (features i) (hpair j i hij)
(allowed j) (allowed i))
simp only [combinedProjection, LinearMap.add_apply, LinearMap.sum_apply]
have hc : constantProjection p (featureProjection p (features i) (allowed i) f) = 0 := by
funext x
exact featureProjection_mean p (features i) (hfeature i) (allowed i) f
rw [hc]
simp only [hcomp, Finset.sum_ite_eq', Finset.mem_univ, if_true, zero_add]
/-- A zero feature component, palette support and the total density mass
already determine the complete conditional marginal. -/
theorem component_zero_marginal (p : FiniteDist Ω) (feature : Ω → C)
(hfeature : p.map feature = FiniteDist.uniform C) (allowed : Finset C) (f : Ω → ℝ)
(hcomponent : featureProjection p feature allowed f = 0)
(hsupport : ∀ c ∉ allowed, conditional p feature f c = 0) (c : C) :
conditional p feature f c =
if c ∈ allowed then (Fintype.card C : ℝ) * expectation p f / allowed.card else 0 := by
have hc := congrArg (conditional p feature) hcomponent
change conditional p feature (fun x => centerAllowed allowed (conditional p feature f)
(feature x)) = conditional p feature 0 at hc
rw [conditional_same p feature hfeature, map_zero] at hc
rw [centerAllowed_zero_profile allowed _ hc hsupport c, conditional_sum]
end SpikeRepair
section AffineMarkedChart
variable {F I : Type*} [Field F] [Fintype F] [Fintype I]
end AffineMarkedChart
end BoundaryCalibration
end AFT
end
section
namespace AFT
end AFT
namespace AFT.GaussianSource
end AFT.GaussianSource
namespace AFT.GaussianSource.activation
end AFT.GaussianSource.activation
namespace AFT.Parameters
end AFT.Parameters
namespace AFT.Parameters.anchorWidth
end AFT.Parameters.anchorWidth
namespace AFT.Parameters.legs
end AFT.Parameters.legs
namespace AFT.Parameters.safeMargin
end AFT.Parameters.safeMargin
namespace AFT.primaryCalibrationEnvelope
end AFT.primaryCalibrationEnvelope
namespace AFT.primaryRankEnvelope
end AFT.primaryRankEnvelope
namespace AFT.primaryTranslationEnvelope
end AFT.primaryTranslationEnvelope
/-!
# Actual protected-input charts at the V7 parameter sizes
-/
namespace AFT.BoundaryCalibration
open Filter
open scoped BigOperators Classical Topology
noncomputable section
def protectedInputs (cutoff modulus : ℕ) :
(GaussianSource.Window cutoff × GaussianSource.Window cutoff) → ZMod modulus × ZMod modulus :=
fun input => ((input.1 : ℤ), (input.2 : ℤ))
theorem window_cast_injective (cutoff modulus : ℕ) (hsize : 2 * cutoff < modulus) :
Function.Injective (fun value : GaussianSource.Window cutoff => ((value : ℤ) : ZMod modulus)) := by
intro a b hab
have hd : (modulus : ℤ) ∣ (b : ℤ) - (a : ℤ) :=
(ZMod.intCast_eq_intCast_iff_dvd_sub _ _ _).mp hab
obtain ⟨ha0, ha1⟩ := Finset.mem_Icc.mp a.property
obtain ⟨hb0, hb1⟩ := Finset.mem_Icc.mp b.property
have hdiff : |(b : ℤ) - (a : ℤ)| < (modulus : ℤ) := by
rw [abs_lt]
constructor <;> omega
have habs : ((b : ℤ) - (a : ℤ)).natAbs < (modulus : ℤ).natAbs := by
rw [← Nat.cast_lt (α := ℤ), Int.natCast_natAbs, Int.natCast_natAbs]
simpa only [Int.abs_natCast] using hdiff
have hz := Int.eq_zero_of_dvd_of_natAbs_lt_natAbs hd habs
apply Subtype.ext
omega
theorem protectedInputs_injective (cutoff modulus : ℕ) (hsize : 2 * cutoff < modulus) :
Function.Injective (protectedInputs cutoff modulus) := by
intro a b hab
apply Prod.ext
· exact window_cast_injective cutoff modulus hsize (congrArg Prod.fst hab)
· exact window_cast_injective cutoff modulus hsize (congrArg Prod.snd hab)
theorem protectedInputs_card (cutoff : ℕ) :
Fintype.card (GaussianSource.Window cutoff × GaussianSource.Window cutoff) = (2 * cutoff + 1) ^ 2 := by
have hc : Fintype.card (GaussianSource.Window cutoff) = 2 * cutoff + 1 := by
simp only [GaussianSource.Window, Fintype.card_coe, Int.card_Icc]
omega
rw [Fintype.card_prod, hc, pow_two]
def fieldPalette (modulus : ℕ) [NeZero modulus] (boundary shift : ℤ) : Finset (ZMod modulus) :=
(TrimmedSlice.paletteSlice modulus boundary shift).map (ZMod.finEquiv modulus).toEquiv.toEmbedding
theorem fieldPalette_card (modulus : ℕ) [NeZero modulus] (boundary shift : ℤ) (hb : 0 ≤ boundary) :
(fieldPalette modulus boundary shift).card = ((modulus : ℤ) - 2 * boundary - |shift|).toNat := by
rw [fieldPalette, Finset.card_map, TrimmedSlice.paletteSlice_card modulus boundary shift hb]
def protectedPalettes (cutoff modulus : ℕ) [NeZero modulus] (boundary baseline : ℤ) :
(GaussianSource.Window cutoff × GaussianSource.Window cutoff) → Finset (ZMod modulus) :=
fun input => fieldPalette modulus boundary (baseline - (input.2 : ℤ))
theorem affineDeletionBudget_le {F I : Type*} [Fintype F] [Fintype I]
(allowed : I → Finset F) (deleted : ℝ) (hcard : 0 < Fintype.card F)
(hdeleted : ∀ i, (Fintype.card F : ℝ) - (allowed i).card ≤ deleted) :
affineDeletionBudget allowed ≤
(1 + (Fintype.card I : ℝ) * deleted) / (Fintype.card F : ℝ) := by
have hq : (0 : ℝ) < Fintype.card F := by exact_mod_cast hcard
have hsum : (∑ i : I, (1 - (allowed i).card / (Fintype.card F : ℝ))) ≤
(Fintype.card I : ℝ) * (deleted / (Fintype.card F : ℝ)) := by
calc
_ ≤ ∑ _i : I, deleted / (Fintype.card F : ℝ) := by
apply Finset.sum_le_sum
intro i _
rw [le_div_iff₀ hq]
have hh := hdeleted i
field_simp
linarith
_ = _ := by simp
unfold affineDeletionBudget
have heq : (1 + (Fintype.card I : ℝ) * deleted) / (Fintype.card F : ℝ) =
(Fintype.card F : ℝ)⁻¹ + (Fintype.card I : ℝ) * (deleted / (Fintype.card F : ℝ)) := by ring
rw [heq]
exact add_le_add le_rfl hsum
theorem protectedPalette_budget (cutoff modulus : ℕ) [NeZero modulus]
(boundary baseline shiftBound : ℤ) (hb : 0 ≤ boundary) (hs : |baseline| ≤ shiftBound)
(hclear : 2 * boundary + shiftBound + cutoff < modulus) :
affineDeletionBudget (protectedPalettes cutoff modulus boundary baseline) ≤
(1 + ((2 * cutoff + 1 : ℕ) : ℝ) ^ 2 *
(2 * (boundary : ℝ) + shiftBound + cutoff)) / modulus := by
have hq : 0 < modulus := Nat.pos_of_ne_zero (NeZero.ne modulus)
have hbound (input : GaussianSource.Window cutoff × GaussianSource.Window cutoff) :
|baseline - (input.2 : ℤ)| ≤ shiftBound + cutoff := by
have ha : |(input.2 : ℤ)| ≤ cutoff := abs_le.mpr (Finset.mem_Icc.mp input.2.property)
exact (abs_sub _ _).trans (add_le_add hs ha)
have hbudget := affineDeletionBudget_le
(protectedPalettes cutoff modulus boundary baseline)
(2 * (boundary : ℝ) + shiftBound + cutoff) (by simpa using hq)
(by
intro input
rw [protectedPalettes, fieldPalette_card modulus boundary _ hb, ZMod.card]
have hi : 0 ≤ (modulus : ℤ) - 2 * boundary - |baseline - (input.2 : ℤ)| := by
have hh := hbound input
omega
have heq : (((modulus : ℤ) - 2 * boundary - |baseline - (input.2 : ℤ)|).toNat : ℤ) =
(modulus : ℤ) - 2 * boundary - |baseline - (input.2 : ℤ)| := Int.toNat_of_nonneg hi
have hh : (modulus : ℤ) - ((modulus : ℤ) - 2 * boundary - |baseline - (input.2 : ℤ)|).toNat ≤
2 * boundary + shiftBound + cutoff := by rw [heq]; have := hbound input; omega
exact_mod_cast hh)
simpa only [ZMod.card, protectedInputs_card, Nat.cast_pow] using hbudget
end
end AFT.BoundaryCalibration
namespace AFT.BoundaryCalibration
open Filter
open scoped Topology
instance v7ModulusNeZero (parameter : ℕ) : NeZero (Parameters.modulus parameter) :=
⟨Nat.ne_of_gt (Parameters.modulus_prime parameter).pos⟩
instance v7ModulusPrime (parameter : ℕ) : Fact (Parameters.modulus parameter).Prime :=
⟨Parameters.modulus_prime parameter⟩
end AFT.BoundaryCalibration
namespace AFT.BoundaryCalibration
open Filter
open scoped Topology
noncomputable local instance _root_.AFT.BoundaryCalibration.instDecidableEqZModModulus (parameter : ℕ) : DecidableEq (ZMod (Parameters.modulus parameter)) := Classical.decEq _
end AFT.BoundaryCalibration
end
section
/-! # A computed common denominator with polynomial binary height -/
namespace AFT.RationalNumerics
open scoped BigOperators
variable {Index : Type*} [Fintype Index]
def commonDenominator (values : Index → ℚ) : ℕ := ∏ index,(values index).den
def commonNumerator (values : Index → ℚ) (index : Index) : ℤ :=
(values index).num*(commonDenominator values/(values index).den : ℕ)
end AFT.RationalNumerics
end
section
/-! # Executable linear iteration and stability in primary activity -/
namespace AFT.RationalNumerics
open scoped BigOperators
def matrixApply {Color : Type*} [Fintype Color]
(matrix : Color → Color → ℚ) (profile : Color → ℚ) (output : Color) : ℚ :=
∑ input,matrix output input*profile input
/-- The same right-hand side and stored matrix are used at every step. -/
def linearIteration {Color : Type*} [Fintype Color]
(matrix : Color → Color → ℚ) (rhs : Color → ℚ) : ℕ → Color → ℚ
| 0 => 0
| steps+1 => rhs-matrixApply matrix (linearIteration matrix rhs steps)
noncomputable section
def realMatrixOperator {Color : Type*} [Fintype Color] (matrix : Color → Color → ℚ) :
Module.End ℝ (Color → ℝ) where
toFun profile output := ∑ input,(matrix output input : ℝ)*profile input
map_add' first second := by
funext output
simp only [Pi.add_apply,mul_add,Finset.sum_add_distrib]
map_smul' scalar profile := by
funext output
simp only [Pi.smul_apply,smul_eq_mul,RingHom.id_apply,Finset.mul_sum]
apply Finset.sum_congr rfl
intro input _
ring
def realLinearIteration {Color : Type*}
(operator : Module.End ℝ (Color → ℝ)) (rhs : Color → ℝ) : ℕ → Color → ℝ
| 0 => 0
| steps+1 => rhs-operator (realLinearIteration operator rhs steps)
end
end AFT.RationalNumerics
end
section
/-! # Common-denominator iteration with linear operand bit growth -/
namespace AFT.RationalNumerics
open scoped BigOperators
variable {Color : Type*} [Fintype Color]
def integerLinearIteration (denominator : ℕ) (matrix : Color → Color → ℤ)
(rhs : Color → ℤ) : ℕ → Color → ℤ
| 0 => 0
| steps+1 => fun output => rhs output*(denominator : ℤ)^steps-
∑ input,matrix output input*integerLinearIteration denominator matrix rhs steps input
def iterationHeightSlope (colors coefficientBits denominatorBits : ℕ) : ℕ :=
coefficientBits+denominatorBits+colors+1
end AFT.RationalNumerics
end
section
namespace AFT
end AFT
namespace AFT.RationalNumerics
end AFT.RationalNumerics
namespace AFT.RationalNumerics.cachedLinearIteration
end AFT.RationalNumerics.cachedLinearIteration
namespace AFT.RationalNumerics.cachedLinearIteration.match_1
end AFT.RationalNumerics.cachedLinearIteration.match_1
namespace AFT.RationalNumerics.cachedMatrix
end AFT.RationalNumerics.cachedMatrix
namespace AFT.RationalNumerics.cachedMatrixApply
end AFT.RationalNumerics.cachedMatrixApply
namespace AFT.V7Calibration
end AFT.V7Calibration
namespace AFT.V7Calibration.actualAnchorError
end AFT.V7Calibration.actualAnchorError
namespace AFT.V7Calibration.actualAnchorErrorProgram
end AFT.V7Calibration.actualAnchorErrorProgram
namespace AFT.V7Calibration.actualAnchorMatrix
end AFT.V7Calibration.actualAnchorMatrix
namespace AFT.V7Calibration.actualCachedInverseProgram
end AFT.V7Calibration.actualCachedInverseProgram
namespace AFT.V7Calibration.actualErrorApprox
end AFT.V7Calibration.actualErrorApprox
namespace AFT.V7Calibration.actualInverseIterationProgram
end AFT.V7Calibration.actualInverseIterationProgram
namespace AFT.V7Calibration.actualInverseIterationProgram.match_1
end AFT.V7Calibration.actualInverseIterationProgram.match_1
namespace AFT.V7Calibration.actualNormalizedSign
end AFT.V7Calibration.actualNormalizedSign
namespace AFT.V7Calibration.actualNormalizedSignProgram
end AFT.V7Calibration.actualNormalizedSignProgram
namespace AFT.V7Calibration.actualPreconditionedMatrixProgram
end AFT.V7Calibration.actualPreconditionedMatrixProgram
namespace AFT.V7Calibration.actualRankApprox
end AFT.V7Calibration.actualRankApprox
namespace AFT.V7Calibration.actualRankDenominator
end AFT.V7Calibration.actualRankDenominator
namespace AFT.V7Calibration.actualRankDenominatorProgram
end AFT.V7Calibration.actualRankDenominatorProgram
namespace AFT.V7Calibration.actualRankInverseProgram
end AFT.V7Calibration.actualRankInverseProgram
namespace AFT.V7Calibration.actualResponseProgram
end AFT.V7Calibration.actualResponseProgram
namespace AFT.V7Calibration.actualSignedSliceMean
end AFT.V7Calibration.actualSignedSliceMean
/-! # Rational finite chart projection and a cached Neumann program
All entries of the unrestricted uniform chart projection are rational.
The program stores its deletion matrix and complete iterate vectors.
-/
namespace AFT.BoundaryCalibration
open RationalNumerics
open scoped BigOperators
def chartExpectationProgram (charts : ℕ) (value : Fin charts → ℚ) : ℚ :=
(∑ chart,value chart)/(charts : ℚ)
def chartConditionalProgram (charts colors : ℕ) (feature : Fin charts → Fin colors)
(value : Fin charts → ℚ) (color : Fin colors) : ℚ :=
(colors : ℚ)*chartExpectationProgram charts (fun chart => if feature chart=color then value chart else 0)
def chartFeatureProgram (charts colors : ℕ) (feature : Fin charts → Fin colors)
(allowed : Finset (Fin colors)) (value : Fin charts → ℚ) (chart : Fin charts) : ℚ :=
if feature chart∈allowed then
chartConditionalProgram charts colors feature value (feature chart)-
(∑color∈allowed,chartConditionalProgram charts colors feature value color)/(allowed.card : ℚ)
else 0
def chartProjectionProgram (charts colors features : ℕ)
(feature : Fin features → Fin charts → Fin colors) (allowed : Fin features → Finset (Fin colors))
(value : Fin charts → ℚ) (chart : Fin charts) : ℚ :=
chartExpectationProgram charts value+∑index,chartFeatureProgram charts colors (feature index) (allowed index) value chart
def chartDeletionProgram (charts colors features : ℕ)
(feature : Fin features → Fin charts → Fin colors) (allowed : Fin features → Finset (Fin colors))
(safe : Finset (Fin charts)) (value : Fin charts → ℚ) (chart : Fin charts) : ℚ :=
chartProjectionProgram charts colors features feature allowed (fun input => if input∈safe then 0 else value input) chart
def chartDeletionMatrixProgram (charts colors features : ℕ)
(feature : Fin features → Fin charts → Fin colors) (allowed : Fin features → Finset (Fin colors))
(safe : Finset (Fin charts)) (output input : Fin charts) : ℚ :=
-chartDeletionProgram charts colors features feature allowed safe (fun point => if point=input then 1 else 0) output
noncomputable section
open scoped Classical
set_option backward.isDefEq.respectTransparency false
set_option maxHeartbeats 1000000
variable (charts colors features : ℕ) [NeZero charts]
end
end AFT.BoundaryCalibration
end
section
/-! # Executable positive normalization and finite fair-bit sampling -/
namespace AFT.RationalNumerics
open scoped BigOperators
def positivePartProgram {count : ℕ} (raw : Fin (count+1) → ℚ) (index : Fin (count+1)) : ℚ := max 0 (raw index)
def positiveNormalizerProgram {count : ℕ} (raw : Fin (count+1) → ℚ) : ℚ := ∑index,positivePartProgram raw index
def positiveWeightProgram {count : ℕ} (raw : Fin (count+1) → ℚ) (index : Fin (count+1)) : ℚ :=
if positiveNormalizerProgram raw=0 then (if index=0 then 1 else 0)
else positivePartProgram raw index/positiveNormalizerProgram raw
theorem positiveNormalizerProgram_nonneg {count : ℕ} (raw : Fin (count+1) → ℚ) : 0≤positiveNormalizerProgram raw :=
Finset.sum_nonneg (fun _ _ => le_max_left _ _)
theorem positiveWeightProgram_nonneg {count : ℕ} (raw : Fin (count+1) → ℚ) (index : Fin (count+1)) :
0≤positiveWeightProgram raw index := by
unfold positiveWeightProgram
split_ifs
· exact zero_le_one
· exact le_refl _
· exact div_nonneg (le_max_left _ _) (positiveNormalizerProgram_nonneg raw)
theorem positiveWeightProgram_sum {count : ℕ} (raw : Fin (count+1) → ℚ) :
∑index,positiveWeightProgram raw index=1 := by
unfold positiveWeightProgram
split_ifs with hz
· simp
· rw [←Finset.sum_div]
exact div_self hz
def positiveNormalizeDraw {count : ℕ} (raw : Fin (count+1) → ℚ) (bits : ℕ)
(word : Fin (bits+(count+1)+1) → Fin 2) : Fin (count+1) :=
RationalFiniteQuantization.draw (positiveWeightProgram raw)
(positiveWeightProgram_nonneg raw) (positiveWeightProgram_sum raw) (bits+(count+1)+1) word
noncomputable section
open scoped Classical
set_option backward.isDefEq.respectTransparency false
def positiveProgramLaw {count : ℕ} (raw : Fin (count+1) → ℚ) : FiniteDist (Fin (count+1)) where
weight index := (positiveWeightProgram raw index : ℝ)
nonneg index := by exact_mod_cast positiveWeightProgram_nonneg raw index
sum_one := by exact_mod_cast positiveWeightProgram_sum raw
end
end AFT.RationalNumerics
end
section
namespace AFT
end AFT
namespace AFT.BoundaryCalibration
end AFT.BoundaryCalibration
/-! # Rational marked-chart density from the explicit protected repair -/
namespace AFT.BoundaryCalibration
open RationalNumerics
open scoped BigOperators
def chartSpikeProgram (charts : ℕ) (survivingFiber : Finset (Fin charts)) (point : Fin charts) : ℚ :=
if point∈survivingFiber then (charts : ℚ)/survivingFiber.card else 0
def chartSpikeDefectProgram (charts colors features : ℕ)
(feature : Fin features → Fin charts → Fin colors) (allowed : Fin features → Finset (Fin colors))
(marked : Fin features) (atom : ℚ) (spike : Fin charts → ℚ) (point : Fin charts) : ℚ :=
atom*∑ index,if index=marked then 0 else chartFeatureProgram charts colors (feature index) (allowed index) spike point
noncomputable section
open scoped Classical
set_option backward.isDefEq.respectTransparency false
set_option maxHeartbeats 600000
variable (charts colors features : ℕ) [NeZero charts]
end
end AFT.BoundaryCalibration
end
section
namespace AFT
end AFT
namespace AFT.BoundaryCalibration
end AFT.BoundaryCalibration
namespace AFT.BoundaryCalibration.explicitMarkedChartDensity
end AFT.BoundaryCalibration.explicitMarkedChartDensity
/-! # Explicit array indexing of the actual affine F³ chart and protected inputs -/
namespace AFT.BoundaryCalibration
open scoped BigOperators
/-- The order is base, scale, shear, as in the physical affine chart. -/
def finiteChartEquiv (modulus : ℕ) [NeZero modulus] :
Fin (modulus*(modulus*modulus)) ≃ Chart (ZMod modulus) :=
finProdFinEquiv.symm.trans ((ZMod.finEquiv modulus).toEquiv.prodCongr
(finProdFinEquiv.symm.trans ((ZMod.finEquiv modulus).toEquiv.prodCongr (ZMod.finEquiv modulus).toEquiv)))
def finiteInputEquiv (cutoff : ℕ) :
Fin ((2*cutoff+1)*(2*cutoff+1)) ≃ GaussianSource.Window cutoff × GaussianSource.Window cutoff :=
finProdFinEquiv.symm.trans ((FiniteConvolutionProgram.windowIndexEquiv cutoff).prodCongr
(FiniteConvolutionProgram.windowIndexEquiv cutoff))
def finiteAffineFeature (modulus : ℕ) [NeZero modulus] [Fact modulus.Prime] (first second : ZMod modulus)
(chart : Fin (modulus*(modulus*modulus))) : Fin modulus :=
(ZMod.finEquiv modulus).symm (feature first second (finiteChartEquiv modulus chart))
def finiteAffineScale (modulus : ℕ) [NeZero modulus]
(chart : Fin (modulus*(modulus*modulus))) : Fin modulus :=
(ZMod.finEquiv modulus).symm (finiteChartEquiv modulus chart).2.1
def finiteProtectedFeatures (cutoff modulus : ℕ) [NeZero modulus] [Fact modulus.Prime]
(index : Fin ((2*cutoff+1)*(2*cutoff+1))) : Fin (modulus*(modulus*modulus)) → Fin modulus :=
finiteAffineFeature modulus ((finiteInputEquiv cutoff index).1 : ℤ) ((finiteInputEquiv cutoff index).2 : ℤ)
def finiteProtectedPalettes (cutoff modulus : ℕ) (boundary baseline : ℤ)
(index : Fin ((2*cutoff+1)*(2*cutoff+1))) : Finset (Fin modulus) :=
Finset.univ.filter fun color =>
boundary ≤ (color.val : ℤ) ∧ (color.val : ℤ) ≤ (modulus : ℤ) - 1 - boundary ∧
boundary ≤ (modulus : ℤ) - 1 + (baseline - ((finiteInputEquiv cutoff index).2 : ℤ)) - color.val ∧
(modulus : ℤ) - 1 + (baseline - ((finiteInputEquiv cutoff index).2 : ℤ)) - color.val ≤
(modulus : ℤ) - 1 - boundary
noncomputable section
open scoped Classical
set_option backward.isDefEq.respectTransparency false
set_option maxHeartbeats 600000
variable (modulus : ℕ) [NeZero modulus] [Fact modulus.Prime]
end
end AFT.BoundaryCalibration
end
section
namespace AFT
end AFT
namespace AFT.BoundaryCalibration
end AFT.BoundaryCalibration
namespace AFT.BoundaryCalibration.explicitMarkedChartDensity
end AFT.BoundaryCalibration.explicitMarkedChartDensity
/-! # Positive marked-chart laws on the explicitly indexed array -/
namespace AFT.BoundaryCalibration
open scoped BigOperators
def finiteMarkedSafe {charts colors features : ℕ} [NeZero colors]
(feature : Fin features → Fin charts → Fin colors) (auxiliary : Fin charts → Fin colors)
(allowed : Fin features → Finset (Fin colors)) : Finset (Fin charts) :=
Finset.univ.filter (fun x => auxiliary x≠0 ∧ ∀ i, feature i x∈allowed i)
noncomputable section
open scoped Classical
set_option backward.isDefEq.respectTransparency false
set_option maxHeartbeats 1200000
end
end AFT.BoundaryCalibration
end
section
namespace AFT
end AFT
namespace AFT.BoundaryCalibration
end AFT.BoundaryCalibration
namespace AFT.BoundaryCalibration.explicitMarkedChartDensity
end AFT.BoundaryCalibration.explicitMarkedChartDensity
namespace AFT.BoundaryCalibration.finiteMarkedFiber
end AFT.BoundaryCalibration.finiteMarkedFiber
namespace AFT.BoundaryCalibration.finiteMarkedSafe
end AFT.BoundaryCalibration.finiteMarkedSafe
namespace AFT.BoundaryCalibration.finiteProtectedAtom
end AFT.BoundaryCalibration.finiteProtectedAtom
/-! # The executable F³ chart sampler at the actual V7 parameters -/
namespace AFT.BoundaryCalibration
open V7Calibration Filter
open scoped BigOperators
/-- Both parameters are produced by finite integer programs. -/
def chartProgramModulus (n : ℕ) : ℕ := (ParameterProgram.modulus n).value
instance chartProgramModulusNeZero (n : ℕ) : NeZero (chartProgramModulus n) :=
⟨by rw [chartProgramModulus,ParameterProgram.modulus_value];exact (Parameters.modulus_prime n).ne_zero⟩
instance chartProgramModulusPrime (n : ℕ) : Fact (chartProgramModulus n).Prime :=
⟨by rw [chartProgramModulus,ParameterProgram.modulus_value];exact Parameters.modulus_prime n⟩
noncomputable section
open scoped Classical Topology
set_option backward.isDefEq.respectTransparency false
set_option maxHeartbeats 900000
end
end AFT.BoundaryCalibration
end
section
namespace AFT
end AFT
namespace AFT.BoundaryCalibration
end AFT.BoundaryCalibration
namespace AFT.BoundaryCalibration.chartAtom
end AFT.BoundaryCalibration.chartAtom
namespace AFT.BoundaryCalibration.chartPairOutput
end AFT.BoundaryCalibration.chartPairOutput
namespace AFT.BoundaryCalibration.fieldPalette
end AFT.BoundaryCalibration.fieldPalette
namespace AFT.FiniteDist
end AFT.FiniteDist
namespace AFT.GaussianSource
end AFT.GaussianSource
namespace AFT.GaussianSource.pairCore
end AFT.GaussianSource.pairCore
namespace AFT.GaussianSource.pairCoreDepth
end AFT.GaussianSource.pairCoreDepth
namespace AFT.SafeConvolution
end AFT.SafeConvolution
namespace AFT.SafeConvolution.SupportedInBox
end AFT.SafeConvolution.SupportedInBox
namespace AFT.TrimmedSlice
end AFT.TrimmedSlice
namespace AFT.V7Calibration
end AFT.V7Calibration
namespace AFT.V7Calibration.errorLaw
end AFT.V7Calibration.errorLaw
namespace AFT.V7Calibration.inactiveStart
end AFT.V7Calibration.inactiveStart
/-! # The true primary-dependent public sign branch -/
namespace AFT.V7Calibration
open GaussianSource BoundaryCalibration Filter
open scoped BigOperators Classical Topology
noncomputable section
set_option backward.isDefEq.respectTransparency false
local instance conditionalPairFinDecEq (n : ℕ) : DecidableEq (Fin n) := Classical.decEq _
attribute [local instance] actualModulusNeZero
/-- The baseline interval of the pair sum, before its actual body blur. -/
def conditionalBaselineStart (modulus width : ℕ) (mark : Fin modulus) (coin : Bool) : ℤ :=
publicAnchorStart modulus width mark coin + mark.val - ((modulus : ℤ) - 1)
def conditionalPairStart (cutoffScale : ℝ) (parameter : ℕ) (mark : Fin (Parameters.modulus parameter))
(sample : bodySample cutoffScale parameter × Bool) : ℤ :=
conditionalBaselineStart (Parameters.modulus parameter) (Parameters.anchorWidth parameter) mark sample.2 +
bodyShift cutoffScale parameter sample.1
end
end AFT.V7Calibration
end
section
/-! # Executable actual trimmed endpoint pairs, conditional on the shared source -/
namespace AFT.V7Calibration
open GaussianSource RationalNumerics Filter
open scoped BigOperators
/-- The exact integer pair sum fixes the only possible anchor offset. -/
def averagedPairProgram (modulus : ℕ) (boundary start source : ℤ) (width : ℕ)
(first second : ℕ) : ℚ :=
let shift : ℤ := (first : ℤ)+second-((modulus : ℤ)-1)
intervalProbabilityProgram start width (shift+source)*sliceProbabilityProgram modulus boundary shift first
noncomputable section
open scoped Classical Topology
set_option backward.isDefEq.respectTransparency false
set_option maxHeartbeats 400000
local instance conditionalPairProgramFinDecEq (n : ℕ) : DecidableEq (Fin n) := Classical.decEq _
end
end AFT.V7Calibration
end
Source
Local manuscript proof repository commit 5c3becb254daaa8738368b474349766c1769c2a0; Lean source modules AFT/ActualAnchorProgram.lean, AFT/BoundaryCalibration.lean, AFT/BoundarySpike.lean, AFT/BoundaryChartParameters.lean, AFT/RationalCommonDenominator.lean, AFT/RationalLinearIteration.lean, AFT/IntegerLinearIteration.lean, AFT/ChartProjectionProgram.lean, AFT/RationalPositiveNormalize.lean, AFT/MarkedChartProgram.lean, AFT/FiniteAffineFeatures.lean, AFT/FiniteMarkedChart.lean, AFT/ActualChartProgram.lean, AFT/ConditionalPairOutput.lean, AFT/ActualConditionalPairProgram.lean. Source bodies and declaration spans are recorded in native_sparse_prefix/manifest.json; SHA256 a8c9d88af9bf626ed44144f9fcf570f73db25a50c07c5779e985035205d5df9e. Repackaging of identical data declarations, with 4163 public types matched to native source and 7722 origin declarations recursively audited for standard logical axioms only.