From e165515cee18fd3b8033a05df08caa025ba98a2a Mon Sep 17 00:00:00 2001 From: Tomas Ortega Date: Thu, 5 Nov 2026 14:28:07 -0500 Subject: [PATCH] feat(lean): reject unused theorem assumptions Audit every current local source module for unused compiled theorem parameters, including instances and underscore names. Remove verified redundant assumptions and update affected callers and claim versions. Add stronger-signature and audit regression coverage, and restrict research admissions to the public problem layer. Assisted-by: Codex:GPT-6 --- CONTRIBUTING.md | 4 + data/problems/finite-dmc-input-cost.yaml | 9 +- .../two-user-discrete-memoryless-mac.yaml | 5 +- docs/lean.md | 15 + lean/CapacityAtlas/Channels/InputCost.lean | 11 +- .../Channels/MultipleAccess.lean | 4 +- .../CapacityAtlas/Channels/QarySymmetric.lean | 15 +- .../Claims/GaussianInterference.lean | 4 +- .../Tests/GaussianMIMOBroadcast.lean | 3 +- lean/CapacityAtlasAudit.lean | 4 +- lean/CapacityAtlasAuditCore.lean | 50 ++- .../CapacityAtlasAuditCore/SourceModules.lean | 32 ++ lean/CapacityAtlasAuditTests.lean | 5 + .../AssumptionBoundaries.lean | 99 +++++ lean/CapacityAtlasAuditTests/Assumptions.lean | 35 ++ .../Assumptions/Fixtures.lean | 48 +++ .../GaussianAssumptions.lean | 351 ++++++++++++++++++ .../SourceModules.lean | 34 ++ .../TrustBoundary.lean | 34 ++ .../CausalState/BlockInformation.lean | 2 +- .../CausalState/Converse.lean | 8 +- .../ConditionalDensity.lean | 2 +- .../ConfidentialBroadcast/CoordinateLaw.lean | 6 +- .../EnsembleCodeBounds.lean | 2 +- .../InformationTheory/Entropy/Kernel.lean | 14 +- .../Entropy/RandomVariable.lean | 2 +- .../GaussianAffineDeBruijn.lean | 2 +- .../GaussianChannelEntropy.lean | 2 +- .../InformationTheory/GaussianDeBruijn.lean | 24 +- .../GaussianFiniteConditioning.lean | 6 +- .../GaussianFisherBasis.lean | 4 +- .../GaussianFisherConvolution.lean | 14 +- .../GaussianInterference/Capacity.lean | 8 +- .../CapacityConverse.lean | 28 +- .../GaussianInterference/CodeConverse.lean | 9 +- .../GaussianInterference/CodeLaws.lean | 2 +- .../GaussianInterference/ConverseEnergy.lean | 12 +- .../AchievabilityClosure.lean | 7 +- .../GaussianMIMOBroadcast/Boundary.lean | 4 +- .../EnhancedEntropy.lean | 5 +- .../EnhancedSupport.lean | 2 +- .../GaussianMIMOBroadcast/LayeredOneShot.lean | 2 +- .../LayeredReadback.lean | 8 +- .../RegionProperties.lean | 16 +- .../GaussianMixtureEntropy.lean | 13 +- .../GaussianMixtureScore.lean | 42 ++- .../GaussianProportionalEntropy.lean | 3 +- .../GaussianProportionalMixtureEntropy.lean | 4 +- .../GaussianRelativeEntropy.lean | 2 +- .../GaussianScoreIntegration.lean | 2 +- .../InformationTheory/InputCost/Capacity.lean | 15 +- .../MeasureRandomBinning/Rejection.lean | 4 +- .../MeasureRandomBinning/SampledSequence.lean | 2 +- .../MeasureRandomBinning/SequenceDecoder.lean | 2 +- .../MeasureRandomCoding.lean | 25 +- .../MeasureRandomCoding/Asymptotic.lean | 41 +- .../MeasureRandomCoding/IIDCoding.lean | 4 +- .../MeasureRandomCoding/Tensor.lean | 4 +- .../MultivariateGaussianEntropy.lean | 8 +- .../LinearAlgebra/LogDetConcavity.lean | 13 +- .../Network/LinearMulticast/Circuit.lean | 11 +- .../Network/LinearMulticast/Routing.lean | 2 +- .../Network/WirelessTransport/Capacity.lean | 4 +- .../Network/WirelessTransport/Grid.lean | 18 +- .../Network/WirelessTransport/Operations.lean | 22 +- .../Probability/GaussianChannel.lean | 2 +- .../Probability/GaussianDensity.lean | 24 +- .../Probability/Kernel/Disintegration.lean | 2 +- lean/lakefile.toml | 1 + tests/test_data.py | 1 - 70 files changed, 992 insertions(+), 232 deletions(-) create mode 100644 lean/CapacityAtlasAuditCore/SourceModules.lean create mode 100644 lean/CapacityAtlasAuditTests/AssumptionBoundaries.lean create mode 100644 lean/CapacityAtlasAuditTests/Assumptions.lean create mode 100644 lean/CapacityAtlasAuditTests/Assumptions/Fixtures.lean create mode 100644 lean/CapacityAtlasAuditTests/GaussianAssumptions.lean create mode 100644 lean/CapacityAtlasAuditTests/SourceModules.lean create mode 100644 lean/CapacityAtlasAuditTests/TrustBoundary.lean diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 998992d..343f07c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -82,6 +82,10 @@ Capacity Atlas uses Lean 4 for formal verification. nonempty Lean docstrings (`/-- ... -/`), or use `@[inherit_doc source]` when the meaning is shared. State the purpose, domain, and units when they are not clear from the type. The documentation linter runs with warnings as errors in CI. +- Remove unused theorem parameters instead of hiding them behind underscore names + or linter exclusions. The compiled audit checks the proof, result, and dependent + parameter types. Derive redundant conditions inside the proof where possible; + review mathematical generalizations even when the current proof uses the condition. - Attach `@[capacity_problem "problem-id"]` to problem-specific declarations. - Mark declaration roles with `@[capacity_definition]`, `@[capacity_statement]`, or `@[capacity_shared_api]`. diff --git a/data/problems/finite-dmc-input-cost.yaml b/data/problems/finite-dmc-input-cost.yaml index 89ab4b9..de98a42 100644 --- a/data/problems/finite-dmc-input-cost.yaml +++ b/data/problems/finite-dmc-input-cost.yaml @@ -3,7 +3,7 @@ id: finite-dmc-input-cost title: Finite discrete memoryless channel with input cost status: solved -updated: '2026-10-11' +updated: '2026-11-05' summary: A finite DMC under a feasible maximum-codeword average-cost constraint has a constrained mutual-information capacity formula. tags: model: [point-to-point] @@ -40,16 +40,17 @@ formalization: kind: exact-capacity category: solved formal_status: proved - version: 1 - description: For nonnegative cost with a feasible symbol, maximum-codeword-cost operational capacity + version: 2 + description: For real-valued cost with a feasible symbol, maximum-codeword-cost operational capacity equals constrained information capacity. notes: The local proof uses cost-controlled random coding and a finite-mixture converse. It covers the minimum feasible budget and proves that an admissible input attains the information supremum. + The version 2 theorem also permits signed costs; nonnegativity is not needed by the proof. files: - path: lean/CapacityAtlas/Channels/InputCost.lean declaration: CapacityAtlas.FiniteChannel.finiteDMCInputCostCapacityStatement role: claim - description: For nonnegative cost with a feasible symbol, maximum-codeword-cost operational capacity + description: For real-valued cost with a feasible symbol, maximum-codeword-cost operational capacity equals constrained information capacity. claim_id: exact-capacity proofs: [] diff --git a/data/problems/two-user-discrete-memoryless-mac.yaml b/data/problems/two-user-discrete-memoryless-mac.yaml index 64dbb0f..7bff5a9 100644 --- a/data/problems/two-user-discrete-memoryless-mac.yaml +++ b/data/problems/two-user-discrete-memoryless-mac.yaml @@ -4,7 +4,7 @@ id: two-user-discrete-memoryless-mac title: Two-user discrete memoryless multiple-access channel abbreviation: DM-MAC status: solved -updated: '2026-10-11' +updated: '2026-11-05' summary: Two independent senders communicate to one receiver through a finite memoryless channel. tags: model: [multiple-access] @@ -48,10 +48,11 @@ formalization: kind: exact-capacity category: solved formal_status: proved - version: 1 + version: 2 description: The complete average-error capacity region with separate deterministic encoders equals the three single-letter inequalities over arbitrary finite time sharing, including boundary rates and zero-rate axes. notes: The local proof uses separate random codebooks and a fixed time-sharing schedule. Three Fano bounds share one time coordinate; compactness handles boundary rates. The region allows arbitrary finite Q. + The version 2 theorem also covers empty input alphabets, without separate nonemptiness assumptions. files: - path: lean/CapacityAtlasForMathlib/InformationTheory/MultipleAccess.lean declaration: CapacityAtlas.MultipleAccess.BlockCode diff --git a/docs/lean.md b/docs/lean.md index 16ca574..8d5410f 100644 --- a/docs/lean.md +++ b/docs/lean.md @@ -239,6 +239,21 @@ The builds below treat documentation warnings as errors. Documentation regressio tests also check missing and empty docstrings, structure fields, private helpers, and `inherit_doc`, so disabling the package option breaks the test suite. +Unused-variable linting is enabled explicitly. The compiled audit also rejects +unused parameters of public proved theorems across the local libraries: a +parameter must occur in the proof, the result, or another parameter's type or +value. This check includes typeclass instances and underscore-prefixed names; +source linter options and `nolint` attributes do not disable it. Private helpers, +generated declarations, and admitted research statements are excluded. The +existing trust checks still reject admissions in reusable infrastructure and +local proofs. + +Compiled dependency checks cannot establish every mathematical generalization. +An assumption used by the current proof may still be removable with a stronger +proof; those changes need mathematical review and a regression check of the +stronger theorem signature. A materially strengthened registered claim must +increment its version in both Lean and YAML. + ```bash cd lean lake exe cache get diff --git a/lean/CapacityAtlas/Channels/InputCost.lean b/lean/CapacityAtlas/Channels/InputCost.lean index eb04892..ed50916 100644 --- a/lean/CapacityAtlas/Channels/InputCost.lean +++ b/lean/CapacityAtlas/Channels/InputCost.lean @@ -10,15 +10,14 @@ namespace CapacityAtlas.FiniteChannel variable {X Y : Type*} [Fintype X] [Fintype Y] -/-- The finite-DMC coding theorem with a feasible nonnegative input-cost constraint. -/ +/-- The finite-DMC coding theorem with a feasible input-cost constraint. -/ @[capacity_problem "finite-dmc-input-cost", capacity_statement, capacity_solved, - capacity_claim "exact-capacity" 1, capacity_formal_proof] + capacity_claim "exact-capacity" 2, capacity_formal_proof] theorem finiteDMCInputCostCapacityStatement (channel : FiniteChannel X Y) (cost : X → ℝ) (budget : ℝ) : - (∀ symbol, 0 ≤ cost symbol) → - (∃ symbol, cost symbol ≤ budget) → - channel.constrainedOperationalCapacityBits cost budget = - channel.constrainedInformationCapacityBits cost budget := + (∃ symbol, cost symbol ≤ budget) → + channel.constrainedOperationalCapacityBits cost budget = + channel.constrainedInformationCapacityBits cost budget := CapacityAtlasCost.finiteDMCInputCostCapacity channel cost budget end CapacityAtlas.FiniteChannel diff --git a/lean/CapacityAtlas/Channels/MultipleAccess.lean b/lean/CapacityAtlas/Channels/MultipleAccess.lean index 5e9578a..8e84e25 100644 --- a/lean/CapacityAtlas/Channels/MultipleAccess.lean +++ b/lean/CapacityAtlas/Channels/MultipleAccess.lean @@ -12,8 +12,8 @@ variable {X₁ X₂ Y : Type*} [Fintype X₁] [Fintype X₂] [Fintype Y] /-- The average-error capacity region of a finite two-user MAC. -/ @[capacity_problem "two-user-discrete-memoryless-mac", capacity_statement, - capacity_formal_proof, capacity_solved, capacity_claim "exact-capacity" 1] -theorem multipleAccessCapacityStatement [Nonempty X₁] [Nonempty X₂] + capacity_formal_proof, capacity_solved, capacity_claim "exact-capacity" 2] +theorem multipleAccessCapacityStatement (channel : FiniteChannel (X₁ × X₂) Y) : MultipleAccess.operationalRegion channel = MultipleAccess.informationRegion channel := CapacityAtlasMAC.capacityRegion channel diff --git a/lean/CapacityAtlas/Channels/QarySymmetric.lean b/lean/CapacityAtlas/Channels/QarySymmetric.lean index 7d1b68e..83b719c 100644 --- a/lean/CapacityAtlas/Channels/QarySymmetric.lean +++ b/lean/CapacityAtlas/Channels/QarySymmetric.lean @@ -33,11 +33,10 @@ private theorem sum_ite_zero (q : ℕ) [NeZero q] (a b : ℝ) : /-- The atlas q-ary noise range is contained in the probability interval. -/ @[capacity_api] -theorem qarySymmetric_p_le_one (q : ℕ) (hq : 2 ≤ q) {p : ℝ} +theorem qarySymmetric_p_le_one (q : ℕ) {p : ℝ} (hp : p ≤ ((q - 1 : ℕ) : ℝ) / q) : p ≤ 1 := by - have hqpos : (0 : ℝ) < q := by exact_mod_cast (lt_of_lt_of_le (by norm_num) hq) have hsuble : ((q - 1 : ℕ) : ℝ) ≤ q := by exact_mod_cast Nat.sub_le q 1 - exact hp.trans ((div_le_one hqpos).2 hsuble) + exact hp.trans (div_le_one_of_le₀ hsuble (Nat.cast_nonneg q)) /-- The q-ary symmetric noise distribution on the cyclic group with `q` elements. -/ @[capacity_problem "q-ary-symmetric-channel", capacity_definition] @@ -103,7 +102,7 @@ theorem qarySymmetricNoise_entropy (q : ℕ) [NeZero q] (hq : 2 ≤ q) capacity_formal_proof, capacity_claim "information-capacity" 1] theorem qarySymmetric_informationCapacity (q : ℕ) [NeZero q] (hq : 2 ≤ q) (p : ℝ) (hp0 : 0 ≤ p) (hpMax : p ≤ ((q - 1 : ℕ) : ℝ) / q) : - (qarySymmetric q hq p hp0 (qarySymmetric_p_le_one q hq hpMax)).informationCapacityBits = + (qarySymmetric q hq p hp0 (qarySymmetric_p_le_one q hpMax)).informationCapacityBits = Real.log q / Real.log 2 - Real.binEntropy p / Real.log 2 - p * Real.log ((q - 1 : ℕ) : ℝ) / Real.log 2 := by rw [qarySymmetric, additiveNoise_informationCapacity, ZMod.card, @@ -115,15 +114,15 @@ theorem qarySymmetric_informationCapacity (q : ℕ) [NeZero q] (hq : 2 ≤ q) capacity_formal_proof, capacity_claim "operational-capacity" 1] theorem qarySymmetric_operationalCapacity (q : ℕ) [NeZero q] (hq : 2 ≤ q) (p : ℝ) (hp0 : 0 ≤ p) (hpMax : p ≤ ((q - 1 : ℕ) : ℝ) / q) : - (qarySymmetric q hq p hp0 (qarySymmetric_p_le_one q hq hpMax)).operationalCapacityBits = + (qarySymmetric q hq p hp0 (qarySymmetric_p_le_one q hpMax)).operationalCapacityBits = Real.log q / Real.log 2 - Real.binEntropy p / Real.log 2 - p * Real.log ((q - 1 : ℕ) : ℝ) / Real.log 2 := by calc - (qarySymmetric q hq p hp0 (qarySymmetric_p_le_one q hq hpMax)).operationalCapacityBits = + (qarySymmetric q hq p hp0 (qarySymmetric_p_le_one q hpMax)).operationalCapacityBits = (qarySymmetric q hq p hp0 - (qarySymmetric_p_le_one q hq hpMax)).informationCapacityBits := + (qarySymmetric_p_le_one q hpMax)).informationCapacityBits := FiniteChannel.codingTheorem - (qarySymmetric q hq p hp0 (qarySymmetric_p_le_one q hq hpMax)) + (qarySymmetric q hq p hp0 (qarySymmetric_p_le_one q hpMax)) _ = Real.log q / Real.log 2 - Real.binEntropy p / Real.log 2 - p * Real.log ((q - 1 : ℕ) : ℝ) / Real.log 2 := qarySymmetric_informationCapacity q hq p hp0 hpMax diff --git a/lean/CapacityAtlas/Claims/GaussianInterference.lean b/lean/CapacityAtlas/Claims/GaussianInterference.lean index bc6a29f..21cc3bf 100644 --- a/lean/CapacityAtlas/Claims/GaussianInterference.lean +++ b/lean/CapacityAtlas/Claims/GaussianInterference.lean @@ -16,10 +16,10 @@ namespace CapacityAtlas.Claims capacity_formal_proof] theorem gaussianInterferenceDegreesOfFreedom (μ : Measure ℂ) [IsProbabilityMeasure μ] [NullSingletonClass μ] {K : ℕ} (hK : 2 ≤ K) {hmin hmax : ℝ} - (hmin_pos : 0 < hmin) (hmax_nonneg : 0 ≤ hmax) + (hmin_pos : 0 < hmin) (hfading : ∀ᵐ h ∂μ, hmin ≤ ‖h‖ ∧ ‖h‖ ≤ hmax) : Tendsto (fun P : ℝ => Gaussian.Interference.sumCapacity μ K P / Real.logb 2 P) atTop (𝓝 ((K : ℝ) / 2)) := - Gaussian.Interference.sum_degrees_of_freedom μ hK hmin_pos hmax_nonneg hfading + Gaussian.Interference.sum_degrees_of_freedom μ hK hmin_pos hfading end CapacityAtlas.Claims diff --git a/lean/CapacityAtlas/Tests/GaussianMIMOBroadcast.lean b/lean/CapacityAtlas/Tests/GaussianMIMOBroadcast.lean index a12bcc4..cce14c3 100644 --- a/lean/CapacityAtlas/Tests/GaussianMIMOBroadcast.lean +++ b/lean/CapacityAtlas/Tests/GaussianMIMOBroadcast.lean @@ -26,8 +26,7 @@ theorem gaussianMIMOBroadcast_zero_channel {K tx : ℕ} {rx : Fin K → ℕ} Gaussian.MIMOBroadcast.capacityRegion W.channelMatrix W.noiseCovariance W.totalPower = Gaussian.MIMOBroadcast.region W.channelMatrix W.noiseCovariance W.totalPower := by rw [hH] - exact Gaussian.MIMOBroadcast.capacityRegion_eq_region_zero_channel _ - W.noiseCovariance_posDef W.totalPower_nonnegative + exact Gaussian.MIMOBroadcast.capacityRegion_eq_region_zero_channel _ W.totalPower_nonnegative private def constantDecoder {Observation : Type*} [MeasurableSpace Observation] {messages : ℕ} (m : Fin messages) : Gaussian.Decoder Observation messages where diff --git a/lean/CapacityAtlasAudit.lean b/lean/CapacityAtlasAudit.lean index ab71b7d..3aa6be2 100644 --- a/lean/CapacityAtlasAudit.lean +++ b/lean/CapacityAtlasAudit.lean @@ -6,6 +6,7 @@ See https://www.apache.org/licenses/LICENSE-2.0 import CapacityAtlas import CapacityAtlasAuditCore +import CapacityAtlasAuditCore.SourceModules open Lean @@ -14,7 +15,8 @@ namespace CapacityAtlas.Audit private def runAudit : IO Report := do unsafe Lean.enableInitializersExecution initSearchPath (← findSysroot) - let env ← importModules #[{ module := `CapacityAtlas }] {} (loadExts := true) + let modules ← discoverSourceModules (← IO.currentDir) + let env ← importModules (modules.map fun module => { module }) {} (loadExts := true) let context : Core.Context := { fileName := "", fileMap := default } let state : Core.State := { env } Prod.fst <$> (audit env).toIO context state diff --git a/lean/CapacityAtlasAuditCore.lean b/lean/CapacityAtlasAuditCore.lean index e7854a8..e96ce8c 100644 --- a/lean/CapacityAtlasAuditCore.lean +++ b/lean/CapacityAtlasAuditCore.lean @@ -7,6 +7,7 @@ See https://www.apache.org/licenses/LICENSE-2.0 import CapacityAtlasUtil.Metadata import Lean.AutoDecl import Lean.Util.CollectAxioms +import Lean.Util.CollectFVars open Lean @@ -79,6 +80,43 @@ private def unexpectedAxioms (axioms : Array Name) (allowSorry : Bool) : Array N axioms.filter fun axiomName => !standardAxioms.contains axiomName && !(allowSorry && axiomName == ``sorryAx) +private def unusedTheoremArguments (info : ConstantInfo) : MetaM (Array String) := do + let .thmInfo theoremInfo := info | return #[] + Meta.forallTelescope theoremInfo.type fun args resultType => do + let localDeclarations ← args.mapM Meta.getFVarLocalDecl + let mut dependencies := mkApp ((mkAppN theoremInfo.value args).headBeta) resultType + for localDeclaration in localDeclarations do + dependencies := mkApp dependencies localDeclaration.type + if let some value := localDeclaration.value? then + dependencies := mkApp dependencies value + let usedVariables := (Lean.collectFVars {} dependencies).fvarSet + let mut errors := #[] + for index in [:localDeclarations.size] do + let localDeclaration := localDeclarations[index]! + unless usedVariables.contains localDeclaration.fvarId do + let type ← Meta.ppExpr localDeclaration.type + let argument ← Meta.ppExpr (.fvar localDeclaration.fvarId) + let binder := if localDeclaration.binderInfo.isInstImplicit then + s!"[{type}]" else s!"({argument} : {type})" + errors := errors.push s!"unused argument {index + 1}: {binder}; remove this parameter" + return errors + +private def requiresCleanProof (env : Environment) (moduleName declaration : Name) : Bool := + moduleIn moduleName `CapacityAtlasForMathlib || moduleIn moduleName `CapacityAtlasUtil || + capacityTestAttr.hasTag env declaration || capacityFormalProofAttr.hasTag env declaration || + capacityApiAttr.hasTag env declaration || capacitySharedApiAttr.hasTag env declaration || + capacityPropositionAttr.hasTag env declaration + +/-- Whether a public problem-layer research declaration may use an admitted proof. -/ +def allowsResearchAdmission (env : Environment) (moduleName declaration : Name) : CoreM Bool := do + let some info := env.find? declaration | return false + unless moduleIn moduleName `CapacityAtlas && isPublicTheorem info && + !env.isProjectionFn declaration do return false + if ← Lean.isAutoDeclOrPrivate_Internal declaration then return false + return !requiresCleanProof env moduleName declaration && + (capacityClaimAttr.getParam? env declaration).isSome && + (capacityOpenAttr.hasTag env declaration || capacitySolvedAttr.hasTag env declaration) + /-- Check compiled declarations, including the bodies of canonical proposition definitions. -/ def audit (env : Environment) : CoreM Report := do let mut records := #[] @@ -92,7 +130,6 @@ def audit (env : Environment) : CoreM Report := do let isTest := capacityTestAttr.hasTag env declaration let isFormalProof := capacityFormalProofAttr.hasTag env declaration let isProposition := capacityPropositionAttr.hasTag env declaration - let isApi := capacityApiAttr.hasTag env declaration let isSharedApi := capacitySharedApiAttr.hasTag env declaration let claim? := capacityClaimAttr.getParam? env declaration let claimId? := claim?.map Claim.id @@ -106,6 +143,10 @@ def audit (env : Environment) : CoreM Report := do let isAutoOrPrivate ← Lean.isAutoDeclOrPrivate_Internal declaration let isProblemTheorem := inProblemLayer && isPublicTheorem info && !isAutoOrPrivate && !env.isProjectionFn declaration + if isPublicTheorem info && !isAutoOrPrivate && !env.isProjectionFn declaration && + !axioms.contains ``sorryAx then + for error in ← (unusedTheoremArguments info).run' do + errors := errors.push s!"{declaration}: {error}" if inProblemLayer && isAxiom info && !isAutoOrPrivate then errors := errors.push s!"{declaration}: public problem-layer axioms are not permitted" if isProblemTheorem then @@ -144,11 +185,8 @@ def audit (env : Environment) : CoreM Report := do claim?.isNone then errors := errors.push s!"{declaration}: research claim is missing [capacity_claim] identity and version" - let admittedResearchClaim := claim?.isSome && isPublicTheorem info && !isProposition && - (capacityOpenAttr.hasTag env declaration || capacitySolvedAttr.hasTag env declaration) && - !isFormalProof && !isTest - let requiresCleanAxioms := - inForMathlib || inUtil || isTest || isFormalProof || isApi || isSharedApi || isProposition + let admittedResearchClaim ← allowsResearchAdmission env moduleName declaration + let requiresCleanAxioms := requiresCleanProof env moduleName declaration let checkedAxioms := if requiresCleanAxioms || isProblemTheorem then axioms else #[] let unexpected := unexpectedAxioms checkedAxioms admittedResearchClaim unless unexpected.isEmpty do diff --git a/lean/CapacityAtlasAuditCore/SourceModules.lean b/lean/CapacityAtlasAuditCore/SourceModules.lean new file mode 100644 index 0000000..b7f050f --- /dev/null +++ b/lean/CapacityAtlasAuditCore/SourceModules.lean @@ -0,0 +1,32 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import Lean.Data.Name +import Lean.Util.Path + +namespace CapacityAtlas.Audit + +/-- Discover every current library source module under the Lean package directory. -/ +def discoverSourceModules (packageDir : System.FilePath) : IO (Array Lean.Name) := do + let roots := #[`CapacityAtlas, `CapacityAtlasForMathlib, `CapacityAtlasUtil] + let invalidPackage := IO.userError + s!"capacity_audit requires the Lean package directory: {packageDir}; expected lakefile.toml and all three library source roots" + unless ← (packageDir / "lakefile.toml").pathExists do + throw invalidPackage + let mut modules := #[] + for root in roots do + let source := packageDir / s!"{root}.lean" + let directory := packageDir / root.toString + unless (← source.pathExists) && (← directory.isDir) do + throw invalidPackage + modules := modules.push root + let found ← IO.mkRef #[] + Lean.forEachModuleInDir directory fun name => do + found.modify (·.push (root ++ name)) + modules := modules ++ (← found.get) + return modules.qsort Lean.Name.quickLt + +end CapacityAtlas.Audit diff --git a/lean/CapacityAtlasAuditTests.lean b/lean/CapacityAtlasAuditTests.lean index f50edfa..4ce339b 100644 --- a/lean/CapacityAtlasAuditTests.lean +++ b/lean/CapacityAtlasAuditTests.lean @@ -5,8 +5,13 @@ See https://www.apache.org/licenses/LICENSE-2.0 -/ import CapacityAtlasAuditCore +import CapacityAtlasAuditTests.Assumptions +import CapacityAtlasAuditTests.AssumptionBoundaries import CapacityAtlasAuditTests.Documentation import CapacityAtlasAuditTests.Fixtures +import CapacityAtlasAuditTests.GaussianAssumptions +import CapacityAtlasAuditTests.SourceModules +import CapacityAtlasAuditTests.TrustBoundary open Lean CapacityAtlas.Audit diff --git a/lean/CapacityAtlasAuditTests/AssumptionBoundaries.lean b/lean/CapacityAtlasAuditTests/AssumptionBoundaries.lean new file mode 100644 index 0000000..7b1624c --- /dev/null +++ b/lean/CapacityAtlasAuditTests/AssumptionBoundaries.lean @@ -0,0 +1,99 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlas.Channels.QarySymmetric +import CapacityAtlas.Channels.MultipleAccess +import CapacityAtlas.Channels.InputCost +import CapacityAtlasForMathlib.InformationTheory.ConfidentialBroadcast.CoordinateLaw +import CapacityAtlasForMathlib.InformationTheory.MeasureRandomCoding.Asymptotic +import CapacityAtlasForMathlib.InformationTheory.Entropy.Kernel +import CapacityAtlasForMathlib.InformationTheory.MeasureRandomBinning.Rejection +import CapacityAtlasForMathlib.LinearAlgebra.LogDetConcavity +import CapacityAtlasForMathlib.Network.LinearMulticast.Circuit +import CapacityAtlasForMathlib.Network.WirelessTransport.Grid + +/-! These applications keep helper APIs usable without redundant assumptions. -/ + +open MeasureTheory ProbabilityTheory +open scoped ENNReal + +namespace CapacityAtlasAuditTests.AssumptionBoundaries + +example {ι : Type*} [Fintype ι] [DecidableEq ι] + {A B : Matrix ι ι ℝ} (hB : B.PosDef) {a : ℝ} (h : B⁻¹ = a • A⁻¹) : + a • B = A := + Matrix.inv_proportional_smul hB h + +example (q : ℕ) {p : ℝ} (hp : p ≤ ((q - 1 : ℕ) : ℝ) / q) : p ≤ 1 := + CapacityAtlas.Channel.qarySymmetric_p_le_one q hp + +example {X₁ X₂ Y : Type*} [Fintype X₁] [Fintype X₂] [Fintype Y] + (channel : CapacityAtlas.FiniteChannel (X₁ × X₂) Y) : + CapacityAtlas.MultipleAccess.operationalRegion channel = + CapacityAtlas.MultipleAccess.informationRegion channel := + CapacityAtlas.Channel.multipleAccessCapacityStatement channel + +example {X Y : Type*} [Fintype X] [Fintype Y] + (channel : CapacityAtlas.FiniteChannel X Y) (cost : X → ℝ) (budget : ℝ) + (hfeasible : ∃ symbol, cost symbol ≤ budget) : + channel.constrainedOperationalCapacityBits cost budget = + channel.constrainedInformationCapacityBits cost budget := + channel.finiteDMCInputCostCapacityStatement cost budget hfeasible + +example {R : ℝ} {m : ℕ} (hR : 0 < R) (i : Fin m) : + 0 ≤ (i.val : ℝ) * CapacityAtlas.WirelessTransport.gridStep R m ∧ + (i.val : ℝ) * CapacityAtlas.WirelessTransport.gridStep R m + + CapacityAtlas.WirelessTransport.gridStep R m ≤ R / 2 := + CapacityAtlas.WirelessTransport.grid_coord_bounds hR i + +example {R Δ : ℝ} {m : ℕ} (hR : 0 < R) + (i : CapacityAtlas.WirelessTransport.GridIndex m) : + ‖CapacityAtlas.WirelessTransport.gridTx R Δ m i‖ ≤ R := + CapacityAtlas.WirelessTransport.gridTx_norm_le hR i + +example (R a : ℝ) (n : ℕ) : + (CapacityAtlas.FiniteChannel.messageCountAtRate R n - 1 : ℕ) * + (ENNReal.ofReal (Real.exp ((n : ℝ) * a)))⁻¹ ≤ + ENNReal.ofReal (2 * Real.exp (-((n : ℝ) * (a - R * Real.log 2)))) := + CapacityAtlas.MeasureChannel.roundedMessage_threshold_le R a n + +example {X Y Z O : Type*} [Fintype X] [Fintype Y] [Fintype Z] + [Fintype O] [DecidableEq O] {W : CapacityAtlas.FiniteBroadcastChannel X Y Z} + {n : ℕ} (c : CapacityAtlas.ConfidentialBroadcast.Code W n) + (V : CapacityAtlas.FiniteChannel X O) (observe : Y × Z → O) + (hobserve : ∀ x, ((CapacityAtlas.ConfidentialBroadcast.receiverPair W).rowDistribution x).map + observe = V.rowDistribution x) : + c.fullJoint.map (fun z ↦ (z.1.1, fun j ↦ observe (z.2 j))) = c.joint V := + c.fullJoint_observe V observe hobserve + +example {X Y M : Type*} [MeasurableSpace X] [MeasurableSpace Y] + [MeasurableSpace M] [Fintype M] (κ : Kernel X Y) [IsMarkovKernel κ] + (code : CapacityAtlas.MeasureChannel.OneShotCode X Y M) : + CapacityAtlas.MeasureChannel.averageError κ code ≤ 1 := + CapacityAtlas.MeasureChannel.averageError_le_one κ code + +example {S T T' : Type*} [MeasurableSpace S] [MeasurableSpace T] [MeasurableSpace T'] + (κ : Kernel T S) (μ : Measure T) (f : T' ≃ᵐ T) : + Kernel.entropy (Kernel.comap κ f f.measurable) (μ.comap f) = Kernel.entropy κ μ := + Kernel.entropy_comap_equiv κ f + +example {U : Type*} [MeasurableSpace U] (μ : Measure U) {g : U → ℝ≥0∞} + (hg : Measurable g) {B E : Set U} (hB : MeasurableSet B) (hE : MeasurableSet E) + {T : ℝ} (hT : 0 < T) (hcut : ∀ u ∈ B, g u ≤ ENNReal.ofReal T) : + (μ.prod CapacityAtlas.MeasureBinning.seedLaw) + (CapacityAtlas.MeasureBinning.seededAcceptance g B T ∩ Prod.fst ⁻¹' E) = + (μ.withDensity g) (B ∩ E) / ENNReal.ofReal T := + CapacityAtlas.MeasureBinning.measure_seededAcceptance_inter μ hg hB hE hT hcut + +open scoped Classical in +example {I W T : Type} [Fintype W] [Fintype I] + (G : CapacityAtlas.LinearMulticast.Circuit I W) (output : T → I → I ⊕ W) + (route : ∀ t, ∃ c : G.Variable → ZMod 2, G.outputMatrix c (output t) = 1) : + ∃ b : ℕ, 0 < b ∧ ∃ c : G.Variable → GaloisField 2 b, + ∀ t, (G.outputMatrix c (output t)).det ≠ 0 := + G.simultaneous output route + +end CapacityAtlasAuditTests.AssumptionBoundaries diff --git a/lean/CapacityAtlasAuditTests/Assumptions.lean b/lean/CapacityAtlasAuditTests/Assumptions.lean new file mode 100644 index 0000000..26fd0ce --- /dev/null +++ b/lean/CapacityAtlasAuditTests/Assumptions.lean @@ -0,0 +1,35 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlasAuditCore +import CapacityAtlasAuditTests.Assumptions.Fixtures + +open Lean CapacityAtlas.Audit + +run_meta do + let report ← audit (← getEnv) + let fixtures := "CapacityAtlasAuditTests.Assumptions.Fixtures." + for (declaration, type) in #[ + ("namedUnused", "True"), ("underscoreUnused", "True"), + ("instanceUnused", "Nonempty"), ("dataUnused", "Nat"), + ("suppressedUnused", "True")] do + unless report.errors.any (fun error => + error.startsWith (fixtures ++ declaration ++ ":") && + (error.splitOn "unused argument 1:").length > 1 && + (error.splitOn type).length > 1) do + throwError "audit failed to reject unused theorem argument in {declaration}" + for declaration in #["necessaryProof", "finalResult", "laterBinderType", "propositionOnly"] do + if report.errors.any (·.startsWith (fixtures ++ declaration ++ ":")) then + throwError "audit rejected necessary theorem argument in {declaration}" + let dependentErrors := report.errors.filter + (·.startsWith (fixtures ++ "laterUnusedBinderType:")) + unless dependentErrors.size == 1 && + (dependentErrors[0]!.splitOn "unused argument 2:").length > 1 do + throwError "audit ignored a dependency in a later binder's type" + if report.errors.any (fun error => + (error.splitOn "privateHelper").length > 1 && + (error.splitOn "unused argument").length > 1) then + throwError "audit rejected a private helper" diff --git a/lean/CapacityAtlasAuditTests/Assumptions/Fixtures.lean b/lean/CapacityAtlasAuditTests/Assumptions/Fixtures.lean new file mode 100644 index 0000000..f9df964 --- /dev/null +++ b/lean/CapacityAtlasAuditTests/Assumptions/Fixtures.lean @@ -0,0 +1,48 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlasUtil.Metadata +import Batteries.Tactic.Lint.Misc + +set_option linter.unusedVariables false + +namespace CapacityAtlasAuditTests.Assumptions.Fixtures + +@[capacity_test] +theorem namedUnused (h : True) : True := True.intro + +@[capacity_test] +theorem underscoreUnused (_h : True) : True := True.intro + +@[capacity_test] +theorem instanceUnused [Nonempty Nat] : True := True.intro + +@[capacity_test] +theorem dataUnused (n : Nat) : True := True.intro + +@[capacity_test, nolint unusedArguments] +theorem suppressedUnused (_h : True) : True := True.intro + +@[capacity_test] +theorem necessaryProof {p : Prop} (h : p) : p := h + +@[capacity_test] +theorem finalResult (n : Nat) : n = n := rfl + +@[capacity_test] +theorem laterBinderType (h : True) (proof : h = h) : proof = proof := rfl + +@[capacity_test] +theorem laterUnusedBinderType (h : True) (_proof : h = h) : True := True.intro + +@[capacity_test] +private theorem privateHelper (_h : True) : True := True.intro + +/-- A proposition definition has no proof from which to infer redundant premises. -/ +@[capacity_test] +def propositionOnly (_h : True) : Prop := True + +end CapacityAtlasAuditTests.Assumptions.Fixtures diff --git a/lean/CapacityAtlasAuditTests/GaussianAssumptions.lean b/lean/CapacityAtlasAuditTests/GaussianAssumptions.lean new file mode 100644 index 0000000..8b9cecb --- /dev/null +++ b/lean/CapacityAtlasAuditTests/GaussianAssumptions.lean @@ -0,0 +1,351 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlas.Claims.GaussianInterference +import CapacityAtlasForMathlib.InformationTheory.GaussianMixtureScore +import CapacityAtlasForMathlib.InformationTheory.GaussianMIMOBroadcast.LayeredReadback +import CapacityAtlasForMathlib.InformationTheory.GaussianMIMOBroadcast.RegionProperties +import CapacityAtlasForMathlib.InformationTheory.GaussianProportionalEntropy +import CapacityAtlasForMathlib.InformationTheory.GaussianMIMOBroadcast.EnhancedEntropy +import CapacityAtlasForMathlib.InformationTheory.GaussianDeBruijn +import CapacityAtlasForMathlib.InformationTheory.GaussianFisherBasis +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.CodeConverse +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.Capacity +import CapacityAtlasForMathlib.Probability.GaussianDensity +import CapacityAtlasForMathlib.InformationTheory.GaussianMIMOBroadcast.AchievabilityClosure +import CapacityAtlasForMathlib.InformationTheory.GaussianMixtureEntropy + +/-! Exact signature checks keep Gaussian APIs free of the removed assumptions. -/ + +open MeasureTheory ProbabilityTheory InformationTheory Real Matrix Filter +open CapacityAtlas.MeasureChannel CapacityAtlas.MeasureBinning +open scoped BigOperators ENNReal Topology Classical MatrixOrder + +namespace CapacityAtlas.MeasureInformation + +example : ∀ {α : Type*} [Fintype α] + (a s : α → ℝ) (_ : ∀ k, 0 ≤ a k), + |(∑ k, a k * s k) / ∑ k, a k| ≤ ∑ k, |s k| := + @abs_weighted_average_le_sum_abs + +end CapacityAtlas.MeasureInformation + +namespace CapacityAtlas.Gaussian.MIMOBroadcast + +example : ∀ {K tx : ℕ} {rx : Fin K → ℕ} (H : (i : Fin K) → Matrix (Fin (rx i)) (Fin tx) ℝ) + (N : (i : Fin K) → Matrix (Fin (rx i)) (Fin (rx i)) ℝ) + (Q : Fin K → Matrix (Fin tx) (Fin tx) ℝ) (hQ : ∀ i, (Q i).PosDef) + (perm : Equiv.Perm (Fin K)) (order : ℕ → Fin K) + (_ : ∀ i j : Fin K, i < j → order j.val < order i.val) + (n : ℕ) (L : ℕ → ℕ) (T : ℕ → ℝ) (hT : ∀ i, 0 < T i) + (initial : LayerBlocks K tx n) (i : Fin K), + let D := gaussianStages H N Q hQ perm order n L T hT + ((sequenceReferenceLaw (fun j ↦ (D j).referenceKernel) initial i.val) ⊗ₘ (D i.val).target) + (D i.val).goodᶜ = (blockLayerLaw Q perm n) + {x | ENNReal.ofReal (T i.val) < blockLayerStateLikelihood + (H (perm (order i.val))) (N (perm (order i.val))) Q perm (order i.val) n x} := + @gaussianStages_jointBad_eq_terminal + +end CapacityAtlas.Gaussian.MIMOBroadcast + +namespace CapacityAtlas.Gaussian.MIMOBroadcast + +example : ∀ {K tx : ℕ} {rx : Fin K → ℕ} (N : (i : Fin K) → Matrix (Fin (rx i)) (Fin (rx i)) ℝ) + {P : ℝ} (_ : 0 ≤ P), + region (0 : (i : Fin K) → Matrix (Fin (rx i)) (Fin tx) ℝ) N P = {0} := + @region_zero_channel + +end CapacityAtlas.Gaussian.MIMOBroadcast + +namespace CapacityAtlas.MeasureInformation + +example : ∀ {P Q A B a : ℝ} (_ : 0 < P) (_ : 0 < A) (_ : 0 < B) + (_ : a ≤ 1) (_ : A = a * B) (_ : P + (B - A) ≤ Q), + a * log P - log Q ≤ a * log A - log B := + @proportional_log_sub_le + +end CapacityAtlas.MeasureInformation + +namespace CapacityAtlas.Gaussian.MIMOBroadcast + +example : ∀ {K tx n : ℕ} {rx : Fin K → ℕ} (c : Code K tx rx n) (_ : 0 < tx) (_ : 0 < n) + (E F S : Matrix (Fin tx) (Fin tx) ℝ) (_ : E.PosDef) (_ : F.PosDef) (_ : S.PosSemidef) + {f g : ℝ} (_ : 0 < f) (_ : f ≤ g) + (_ : g • (S + F)⁻¹ = f • (S + E)⁻¹) (k : ℕ), + f * codePrefixEntropy c E k - g * codePrefixEntropy c F k ≤ + n * (f * MeasureInformation.entropyWith (multivariateGaussian 0 (S + E)) volume - + g * MeasureInformation.entropyWith (multivariateGaussian 0 (S + F)) volume) := + @codePrefixEntropy_difference_le + +end CapacityAtlas.Gaussian.MIMOBroadcast + +namespace CapacityAtlas.MeasureInformation + +example : ∀ {ι α : Type*} [Fintype ι] [DecidableEq ι] [Fintype α] + (w : α → ℝ) (_ : ∀ a, 0 ≤ w a) + (m : α → EuclideanSpace ℝ ι) (N : Matrix ι ι ℝ) (_ : N.PosDef) + (x v : EuclideanSpace ℝ ι), + HasLineDerivAt ℝ (fun y ↦ 1 + log (gaussianMixturePDFReal w m N y)) + (lineDeriv ℝ (gaussianMixturePDFReal w m N) x v / gaussianMixturePDFReal w m N x) x v := + @hasLineDerivAt_one_add_log_gaussianMixturePDFReal + +end CapacityAtlas.MeasureInformation + +namespace CapacityAtlas.Gaussian.Interference + +example : ∀ (μ : Measure ℂ) [IsProbabilityMeasure μ] + {L U P : ℝ} (_ : 0 < L) (_ : 0 ≤ P) + (_ : ∀ᵐ z ∂μ, L ≤ ‖z‖ ∧ ‖z‖ ≤ U) + {K n : ℕ} (c : Code K n) (_ : PowerAdmissible μ P c) + (i j : Fin K) (_ : i ≠ j), + (1 - error μ c) * (Real.log (c.messages i) + Real.log (c.messages j)) ≤ + (n : ℝ) * Real.log (1 + U ^ 2 * P / converseNoise L U) + 2 * Real.log 2 := + @code_pair_converse + +end CapacityAtlas.Gaussian.Interference + +namespace ProbabilityTheory + +example : ∀ {ι : Type*} [Fintype ι] [DecidableEq ι] + {μ : Measure (EuclideanSpace ℝ ι)} [IsFiniteMeasure μ] + (m : EuclideanSpace ℝ ι) (S : Matrix ι ι ℝ) + (_ : Integrable (fun x : EuclideanSpace ℝ ι ↦ (x - m) ⬝ᵥ S⁻¹ *ᵥ (x - m)) μ), + Integrable (fun x ↦ Real.log (multivariateGaussianPDFReal m S x)) μ := + @integrable_log_multivariateGaussianPDFReal + +end ProbabilityTheory + +namespace CapacityAtlas.Gaussian.MIMOBroadcast + +example : ∀ {K : ℕ} {rx : Fin K → ℕ} + (H : (i : Fin K) → Matrix (Fin (rx i)) (Fin 0) ℝ) + (N : (i : Fin K) → Matrix (Fin (rx i)) (Fin (rx i)) ℝ) + {P : ℝ} (_ : 0 ≤ P), capacityRegion H N P = region H N P := + @capacityRegion_eq_region_no_transmit_antennas + +end CapacityAtlas.Gaussian.MIMOBroadcast + +namespace CapacityAtlas.MeasureInformation + +example : ∀ {α : Type*} [MeasurableSpace α] [Fintype α] [MeasurableSingletonClass α] + {ι : Type*} [Fintype ι] [DecidableEq ι] (μ : Measure α) [IsProbabilityMeasure μ] + (κ : Kernel α (EuclideanSpace ℝ ι)) + (m : α → EuclideanSpace ℝ ι) (N : Matrix ι ι ℝ) (_ : N.PosDef) + (_ : ∀ x, κ x = multivariateGaussian (m x) N) + (S : Matrix ι ι ℝ) (_ : S.PosDef) + (_ : ∀ i j, covariance (fun y : EuclideanSpace ℝ ι ↦ y i) + (fun y ↦ y j) (κ ∘ₘ μ) = S i j), + mutualInfo (μ ⊗ₘ κ) ≤ ENNReal.ofReal ((log S.det - log N.det) / 2) := + @mutualInfo_gaussianMixture_le_of_covariance_ennreal + +end CapacityAtlas.MeasureInformation + +namespace CapacityAtlas.Gaussian.Interference + +example : ∀ {K n : ℕ} (μ : Measure ℂ) (c : Code K n) (m : c.Message) (i : Fin K), + (∫ H, receiverErrorAt c m H i ∂stateLaw μ K n) = + ((stateLaw μ K n).prod (blockNoise K n)).real (receiverEvent c m i) := + @integral_receiverErrorAt + +end CapacityAtlas.Gaussian.Interference + +namespace CapacityAtlas.MeasureInformation + +example : ∀ {α β ι : Type*} [MeasurableSpace α] [MeasurableSpace β] + [Fintype α] [Fintype β] [MeasurableSingletonClass α] [MeasurableSingletonClass β] + [Fintype ι] [DecidableEq ι] + (μ : Measure α) (f : α → β) (m : β → EuclideanSpace ℝ ι) (N : Matrix ι ι ℝ), + gaussianCodebookKernel m N ∘ₘ μ.map f = gaussianCodebookKernel (m ∘ f) N ∘ₘ μ := + @gaussianCodebookKernel_comp_map + +example : ∀ {α β ι : Type*} [MeasurableSpace α] [MeasurableSpace β] + [Fintype α] [Fintype β] [MeasurableSingletonClass α] [MeasurableSingletonClass β] + [Fintype ι] [DecidableEq ι] + (μ : Measure α) (ν : Measure β) (m : α → β → EuclideanSpace ℝ ι) (N : Matrix ι ι ℝ), + gaussianMarginalCodebookKernel ν m N ∘ₘ μ = + gaussianCodebookKernel (fun p : α × β ↦ m p.1 p.2) N ∘ₘ μ.prod ν := + @gaussianMarginalCodebookKernel_comp + +end CapacityAtlas.MeasureInformation + +namespace CapacityAtlas.MeasureInformation + +example : ∀ {ι α : Type*} [Fintype ι] [DecidableEq ι] [Fintype α] (w : α → ℝ) (_ : ∀ a, 0 ≤ w a) + (m : α → EuclideanSpace ℝ ι) (N : Matrix ι ι ℝ) (_ : N.PosDef) + (v x : EuclideanSpace ℝ ι), + |directionalScore (gaussianMixturePDFReal w m N) v x| ≤ + ∑ k, |v ⬝ᵥ N⁻¹ *ᵥ (x - m k)| := + @abs_directionalScore_gaussianMixturePDFReal_le + +example : ∀ {ι α : Type*} [Fintype ι] [DecidableEq ι] [Fintype α] (w : α → ℝ) (_ : ∀ a, 0 ≤ w a) + (m : α → EuclideanSpace ℝ ι) (N : Matrix ι ι ℝ) (_ : N.PosDef) + (v k : EuclideanSpace ℝ ι) (S : Matrix ι ι ℝ) (p : ℝ≥0∞) (_ : p ≠ ⊤), + MemLp (directionalScore (gaussianMixturePDFReal w m N) v) p + (multivariateGaussian k S) := + @memLp_directionalScore_gaussianMixturePDFReal + +example : ∀ {ι α : Type*} [Fintype ι] [DecidableEq ι] [Fintype α] (w : α → ℝ) (_ : ∀ a, 0 ≤ w a) + (m : α → EuclideanSpace ℝ ι) (N : Matrix ι ι ℝ) (_ : N.PosDef) + (v k : EuclideanSpace ℝ ι) (S : Matrix ι ι ℝ), + MemLp (fun x ↦ lineDeriv ℝ + (fun y ↦ lineDeriv ℝ (gaussianMixturePDFReal w m N) y v) x v / + gaussianMixturePDFReal w m N x) 2 (multivariateGaussian k S) := + @memLp_two_secondDeriv_div_gaussianMixturePDFReal + +end CapacityAtlas.MeasureInformation + +namespace CapacityAtlas.Gaussian.Interference + +example : ∀ {K n : ℕ} (c : Code K n) (H : StateBlock K n) (i j : Fin K) + (_ : i ≠ j) (m : c.Message) {U : ℝ} + (_ : ∀ s, ‖H s i i‖ ≤ U) (_ : ∀ s, ‖H s i j‖ ≤ U), + pairEnergy c H i j m ≤ 2 * U ^ 2 * energy c m H := + @pairEnergy_le_energy + +example : ∀ {K n : ℕ} (μ : Measure ℂ) (c : Code K n) {P U : ℝ} + (_ : PowerAdmissible μ P c) (i j : Fin K) (_ : i ≠ j) + (_ : ∀ᵐ H ∂stateLaw μ K n, (∀ s, ‖H s i i‖ ≤ U) ∧ (∀ s, ‖H s i j‖ ≤ U)) + (m : c.Message), Integrable (fun H ↦ pairEnergy c H i j m) (stateLaw μ K n) := + @integrable_pairEnergy + +example : ∀ {K n : ℕ} (μ : Measure ℂ) (c : Code K n) {P U : ℝ} + (_ : PowerAdmissible μ P c) (i j : Fin K) (_ : i ≠ j) + (_ : ∀ᵐ H ∂stateLaw μ K n, (∀ s, ‖H s i i‖ ≤ U) ∧ (∀ s, ‖H s i j‖ ≤ U)), + (∫ H, ∫ m, pairEnergy c H i j m ∂messageLaw c ∂stateLaw μ K n) ≤ + 2 * U ^ 2 * ((n : ℝ) * P) := + @integral_pairEnergy_le + +end CapacityAtlas.Gaussian.Interference + +namespace CapacityAtlas.Gaussian.MIMOBroadcast + +example : ∀ {K tx : ℕ} {rx : Fin K → ℕ} (N : (i : Fin K) → Matrix (Fin (rx i)) (Fin (rx i)) ℝ) + {P : ℝ} (_ : 0 ≤ P), + capacityRegion (0 : (i : Fin K) → Matrix (Fin (rx i)) (Fin tx) ℝ) N P = + region (tx := tx) 0 N P := + @capacityRegion_eq_region_zero_channel + +end CapacityAtlas.Gaussian.MIMOBroadcast + +namespace CapacityAtlas.MeasureInformation + +example : ∀ {ι α : Type*} [Fintype ι] [DecidableEq ι] [Fintype α] + (w : α → ℝ) (_ : ∀ a, 0 ≤ w a) + (m : α → EuclideanSpace ℝ ι) (N : Matrix ι ι ℝ) (_ : N.PosDef) + (b b' : OrthonormalBasis ι ℝ (EuclideanSpace ℝ ι)), + (∑ i, directionalFisherWith volume (gaussianMixturePDFReal w m N) (b i)) = + ∑ i, directionalFisherWith volume (gaussianMixturePDFReal w m N) (b' i) := + @sum_directionalFisherWith_gaussianMixturePDFReal_basis + +end CapacityAtlas.MeasureInformation + +namespace CapacityAtlas.Gaussian.MIMOBroadcast + +example : ∀ {K tx : ℕ} {rx : Fin K → ℕ} + (N : (i : Fin K) → Matrix (Fin (rx i)) (Fin (rx i)) ℝ) + (Q : Fin K → Matrix (Fin tx) (Fin tx) ℝ) + (perm : Equiv.Perm (Fin K)) (k : Fin K), dpcRate 0 N Q perm k = 0 := + @dpcRate_zero_channel + +example : ∀ {K tx : ℕ} {rx : Fin K → ℕ} + (N : (i : Fin K) → Matrix (Fin (rx i)) (Fin (rx i)) ℝ) {P : ℝ} (_ : 0 ≤ P), + rawRegion (0 : (i : Fin K) → Matrix (Fin (rx i)) (Fin tx) ℝ) N P = {0} := + @rawRegion_zero_channel + +example : ∀ {K tx : ℕ} {rx : Fin K → ℕ} (H : (i : Fin K) → Matrix (Fin (rx i)) (Fin tx) ℝ) + (N : (i : Fin K) → Matrix (Fin (rx i)) (Fin (rx i)) ℝ) + (Q : Fin K → Matrix (Fin tx) (Fin tx) ℝ) (hQ : ∀ i, (Q i).PosDef) + (perm : Equiv.Perm (Fin K)) (order : ℕ → Fin K) + (_ : ∀ i j : Fin K, i < j → order j.val < order i.val) + (n : ℕ) (L : ℕ → ℕ) (T : ℕ → ℝ) (hT : ∀ i, 0 < T i) + (initial : LayerBlocks K tx n), + let D := gaussianStages H N Q hQ perm order n L T hT + sequenceSampleLaw (fun j ↦ (D j).sampleLaw) K + (sequenceSuccess initial (fun j ↦ (D j).next) (fun j ↦ (D j).success) K)ᶜ ≤ + ∑ i : Fin K, (2 : ℝ≥0∞) ^ i.val * + (2 * (blockLayerLaw Q perm n) + {x | ENNReal.ofReal (T i.val) < blockLayerStateLikelihood + (H (perm (order i.val))) (N (perm (order i.val))) Q perm (order i.val) n x} + + ENNReal.ofReal (Real.exp (-(L i.val : ℝ) * ((1 / 2 : ℝ) / T i.val)))) := + @gaussianStages_failure_le_terminal + +end CapacityAtlas.Gaussian.MIMOBroadcast + +namespace CapacityAtlas.Gaussian.Interference + +example : ∀ (μ : Measure ℂ) [IsProbabilityMeasure μ] + {L U P : ℝ} (_ : 0 < L) (_ : 0 ≤ P) + (_ : ∀ᵐ z ∂μ, L ≤ ‖z‖ ∧ ‖z‖ ≤ U) + {K n : ℕ} (_ : 0 < n) (c : Code K n) (_ : PowerAdmissible μ P c) + (i j : Fin K) (_ : i ≠ j), + (1 - error μ c) * (rates c i + rates c j) ≤ + Real.logb 2 (1 + U ^ 2 * P / converseNoise L U) + 2 / n := + @code_pair_rates_bound + +example : ∀ (μ : Measure ℂ) [IsProbabilityMeasure μ] + {L U P : ℝ} (_ : 0 < L) (_ : 0 ≤ P) + (_ : ∀ᵐ z ∂μ, L ≤ ‖z‖ ∧ ‖z‖ ≤ U) + {K : ℕ} {R : Fin K → ℝ} (_ : R ∈ capacityRegion μ K P) + (i j : Fin K) (_ : i ≠ j), + R i + R j ≤ Real.logb 2 (1 + U ^ 2 * P / converseNoise L U) := + @capacityRegion_pair_bound + +example : ∀ (μ : Measure ℂ) [IsProbabilityMeasure μ] + {L U P : ℝ} (_ : 0 < L) (_ : 0 ≤ P) + (_ : ∀ᵐ z ∂μ, L ≤ ‖z‖ ∧ ‖z‖ ≤ U) + {K : ℕ} (_ : 2 ≤ K) {R : Fin K → ℝ} (_ : R ∈ capacityRegion μ K P), + (∑ i, R i) ≤ (K : ℝ) / 2 * Real.logb 2 (1 + U ^ 2 * P / converseNoise L U) := + @capacityRegion_sum_bound + +example : ∀ (μ : Measure ℂ) [IsProbabilityMeasure μ] + {L U P : ℝ} (_ : 0 < L) (_ : 0 ≤ P) + (_ : ∀ᵐ z ∂μ, L ≤ ‖z‖ ∧ ‖z‖ ≤ U) {K : ℕ} (_ : 2 ≤ K), + sumCapacity μ K P ≤ + (K : ℝ) / 2 * Real.logb 2 (1 + U ^ 2 * P / converseNoise L U) := + @sumCapacity_converse + +example : ∀ (μ : Measure ℂ) [IsProbabilityMeasure μ] + {L U P : ℝ} (_ : 0 < L) (_ : 0 ≤ P) + (_ : ∀ᵐ z ∂μ, L ≤ ‖z‖ ∧ ‖z‖ ≤ U) {K : ℕ} (_ : 2 ≤ K), + BddAbove {s | ∃ R ∈ capacityRegion μ K P, s = ∑ i, R i} := + @sumRates_bddAbove + +example : ∀ (μ : Measure ℂ) [IsProbabilityMeasure μ] + {L U : ℝ} (_ : 0 < L) + (_ : ∀ᵐ z ∂μ, L ≤ ‖z‖ ∧ ‖z‖ ≤ U) {K : ℕ} (_ : 2 ≤ K) (P : ℝ), + BddAbove {s | ∃ R ∈ capacityRegion μ K P, s = ∑ i, R i} := + @sumRates_bddAbove_all + +example : ∀ (μ : Measure ℂ) [IsProbabilityMeasure μ] + {L U : ℝ} (_ : 0 < L) + (_ : ∀ᵐ z ∂μ, L ≤ ‖z‖ ∧ ‖z‖ ≤ U) {K : ℕ} (_ : 2 ≤ K), + Monotone (sumCapacity μ K) := + @sumCapacity_monotone + +example : ∀ (μ : Measure ℂ) [IsProbabilityMeasure μ] [NullSingletonClass μ] + {K : ℕ} (_ : 2 ≤ K) {L U : ℝ} (_ : 0 < L) + (_ : ∀ᵐ z ∂μ, L ≤ ‖z‖ ∧ ‖z‖ ≤ U), + Tendsto (fun P : ℝ ↦ sumCapacity μ K P / Real.logb 2 P) + atTop (𝓝 ((K : ℝ) / 2)) := + @sum_degrees_of_freedom + +end CapacityAtlas.Gaussian.Interference + +namespace CapacityAtlas.Claims + +example (μ : Measure ℂ) [IsProbabilityMeasure μ] {U : ℝ} + (hμ : ∀ᵐ z ∂μ, ‖z‖ ≤ U) : 0 ≤ U := by + obtain ⟨z, hz⟩ := hμ.exists + exact (norm_nonneg z).trans hz + +example : ∀ (μ : Measure ℂ) [IsProbabilityMeasure μ] [NullSingletonClass μ] + {K : ℕ} (_ : 2 ≤ K) {hmin hmax : ℝ} (_ : 0 < hmin) + (_ : ∀ᵐ h ∂μ, hmin ≤ ‖h‖ ∧ ‖h‖ ≤ hmax), + Tendsto (fun P : ℝ ↦ Gaussian.Interference.sumCapacity μ K P / Real.logb 2 P) + atTop (𝓝 ((K : ℝ) / 2)) := + @gaussianInterferenceDegreesOfFreedom + +end CapacityAtlas.Claims diff --git a/lean/CapacityAtlasAuditTests/SourceModules.lean b/lean/CapacityAtlasAuditTests/SourceModules.lean new file mode 100644 index 0000000..b927f97 --- /dev/null +++ b/lean/CapacityAtlasAuditTests/SourceModules.lean @@ -0,0 +1,34 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlasAuditCore.SourceModules +import Lean.Elab.Command + +open CapacityAtlas.Audit + +run_cmd do + Lean.Elab.Command.liftIO <| IO.FS.withTempDir fun directory => do + let emptyRejected ← try + let _ ← discoverSourceModules directory + pure false + catch error => + pure ((error.toString.splitOn "Lean package directory").length > 1) + unless emptyRejected do + throw <| IO.userError "source discovery accepted a directory outside the Lean package" + IO.FS.writeFile (directory / "lakefile.toml") "" + for root in #["CapacityAtlas", "CapacityAtlasForMathlib", "CapacityAtlasUtil"] do + IO.FS.writeFile (directory / s!"{root}.lean") "" + IO.FS.createDirAll (directory / root) + let nested := directory / "CapacityAtlasForMathlib" / "Unimported" + IO.FS.createDirAll nested + IO.FS.writeFile (nested / "NewTheorem.lean") "" + IO.FS.writeFile (nested / "DeletedTheorem.olean") "" + IO.FS.writeFile (directory / "Unrelated.lean") "" + let modules ← discoverSourceModules directory + let expected := #[`CapacityAtlas, `CapacityAtlasForMathlib, + `CapacityAtlasForMathlib.Unimported.NewTheorem, `CapacityAtlasUtil] + unless modules == expected.qsort Lean.Name.quickLt do + throw <| IO.userError s!"source discovery omitted a current module or included stale artifacts: {modules}" diff --git a/lean/CapacityAtlasAuditTests/TrustBoundary.lean b/lean/CapacityAtlasAuditTests/TrustBoundary.lean new file mode 100644 index 0000000..cf2c52c --- /dev/null +++ b/lean/CapacityAtlasAuditTests/TrustBoundary.lean @@ -0,0 +1,34 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlasAuditCore +import CapacityAtlas.Claims.GaussianWiretap + +open Lean CapacityAtlas.Audit CapacityAtlas.Metadata + +namespace CapacityAtlasAuditTests.TrustBoundary + +@[capacity_problem "audit-fixture", capacity_claim "shared-research" 1, + capacity_statement, capacity_solved, capacity_shared_api] +theorem sharedResearch : True := True.intro + +run_meta do + let env ← getEnv + let declaration := `CapacityAtlas.Claims.gaussianWiretap + unless (← Lean.collectAxioms declaration).contains ``sorryAx do + throwError "trust fixture no longer refers to an admitted research claim" + let some moduleIndex := env.getModuleIdxFor? declaration + | throwError "trust fixture is missing its imported module" + let problemModule := env.header.moduleNames[moduleIndex]! + unless ← allowsResearchAdmission env problemModule declaration do + throwError "audit policy rejected a registered problem-layer research admission" + for moduleName in #[`CapacityAtlasForMathlib.InformationTheory, `CapacityAtlasUtil.Metadata] do + if ← allowsResearchAdmission env moduleName declaration then + throwError "audit policy permitted a research admission in the trusted library {moduleName}" + if ← allowsResearchAdmission env `CapacityAtlas.Claims ``sharedResearch then + throwError "audit policy permitted a reusable API research admission" + +end CapacityAtlasAuditTests.TrustBoundary diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/CausalState/BlockInformation.lean b/lean/CapacityAtlasForMathlib/InformationTheory/CausalState/BlockInformation.lean index 5e0d65f..723b779 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/CausalState/BlockInformation.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/CausalState/BlockInformation.lean @@ -59,7 +59,7 @@ theorem latentExtension_relabel_eq_block (state : FiniteDistribution S) ring /-- Every causal encoder family obeys the strategy-channel block information bound. -/ -theorem block_mutualInformation_le [Nonempty X] (state : FiniteDistribution S) +theorem block_mutualInformation_le (state : FiniteDistribution S) (channels : S → FiniteChannel X Y) (n : ℕ) (encode : M → CausalState.Policy S X n) (input : FiniteDistribution M) : ((CausalState.blockChannel state channels n).encoded encode).mutualInformation input ≤ diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/CausalState/Converse.lean b/lean/CapacityAtlasForMathlib/InformationTheory/CausalState/Converse.lean index 63dac1b..e5f8d2b 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/CausalState/Converse.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/CausalState/Converse.lean @@ -18,7 +18,7 @@ namespace CapacityAtlasCausal attribute [local instance] Classical.propDecidable -variable {X S Y : Type*} [Fintype X] [Fintype S] [Fintype Y] [Nonempty X] +variable {X S Y : Type*} [Fintype X] [Fintype S] [Fintype Y] /-- Fano bounds the message count for every deterministic causal code. -/ theorem blockCode_log_messageCount_le (state : FiniteDistribution S) @@ -51,7 +51,7 @@ theorem blockCode_rate_bound (state : FiniteDistribution S) exact fano_rate_bound hblocklength (blockCode_log_messageCount_le state channels code) /-- Past state dependence cannot increase the achievable rate beyond strategy capacity. -/ -theorem achievableRate_le_strategyCapacity (state : FiniteDistribution S) +theorem achievableRate_le_strategyCapacity [Nonempty X] (state : FiniteDistribution S) (channels : S → FiniteChannel X Y) {rate : ℝ} (hachievable : CausalState.AchievableRate state channels rate) : rate ≤ (CausalState.strategyChannel state channels).informationCapacityBits := by @@ -65,7 +65,7 @@ theorem achievableRate_le_strategyCapacity (state : FiniteDistribution S) (blockCode_rate_bound state channels code (lt_of_lt_of_le hfirstPositive hn)) /-- Shannon strategy coding and the causal converse identify operational capacity. -/ -theorem causalStateCapacity (state : FiniteDistribution S) +theorem causalStateCapacity [Nonempty X] (state : FiniteDistribution S) (channels : S → FiniteChannel X Y) : CausalState.operationalCapacityBits state channels = (CausalState.strategyChannel state channels).informationCapacityBits := by @@ -85,7 +85,7 @@ theorem causalStateCapacity (state : FiniteDistribution S) (strategy.achievableRate_of_lt_informationCapacityBits hrate)) /-- The finite strategy alphabet admits an input attaining causal operational capacity. -/ -theorem exists_capacityAchieving_strategy (state : FiniteDistribution S) +theorem exists_capacityAchieving_strategy [Nonempty X] (state : FiniteDistribution S) (channels : S → FiniteChannel X Y) : ∃ input : FiniteDistribution (S → X), (CausalState.strategyChannel state channels).mutualInformationBits input = diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/ConfidentialBroadcast/ConditionalDensity.lean b/lean/CapacityAtlasForMathlib/InformationTheory/ConfidentialBroadcast/ConditionalDensity.lean index f8e561f..18bc6c8 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/ConfidentialBroadcast/ConditionalDensity.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/ConfidentialBroadcast/ConditionalDensity.lean @@ -41,7 +41,7 @@ theorem block_informationDensity_productFamily (W : FiniteChannel X Y) (n : ℕ) rw [block_transition, block_outputDistribution_productFamily, ← Finset.prod_div_distrib, Real.log_prod (fun i _ ↦ div_ne_zero (htransition i).ne' (houtput i).ne')] -theorem block_mutualInformationBits_productFamily_le [DecidableEq X] +theorem block_mutualInformationBits_productFamily_le (W : FiniteChannel X Y) (n : ℕ) (p : Fin n → FiniteDistribution X) : (W.block n).mutualInformationBits (FiniteDistribution.productFamily p) ≤ ∑ i, W.mutualInformationBits (p i) := by diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/ConfidentialBroadcast/CoordinateLaw.lean b/lean/CapacityAtlasForMathlib/InformationTheory/ConfidentialBroadcast/CoordinateLaw.lean index 921c897..8e8c264 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/ConfidentialBroadcast/CoordinateLaw.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/ConfidentialBroadcast/CoordinateLaw.lean @@ -253,7 +253,7 @@ theorem fullJoint_coordinate_eavesdropper (c : Code W n) (i : Fin n) : FiniteDistribution.map_joint_snd, receiverPair, FiniteChannel.rowDistribution_ofRows, FiniteDistribution.map_snd_joint, FiniteDistribution.mixture_const] using h -omit [DecidableEq Y] [DecidableEq Z] in +omit [DecidableEq X] [DecidableEq Y] [DecidableEq Z] in @[capacity_shared_api] theorem fullJoint_observe {O : Type*} [Fintype O] [DecidableEq O] (c : Code W n) (V : FiniteChannel X O) (observe : Y × Z → O) @@ -283,7 +283,7 @@ theorem fullJoint_observe {O : Type*} [Fintype O] [DecidableEq O] simpa only [FiniteDistribution.map_map, Function.comp_def, FiniteInformation.joint_comp, joint, induced] using h -omit [DecidableEq Z] in +omit [DecidableEq X] [DecidableEq Z] in @[capacity_shared_api] theorem fullJoint_legitimate (c : Code W n) : c.fullJoint.map (fun z ↦ (z.1.1, fun j ↦ (z.2 j).1)) = c.joint W.receiver₁ := by @@ -295,7 +295,7 @@ theorem fullJoint_legitimate (c : Code W n) : exact FiniteDistribution.map_fst_joint (W.receiver₁.rowDistribution x) (fun _ ↦ W.receiver₂.rowDistribution x) -omit [DecidableEq Y] in +omit [DecidableEq X] [DecidableEq Y] in @[capacity_shared_api] theorem fullJoint_eavesdropper (c : Code W n) : c.fullJoint.map (fun z ↦ (z.1.1, fun j ↦ (z.2 j).2)) = c.joint W.receiver₂ := by diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/ConfidentialBroadcast/EnsembleCodeBounds.lean b/lean/CapacityAtlasForMathlib/InformationTheory/ConfidentialBroadcast/EnsembleCodeBounds.lean index d8dce97..9bc4d7f 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/ConfidentialBroadcast/EnsembleCodeBounds.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/ConfidentialBroadcast/EnsembleCodeBounds.lean @@ -54,7 +54,7 @@ theorem rawCommonError_nonnegative {A O : Type*} [Fintype A] [Fintype O] intro c s l exact Finset.sum_nonneg fun y _ ↦ by split_ifs; exact W.nonnegative _ y; rfl -theorem rawSatelliteError_nonnegative {A O : Type*} [Fintype A] [Fintype O] +theorem rawSatelliteError_nonnegative {A O : Type*} [Fintype O] (q : A → FiniteDistribution (Fin n → V)) (tau : A → ℝ) (cloud : Fin C → A) (satellites : Fin C → (Fin S × Fin L) → Fin n → V) (W : FiniteChannel (Fin n → V) O) : diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/Entropy/Kernel.lean b/lean/CapacityAtlasForMathlib/InformationTheory/Entropy/Kernel.lean index d5fd452..7050bb4 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/Entropy/Kernel.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/Entropy/Kernel.lean @@ -75,22 +75,18 @@ lemma aefiniteKernelSupport_condDistrib rw [ha] exact finiteSupport_of_finiteRange.finite -lemma entropy_comap_equiv [MeasurableSingletonClass T] - {T' : Type*} [MeasurableSpace T'] [MeasurableSingletonClass T'] - (κ : Kernel T S) {μ : Measure T} (f : T' ≃ᵐ T) - [IsFiniteMeasure μ] [FiniteSupport μ] : +lemma entropy_comap_equiv {T' : Type*} [MeasurableSpace T'] + (κ : Kernel T S) {μ : Measure T} (f : T' ≃ᵐ T) : Hk[comap κ f f.measurable, μ.comap f] = Hk[κ, μ] := by simp only [entropy, ← MeasurableEquiv.map_symm, integral_map_equiv, coe_comap, Function.comp_apply, MeasurableEquiv.apply_symm_apply] -lemma entropy_comap_swap [MeasurableSingletonClass T] - {T' : Type*} [MeasurableSpace T'] [MeasurableSingletonClass T'] - (κ : Kernel (T' × T) S) {μ : Measure (T' × T)} [IsFiniteMeasure μ] [FiniteSupport μ] : +lemma entropy_comap_swap {T' : Type*} [MeasurableSpace T'] + (κ : Kernel (T' × T) S) {μ : Measure (T' × T)} : Hk[comap κ Prod.swap measurable_swap, μ.comap Prod.swap] = Hk[κ, μ] := entropy_comap_equiv κ MeasurableEquiv.prodComm -lemma entropy_prodMkLeft_unit [MeasurableSingletonClass T] - (κ : Kernel T S) {μ : Measure T} [IsZeroOrProbabilityMeasure μ] [FiniteSupport μ] : +lemma entropy_prodMkLeft_unit (κ : Kernel T S) {μ : Measure T} : Hk[prodMkLeft Unit κ, μ.map (Prod.mk ())] = Hk[κ, μ] := by convert entropy_comap_equiv κ (.punitProd) (μ := μ) · rfl diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/Entropy/RandomVariable.lean b/lean/CapacityAtlasForMathlib/InformationTheory/Entropy/RandomVariable.lean index dab9591..cd073d5 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/Entropy/RandomVariable.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/Entropy/RandomVariable.lean @@ -121,7 +121,7 @@ lemma condEntropy_two_eq_kernel_entropy (hX : Measurable X) (hY : Measurable Y) Hk[Kernel.condKernel (condDistrib (fun a ↦ (Y a, X a)) Z μ), Measure.map Z μ ⊗ₘ Kernel.fst (condDistrib (fun a ↦ (Y a, X a)) Z μ)] := by rw [Measure.compProd_congr (condDistrib_fst_ae_eq hY hX hZ μ), - map_compProd_condDistrib hY hZ, + map_compProd_condDistrib hY, Kernel.entropy_congr (condKernel_condDistrib_ae_eq hY hX hZ μ), ← Kernel.entropy_congr (swap_condDistrib_ae_eq hY hX hZ μ)] have : μ.map (fun ω ↦ (Z ω, Y ω)) = (μ.map (fun ω ↦ (Y ω, Z ω))).comap Prod.swap := by diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianAffineDeBruijn.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianAffineDeBruijn.lean index c7a2907..d53d3ba 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianAffineDeBruijn.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianAffineDeBruijn.lean @@ -142,7 +142,7 @@ theorem hasDerivAt_entropyWith_gaussianMixtureMeasure_add_isotropic _ = _ := by congr 1 simpa only [EuclideanSpace.basisFun_apply] using - sum_directionalFisherWith_gaussianMixturePDFReal_basis w hw hw1 m _ hNt + sum_directionalFisherWith_gaussianMixturePDFReal_basis w hw m _ hNt hN.isHermitian.eigenvectorBasis (EuclideanSpace.basisFun ι ℝ) /-- Every positive covariance direction admits an exact native entropy derivative. -/ diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianChannelEntropy.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianChannelEntropy.lean index 7cca10e..070b16c 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianChannelEntropy.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianChannelEntropy.lean @@ -29,7 +29,7 @@ lemma integrable_log_gaussianChannel_density (H : Matrix ο ι ℝ) (N : Matrix rw [gaussianChannel_compProd_eq_map] apply (integrable_map_measure (measurable_gaussianChannel_density H N).log.aestronglyMeasurable (by fun_prop)).mpr - have hnoise := integrable_log_multivariateGaussianPDFReal 0 N hN + have hnoise := integrable_log_multivariateGaussianPDFReal 0 N (integrable_covarianceQuadratic_multivariateGaussian 0 N hN) simpa only [Function.comp_def, gaussianChannel_density_physical] using hnoise.comp_snd μ diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianDeBruijn.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianDeBruijn.lean index 9d511dd..2789631 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianDeBruijn.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianDeBruijn.lean @@ -110,16 +110,26 @@ lemma integrable_gaussianMixture_lineDeriv_lineDeriv_mul (w : α → ℝ) (integrable_gaussian_lineDeriv_lineDeriv_mul (m k) v N hN f (hf k)).const_mul (w k)) lemma hasLineDerivAt_one_add_log_gaussianMixturePDFReal - (w : α → ℝ) (hw : ∀ a, 0 ≤ w a) (hw1 : ∑ a, w a = 1) + (w : α → ℝ) (hw : ∀ a, 0 ≤ w a) (m : α → EuclideanSpace ℝ ι) (N : Matrix ι ι ℝ) (hN : N.PosDef) (x v : EuclideanSpace ℝ ι) : HasLineDerivAt ℝ (fun y ↦ 1 + log (gaussianMixturePDFReal w m N y)) (lineDeriv ℝ (gaussianMixturePDFReal w m N) x v / gaussianMixturePDFReal w m N x) x v := by - have hp := hasLineDerivAt_gaussianMixturePDFReal w m N hN x v - have hpos := gaussianMixturePDFReal_pos w hw hw1 m N hN x - unfold HasLineDerivAt at hp ⊢ - have hd := hp.log (by simpa only [zero_smul, add_zero] using hpos.ne') - simpa only [zero_smul, add_zero] using hd.const_add 1 + by_cases hpos : ∃ j, 0 < w j + · obtain ⟨j, hj⟩ := hpos + have hp := hasLineDerivAt_gaussianMixturePDFReal w m N hN x v + have hpositive := gaussianMixturePDFReal_pos_of_pos_weight w hw m N hN j hj x + unfold HasLineDerivAt at hp ⊢ + have hd := hp.log (by simpa only [zero_smul, add_zero] using hpositive.ne') + simpa only [zero_smul, add_zero] using hd.const_add 1 + · have hwzero : ∀ j, w j = 0 := fun j ↦ le_antisymm + (le_of_not_gt (fun hj ↦ hpos ⟨j, hj⟩)) (hw j) + have hdensity : gaussianMixturePDFReal w m N = fun _ ↦ 0 := by + funext y + simp [gaussianMixturePDFReal, hwzero] + simp only [hdensity, Real.log_zero, add_zero, div_zero] + unfold HasLineDerivAt + simpa using (hasDerivAt_const (0 : ℝ) (1 : ℝ)) /-- Integration by parts identifies the entropy's directional second-derivative term. -/ theorem integral_one_add_log_mul_secondDeriv_gaussianMixture @@ -152,7 +162,7 @@ theorem integral_one_add_log_mul_secondDeriv_gaussianMixture (B := ContinuousLinearMap.mul ℝ ℝ) (μ := volume) hfisher (by simpa only [ContinuousLinearMap.mul_apply', mul_comm] using hsecond) (by simpa only [ContinuousLinearMap.mul_apply', mul_comm] using hfirst) - (fun x _ ↦ hasLineDerivAt_one_add_log_gaussianMixturePDFReal w hw hw1 m (t • N) (hN.smul ht) x v) + (fun x _ ↦ hasLineDerivAt_one_add_log_gaussianMixturePDFReal w hw m (t • N) (hN.smul ht) x v) (fun x _ ↦ hasLineDerivAt_lineDeriv_gaussianMixturePDFReal w m (t • N) (hN.smul ht) x v) convert! h using 1 congr 1 diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianFiniteConditioning.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianFiniteConditioning.lean index 18b02dd..aed3b6d 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianFiniteConditioning.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianFiniteConditioning.lean @@ -50,7 +50,7 @@ theorem gaussianCodebookKernel_output_ac (μ : Measure α) [IsProbabilityMeasure gaussianCodebookKernel m N ∘ₘ μ ≪ volume := gaussianMixture_absolutelyContinuous μ _ m N hN (fun _ ↦ rfl) -theorem gaussianCodebookKernel_comp_map (μ : Measure α) [IsProbabilityMeasure μ] +theorem gaussianCodebookKernel_comp_map (μ : Measure α) (f : α → β) (m : β → EuclideanSpace ℝ ι) (N : Matrix ι ι ℝ) : gaussianCodebookKernel m N ∘ₘ μ.map f = gaussianCodebookKernel (m ∘ f) N ∘ₘ μ := by ext s hs @@ -79,8 +79,8 @@ instance gaussianMarginalCodebookKernel_isMarkovKernel (ν : Measure β) [IsProb (m : α → β → EuclideanSpace ℝ ι) (N : Matrix ι ι ℝ) (a : α) : gaussianMarginalCodebookKernel ν m N a = gaussianCodebookKernel (m a) N ∘ₘ ν := rfl -theorem gaussianMarginalCodebookKernel_comp (μ : Measure α) [IsProbabilityMeasure μ] - (ν : Measure β) [IsProbabilityMeasure ν] +theorem gaussianMarginalCodebookKernel_comp (μ : Measure α) + (ν : Measure β) (m : α → β → EuclideanSpace ℝ ι) (N : Matrix ι ι ℝ) : gaussianMarginalCodebookKernel ν m N ∘ₘ μ = gaussianCodebookKernel (fun p : α × β ↦ m p.1 p.2) N ∘ₘ μ.prod ν := by diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianFisherBasis.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianFisherBasis.lean index 89748a8..5551951 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianFisherBasis.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianFisherBasis.lean @@ -39,7 +39,7 @@ lemma differentiable_gaussianMixturePDFReal (w : α → ℝ) (m : α → Euclide /-- The total Fisher information is independent of the orthonormal basis. -/ theorem sum_directionalFisherWith_gaussianMixturePDFReal_basis - (w : α → ℝ) (hw : ∀ a, 0 ≤ w a) (hw1 : ∑ a, w a = 1) + (w : α → ℝ) (hw : ∀ a, 0 ≤ w a) (m : α → EuclideanSpace ℝ ι) (N : Matrix ι ι ℝ) (hN : N.PosDef) (b b' : OrthonormalBasis ι ℝ (EuclideanSpace ℝ ι)) : (∑ i, directionalFisherWith volume (gaussianMixturePDFReal w m N) (b i)) = @@ -51,7 +51,7 @@ theorem sum_directionalFisherWith_gaussianMixturePDFReal_basis intro a exact (memLp_two_iff_integrable_sq (measurable_directionalScore_gaussianMixturePDFReal w m N hN v).aestronglyMeasurable).mp - (memLp_directionalScore_gaussianMixturePDFReal w hw hw1 m N hN v (m a) N 2 (by norm_num)) + (memLp_directionalScore_gaussianMixturePDFReal w hw m N hN v (m a) N 2 (by norm_num)) simp_rw [directionalFisherWith_eq_gaussianMixtureMeasure w hw m N hN] rw [← integral_finsetSum Finset.univ (fun i _ ↦ hint (b i)), ← integral_finsetSum Finset.univ (fun i _ ↦ hint (b' i))] apply integral_congr_ae diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianFisherConvolution.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianFisherConvolution.lean index 5b8d619..0955593 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianFisherConvolution.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianFisherConvolution.lean @@ -49,7 +49,7 @@ lemma integral_score_fst_mul_sum_gaussianMixture measurable_lineDeriv_directionalScore_gaussianMixturePDFReal w hw hw1 _ _ hNS v have hC : MemLp C 2 (gaussianMixtureMeasure w (fun a ↦ m a + n) (N + S)) := memLp_two_gaussianMixtureMeasure hCm (fun a ↦ - memLp_directionalScore_gaussianMixturePDFReal w hw hw1 _ _ hNS v _ _ 2 (by norm_num)) + memLp_directionalScore_gaussianMixturePDFReal w hw _ _ hNS v _ _ 2 (by norm_num)) have hC' : MemLp C' 2 (gaussianMixtureMeasure w (fun a ↦ m a + n) (N + S)) := memLp_two_gaussianMixtureMeasure hC'm (fun a ↦ memLp_two_lineDeriv_directionalScore_gaussianMixturePDFReal w hw hw1 _ _ hNS v _ _) @@ -58,7 +58,7 @@ lemma integral_score_fst_mul_sum_gaussianMixture have hA : MemLp (directionalScore (gaussianMixturePDFReal w m N) v) 2 (gaussianMixtureMeasure w m N) := memLp_two_gaussianMixtureMeasure (measurable_directionalScore_gaussianMixturePDFReal w m N hN v) - (fun a ↦ memLp_directionalScore_gaussianMixturePDFReal w hw hw1 m N hN v _ _ 2 (by norm_num)) + (fun a ↦ memLp_directionalScore_gaussianMixturePDFReal w hw m N hN v _ _ 2 (by norm_num)) have hint := (hA.comp_fst (multivariateGaussian n S)).integrable_mul hsum have hint' := hsum'.integrable (by norm_num) change (∫ z, directionalScore (gaussianMixturePDFReal w m N) v z.1 * C (z.1 + z.2) @@ -77,7 +77,7 @@ lemma integral_score_fst_mul_sum_gaussianMixture simpa only [C, C', q, HasLineDerivAt, add_assoc, add_left_comm, add_comm] using hd · intro a exact memLp_comp_add_const_multivariateGaussian hCm (m a) y N - (memLp_directionalScore_gaussianMixturePDFReal w hw hw1 _ _ hNS v _ _ 2 (by norm_num)) + (memLp_directionalScore_gaussianMixturePDFReal w hw _ _ hNS v _ _ 2 (by norm_num)) · intro a exact (memLp_comp_add_const_multivariateGaussian hC'm (m a) y N (memLp_two_lineDeriv_directionalScore_gaussianMixturePDFReal @@ -107,7 +107,7 @@ lemma integral_score_snd_mul_sum_gaussianMixture measurable_lineDeriv_directionalScore_gaussianMixturePDFReal w hw hw1 _ _ hNS v have hC : MemLp C 2 (gaussianMixtureMeasure w (fun a ↦ m a + n) (N + S)) := memLp_two_gaussianMixtureMeasure hCm (fun a ↦ - memLp_directionalScore_gaussianMixturePDFReal w hw hw1 _ _ hNS v _ _ 2 (by norm_num)) + memLp_directionalScore_gaussianMixturePDFReal w hw _ _ hNS v _ _ 2 (by norm_num)) have hC' : MemLp C' 2 (gaussianMixtureMeasure w (fun a ↦ m a + n) (N + S)) := memLp_two_gaussianMixtureMeasure hC'm (fun a ↦ memLp_two_lineDeriv_directionalScore_gaussianMixturePDFReal w hw hw1 _ _ hNS v _ _) @@ -131,7 +131,7 @@ lemma integral_score_snd_mul_sum_gaussianMixture w hw hw1 (fun a ↦ m a + n) (N + S) hNS v (x + y)).lineDifferentiableAt.hasLineDerivAt simpa only [C, C', q, HasLineDerivAt, add_assoc, add_left_comm, add_comm] using hd · simpa only [add_comm] using memLp_comp_add_const_multivariateGaussian hCm n x S - (memLp_directionalScore_gaussianMixturePDFReal w hw hw1 _ _ hNS v _ _ 2 (by norm_num)) + (memLp_directionalScore_gaussianMixturePDFReal w hw _ _ hNS v _ _ 2 (by norm_num)) · have hi := (memLp_comp_add_const_multivariateGaussian hC'm n x S (memLp_two_lineDeriv_directionalScore_gaussianMixturePDFReal w hw hw1 _ _ hNS v _ _)).integrable (by norm_num) @@ -203,14 +203,14 @@ theorem directionalFisherWith_gaussianMixture_add_le have hNS := hN.add hS have hA : MemLp A 2 μ := memLp_two_gaussianMixtureMeasure (measurable_directionalScore_gaussianMixturePDFReal w m N hN v) - (fun a ↦ memLp_directionalScore_gaussianMixturePDFReal w hw hw1 m N hN v _ _ 2 (by norm_num)) + (fun a ↦ memLp_directionalScore_gaussianMixturePDFReal w hw m N hN v _ _ 2 (by norm_num)) have hB : MemLp B 2 ν := memLp_directionalScore_multivariateGaussianPDFReal n v n S S hS 2 (by norm_num) have hCm : Measurable C := measurable_directionalScore_gaussianMixturePDFReal w _ _ hNS v have hC : MemLp (fun z : EuclideanSpace ℝ ι × EuclideanSpace ℝ ι ↦ C (z.1 + z.2)) 2 (μ.prod ν) := memLp_comp_add_gaussianMixture w m n N S hN.posSemidef hS.posSemidef hCm (memLp_two_gaussianMixtureMeasure hCm (fun a ↦ - memLp_directionalScore_gaussianMixturePDFReal w hw hw1 _ _ hNS v _ _ 2 (by norm_num))) + memLp_directionalScore_gaussianMixturePDFReal w hw _ _ hNS v _ _ 2 (by norm_num))) have hA2 : (∫ z : EuclideanSpace ℝ ι × EuclideanSpace ℝ ι, A z.1 ^ 2 ∂μ.prod ν) = directionalFisherWith volume (gaussianMixturePDFReal w m N) v := by rw [integral_fun_fst (fun x ↦ A x ^ 2), probReal_univ, one_smul, diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/Capacity.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/Capacity.lean index 6906ee1..84a50a7 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/Capacity.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/Capacity.lean @@ -15,7 +15,7 @@ namespace CapacityAtlas.Gaussian.Interference /-- The fully connected time-varying interference channel has K/2 sum degrees of freedom. -/ theorem sum_degrees_of_freedom (μ : Measure ℂ) [IsProbabilityMeasure μ] [NullSingletonClass μ] - {K : ℕ} (hK : 2 ≤ K) {L U : ℝ} (hL : 0 < L) (hU : 0 ≤ U) + {K : ℕ} (hK : 2 ≤ K) {L U : ℝ} (hL : 0 < L) (hμ : ∀ᵐ z ∂μ, L ≤ ‖z‖ ∧ ‖z‖ ≤ U) : Tendsto (fun P : ℝ ↦ sumCapacity μ K P / Real.logb 2 P) atTop (𝓝 ((K : ℝ) / 2)) := by @@ -23,13 +23,13 @@ theorem sum_degrees_of_freedom (μ : Measure ℂ) [IsProbabilityMeasure μ] [Nul have hUp : 0 < U := annulus_upper_pos μ hL hμ let F : ℝ → ℝ := fun P ↦ sumCapacity μ K P * Real.log 2 have hmono : Monotone F := fun P P' h ↦ - mul_le_mul_of_nonneg_right (sumCapacity_monotone μ hL hU hμ hK h) hlog.le + mul_le_mul_of_nonneg_right (sumCapacity_monotone μ hL hμ hK h) hlog.le have hc : 0 < U ^ 2 / converseNoise L U := by exact div_pos (sq_pos_of_pos hUp) (converseNoise_pos hL) have hupper : ∀ᶠ P : ℝ in atTop, F P ≤ (K : ℝ) / 2 * Real.log (1 + (U ^ 2 / converseNoise L U) * P) := by filter_upwards [eventually_ge_atTop (0 : ℝ)] with P hP - have hp := mul_le_mul_of_nonneg_right (sumCapacity_converse μ hL hU hP hμ hK) hlog.le + have hp := mul_le_mul_of_nonneg_right (sumCapacity_converse μ hL hP hμ hK) hlog.le change F P ≤ _ at hp convert hp using 1 rw [Real.logb] @@ -43,7 +43,7 @@ theorem sum_degrees_of_freedom (μ : Measure ℂ) [IsProbabilityMeasure μ] [Nul extensionLength K n) * Real.log q - b ≤ F (C * (q : ℝ) ^ 2) := by intro n hn ε hε exact exists_quadratic_grid_lower μ (by omega) U - (hμ.mono fun _ h ↦ h.2) (sumRates_bddAbove_all μ hL hU hμ hK) hn hε + (hμ.mono fun _ h ↦ h.2) (sumRates_bddAbove_all μ hL hμ hK) hn hε have hpre := prelog_of_alignment_grid hmono hc hupper hlower convert hpre using 1 funext P diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/CapacityConverse.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/CapacityConverse.lean index 48612c8..a9e967c 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/CapacityConverse.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/CapacityConverse.lean @@ -19,13 +19,13 @@ theorem rates_nonneg {K n : ℕ} (c : Code K n) (i : Fin K) : 0 ≤ rates c i := exact Real.logb_nonneg (by norm_num) (by exact_mod_cast c.messages_pos i) theorem code_pair_rates_bound (μ : Measure ℂ) [IsProbabilityMeasure μ] - {L U P : ℝ} (hL : 0 < L) (hU : 0 ≤ U) (hP : 0 ≤ P) + {L U P : ℝ} (hL : 0 < L) (hP : 0 ≤ P) (hμ : ∀ᵐ z ∂μ, L ≤ ‖z‖ ∧ ‖z‖ ≤ U) {K n : ℕ} (hn : 0 < n) (c : Code K n) (hc : PowerAdmissible μ P c) (i j : Fin K) (hij : i ≠ j) : (1 - error μ c) * (rates c i + rates c j) ≤ Real.logb 2 (1 + U ^ 2 * P / converseNoise L U) + 2 / n := by - have hf := code_pair_converse μ hL hU hP hμ c hc i j hij + have hf := code_pair_converse μ hL hP hμ c hc i j hij have hnR : (0 : ℝ) < n := Nat.cast_pos.mpr hn have hlog : 0 < Real.log 2 := Real.log_pos (by norm_num) have hd := div_le_div_of_nonneg_right hf (mul_pos hnR hlog).le @@ -38,7 +38,7 @@ theorem code_pair_rates_bound (μ : Measure ℂ) [IsProbabilityMeasure μ] field_simp theorem capacityRegion_pair_bound (μ : Measure ℂ) [IsProbabilityMeasure μ] - {L U P : ℝ} (hL : 0 < L) (hU : 0 ≤ U) (hP : 0 ≤ P) + {L U P : ℝ} (hL : 0 < L) (hP : 0 ≤ P) (hμ : ∀ᵐ z ∂μ, L ≤ ‖z‖ ∧ ‖z‖ ≤ U) {K : ℕ} {R : Fin K → ℝ} (hR : R ∈ capacityRegion μ K P) (i j : Fin K) (hij : i ≠ j) : @@ -58,7 +58,7 @@ theorem capacityRegion_pair_bound (μ : Measure ℂ) [IsProbabilityMeasure μ] have hscaled := mul_le_mul_of_nonneg_left hrate (sub_pos.mpr hε1).le have herrscaled := mul_le_mul_of_nonneg_right (sub_le_sub_left herr 1) (add_nonneg (rates_nonneg c i) (rates_nonneg c j)) - have hb := code_pair_rates_bound μ hL hU hP hμ (hN.trans_le hn) c hc i j hij + have hb := code_pair_rates_bound μ hL hP hμ (hN.trans_le hn) c hc i j hij dsimp only [B] nlinarith have hlim : Tendsto (fun ε : ℝ ↦ (1 - ε) * (R i + R j - 2 * ε)) @@ -73,39 +73,39 @@ theorem capacityRegion_pair_bound (μ : Measure ℂ) [IsProbabilityMeasure μ] exact heps ε hε hε1 theorem capacityRegion_sum_bound (μ : Measure ℂ) [IsProbabilityMeasure μ] - {L U P : ℝ} (hL : 0 < L) (hU : 0 ≤ U) (hP : 0 ≤ P) + {L U P : ℝ} (hL : 0 < L) (hP : 0 ≤ P) (hμ : ∀ᵐ z ∂μ, L ≤ ‖z‖ ∧ ‖z‖ ≤ U) {K : ℕ} (hK : 2 ≤ K) {R : Fin K → ℝ} (hR : R ∈ capacityRegion μ K P) : (∑ i, R i) ≤ (K : ℝ) / 2 * Real.logb 2 (1 + U ^ 2 * P / converseNoise L U) := - sum_le_of_pair_bounds hK R _ (fun i j hij ↦ capacityRegion_pair_bound μ hL hU hP hμ hR i j hij) + sum_le_of_pair_bounds hK R _ (fun i j hij ↦ capacityRegion_pair_bound μ hL hP hμ hR i j hij) theorem sumCapacity_converse (μ : Measure ℂ) [IsProbabilityMeasure μ] - {L U P : ℝ} (hL : 0 < L) (hU : 0 ≤ U) (hP : 0 ≤ P) + {L U P : ℝ} (hL : 0 < L) (hP : 0 ≤ P) (hμ : ∀ᵐ z ∂μ, L ≤ ‖z‖ ∧ ‖z‖ ≤ U) {K : ℕ} (hK : 2 ≤ K) : sumCapacity μ K P ≤ (K : ℝ) / 2 * Real.logb 2 (1 + U ^ 2 * P / converseNoise L U) := - sumCapacity_le hP (fun _ hR ↦ capacityRegion_sum_bound μ hL hU hP hμ hK hR) + sumCapacity_le hP (fun _ hR ↦ capacityRegion_sum_bound μ hL hP hμ hK hR) theorem sumRates_bddAbove (μ : Measure ℂ) [IsProbabilityMeasure μ] - {L U P : ℝ} (hL : 0 < L) (hU : 0 ≤ U) (hP : 0 ≤ P) + {L U P : ℝ} (hL : 0 < L) (hP : 0 ≤ P) (hμ : ∀ᵐ z ∂μ, L ≤ ‖z‖ ∧ ‖z‖ ≤ U) {K : ℕ} (hK : 2 ≤ K) : BddAbove {s | ∃ R ∈ capacityRegion μ K P, s = ∑ i, R i} := - sumRates_bddAbove_of_bound (fun _ hR ↦ capacityRegion_sum_bound μ hL hU hP hμ hK hR) + sumRates_bddAbove_of_bound (fun _ hR ↦ capacityRegion_sum_bound μ hL hP hμ hK hR) theorem sumRates_bddAbove_all (μ : Measure ℂ) [IsProbabilityMeasure μ] - {L U : ℝ} (hL : 0 < L) (hU : 0 ≤ U) + {L U : ℝ} (hL : 0 < L) (hμ : ∀ᵐ z ∂μ, L ≤ ‖z‖ ∧ ‖z‖ ≤ U) {K : ℕ} (hK : 2 ≤ K) (P : ℝ) : BddAbove {s | ∃ R ∈ capacityRegion μ K P, s = ∑ i, R i} := by - obtain ⟨B, hB⟩ := sumRates_bddAbove μ hL hU (le_max_right P 0) hμ hK + obtain ⟨B, hB⟩ := sumRates_bddAbove μ hL (le_max_right P 0) hμ hK refine ⟨B, ?_⟩ rintro s ⟨R, hR, rfl⟩ exact hB ⟨R, capacityRegion_mono μ K (le_max_left P 0) hR, rfl⟩ theorem sumCapacity_monotone (μ : Measure ℂ) [IsProbabilityMeasure μ] - {L U : ℝ} (hL : 0 < L) (hU : 0 ≤ U) + {L U : ℝ} (hL : 0 < L) (hμ : ∀ᵐ z ∂μ, L ≤ ‖z‖ ∧ ‖z‖ ≤ U) {K : ℕ} (hK : 2 ≤ K) : Monotone (sumCapacity μ K) := - monotone_sumCapacity μ K (sumRates_bddAbove_all μ hL hU hμ hK) + monotone_sumCapacity μ K (sumRates_bddAbove_all μ hL hμ hK) theorem annulus_upper_pos (μ : Measure ℂ) [IsProbabilityMeasure μ] {L U : ℝ} (hL : 0 < L) (hμ : ∀ᵐ z ∂μ, L ≤ ‖z‖ ∧ ‖z‖ ≤ U) : 0 < U := by diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/CodeConverse.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/CodeConverse.lean index a11abac..4059eeb 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/CodeConverse.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/CodeConverse.lean @@ -58,12 +58,15 @@ theorem stateLaw_ae_annulus (μ : Measure ℂ) [IsProbabilityMeasure μ] (i := t)).eventually hmatrix theorem code_pair_converse (μ : Measure ℂ) [IsProbabilityMeasure μ] - {L U P : ℝ} (hL : 0 < L) (hU : 0 ≤ U) (hP : 0 ≤ P) + {L U P : ℝ} (hL : 0 < L) (hP : 0 ≤ P) (hμ : ∀ᵐ z ∂μ, L ≤ ‖z‖ ∧ ‖z‖ ≤ U) {K n : ℕ} (c : Code K n) (hc : PowerAdmissible μ P c) (i j : Fin K) (hij : i ≠ j) : (1 - error μ c) * (Real.log (c.messages i) + Real.log (c.messages j)) ≤ (n : ℝ) * Real.log (1 + U ^ 2 * P / converseNoise L U) + 2 * Real.log 2 := by + have hU : 0 ≤ U := by + obtain ⟨z, hz⟩ := hμ.exists + exact (norm_nonneg z).trans hz.2 let e := converseNoise L U let t := e + U ^ 2 * P have he : 0 < e := converseNoise_pos hL @@ -74,7 +77,7 @@ theorem code_pair_converse (μ : Measure ℂ) [IsProbabilityMeasure μ] filter_upwards [hstate] with H hh exact ⟨fun s ↦ (hh s i i).2, fun s ↦ (hh s i j).2⟩ have hienergy := integrable_messageAverage μ c (fun m H ↦ pairEnergy c H i j m) - (integrable_pairEnergy μ c hc hU i j hij hupper) + (integrable_pairEnergy μ c hc i j hij hupper) have hierror (k : Fin K) := integrable_messageAverage μ c (fun m H ↦ receiverErrorAt c m H k) (fun m ↦ integrable_receiverErrorAt μ c m k) have herror (k : Fin K) : @@ -83,7 +86,7 @@ theorem code_pair_converse (μ : Measure ℂ) [IsProbabilityMeasure μ] exact average_receiverErrorAt_le_error μ c k have henergy : (∫ H, ∫ m, pairEnergy c H i j m ∂messageLaw c ∂stateLaw μ K n) ≤ 2 * n * (t - e) := by - convert integral_pairEnergy_le μ c hc hU i j hij hupper using 1 + convert integral_pairEnergy_le μ c hc i j hij hupper using 1 dsimp [t] ring have hpointwise : ∀ᵐ H ∂stateLaw μ K n, diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/CodeLaws.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/CodeLaws.lean index bcd222f..7c3d522 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/CodeLaws.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/CodeLaws.lean @@ -82,7 +82,7 @@ theorem integrable_receiverErrorAt (μ : Measure ℂ) [IsProbabilityMeasure μ] rw [Real.norm_eq_abs, abs_of_nonneg measureReal_nonneg] exact measureReal_le_one -theorem integral_receiverErrorAt (μ : Measure ℂ) [IsProbabilityMeasure μ] +theorem integral_receiverErrorAt (μ : Measure ℂ) (c : Code K n) (m : c.Message) (i : Fin K) : (∫ H, receiverErrorAt c m H i ∂stateLaw μ K n) = ((stateLaw μ K n).prod (blockNoise K n)).real (receiverEvent c m i) := by diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/ConverseEnergy.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/ConverseEnergy.lean index 35c4bc5..974e802 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/ConverseEnergy.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/ConverseEnergy.lean @@ -30,7 +30,7 @@ theorem pairEnergy_nonneg (c : Code K n) (H : StateBlock K n) (i j : Fin K) (m : c.Message) : 0 ≤ pairEnergy c H i j m := sq_nonneg _ theorem pairEnergy_le_energy (c : Code K n) (H : StateBlock K n) (i j : Fin K) - (hij : i ≠ j) (m : c.Message) {U : ℝ} (_hU : 0 ≤ U) + (hij : i ≠ j) (m : c.Message) {U : ℝ} (hHi : ∀ s, ‖H s i i‖ ≤ U) (hHj : ∀ s, ‖H s i j‖ ≤ U) : pairEnergy c H i j m ≤ 2 * U ^ 2 * energy c m H := by unfold pairEnergy userSignal @@ -65,14 +65,14 @@ theorem pairEnergy_le_energy (c : Code K n) (H : StateBlock K n) (i j : Fin K) nlinarith theorem integrable_pairEnergy (μ : Measure ℂ) (c : Code K n) {P U : ℝ} - (hc : PowerAdmissible μ P c) (hU : 0 ≤ U) (i j : Fin K) (hij : i ≠ j) + (hc : PowerAdmissible μ P c) (i j : Fin K) (hij : i ≠ j) (hH : ∀ᵐ H ∂stateLaw μ K n, (∀ s, ‖H s i i‖ ≤ U) ∧ (∀ s, ‖H s i j‖ ≤ U)) (m : c.Message) : Integrable (fun H ↦ pairEnergy c H i j m) (stateLaw μ K n) := by apply Integrable.mono' ((hc.1 m).const_mul (2 * U ^ 2)) (measurable_pairEnergy c i j m).aestronglyMeasurable filter_upwards [hH] with H hh rw [Real.norm_eq_abs, abs_of_nonneg (pairEnergy_nonneg c H i j m)] - exact pairEnergy_le_energy c H i j hij m hU hh.1 hh.2 + exact pairEnergy_le_energy c H i j hij m hh.1 hh.2 theorem integrable_messageAverage (μ : Measure ℂ) (c : Code K n) (f : c.Message → StateBlock K n → ℝ) @@ -90,18 +90,18 @@ theorem integral_state_messageAverage (μ : Measure ℂ) (c : Code K n) rw [integral_const_mul, integral_finsetSum Finset.univ (fun m _ ↦ hf m)] theorem integral_pairEnergy_le (μ : Measure ℂ) (c : Code K n) {P U : ℝ} - (hc : PowerAdmissible μ P c) (hU : 0 ≤ U) (i j : Fin K) (hij : i ≠ j) + (hc : PowerAdmissible μ P c) (i j : Fin K) (hij : i ≠ j) (hH : ∀ᵐ H ∂stateLaw μ K n, (∀ s, ‖H s i i‖ ≤ U) ∧ (∀ s, ‖H s i j‖ ≤ U)) : (∫ H, ∫ m, pairEnergy c H i j m ∂messageLaw c ∂stateLaw μ K n) ≤ 2 * U ^ 2 * ((n : ℝ) * P) := by - have hp (m : c.Message) := integrable_pairEnergy μ c hc hU i j hij hH m + have hp (m : c.Message) := integrable_pairEnergy μ c hc i j hij hH m rw [integral_state_messageAverage μ c _ hp, integral_messageLaw] have hi (m : c.Message) : (∫ H, pairEnergy c H i j m ∂stateLaw μ K n) ≤ 2 * U ^ 2 * (∫ H, energy c m H ∂stateLaw μ K n) := by rw [← integral_const_mul] apply integral_mono_ae (hp m) ((hc.1 m).const_mul _) filter_upwards [hH] with H hh - exact pairEnergy_le_energy c H i j hij m hU hh.1 hh.2 + exact pairEnergy_le_energy c H i j hij m hh.1 hh.2 calc _ ≤ (∏ i, (c.messages i : ℝ))⁻¹ * ∑ m, 2 * U ^ 2 * (∫ H, energy c m H ∂stateLaw μ K n) := diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMIMOBroadcast/AchievabilityClosure.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMIMOBroadcast/AchievabilityClosure.lean index 0f3b24e..ff89d9d 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMIMOBroadcast/AchievabilityClosure.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMIMOBroadcast/AchievabilityClosure.lean @@ -23,11 +23,10 @@ theorem mem_capacityRegion_no_receivers {rx : Fin 0 → ℕ} theorem capacityRegion_eq_region_no_transmit_antennas (H : (i : Fin K) → Matrix (Fin (rx i)) (Fin 0) ℝ) (N : (i : Fin K) → Matrix (Fin (rx i)) (Fin (rx i)) ℝ) - (hN : ∀ i, (N i).PosDef) {P : ℝ} (hP : 0 ≤ P) : + {P : ℝ} (hP : 0 ≤ P) : capacityRegion H N P = region H N P := by have hH : H = 0 := by funext i a b; exact Fin.elim0 b - rw [hH] - exact capacityRegion_eq_region_zero_channel N hN hP + rw [hH, capacityRegion_zero_channel N hP, region_zero_channel N hP] /-- Strict interior coding suffices for the full closed convex DPC region. -/ theorem region_subset_capacityRegion_of_strict_dpc_achievable @@ -44,7 +43,7 @@ theorem region_subset_capacityRegion_of_strict_dpc_achievable exact fun R _ ↦ mem_capacityRegion_no_receivers H N hP R by_cases htx : tx = 0 · subst tx - rw [capacityRegion_eq_region_no_transmit_antennas H N hN hP] + rw [capacityRegion_eq_region_no_transmit_antennas H N hP] by_cases hPzero : P = 0 · subst P rw [capacityRegion_eq_region_zero_power H N hN] diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMIMOBroadcast/Boundary.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMIMOBroadcast/Boundary.lean index d9eade5..8502bd5 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMIMOBroadcast/Boundary.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMIMOBroadcast/Boundary.lean @@ -21,9 +21,9 @@ theorem capacityRegion_eq_region_zero_power /-- Zero channel gains preclude information transmission at any nonnegative power. -/ theorem capacityRegion_eq_region_zero_channel (N : (i : Fin K) → Matrix (Fin (rx i)) (Fin (rx i)) ℝ) - (hN : ∀ i, (N i).PosDef) {P : ℝ} (hP : 0 ≤ P) : + {P : ℝ} (hP : 0 ≤ P) : capacityRegion (0 : (i : Fin K) → Matrix (Fin (rx i)) (Fin tx) ℝ) N P = region (tx := tx) 0 N P := by - rw [capacityRegion_zero_channel N hP, region_zero_channel N hN hP] + rw [capacityRegion_zero_channel N hP, region_zero_channel N hP] end CapacityAtlas.Gaussian.MIMOBroadcast diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMIMOBroadcast/EnhancedEntropy.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMIMOBroadcast/EnhancedEntropy.lean index 94233a8..7b34034 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMIMOBroadcast/EnhancedEntropy.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMIMOBroadcast/EnhancedEntropy.lean @@ -17,11 +17,12 @@ variable {K tx n : ℕ} {rx : Fin K → ℕ} theorem codePrefixEntropy_difference_le (c : Code K tx rx n) (htx : 0 < tx) (hn : 0 < n) (E F S : Matrix (Fin tx) (Fin tx) ℝ) (hE : E.PosDef) (hF : F.PosDef) (hS : S.PosSemidef) - {f g : ℝ} (hf : 0 < f) (hg : 0 < g) (hfg : f ≤ g) + {f g : ℝ} (hf : 0 < f) (hfg : f ≤ g) (hprop : g • (S + F)⁻¹ = f • (S + E)⁻¹) (k : ℕ) : f * codePrefixEntropy c E k - g * codePrefixEntropy c F k ≤ n * (f * MeasureInformation.entropyWith (multivariateGaussian 0 (S + E)) volume - g * MeasureInformation.entropyWith (multivariateGaussian 0 (S + F)) volume) := by + have hg : 0 < g := lt_of_lt_of_le hf hfg letI : Nonempty (Fin tx) := ⟨⟨0, htx⟩⟩ letI : Nonempty (Fin n) := ⟨⟨0, hn⟩⟩ have hSE := PosDef.posSemidef_add hS hE @@ -118,7 +119,7 @@ theorem weighted_codePrefixEntropy_le (c : Code (m + 1) tx rx n) (htx : 0 < tx) codePrefixEntropy_difference_le c htx hn (E k.castSucc) (E k.succ) (prefixCovariance Q (Equiv.refl _) k.succ) (hE _) (hE _) (prefixCovariance_posSemidef Q hQ.1 (Equiv.refl _) k.succ) - (hw _) (hw _) (hm k.castSucc_lt_succ.le) (hprop k) (k.val + 1)) + (hw _) (hm k.castSucc_lt_succ.le) (hprop k) (k.val + 1)) have ht := codePrefixEntropy_last_le c (E (Fin.last m)) (∑ k, Q k) (hE _) (posSemidef_sum _ (fun k _ ↦ hQ.1 k)) hc (hw _).le hlam hstat (by simpa only [trace_sum] using hcomp) diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMIMOBroadcast/EnhancedSupport.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMIMOBroadcast/EnhancedSupport.lean index 9de7099..6fa6292 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMIMOBroadcast/EnhancedSupport.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMIMOBroadcast/EnhancedSupport.lean @@ -77,7 +77,7 @@ theorem adjacent_logObjective_le (prefix_add_noise_posDef Y E hY hE k.succ k.succ) (div_pos (hγ k.castSucc) (hγ k.succ)) ((div_le_one (hγ k.succ)).mpr (hm k.castSucc_lt_succ.le)) - (inv_proportional_smul ha hb hp) (by abel) + (inv_proportional_smul hb hp) (by abel) have hh := mul_le_mul_of_nonneg_left h (hγ k.succ).le have he : γ k.succ * (γ k.castSucc / γ k.succ) = γ k.castSucc := mul_div_cancel₀ _ (hγ k.succ).ne' diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMIMOBroadcast/LayeredOneShot.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMIMOBroadcast/LayeredOneShot.lean index 1b35b9f..295dc10 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMIMOBroadcast/LayeredOneShot.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMIMOBroadcast/LayeredOneShot.lean @@ -72,7 +72,7 @@ theorem exists_layeredCode_error_le (sequenceSuccess 0 (fun j ↦ (D j).next) (fun j ↦ (D j).success) K)ᶜ ≤ layeredFailureBound H N Q π order n L T := by simpa only [layeredFailureBound, layeredStateTail, blockLayerStateLikelihood, neg_mul] using - gaussianStages_failure_le_terminal H N Q hQ π order e horder hdesc n L T hT 0 + gaussianStages_failure_le_terminal H N Q hQ π order hdesc n L T hT 0 have href : sequenceReferenceLaw (fun j ↦ (D j).referenceKernel) (0 : LayerBlocks K tx n) K = blockLayerLaw Q π n := gaussianStages_referenceLaw H N Q hQ π order e horder n L T hT 0 rw [href] diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMIMOBroadcast/LayeredReadback.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMIMOBroadcast/LayeredReadback.lean index 0d469bd..c715a50 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMIMOBroadcast/LayeredReadback.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMIMOBroadcast/LayeredReadback.lean @@ -82,12 +82,17 @@ variable {rx : Fin K → ℕ} include e horder hdesc +omit e horder in theorem gaussianStages_jointBad_eq_terminal (i : Fin K) : let D := gaussianStages H N Q hQ π order n L T hT ((sequenceReferenceLaw (fun j ↦ (D j).referenceKernel) initial i.val) ⊗ₘ (D i.val).target) (D i.val).goodᶜ = (blockLayerLaw Q π n) {x | ENNReal.ofReal (T i.val) < blockLayerStateLikelihood (H (π (order i.val))) (N (π (order i.val))) Q π (order i.val) n x} := by + let f : Fin K → Fin K := fun j ↦ order j.val + have hinj : Function.Injective f := (show StrictAnti f from hdesc).injective + let e : Equiv.Perm (Fin K) := Equiv.ofBijective f ⟨hinj, Finite.surjective_of_injective hinj⟩ + have horder (j : Fin K) : order j.val = e j := rfl let D := gaussianStages H N Q hQ π order n L T hT let E : Set (LayerBlocks K tx n) := {x | ENNReal.ofReal (T i.val) < blockLayerStateLikelihood @@ -115,6 +120,7 @@ theorem gaussianStages_jointBad_eq_terminal (i : Fin K) : (hdesc i ⟨j, hjK⟩ (by exact Nat.lt_of_succ_le hij))] rfl +omit e horder in theorem gaussianStages_failure_le_terminal : let D := gaussianStages H N Q hQ π order n L T hT sequenceSampleLaw (fun j ↦ (D j).sampleLaw) K @@ -132,7 +138,7 @@ theorem gaussianStages_failure_le_terminal : intro i _ congr 1 unfold RejectionStage.failureBound - rw [gaussianStages_jointBad_eq_terminal H N Q hQ π order e horder hdesc n L T hT initial i] + rw [gaussianStages_jointBad_eq_terminal H N Q hQ π order hdesc n L T hT initial i] simp only [gaussianStages, gaussianRejectionStage, neg_mul] omit e horder in diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMIMOBroadcast/RegionProperties.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMIMOBroadcast/RegionProperties.lean index 07d61bb..f706974 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMIMOBroadcast/RegionProperties.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMIMOBroadcast/RegionProperties.lean @@ -124,22 +124,24 @@ theorem rawRegion_zero_power theorem dpcRate_zero_channel (N : (i : Fin K) → Matrix (Fin (rx i)) (Fin (rx i)) ℝ) (Q : Fin K → Matrix (Fin tx) (Fin tx) ℝ) - (hN : ∀ i, (N i).PosDef) (π : Equiv.Perm (Fin K)) (k : Fin K) : + (π : Equiv.Perm (Fin K)) (k : Fin K) : dpcRate 0 N Q π k = 0 := by - simp [dpcRate, receivedCovariance, (hN (π k)).det_pos.ne'] + by_cases hd : (N (π k)).det = 0 <;> simp [dpcRate, receivedCovariance, hd] theorem rawRegion_zero_channel (N : (i : Fin K) → Matrix (Fin (rx i)) (Fin (rx i)) ℝ) - (hN : ∀ i, (N i).PosDef) {P : ℝ} (hP : 0 ≤ P) : + {P : ℝ} (hP : 0 ≤ P) : rawRegion (0 : (i : Fin K) → Matrix (Fin (rx i)) (Fin tx) ℝ) N P = {0} := by apply Set.Subset.antisymm · rintro R ⟨hR, Q, _, π, hbound⟩ apply Set.mem_singleton_iff.mpr funext i apply le_antisymm _ (hR i) - simpa [dpcRate_zero_channel N Q hN] using hbound (π.symm i) + simpa [dpcRate_zero_channel N Q] using hbound (π.symm i) · rintro R rfl - exact zero_mem_rawRegion 0 N hN hP + refine ⟨fun _ ↦ le_rfl, 0, allocationAdmissible_zero hP, Equiv.refl _, ?_⟩ + intro k + simp [dpcRate_zero_channel N] theorem zero_mem_region (H : (i : Fin K) → Matrix (Fin (rx i)) (Fin tx) ℝ) @@ -162,9 +164,9 @@ theorem region_zero_power theorem region_zero_channel (N : (i : Fin K) → Matrix (Fin (rx i)) (Fin (rx i)) ℝ) - (hN : ∀ i, (N i).PosDef) {P : ℝ} (hP : 0 ≤ P) : + {P : ℝ} (hP : 0 ≤ P) : region (0 : (i : Fin K) → Matrix (Fin (rx i)) (Fin tx) ℝ) N P = {0} := by - simp [region, rawRegion_zero_channel N hN hP, convexHull_singleton] + simp [region, rawRegion_zero_channel N hP, convexHull_singleton] theorem isClosed_region (H : (i : Fin K) → Matrix (Fin (rx i)) (Fin tx) ℝ) diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMixtureEntropy.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMixtureEntropy.lean index 5c674c2..b855ed8 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMixtureEntropy.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMixtureEntropy.lean @@ -137,7 +137,7 @@ theorem integrable_llr_gaussianMixture_volume : have hspec := klDiv_ne_top_iff.mp hfin have hγ : γ ≪ volume := multivariateGaussian_absolutelyContinuous 0 1 hI have hlog : Integrable (llr γ volume) (κ ∘ₘ μ) := by - apply (integrable_log_multivariateGaussianPDFReal 0 1 hI + apply (integrable_log_multivariateGaussianPDFReal 0 1 (integrable_covarianceQuadratic (memLp_eval_gaussianMixture μ κ m N hrows) 0 1⁻¹)).congr exact hspec.1.ae_le (llr_multivariateGaussian_volume 0 1 hI).symm have hchain := llr_sub_of_absolutelyContinuous (μ := κ ∘ₘ μ) (τ := γ) hspec.1 hγ @@ -163,7 +163,7 @@ private theorem gaussianMixture_density_facts : · apply (Measure.integrable_compProd_iff hf.ennreal_toReal.log.aestronglyMeasurable).mpr refine ⟨Filter.Eventually.of_forall (fun a ↦ ?_), Integrable.of_finite⟩ simp only [ENNReal.toReal_ofReal (multivariateGaussianPDFReal_pos _ N hN _).le, hrows a] - exact integrable_log_multivariateGaussianPDFReal (m a) N hN + exact integrable_log_multivariateGaussianPDFReal (m a) N (integrable_covarianceQuadratic_multivariateGaussian (m a) N hN) theorem mutualInfo_gaussianMixture_ne_top : mutualInfo (μ ⊗ₘ κ) ≠ ⊤ := by @@ -196,15 +196,18 @@ theorem mutualInfo_gaussianMixture_le_of_covariance rw [entropyWith_multivariateGaussian a S hS] at h linarith +omit [IsMarkovKernel κ] in theorem mutualInfo_gaussianMixture_le_of_covariance_ennreal - (a : EuclideanSpace ℝ ι) (S : Matrix ι ι ℝ) (hS : S.PosDef) - (hmean : ∀ i, (∫ y : EuclideanSpace ℝ ι, y i ∂κ ∘ₘ μ) = a i) + (S : Matrix ι ι ℝ) (hS : S.PosDef) (hcov : ∀ i j, covariance (fun y : EuclideanSpace ℝ ι ↦ y i) (fun y ↦ y j) (κ ∘ₘ μ) = S i j) : mutualInfo (μ ⊗ₘ κ) ≤ ENNReal.ofReal ((log S.det - log N.det) / 2) := by + letI : IsMarkovKernel κ := ⟨fun x ↦ by rw [hrows x]; infer_instance⟩ + let a : EuclideanSpace ℝ ι := WithLp.toLp 2 + (fun i ↦ ∫ y : EuclideanSpace ℝ ι, y i ∂κ ∘ₘ μ) rw [← ENNReal.ofReal_toReal (mutualInfo_gaussianMixture_ne_top μ κ m N hN hrows)] exact ENNReal.ofReal_le_ofReal - (mutualInfo_gaussianMixture_le_of_covariance μ κ m N hN hrows a S hS hmean hcov) + (mutualInfo_gaussianMixture_le_of_covariance μ κ m N hN hrows a S hS (fun _ ↦ rfl) hcov) omit hN in theorem integral_eval_gaussianMixture (i : ι) : diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMixtureScore.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMixtureScore.lean index 6a23361..ec390e6 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMixtureScore.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianMixtureScore.lean @@ -13,19 +13,23 @@ namespace CapacityAtlas.MeasureInformation variable {ι α : Type*} [Fintype ι] [DecidableEq ι] [Fintype α] -lemma abs_weighted_average_le_sum_abs (a s : α → ℝ) (ha : ∀ k, 0 ≤ a k) - (hpos : 0 < ∑ k, a k) : +lemma abs_weighted_average_le_sum_abs (a s : α → ℝ) (ha : ∀ k, 0 ≤ a k) : |(∑ k, a k * s k) / ∑ k, a k| ≤ ∑ k, |s k| := by - rw [abs_div, abs_of_pos hpos, div_le_iff₀ hpos] - calc - _ ≤ ∑ k, |a k * s k| := Finset.abs_sum_le_sum_abs _ _ - _ = ∑ k, a k * |s k| := by simp only [abs_mul, abs_of_nonneg (ha _)] - _ ≤ ∑ k, a k * (∑ i, |s i|) := by - apply Finset.sum_le_sum - intro k _ - exact mul_le_mul_of_nonneg_left - (Finset.single_le_sum (fun i _ ↦ abs_nonneg (s i)) (Finset.mem_univ k)) (ha k) - _ = _ := by rw [← Finset.sum_mul, mul_comm] + by_cases hzero : (∑ k, a k) = 0 + · simp only [hzero, div_zero, abs_zero] + exact Finset.sum_nonneg (fun k _ ↦ abs_nonneg (s k)) + · have hnonneg : 0 ≤ ∑ k, a k := Finset.sum_nonneg (fun k _ ↦ ha k) + have hpos : 0 < ∑ k, a k := lt_of_le_of_ne hnonneg (Ne.symm hzero) + rw [abs_div, abs_of_pos hpos, div_le_iff₀ hpos] + calc + _ ≤ ∑ k, |a k * s k| := Finset.abs_sum_le_sum_abs _ _ + _ = ∑ k, a k * |s k| := by simp only [abs_mul, abs_of_nonneg (ha _)] + _ ≤ ∑ k, a k * (∑ i, |s i|) := by + apply Finset.sum_le_sum + intro k _ + exact mul_le_mul_of_nonneg_left + (Finset.single_le_sum (fun i _ ↦ abs_nonneg (s i)) (Finset.mem_univ k)) (ha k) + _ = _ := by rw [← Finset.sum_mul, mul_comm] lemma directionalScore_gaussianMixturePDFReal (w : α → ℝ) (m : α → EuclideanSpace ℝ ι) (N : Matrix ι ι ℝ) (hN : N.PosDef) (v x : EuclideanSpace ℝ ι) : @@ -40,7 +44,7 @@ lemma directionalScore_gaussianMixturePDFReal (w : α → ℝ) (m : α → Eucli ring lemma abs_directionalScore_gaussianMixturePDFReal_le - (w : α → ℝ) (hw : ∀ a, 0 ≤ w a) (hw1 : ∑ a, w a = 1) + (w : α → ℝ) (hw : ∀ a, 0 ≤ w a) (m : α → EuclideanSpace ℝ ι) (N : Matrix ι ι ℝ) (hN : N.PosDef) (v x : EuclideanSpace ℝ ι) : |directionalScore (gaussianMixturePDFReal w m N) v x| ≤ @@ -50,7 +54,6 @@ lemma abs_directionalScore_gaussianMixturePDFReal_le (fun k ↦ w k * multivariateGaussianPDFReal (m k) N x) (fun k ↦ -(v ⬝ᵥ N⁻¹ *ᵥ (x - m k))) (fun k ↦ mul_nonneg (hw k) (multivariateGaussianPDFReal_pos (m k) N hN x).le) - (gaussianMixturePDFReal_pos w hw hw1 m N hN x) @[fun_prop] lemma measurable_directionalScore_gaussianMixturePDFReal (w : α → ℝ) @@ -79,7 +82,7 @@ lemma memLp_gaussian_directional_score (m v k : EuclideanSpace ℝ ι) /-- Every finite Gaussian-mixture score has all finite moments under any native Gaussian law. -/ theorem memLp_directionalScore_gaussianMixturePDFReal - (w : α → ℝ) (hw : ∀ a, 0 ≤ w a) (hw1 : ∑ a, w a = 1) + (w : α → ℝ) (hw : ∀ a, 0 ≤ w a) (m : α → EuclideanSpace ℝ ι) (N : Matrix ι ι ℝ) (hN : N.PosDef) (v k : EuclideanSpace ℝ ι) (S : Matrix ι ι ℝ) (p : ℝ≥0∞) (hp : p ≠ ⊤) : MemLp (directionalScore (gaussianMixturePDFReal w m N) v) p @@ -90,7 +93,7 @@ theorem memLp_directionalScore_gaussianMixturePDFReal apply hbound.mono' (measurable_directionalScore_gaussianMixturePDFReal w m N hN v).aestronglyMeasurable filter_upwards with x exact (Real.norm_eq_abs _).trans_le - (abs_directionalScore_gaussianMixturePDFReal_le w hw hw1 m N hN v x) + (abs_directionalScore_gaussianMixturePDFReal_le w hw m N hN v x) lemma secondDeriv_div_gaussianMixturePDFReal (w : α → ℝ) (m : α → EuclideanSpace ℝ ι) (N : Matrix ι ι ℝ) (hN : N.PosDef) (v x : EuclideanSpace ℝ ι) : @@ -137,7 +140,7 @@ lemma measurable_secondDeriv_div_gaussianMixturePDFReal (w : α → ℝ) fun_prop lemma memLp_two_secondDeriv_div_gaussianMixturePDFReal - (w : α → ℝ) (hw : ∀ a, 0 ≤ w a) (hw1 : ∑ a, w a = 1) + (w : α → ℝ) (hw : ∀ a, 0 ≤ w a) (m : α → EuclideanSpace ℝ ι) (N : Matrix ι ι ℝ) (hN : N.PosDef) (v k : EuclideanSpace ℝ ι) (S : Matrix ι ι ℝ) : MemLp (fun x ↦ lineDeriv ℝ @@ -156,7 +159,6 @@ lemma memLp_two_secondDeriv_div_gaussianMixturePDFReal (fun a ↦ w a * multivariateGaussianPDFReal (m a) N x) (fun a ↦ (v ⬝ᵥ N⁻¹ *ᵥ (x - m a)) ^ 2 - v ⬝ᵥ N⁻¹ *ᵥ v) (fun a ↦ mul_nonneg (hw a) (multivariateGaussianPDFReal_pos (m a) N hN x).le) - (gaussianMixturePDFReal_pos w hw hw1 m N hN x) /-- The actual score derivative is square-integrable under every Gaussian law. -/ theorem memLp_two_lineDeriv_directionalScore_gaussianMixturePDFReal @@ -168,12 +170,12 @@ theorem memLp_two_lineDeriv_directionalScore_gaussianMixturePDFReal letI : ENNReal.HolderTriple 4 4 2 := ⟨by apply (ENNReal.toReal_eq_toReal_iff' (by finiteness) (by finiteness)).mp norm_num [ENNReal.toReal_add]⟩ - have hs := memLp_directionalScore_gaussianMixturePDFReal w hw hw1 m N hN v k S 4 (by norm_num) + have hs := memLp_directionalScore_gaussianMixturePDFReal w hw m N hN v k S 4 (by norm_num) have hsq : MemLp (fun x ↦ directionalScore (gaussianMixturePDFReal w m N) v x ^ 2) 2 (multivariateGaussian k S) := by simpa only [pow_two] using hs.mul' hs simp_rw [(hasLineDerivAt_directionalScore_gaussianMixturePDFReal w hw hw1 m N hN v _).lineDeriv] - exact (memLp_two_secondDeriv_div_gaussianMixturePDFReal w hw hw1 m N hN v k S).sub hsq + exact (memLp_two_secondDeriv_div_gaussianMixturePDFReal w hw m N hN v k S).sub hsq @[fun_prop] lemma measurable_lineDeriv_directionalScore_gaussianMixturePDFReal diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianProportionalEntropy.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianProportionalEntropy.lean index 285818b..971907e 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianProportionalEntropy.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianProportionalEntropy.lean @@ -38,10 +38,11 @@ theorem weighted_log_sub_le_of_proportional nlinarith theorem proportional_log_sub_le - {P Q A B a : ℝ} (hP : 0 < P) (hQ : 0 < Q) (hA : 0 < A) (hB : 0 < B) + {P Q A B a : ℝ} (hP : 0 < P) (hA : 0 < A) (hB : 0 < B) (ha1 : a ≤ 1) (hAeq : A = a * B) (hPQ : P + (B - A) ≤ Q) : a * log P - log Q ≤ a * log A - log B := by have hAB : A ≤ B := by rw [hAeq]; nlinarith + have hQ : 0 < Q := by linarith have hf : a = (1 : ℝ) * A / B := by rw [one_mul, hAeq, mul_div_cancel_right₀ a hB.ne'] simpa only [one_mul] using weighted_log_sub_le_of_proportional hP hQ hA hB hAB hPQ zero_lt_one hf diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianProportionalMixtureEntropy.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianProportionalMixtureEntropy.lean index cfc8794..450080f 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianProportionalMixtureEntropy.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianProportionalMixtureEntropy.lean @@ -51,7 +51,6 @@ theorem entropyWith_gaussianMixtureMeasure_difference_le_of_proportional rw [hpowerD] at hEPI have hlog := proportional_log_sub_le (entropyPower_pos (gaussianMixtureMeasure w m N)) - (entropyPower_pos (gaussianMixtureMeasure w m M)) (entropyPower_pos (multivariateGaussian (0 : EuclideanSpace ℝ ι) A)) (entropyPower_pos (multivariateGaussian (0 : EuclideanSpace ℝ ι) B)) ha1 hpowerA hEPI @@ -90,7 +89,6 @@ theorem entropyWith_gaussianCodebook_weighted_difference_le_of_precision g * entropyWith (gaussianCodebookKernel m M ∘ₘ μ) volume ≤ f * entropyWith (multivariateGaussian (0 : EuclideanSpace ℝ ι) (S + N)) volume - g * entropyWith (multivariateGaussian (0 : EuclideanSpace ℝ ι) (S + M)) volume := by - have hA : (S + N).PosDef := PosDef.posSemidef_add hS hN have hB : (S + M).PosDef := PosDef.posSemidef_add hS hM have hp : (S + M)⁻¹ = (f / g) • (S + N)⁻¹ := by have h := congrArg (fun Z ↦ g⁻¹ • Z) hprop @@ -98,7 +96,7 @@ theorem entropyWith_gaussianCodebook_weighted_difference_le_of_precision simp only [gaussianCodebookKernel_comp_eq_mixture] exact entropyWith_gaussianMixtureMeasure_weighted_difference_le_of_proportional (fun a ↦ μ.real {a}) (fun _ ↦ measureReal_nonneg) (sum_real_singleton_eq_one μ) - m N M (S + N) (S + M) hN hB hf hg hfg (inv_proportional_smul hA hB hp).symm (by abel) + m N M (S + N) (S + M) hN hB hf hg hfg (inv_proportional_smul hB hp).symm (by abel) theorem entropyWith_gaussianCodebook_weighted_difference_le_of_proportional (μ : Measure α) [IsProbabilityMeasure μ] diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianRelativeEntropy.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianRelativeEntropy.lean index c4f9b37..fe16ccd 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianRelativeEntropy.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianRelativeEntropy.lean @@ -53,7 +53,7 @@ theorem klDiv_multivariateGaussian_ne_top (m a : EuclideanSpace ℝ ι) exact _root_.InformationTheory.klDiv_ne_top ((multivariateGaussian_absolutelyContinuous m S hS).trans (absolutelyContinuous_tilted hexp)) (integrable_llr_tilted_right (multivariateGaussian_absolutelyContinuous m S hS) - (integrable_log_multivariateGaussianPDFReal a T hT + (integrable_log_multivariateGaussianPDFReal a T (integrable_covarianceQuadratic (memLp_eval_multivariateGaussian m S) a T⁻¹)) (integrable_llr_multivariateGaussian_volume m S hS) hexp) diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianScoreIntegration.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianScoreIntegration.lean index 9d54767..817fad0 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianScoreIntegration.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianScoreIntegration.lean @@ -74,7 +74,7 @@ lemma integral_lineDeriv_directionalScore_gaussianMixture (fun x ↦ lineDeriv ℝ (directionalScore (gaussianMixturePDFReal w m N) v) x v) (fun x ↦ (hasLineDerivAt_directionalScore_gaussianMixturePDFReal w hw hw1 m N hN v x).lineDifferentiableAt.hasLineDerivAt) - (fun a ↦ memLp_directionalScore_gaussianMixturePDFReal w hw hw1 m N hN v (m a) N 2 (by norm_num)) + (fun a ↦ memLp_directionalScore_gaussianMixturePDFReal w hw m N hN v (m a) N 2 (by norm_num)) (fun a ↦ (memLp_two_lineDeriv_directionalScore_gaussianMixturePDFReal w hw hw1 m N hN v (m a) N).integrable (by norm_num)) rw [directionalFisherWith_eq_gaussianMixtureMeasure w hw m N hN] diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/InputCost/Capacity.lean b/lean/CapacityAtlasForMathlib/InformationTheory/InputCost/Capacity.lean index 1685cea..150ac04 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/InputCost/Capacity.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/InputCost/Capacity.lean @@ -48,14 +48,13 @@ theorem achievableRate_of_lt_constrainedInformationCapacityBits channel.exists_input_of_lt_constrainedInformationCapacityBits cost budget hfeasible hrate exact achievableRate_of_admissible_input channel input cost budget hfeasible hinput hrateInput -/-- Certificate for the unchanged Atlas exact-capacity claim, version 1. -/ +/-- A feasible per-symbol cost constraint identifies finite-DMC capacity. -/ theorem finiteDMCInputCostCapacity (channel : FiniteChannel X Y) (cost : X → ℝ) (budget : ℝ) : - (∀ symbol, 0 ≤ cost symbol) → - (∃ symbol, cost symbol ≤ budget) → - channel.constrainedOperationalCapacityBits cost budget = - channel.constrainedInformationCapacityBits cost budget := by - intro _ hfeasible + (∃ symbol, cost symbol ≤ budget) → + channel.constrainedOperationalCapacityBits cost budget = + channel.constrainedInformationCapacityBits cost budget := by + intro hfeasible apply le_antisymm · exact channel.constrainedOperationalCapacityBits_le_constrainedInformationCapacityBits cost budget hfeasible @@ -66,11 +65,11 @@ theorem finiteDMCInputCostCapacity (channel : FiniteChannel X Y) /-- The information supremum is a maximum and equals operational capacity. -/ theorem exists_capacityAchieving_input (channel : FiniteChannel X Y) - (cost : X → ℝ) (budget : ℝ) (hcost : ∀ symbol, 0 ≤ cost symbol) + (cost : X → ℝ) (budget : ℝ) (hfeasible : ∃ symbol, cost symbol ≤ budget) : ∃ input : FiniteDistribution X, input.IsAdmissibleCost cost budget ∧ channel.mutualInformationBits input = channel.constrainedOperationalCapacityBits cost budget := by - rw [finiteDMCInputCostCapacity channel cost budget hcost hfeasible] + rw [finiteDMCInputCostCapacity channel cost budget hfeasible] exact channel.exists_admissible_input_attaining_constrainedInformationCapacityBits cost budget hfeasible diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/MeasureRandomBinning/Rejection.lean b/lean/CapacityAtlasForMathlib/InformationTheory/MeasureRandomBinning/Rejection.lean index ce4a2f1..979278f 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/MeasureRandomBinning/Rejection.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/MeasureRandomBinning/Rejection.lean @@ -38,7 +38,7 @@ theorem measurableSet_seededAcceptance {g : U → ℝ≥0∞} (hg : Measurable g (hB.preimage measurable_fst).inter (measurableSet_le measurable_snd ((hg.comp measurable_fst).ennreal_toReal.div_const T)) -theorem measure_seededAcceptance_inter (μ : Measure U) [SFinite μ] +theorem measure_seededAcceptance_inter (μ : Measure U) {g : U → ℝ≥0∞} (hg : Measurable g) {B E : Set U} (hB : MeasurableSet B) (hE : MeasurableSet E) {T : ℝ} (hT : 0 < T) (hcut : ∀ u ∈ B, g u ≤ ENNReal.ofReal T) : @@ -70,7 +70,7 @@ theorem measure_seededAcceptance_inter (μ : Measure U) [SFinite μ] simp_rw [div_eq_mul_inv] rw [lintegral_mul_const _ hg, withDensity_apply _ (hB.inter hE)] -theorem measure_seededAcceptance (μ : Measure U) [SFinite μ] +theorem measure_seededAcceptance (μ : Measure U) {g : U → ℝ≥0∞} (hg : Measurable g) {B : Set U} (hB : MeasurableSet B) {T : ℝ} (hT : 0 < T) (hcut : ∀ u ∈ B, g u ≤ ENNReal.ofReal T) : (μ.prod seedLaw) (seededAcceptance g B T) = diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/MeasureRandomBinning/SampledSequence.lean b/lean/CapacityAtlasForMathlib/InformationTheory/MeasureRandomBinning/SampledSequence.lean index fd6bc90..7abadc2 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/MeasureRandomBinning/SampledSequence.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/MeasureRandomBinning/SampledSequence.lean @@ -64,7 +64,7 @@ theorem sampledKernel_univ_add_failure (ν : Measure V) [IsProbabilityMeasure ν exact (measure_add_measure_compl (hA.preimage measurable_prodMk_left)).trans (measure_univ : ν univ = 1) theorem sampledKernel_comp_eq_actual {Ω : Type*} [MeasurableSpace Ω] - (π : Measure Ω) [IsProbabilityMeasure π] (ν : Measure V) [IsProbabilityMeasure ν] + (π : Measure Ω) (ν : Measure V) [IsProbabilityMeasure ν] {C : Set Ω} (hC : MeasurableSet C) {state : Ω → S} (hstate : Measurable state) {A : Set (S × V)} (hA : MeasurableSet A) {next : S × V → S} (hnext : Measurable next) : diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/MeasureRandomBinning/SequenceDecoder.lean b/lean/CapacityAtlasForMathlib/InformationTheory/MeasureRandomBinning/SequenceDecoder.lean index 686970f..c3d2d2d 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/MeasureRandomBinning/SequenceDecoder.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/MeasureRandomBinning/SequenceDecoder.lean @@ -97,7 +97,7 @@ theorem measurable_sequenceReceiverBound {M : ℕ → Type*} [∀ j, Fintype (M exact (hfirst.comp (measurable_selectedRows message n)).add hsecond theorem sequenceReceiver_error_le {M : ℕ → Type*} [∀ j, Fintype (M j)] - [∀ j, Nonempty (M j)] [∀ j, MeasurableSpace (M j)] + [∀ j, Nonempty (M j)] (D : ℕ → RejectionStage S U) (initial fallback : S) (C : Set S) (W : Kernel S Y) [IsMarkovKernel W] (aux : S → U) (A : Set (U × Y)) (message : (j : ℕ) → M j) (n : ℕ) (i : Fin n) [Nonempty (Fin (D i.val).count)] diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/MeasureRandomCoding.lean b/lean/CapacityAtlasForMathlib/InformationTheory/MeasureRandomCoding.lean index bac7c9b..9720165 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/MeasureRandomCoding.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/MeasureRandomCoding.lean @@ -95,17 +95,24 @@ theorem averageError_eq_zero_of_subsingleton [Subsingleton M] simp [Subsingleton.elim (code.decode y) m] simp [averageError, errorProbability, herror] +omit [Nonempty M] in theorem averageError_le_one (κ : Kernel X Y) [IsMarkovKernel κ] (code : OneShotCode X Y M) : averageError κ code ≤ 1 := by - unfold averageError - calc - _ ≤ (Fintype.card M : ℝ≥0∞)⁻¹ * ∑ _m : M, (1 : ℝ≥0∞) := by - gcongr - exact prob_le_one - _ = 1 := by - simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, mul_one] - exact ENNReal.inv_mul_cancel (by exact_mod_cast Fintype.card_ne_zero) - (by finiteness) + cases isEmpty_or_nonempty M with + | inl h => + letI := h + simp [averageError] + | inr h => + letI := h + unfold averageError + calc + _ ≤ (Fintype.card M : ℝ≥0∞)⁻¹ * ∑ _m : M, (1 : ℝ≥0∞) := by + gcongr + exact prob_le_one + _ = 1 := by + simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, mul_one] + exact ENNReal.inv_mul_cancel (by exact_mod_cast Fintype.card_ne_zero) + (by finiteness) omit [Nonempty M] in theorem averageError_toReal (κ : Kernel X Y) [IsMarkovKernel κ] diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/MeasureRandomCoding/Asymptotic.lean b/lean/CapacityAtlasForMathlib/InformationTheory/MeasureRandomCoding/Asymptotic.lean index 79a00a9..2b79cc5 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/MeasureRandomCoding/Asymptotic.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/MeasureRandomCoding/Asymptotic.lean @@ -12,22 +12,33 @@ open scoped ENNReal Topology namespace CapacityAtlas.MeasureChannel -theorem roundedMessage_threshold_le (R a : ℝ) (hR : 0 ≤ R) (n : ℕ) : +theorem roundedMessage_threshold_le (R a : ℝ) (n : ℕ) : (FiniteChannel.messageCountAtRate R n - 1 : ℕ) * (ENNReal.ofReal (Real.exp ((n : ℝ) * a)))⁻¹ ≤ ENNReal.ofReal (2 * Real.exp (-((n : ℝ) * (a - R * Real.log 2)))) := by - calc - _ ≤ (FiniteChannel.messageCountAtRate R n : ℝ≥0∞) * - (ENNReal.ofReal (Real.exp ((n : ℝ) * a)))⁻¹ := by - gcongr - exact Nat.sub_le (FiniteChannel.messageCountAtRate R n) 1 - _ = ENNReal.ofReal ((FiniteChannel.messageCountAtRate R n : ℝ) * - Real.exp (-((n : ℝ) * a))) := by - rw [Real.exp_neg, ENNReal.ofReal_mul (Nat.cast_nonneg _), ENNReal.ofReal_natCast, - ENNReal.ofReal_inv_of_pos (Real.exp_pos _)] - _ ≤ _ := ENNReal.ofReal_le_ofReal - (FiniteChannel.messageCountAtRate_mul_exp_neg_le R (a - R * Real.log 2) hR n - (by ring_nf; rfl)) + by_cases hR : 0 ≤ R + · calc + _ ≤ (FiniteChannel.messageCountAtRate R n : ℝ≥0∞) * + (ENNReal.ofReal (Real.exp ((n : ℝ) * a)))⁻¹ := by + gcongr + exact Nat.sub_le (FiniteChannel.messageCountAtRate R n) 1 + _ = ENNReal.ofReal ((FiniteChannel.messageCountAtRate R n : ℝ) * + Real.exp (-((n : ℝ) * a))) := by + rw [Real.exp_neg, ENNReal.ofReal_mul (Nat.cast_nonneg _), ENNReal.ofReal_natCast, + ENNReal.ofReal_inv_of_pos (Real.exp_pos _)] + _ ≤ _ := ENNReal.ofReal_le_ofReal + (FiniteChannel.messageCountAtRate_mul_exp_neg_le R (a - R * Real.log 2) hR n + (by ring_nf; rfl)) + · have he : (n : ℝ) * R * Real.log 2 ≤ 0 := + mul_nonpos_of_nonpos_of_nonneg + (mul_nonpos_of_nonneg_of_nonpos (Nat.cast_nonneg n) (le_of_lt (lt_of_not_ge hR))) + (by positivity) + have hcount : FiniteChannel.messageCountAtRate R n ≤ 1 := by + unfold FiniteChannel.messageCountAtRate + apply Nat.ceil_le.mpr + simpa only [Nat.cast_one] using Real.exp_le_one_iff.mpr he + simp only [Nat.sub_eq_zero_of_le hcount, Nat.cast_zero, zero_mul] + exact zero_le theorem exponential_gap_tendsto_zero {δ : ℝ} (hδ : 0 < δ) : Tendsto (fun n : ℕ ↦ ENNReal.ofReal (2 * Real.exp (-((n : ℝ) * δ)))) @@ -46,7 +57,7 @@ theorem exists_codes_of_likelihood_tail_tendsto_zero (hκ : ∀ n x, κ n x = (κ n ∘ₘ μ n).withDensity (fun y ↦ f n (x, y))) (allowed : (n : ℕ) → Set (X n)) (hallowed : ∀ n, MeasurableSet (allowed n)) (hne : ∀ n, (allowed n).Nonempty) - {R a : ℝ} (hR : 0 ≤ R) (hgap : R * Real.log 2 < a) + {R a : ℝ} (hgap : R * Real.log 2 < a) (htail : Tendsto (fun n ↦ ∫⁻ x, κ n x {y | f n (x, y) ≤ ENNReal.ofReal (Real.exp ((n : ℝ) * a))} ∂μ n) atTop (𝓝 0)) (hcost : Tendsto (fun n ↦ μ n (allowed n)ᶜ) atTop (𝓝 0)) : @@ -76,7 +87,7 @@ theorem exists_codes_of_likelihood_tail_tendsto_zero have hbound : averageError (κ n) code ≤ ENNReal.ofReal ε := by apply herror.trans apply le_trans (add_le_add (add_le_add le_rfl ?_) le_rfl) (hN n (by omega)).le - simpa only [Fintype.card_fin] using roundedMessage_threshold_le R a hR n + simpa only [Fintype.card_fin] using roundedMessage_threshold_le R a n exact (ENNReal.toReal_le_toReal (ne_top_of_le_ne_top ENNReal.ofReal_ne_top hbound) ENNReal.ofReal_ne_top).mpr hbound |>.trans_eq (ENNReal.toReal_ofReal hε.le) diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/MeasureRandomCoding/IIDCoding.lean b/lean/CapacityAtlasForMathlib/InformationTheory/MeasureRandomCoding/IIDCoding.lean index bc3320e..eeb938b 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/MeasureRandomCoding/IIDCoding.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/MeasureRandomCoding/IIDCoding.lean @@ -77,7 +77,7 @@ theorem exists_codes_of_iid_likelihood Measure.pi (fun _ : Fin n ↦ ν)) {cost : X → ℝ} (hcost : Measurable cost) (hcostLp : MemLp cost 2 μ) {P R : ℝ} (hP : (∫ x, cost x ∂μ) < P) (x₀ : X) (hx₀ : cost x₀ ≤ P) - (hR : 0 ≤ R) (hRate : R * Real.log 2 < ∫ z, info z ∂ν) : + (hRate : R * Real.log 2 < ∫ z, info z ∂ν) : ∀ ε : ℝ, 0 < ε → ∃ N : ℕ, 0 < N ∧ ∀ n, N ≤ n → ∃ code : OneShotCode (Fin n → X) (Fin n → Y) (Fin (FiniteChannel.messageCountAtRate R n)), @@ -91,7 +91,7 @@ theorem exists_codes_of_iid_likelihood (fun n ↦ {x | iidSum cost n x ≤ (n : ℝ) * P}) (fun n ↦ measurableSet_le (Finset.measurable_sum _ (fun i _ ↦ hcost.comp (measurable_pi_apply i))) measurable_const) - (fun n ↦ ⟨fun _ ↦ x₀, ?_⟩) hR hRa + (fun n ↦ ⟨fun _ ↦ x₀, ?_⟩) hRa (likelihood_tail_tendsto_zero_of_iid_joint κ μ ν hjoint hinfo hinfoLp ha) (iidCost_rejection_tendsto_zero μ hcostLp hP) change iidSum cost n (fun _ ↦ x₀) ≤ (n : ℝ) * P diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/MeasureRandomCoding/Tensor.lean b/lean/CapacityAtlasForMathlib/InformationTheory/MeasureRandomCoding/Tensor.lean index 9650d24..cf3be94 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/MeasureRandomCoding/Tensor.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/MeasureRandomCoding/Tensor.lean @@ -140,7 +140,7 @@ theorem exists_codes_of_memoryless_likelihood (fun y ↦ ENNReal.ofReal (Real.exp (info (x, y))))) {cost : X → ℝ} (hcost : Measurable cost) (hcostLp : MemLp cost 2 μ) {P R : ℝ} (hP : (∫ x, cost x ∂μ) < P) (x₀ : X) (hx₀ : cost x₀ ≤ P) - (hR : 0 ≤ R) (hRate : R * Real.log 2 < ∫ z, info z ∂(μ ⊗ₘ κ)) : + (hRate : R * Real.log 2 < ∫ z, info z ∂(μ ⊗ₘ κ)) : ∀ ε : ℝ, 0 < ε → ∃ N : ℕ, 0 < N ∧ ∀ n, N ≤ n → ∃ code : OneShotCode (Fin n → X) (Fin n → Y) (Fin (FiniteChannel.messageCountAtRate R n)), @@ -149,6 +149,6 @@ theorem exists_codes_of_memoryless_likelihood R ≤ Real.logb 2 (FiniteChannel.messageCountAtRate R n : ℝ) / n := exists_codes_of_iid_likelihood (iidKernel κ) μ (μ ⊗ₘ κ) hinfo hinfoLp (iidKernel_likelihood κ μ hinfo hrow) (iidKernel_joint κ μ) - hcost hcostLp hP x₀ hx₀ hR hRate + hcost hcostLp hP x₀ hx₀ hRate end CapacityAtlas.MeasureChannel diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/MultivariateGaussianEntropy.lean b/lean/CapacityAtlasForMathlib/InformationTheory/MultivariateGaussianEntropy.lean index 652d527..98962ea 100644 --- a/lean/CapacityAtlasForMathlib/InformationTheory/MultivariateGaussianEntropy.lean +++ b/lean/CapacityAtlasForMathlib/InformationTheory/MultivariateGaussianEntropy.lean @@ -111,7 +111,7 @@ lemma integral_covarianceQuadratic_multivariateGaussian (m : EuclideanSpace ℝ lemma integrable_llr_multivariateGaussian_volume (m : EuclideanSpace ℝ ι) (S : Matrix ι ι ℝ) (hS : S.PosDef) : Integrable (llr (multivariateGaussian m S) volume) (multivariateGaussian m S) := by - apply (integrable_log_multivariateGaussianPDFReal m S hS + apply (integrable_log_multivariateGaussianPDFReal m S (integrable_covarianceQuadratic_multivariateGaussian m S hS)).congr filter_upwards [llr_multivariateGaussian_volume m S hS] with x hx using hx.symm @@ -138,7 +138,7 @@ theorem entropyWith_le_multivariateGaussian_crossEntropy simpa only [exp_log (multivariateGaussianPDFReal_pos m S hS _)] using integrable_multivariateGaussianPDFReal m S hS have h := entropyWith_le_log_partition_sub_integral hμ - (integrable_log_multivariateGaussianPDFReal m S hS hquad) hexp hlog + (integrable_log_multivariateGaussianPDFReal m S hquad) hexp hlog simp_rw [exp_log (multivariateGaussianPDFReal_pos m S hS _)] at h rw [integral_multivariateGaussianPDFReal m S hS, log_one, integral_log_multivariateGaussianPDFReal m S hS hquad] at h @@ -168,7 +168,7 @@ theorem klDiv_multivariateGaussian_eq_crossEntropy_sub_entropy integrable_multivariateGaussianPDFReal m S hS rw [multivariateGaussian_eq_tilted_log_density m S hS, klDiv_tilted_eq_entropy_gap hμ - (integrable_log_multivariateGaussianPDFReal m S hS hquad) hexp hlog] + (integrable_log_multivariateGaussianPDFReal m S hquad) hexp hlog] simp_rw [exp_log (multivariateGaussianPDFReal_pos m S hS _)] rw [integral_multivariateGaussianPDFReal m S hS, log_one, integral_log_multivariateGaussianPDFReal m S hS hquad] @@ -187,7 +187,7 @@ theorem entropyWith_eq_multivariateGaussian_iff simpa only [exp_log (multivariateGaussianPDFReal_pos m S hS _)] using integrable_multivariateGaussianPDFReal m S hS have h := entropyWith_eq_log_partition_sub_integral_iff hμ - (integrable_log_multivariateGaussianPDFReal m S hS hquad) hexp hlog + (integrable_log_multivariateGaussianPDFReal m S hquad) hexp hlog simp_rw [exp_log (multivariateGaussianPDFReal_pos m S hS _)] at h rw [integral_multivariateGaussianPDFReal m S hS, log_one, integral_log_multivariateGaussianPDFReal m S hS hquad, hmoment, diff --git a/lean/CapacityAtlasForMathlib/LinearAlgebra/LogDetConcavity.lean b/lean/CapacityAtlasForMathlib/LinearAlgebra/LogDetConcavity.lean index ea794a4..9d50362 100644 --- a/lean/CapacityAtlasForMathlib/LinearAlgebra/LogDetConcavity.lean +++ b/lean/CapacityAtlasForMathlib/LinearAlgebra/LogDetConcavity.lean @@ -71,11 +71,18 @@ theorem proportional_log_det_difference_le {A B X Y : Matrix ι ι ℝ} rw [hprop] at hp nlinarith -theorem inv_proportional_smul {A B : Matrix ι ι ℝ} (hA : A.PosDef) (hB : B.PosDef) +theorem inv_proportional_smul {A B : Matrix ι ι ℝ} (hB : B.PosDef) {a : ℝ} (h : B⁻¹ = a • A⁻¹) : a • B = A := by + have hBu : IsUnit B.det := isUnit_iff_ne_zero.mpr hB.det_pos.ne' + have hiB : (B⁻¹).det ≠ 0 := isUnit_iff_ne_zero.mp (isUnit_nonsing_inv_det B hBu) + have hprod : a ^ Fintype.card ι * (A⁻¹).det ≠ 0 := by + rw [← Matrix.det_smul, ← h] + exact hiB + have hAu : IsUnit A.det := isUnit_nonsing_inv_det_iff.mp + (isUnit_iff_ne_zero.mpr (right_ne_zero_of_mul hprod)) have hh := congrArg (fun Z ↦ A * Z * B) h - simpa only [nonsing_inv_mul_cancel_right _ _ (isUnit_iff_ne_zero.mpr hB.det_pos.ne'), - Matrix.mul_smul, Matrix.smul_mul, mul_nonsing_inv _ (isUnit_iff_ne_zero.mpr hA.det_pos.ne'), + simpa only [nonsing_inv_mul_cancel_right _ _ hBu, + Matrix.mul_smul, Matrix.smul_mul, mul_nonsing_inv _ hAu, Matrix.one_mul] using hh.symm end Matrix diff --git a/lean/CapacityAtlasForMathlib/Network/LinearMulticast/Circuit.lean b/lean/CapacityAtlasForMathlib/Network/LinearMulticast/Circuit.lean index 06acfeb..6095dfc 100644 --- a/lean/CapacityAtlasForMathlib/Network/LinearMulticast/Circuit.lean +++ b/lean/CapacityAtlasForMathlib/Network/LinearMulticast/Circuit.lean @@ -83,17 +83,18 @@ theorem outputMatrix_map {R S : Type*} [CommSemiring R] [CommSemiring S] /-- Per-receiver routing assignments imply one finite binary-field code whose observations recover every input at every receiver. -/ -theorem simultaneous [Fintype I] {T : Type} [Fintype T] +theorem simultaneous [Fintype I] {T : Type} (output : T → I → I ⊕ W) (route : ∀ t, ∃ c : G.Variable → ZMod 2, G.outputMatrix c (output t) = 1) : ∃ b : ℕ, 0 < b ∧ ∃ c : G.Variable → GaloisField 2 b, ∀ t, (G.outputMatrix c (output t)).det ≠ 0 := by classical + letI : Fintype (Set.range output) := Fintype.ofFinite _ let x : G.Variable → MvPolynomial G.Variable (ZMod 2) := MvPolynomial.X - let p : T → MvPolynomial G.Variable (ZMod 2) := - fun t ↦ (G.outputMatrix x (output t)).det + let p : Set.range output → MvPolynomial G.Variable (ZMod 2) := + fun o ↦ (G.outputMatrix x o.val).det have hp : ∀ t, p t ≠ 0 := by - intro t + rintro ⟨_, t, rfl⟩ obtain ⟨c, hc⟩ := route t intro h have hh := congrArg (MvPolynomial.eval c) h @@ -113,7 +114,7 @@ theorem simultaneous [Fintype I] {T : Type} [Fintype T] ext v simp [x] rw [hx] at hm - have hh := hc t + have hh := hc ⟨output t, ⟨t, rfl⟩⟩ change (MvPolynomial.eval₂Hom (algebraMap (ZMod 2) (GaloisField 2 b)) c) ((G.outputMatrix x (output t)).det) ≠ 0 at hh rw [RingHom.map_det] at hh diff --git a/lean/CapacityAtlasForMathlib/Network/LinearMulticast/Routing.lean b/lean/CapacityAtlasForMathlib/Network/LinearMulticast/Routing.lean index d237d58..78395ef 100644 --- a/lean/CapacityAtlasForMathlib/Network/LinearMulticast/Routing.lean +++ b/lean/CapacityAtlasForMathlib/Network/LinearMulticast/Routing.lean @@ -122,7 +122,7 @@ noncomputable def routingOfPaths (output : I → I ⊕ W) (paths : I → List W) · exact Or.inl hi · exact Or.inr ⟨e, he, (hlabel e i).mpr hm⟩ -theorem simultaneous_of_routing [Fintype I] {T : Type} [Fintype T] +theorem simultaneous_of_routing [Fintype I] {T : Type} (output : T → I → I ⊕ W) (routes : ∀ t, G.Routing (output t)) : ∃ b : ℕ, 0 < b ∧ ∃ c : G.Variable → GaloisField 2 b, ∀ t, (G.outputMatrix c (output t)).det ≠ 0 := diff --git a/lean/CapacityAtlasForMathlib/Network/WirelessTransport/Capacity.lean b/lean/CapacityAtlasForMathlib/Network/WirelessTransport/Capacity.lean index 54a5217..ad84b86 100644 --- a/lean/CapacityAtlasForMathlib/Network/WirelessTransport/Capacity.lean +++ b/lean/CapacityAtlasForMathlib/Network/WirelessTransport/Capacity.lean @@ -17,7 +17,7 @@ theorem capacity_lower {n : ℕ} {R Δ W : ℝ} obtain ⟨m, hm, hcount, hroot⟩ := exists_grid_size hn have hc : 2 * Fintype.card (GridIndex m) ≤ n := by simpa using hcount have ha := oneHop_achievable (GridIndex m) (gridTx R Δ m) (gridRx R Δ m) R Δ W hc hW - (gridTx_norm_le hR hm) (gridRx_norm_le hR hΔ hm) + (gridTx_norm_le hR) (gridRx_norm_le hR hΔ hm) (fun _ _ hij => grid_protocol hR hΔ hm hij) rw [grid_total_length hR hΔ hm] at ha have hlower : W * R * Real.sqrt n / (32 * (1 + Δ)) ≤ @@ -31,7 +31,7 @@ theorem capacity_lower {n : ℕ} {R Δ W : ℝ} ring rw [he] exact mul_le_mul_of_nonneg_left hroot (mul_nonneg hW hR.le) - exact hlower.trans (ha.le_capacity hR.le hΔ hW) + exact hlower.trans (ha.le_capacity hR.le hΔ) /-- Nonsharp constants give matching order bounds for every node count at least four. -/ theorem capacity_bounds {n : ℕ} {R Δ W : ℝ} diff --git a/lean/CapacityAtlasForMathlib/Network/WirelessTransport/Grid.lean b/lean/CapacityAtlasForMathlib/Network/WirelessTransport/Grid.lean index a035c84..d11c2af 100644 --- a/lean/CapacityAtlasForMathlib/Network/WirelessTransport/Grid.lean +++ b/lean/CapacityAtlasForMathlib/Network/WirelessTransport/Grid.lean @@ -63,24 +63,24 @@ theorem grid_hop_length {R Δ : ℝ} {m : ℕ} simp [gridTx, gridRx, Fin.sum_univ_two, Real.dist_eq, Real.sqrt_sq_eq_abs, abs_of_pos hp] -theorem grid_coord_bounds {R : ℝ} {m : ℕ} (hR : 0 < R) (hm : 0 < m) (i : Fin m) : +theorem grid_coord_bounds {R : ℝ} {m : ℕ} (hR : 0 < R) (i : Fin m) : 0 ≤ (i.val : ℝ) * gridStep R m ∧ (i.val : ℝ) * gridStep R m + gridStep R m ≤ R / 2 := by - have hs := gridStep_pos hR hm + have hs := gridStep_pos hR i.pos have hi : (i.val : ℝ) + 1 ≤ (m : ℝ) := by exact_mod_cast i.isLt have he : (m : ℝ) * gridStep R m = R / 2 := by unfold gridStep - have hm' : (m : ℝ) ≠ 0 := by exact_mod_cast Nat.ne_of_gt hm + have hm' : (m : ℝ) ≠ 0 := by exact_mod_cast Nat.ne_of_gt i.pos field_simp constructor · positivity · nlinarith theorem gridTx_norm_le {R Δ : ℝ} {m : ℕ} - (hR : 0 < R) (hm : 0 < m) (i : GridIndex m) : ‖gridTx R Δ m i‖ ≤ R := by - have hx := grid_coord_bounds hR hm i.1 - have hy := grid_coord_bounds hR hm i.2 - have hs := gridStep_pos hR hm + (hR : 0 < R) (i : GridIndex m) : ‖gridTx R Δ m i‖ ≤ R := by + have hx := grid_coord_bounds hR i.1 + have hy := grid_coord_bounds hR i.2 + have hs := gridStep_pos hR i.1.pos have he : ‖gridTx R Δ m i‖ ^ 2 = ((i.1.val : ℝ) * gridStep R m) ^ 2 + ((i.2.val : ℝ) * gridStep R m) ^ 2 := by simpa [gridTx, Fin.sum_univ_two] using @@ -92,8 +92,8 @@ theorem gridTx_norm_le {R Δ : ℝ} {m : ℕ} theorem gridRx_norm_le {R Δ : ℝ} {m : ℕ} (hR : 0 < R) (hΔ : 0 < Δ) (hm : 0 < m) (i : GridIndex m) : ‖gridRx R Δ m i‖ ≤ R := by - have hx := grid_coord_bounds hR hm i.1 - have hy := grid_coord_bounds hR hm i.2 + have hx := grid_coord_bounds hR i.1 + have hy := grid_coord_bounds hR i.2 have hs := gridStep_pos hR hm have hp := gridHop_pos hR hΔ hm have hps := gridHop_le_step hR hΔ hm diff --git a/lean/CapacityAtlasForMathlib/Network/WirelessTransport/Operations.lean b/lean/CapacityAtlasForMathlib/Network/WirelessTransport/Operations.lean index 5deb8c5..7f41ece 100644 --- a/lean/CapacityAtlasForMathlib/Network/WirelessTransport/Operations.lean +++ b/lean/CapacityAtlasForMathlib/Network/WirelessTransport/Operations.lean @@ -23,7 +23,7 @@ namespace Schedule variable {V : Type} [Fintype V] {position : V → Point} {Δ W R : ℝ} theorem hopWork_le (S : Schedule V position Δ W) {n : ℕ} - (hn : Fintype.card V ≤ n) (hR : 0 ≤ R) (hΔ : 0 < Δ) (_hW : 0 ≤ W) + (hn : Fintype.card V ≤ n) (hR : 0 ≤ R) (hΔ : 0 < Δ) (hposition : ∀ v, ‖position v‖ ≤ R) : ∑ r : S.Resource, S.available r * S.length r ≤ W * upperConstant R Δ * Real.sqrt n := by @@ -105,27 +105,27 @@ theorem transportRate_le_hopWork (E : Execution V position Δ W) : mul_le_mul_of_nonneg_right (E.load_le r) dist_nonneg theorem transportRate_le [Fintype V] (E : Execution V position Δ W) {n : ℕ} {R : ℝ} - (hn : Fintype.card V ≤ n) (hR : 0 ≤ R) (hΔ : 0 < Δ) (hW : 0 ≤ W) + (hn : Fintype.card V ≤ n) (hR : 0 ≤ R) (hΔ : 0 < Δ) (hposition : ∀ v, ‖position v‖ ≤ R) : E.transportRate ≤ W * upperConstant R Δ * Real.sqrt n := - E.transportRate_le_hopWork.trans (E.schedule.hopWork_le hn hR hΔ hW hposition) + E.transportRate_le_hopWork.trans (E.schedule.hopWork_le hn hR hΔ hposition) end Execution theorem achievable_le {n : ℕ} {R Δ W t : ℝ} (ht : Achievable n R Δ W t) - (hR : 0 ≤ R) (hΔ : 0 < Δ) (hW : 0 ≤ W) : + (hR : 0 ≤ R) (hΔ : 0 < Δ) : t ≤ W * upperConstant R Δ * Real.sqrt n := by obtain ⟨V, hV, hn, position, hposition, E, rfl⟩ := ht - exact E.transportRate_le hn hR hΔ hW hposition + exact E.transportRate_le hn hR hΔ hposition theorem achievable_bddAbove {n : ℕ} {R Δ W : ℝ} - (hR : 0 ≤ R) (hΔ : 0 < Δ) (hW : 0 ≤ W) : + (hR : 0 ≤ R) (hΔ : 0 < Δ) : BddAbove {t | Achievable n R Δ W t} := - ⟨W * upperConstant R Δ * Real.sqrt n, fun _ ht => achievable_le ht hR hΔ hW⟩ + ⟨W * upperConstant R Δ * Real.sqrt n, fun _ ht => achievable_le ht hR hΔ⟩ theorem Achievable.le_capacity {n : ℕ} {R Δ W t : ℝ} (ht : Achievable n R Δ W t) - (hR : 0 ≤ R) (hΔ : 0 < Δ) (hW : 0 ≤ W) : t ≤ capacity n R Δ W := - le_csSup (achievable_bddAbove hR hΔ hW) ht + (hR : 0 ≤ R) (hΔ : 0 < Δ) : t ≤ capacity n R Δ W := + le_csSup (achievable_bddAbove hR hΔ) ht theorem zero_achievable (n : ℕ) (R Δ W : ℝ) (hW : 0 ≤ W) : Achievable n R Δ W 0 := by @@ -161,12 +161,12 @@ theorem zero_achievable (n : ℕ) (R Δ W : ℝ) (hW : 0 ≤ W) : theorem capacity_nonneg {n : ℕ} {R Δ W : ℝ} (hR : 0 ≤ R) (hΔ : 0 < Δ) (hW : 0 ≤ W) : 0 ≤ capacity n R Δ W := - (zero_achievable n R Δ W hW).le_capacity hR hΔ hW + (zero_achievable n R Δ W hW).le_capacity hR hΔ theorem capacity_le {n : ℕ} {R Δ W : ℝ} (hR : 0 ≤ R) (hΔ : 0 < Δ) (hW : 0 ≤ W) : capacity n R Δ W ≤ W * upperConstant R Δ * Real.sqrt n := - csSup_le ⟨0, zero_achievable n R Δ W hW⟩ fun _ ht => achievable_le ht hR hΔ hW + csSup_le ⟨0, zero_achievable n R Δ W hW⟩ fun _ ht => achievable_le ht hR hΔ theorem capacity_zero_bandwidth {n : ℕ} {R Δ : ℝ} (hR : 0 ≤ R) (hΔ : 0 < Δ) : capacity n R Δ 0 = 0 := by diff --git a/lean/CapacityAtlasForMathlib/Probability/GaussianChannel.lean b/lean/CapacityAtlasForMathlib/Probability/GaussianChannel.lean index 83d86bc..658f9f9 100644 --- a/lean/CapacityAtlasForMathlib/Probability/GaussianChannel.lean +++ b/lean/CapacityAtlasForMathlib/Probability/GaussianChannel.lean @@ -160,7 +160,7 @@ theorem multivariateGaussian_conv (m n : EuclideanSpace ℝ ο) (Q N : Matrix ο ring theorem gaussianChannel_comp_eq_map (H : Matrix ο ι ℝ) (N : Matrix ο ο ℝ) - (μ : Measure (EuclideanSpace ℝ ι)) [SFinite μ] : + (μ : Measure (EuclideanSpace ℝ ι)) : gaussianChannel H N ∘ₘ μ = (μ.prod (multivariateGaussian 0 N)).map (fun p ↦ H.toEuclideanLin p.1 + p.2) := by ext s hs diff --git a/lean/CapacityAtlasForMathlib/Probability/GaussianDensity.lean b/lean/CapacityAtlasForMathlib/Probability/GaussianDensity.lean index e85aa38..52b9f67 100644 --- a/lean/CapacityAtlasForMathlib/Probability/GaussianDensity.lean +++ b/lean/CapacityAtlasForMathlib/Probability/GaussianDensity.lean @@ -293,11 +293,29 @@ theorem log_multivariateGaussianPDFReal (m : EuclideanSpace ℝ ι) theorem integrable_log_multivariateGaussianPDFReal {μ : Measure (EuclideanSpace ℝ ι)} [IsFiniteMeasure μ] - (m : EuclideanSpace ℝ ι) (S : Matrix ι ι ℝ) (hS : S.PosDef) + (m : EuclideanSpace ℝ ι) (S : Matrix ι ι ℝ) (hquad : Integrable (fun x : EuclideanSpace ℝ ι ↦ (x - m) ⬝ᵥ S⁻¹ *ᵥ (x - m)) μ) : Integrable (fun x ↦ Real.log (multivariateGaussianPDFReal m S x)) μ := by - simp_rw [log_multivariateGaussianPDFReal m S hS] - exact (integrable_const _).sub (hquad.div_const _) + by_cases hpos : 0 < S.det + · have hlog (x : EuclideanSpace ℝ ι) : + Real.log (multivariateGaussianPDFReal m S x) = + -((Fintype.card ι : ℝ) * Real.log (2 * Real.pi) + Real.log S.det) / 2 - + ((x - m) ⬝ᵥ S⁻¹ *ᵥ (x - m)) / 2 := by + have hconst : 0 < Real.sqrt (2 * Real.pi) := by positivity + have hdet : 0 < Real.sqrt S.det := Real.sqrt_pos.mpr hpos + rw [multivariateGaussianPDFReal, + Real.log_mul (mul_ne_zero (pow_ne_zero _ (inv_ne_zero hconst.ne')) (inv_ne_zero hdet.ne')) + (Real.exp_pos _).ne', + Real.log_mul (pow_ne_zero _ (inv_ne_zero hconst.ne')) (inv_ne_zero hdet.ne'), + Real.log_pow, Real.log_inv, Real.log_inv, + Real.log_sqrt (by positivity), Real.log_sqrt hpos.le, Real.log_exp] + ring + simp_rw [hlog] + exact (integrable_const _).sub (hquad.div_const _) + · have hdensity (x : EuclideanSpace ℝ ι) : multivariateGaussianPDFReal m S x = 0 := by + simp [multivariateGaussianPDFReal, Real.sqrt_eq_zero_of_nonpos (le_of_not_gt hpos)] + simpa only [hdensity, Real.log_zero] using (integrable_const (0 : ℝ) : + Integrable (fun _ : EuclideanSpace ℝ ι ↦ (0 : ℝ)) μ) theorem integral_log_multivariateGaussianPDFReal {μ : Measure (EuclideanSpace ℝ ι)} [IsProbabilityMeasure μ] diff --git a/lean/CapacityAtlasForMathlib/Probability/Kernel/Disintegration.lean b/lean/CapacityAtlasForMathlib/Probability/Kernel/Disintegration.lean index 9e2e461..d17a326 100644 --- a/lean/CapacityAtlasForMathlib/Probability/Kernel/Disintegration.lean +++ b/lean/CapacityAtlasForMathlib/Probability/Kernel/Disintegration.lean @@ -223,7 +223,7 @@ lemma condDistrib_const_unit (hX : Measurable X) (hY : Measurable Y) rfl omit [Countable U] [DiscreteMeasurableSpace U] in -lemma map_compProd_condDistrib [Nonempty S] (hX : Measurable X) (_hZ : Measurable Z) +lemma map_compProd_condDistrib [Nonempty S] (hX : Measurable X) (μ : Measure Ω) [IsProbabilityMeasure μ] : μ.map Z ⊗ₘ condDistrib X Z μ = μ.map (fun ω ↦ (Z ω, X ω)) := compProd_map_condDistrib hX.aemeasurable diff --git a/lean/lakefile.toml b/lean/lakefile.toml index 5ef24dc..d089ebb 100644 --- a/lean/lakefile.toml +++ b/lean/lakefile.toml @@ -5,6 +5,7 @@ defaultTargets = ["CapacityAtlas"] [leanOptions] autoImplicit = false linter.missingDocs = true +linter.unusedVariables = true [[lean_lib]] name = "CapacityAtlasUtil" diff --git a/tests/test_data.py b/tests/test_data.py index 2cd2047..d4ed0e3 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -74,7 +74,6 @@ def test_local_capacity_proof_does_not_require_external_records( formalization["proofs"] = [] claim = next(claim for claim in formalization["claims"] if claim["id"] == "exact-capacity") assert claim["formal_status"] == "proved" - assert claim["version"] == 1 report = _lean_report() assert validate_atlas(atlas, report if compiled else None) == []