diff --git a/data/problems/wireless-network-transport-capacity.yaml b/data/problems/wireless-network-transport-capacity.yaml new file mode 100644 index 0000000..a7d6548 --- /dev/null +++ b/data/problems/wireless-network-transport-capacity.yaml @@ -0,0 +1,78 @@ +# Copyright 2026 The Capacity Atlas Authors +# SPDX-License-Identifier: CC-BY-4.0 +id: wireless-network-transport-capacity +title: Wireless network transport capacity +status: partially-solved +updated: '2026-10-12' +summary: Optimally placed nodes under guard-zone interference have transport capacity of square-root order in the number of nodes. +tags: + model: [interference, relay] + features: [multiple-unicast] + quantity: [capacity] + knowledge: [bounds] +model: + input: Unicast packets originate at fixed nodes in a planar disk of radius \(R>0\). The budget of n nodes counts sources, destinations, and relays; unused nodes are idle. + output: Each packet reaches its source's chosen destination without error. + law: A transmission from x to y succeeds on a subchannel if every other simultaneous transmitter z on that subchannel satisfies \(\|z-y\|\ge(1+\Delta)\|x-y\|\), where \(\Delta>0\). + assumptions: + - The node budget n is a nonnegative integer and the total link rate satisfies \(W\ge0\). + - Node locations, each source's destination, traffic volumes, routes, transmission ranges, and schedules are optimized. Nodes do not move. + - A finite set of orthogonal subchannels has fixed nonnegative rates summing to at most W bits per second. A node sends to at most one receiver per subchannel at a time. + - Packets are routed without network coding, may wait at intermediate nodes, and traverse their hops in strictly increasing slots. Per-link bit counts obey the slot duration and subchannel rate. + - Finite executions start with the packets at their sources and count only fully delivered packets. Repetition gives a sustained transport rate. Schedules carry no information and multicast is not credited. +quantity: + name: Transport capacity + symbol: T_n(W,R,\Delta) + units: bit-meters per second + criterion: Supremum of the sum of delivered packet bit counts times source-to-destination Euclidean distance, divided by elapsed time, over all permitted placements and finite executions. +capacity: + kind: bounds + display: T_n(W,R,\Delta)=\Theta_\Delta(WR\sqrt n) + lower: c_\Delta WR\sqrt n + upper: C_\Delta WR\sqrt n + notes: Main Result 1 gives matching order bounds for fixed positive guard parameter. The disk has area \(\pi R^2\); unit area means \(R=1/\sqrt\pi\). The exact finite-n optimum is not determined by these bounds. +bounds: +- id: grid-achievability + direction: lower + relation: T_n(W,R,\Delta)=\Omega_\Delta(WR\sqrt n) + method: Place transmitter–receiver pairs on a separated grid and transmit directly and simultaneously; leave unused nodes idle. Gupta–Kumar, Main Result 1 and Section III. + year: 2000 + references: [gupta-kumar-2000] +- id: packing-converse + direction: upper + relation: T_n(W,R,\Delta)=O_\Delta(WR\sqrt n) + method: Protocol inequalities separate receiver guard disks. Area packing and Cauchy–Schwarz bound simultaneous hop distance; route triangle inequalities bound delivered distance. Gupta–Kumar, Theorem 2.1. + year: 2000 + references: [gupta-kumar-2000] +frontier: + question: Determine the finite-n transport capacity or sharpen its leading constant. + bottleneck: The packing converse and explicit grid construction have different constants. + progress: + - The order in n is settled for this arbitrary-placement protocol model. Random placement and physical interference require separate models. +formalization: + status: stated + claims: + - id: square-root-bounds + kind: capacity-bounds + category: solved + formal_status: proved + version: 1 + description: For n at least 4, R and Delta positive, and W nonnegative, transport capacity lies between W R sqrt(n)/(32(1+Delta)) and 2(1+Delta) W R sqrt(n)/Delta. + bound_ids: [grid-achievability, packing-converse] + notes: The local proof gives explicit nonsharp constants for the published order result, including nonsquare node counts. These constants are from the local construction and enclosing-disk proof, not the paper's displayed constants. The model accounts for integer packet bits, causal routes, subchannels, and delivered endpoint distance. + files: + - path: lean/CapacityAtlasForMathlib/Network/WirelessTransport/Basic.lean + declaration: CapacityAtlas.WirelessTransport.Execution + role: definition + description: Finite store-and-forward executions with protocol interference and per-link service constraints. + - path: lean/CapacityAtlasForMathlib/Network/WirelessTransport/Basic.lean + declaration: CapacityAtlas.WirelessTransport.capacity + role: definition + description: Supremum of delivered bit-distance per unit time over node placements and executions. + - path: lean/CapacityAtlas/Claims/WirelessTransport.lean + declaration: CapacityAtlas.Claims.wirelessTransportBounds + role: claim + claim_id: square-root-bounds + description: Full local proof of the matching square-root transport-capacity bounds. + proofs: [] +references: [gupta-kumar-2000] diff --git a/data/references.yaml b/data/references.yaml index d53e880..e7a2c9b 100644 --- a/data/references.yaml +++ b/data/references.yaml @@ -570,3 +570,11 @@ weingarten-steinberg-shamai-2006: venue: IEEE Transactions on Information Theory 52(9), 3936–3964 doi: 10.1109/TIT.2006.880064 url: https://web.stanford.edu/class/ee360/previous/suppRead/read1/WeingartenSteinbergShamai2006.pdf +gupta-kumar-2000: + title: The Capacity of Wireless Networks + authors: + - Piyush Gupta + - P. R. Kumar + year: 2000 + venue: IEEE Transactions on Information Theory 46(2), 388–404 + url: https://pdos.csail.mit.edu/archive/decouto/papers/gupta00.pdf diff --git a/docs/lean.md b/docs/lean.md index 8047cba..5ad81b6 100644 --- a/docs/lean.md +++ b/docs/lean.md @@ -83,6 +83,12 @@ capacities and every sufficiently large blocklength. The converse bounds the number of successfully decoded message tuples across each cut. Locality is expressed through observation factorization, including sources located at sinks. +`Network/WirelessTransport` proves matching square-root bounds for arbitrary +placements under protocol interference. Finite executions account for integer +packet bits, causal routes, subchannel service, and delivered endpoint distance. +Receiver-disk packing supplies the converse; a separated grid supplies the lower +bound for every node count at least four. The constants are nonsharp. + ### `CapacityAtlas` This layer contains concrete channel definitions, problem claims, proofs, and diff --git a/lean/CapacityAtlas.lean b/lean/CapacityAtlas.lean index 645aad6..4c28bfc 100644 --- a/lean/CapacityAtlas.lean +++ b/lean/CapacityAtlas.lean @@ -34,3 +34,4 @@ import CapacityAtlas.Tests.ConfidentialBroadcast import CapacityAtlas.Tests.MultisourceMulticast import CapacityAtlas.Tests.GaussianMIMOBroadcast import CapacityAtlas.Tests.GaussianMIMOBroadcastRegion +import CapacityAtlas.Tests.WirelessTransport diff --git a/lean/CapacityAtlas/Claims.lean b/lean/CapacityAtlas/Claims.lean index b90a82c..8fddfd1 100644 --- a/lean/CapacityAtlas/Claims.lean +++ b/lean/CapacityAtlas/Claims.lean @@ -48,3 +48,4 @@ import CapacityAtlas.Claims.Pentagon import CapacityAtlas.Claims.SevenCycleOperational import CapacityAtlas.Claims.DirectedIndexCycle import CapacityAtlas.Claims.FiveIndexCycle +import CapacityAtlas.Claims.WirelessTransport diff --git a/lean/CapacityAtlas/Claims/WirelessTransport.lean b/lean/CapacityAtlas/Claims/WirelessTransport.lean new file mode 100644 index 0000000..9962dc7 --- /dev/null +++ b/lean/CapacityAtlas/Claims/WirelessTransport.lean @@ -0,0 +1,21 @@ +/- +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 +import CapacityAtlasForMathlib.Network.WirelessTransport.Capacity + +namespace CapacityAtlas.Claims + +@[capacity_problem "wireless-network-transport-capacity", capacity_statement, + capacity_formal_proof, capacity_solved, capacity_claim "square-root-bounds" 1] +theorem wirelessTransportBounds {n : ℕ} {R Δ W : ℝ} + (hn : 4 ≤ n) (hR : 0 < R) (hΔ : 0 < Δ) (hW : 0 ≤ W) : + W * R * Real.sqrt n / (32 * (1 + Δ)) ≤ WirelessTransport.capacity n R Δ W ∧ + WirelessTransport.capacity n R Δ W ≤ + W * (2 * (1 + Δ) * R / Δ) * Real.sqrt n := + WirelessTransport.capacity_bounds hn hR hΔ hW + +end CapacityAtlas.Claims diff --git a/lean/CapacityAtlas/Tests/WirelessTransport.lean b/lean/CapacityAtlas/Tests/WirelessTransport.lean new file mode 100644 index 0000000..726069b --- /dev/null +++ b/lean/CapacityAtlas/Tests/WirelessTransport.lean @@ -0,0 +1,121 @@ +/- +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 CapacityAtlasForMathlib.Network.WirelessTransport.Operations +import CapacityAtlasUtil.Metadata + +open scoped BigOperators + +namespace CapacityAtlas.Tests + +open WirelessTransport + +noncomputable section + +private def linePoint (x : ℝ) : Point := WithLp.toLp 2 ![x, 0] + +private theorem linePoint_dist (x y : ℝ) : dist (linePoint x) (linePoint y) = |x - y| := by + simp [linePoint, EuclideanSpace.dist_eq, Fin.sum_univ_two, Real.dist_eq, + Real.sqrt_sq_eq_abs] + +private def detourPosition (v : Fin 3) : Point := linePoint (![0, 1, 1 / 2] v) + +private def detourPattern (s : Fin 2) : Pattern (Fin 3) detourPosition 1 where + Link := Fin 1 + finiteLink := inferInstance + sender := fun _ => if s = 0 then 0 else 1 + receiver := fun _ => if s = 0 then 1 else 2 + sender_injective := fun _ _ _ => Subsingleton.elim _ _ + protocol := fun _ _ h => (h (Subsingleton.elim _ _)).elim + +private def detourSchedule : Schedule (Fin 3) detourPosition 1 1 where + slots := 2 + bands := 1 + duration := fun _ => 1 / 2 + duration_nonneg := fun _ => by norm_num + duration_sum := by norm_num + bandRate := fun _ => 1 + bandRate_nonneg := fun _ => zero_le_one + bandRate_sum := by norm_num + pattern := fun s _ => detourPattern s + +private def detourExecution : Execution (Fin 3) detourPosition 1 1 where + schedule := detourSchedule + Packet := Fin 1 + finitePacket := inferInstance + amount := fun _ => 1 / 2 + amount_nonneg := fun _ => by norm_num + integralAmounts := ⟨2, by norm_num, fun _ => ⟨1, by norm_num⟩⟩ + destination := fun _ => 2 + hops := fun _ => 2 + route := fun _ k => if k = 0 then 0 else if k = 1 then 1 else 2 + delivered := fun _ => by norm_num + resource := fun _ h => ⟨h, (0 : Fin 1), (0 : Fin 1)⟩ + causal := fun _ _ _ h => h + hop_sender := by + intro p h + change (if h = 0 then (0 : Fin 3) else 1) = + (if h.val = 0 then 0 else if h.val = 1 then 1 else 2) + fin_cases h <;> decide + hop_receiver := by + intro p h + change (if h = 0 then (1 : Fin 3) else 2) = + (if h.val + 1 = 0 then 0 else if h.val + 1 = 1 then 1 else 2) + fin_cases h <;> decide + load_le := by + classical + dsimp only [detourSchedule, detourPattern, Schedule.Resource, Schedule.available] + intro r + change _ ≤ (1 / 2 : ℝ) * 1 + rcases r with ⟨s, b, l⟩ + fin_cases s <;> fin_cases b <;> fin_cases l <;> + norm_num [Fin.sum_univ_succ] + +/-- A detour earns endpoint distance once, not the sum of its hop lengths. -/ +@[capacity_test] +theorem wireless_detour_transport : detourExecution.transportRate = 1 / 4 := by + dsimp only [Execution.transportRate, detourExecution, detourPosition] + norm_num [linePoint_dist, Matrix.cons_val_two] + +@[capacity_test] +theorem wireless_detour_hop_work : + (∑ h : Fin 2, (1 / 2 : ℝ) * + detourSchedule.length (detourExecution.resource (0 : Fin 1) h)) = + 3 / 4 := by + dsimp only [Schedule.length, Schedule.sender, Schedule.receiver, detourExecution, + detourSchedule, detourPattern, detourPosition] + norm_num [Fin.sum_univ_succ, linePoint_dist, Matrix.cons_val_two] + +@[capacity_test] +theorem wireless_no_instantaneous_relay {V : Type} {position : V → Point} {Δ W : ℝ} + (E : Execution V position Δ W) (hslot : E.schedule.slots = 1) (p : E.Packet) : + E.hops p ≤ 1 := by + have h := Fintype.card_le_of_injective _ (E.causal p).injective + simpa [hslot] using h + +@[capacity_test] +theorem wireless_receiver_cannot_transmit {V : Type} {position : V → Point} {Δ : ℝ} + (hΔ : 0 < Δ) (P : Pattern V position Δ) {i j : P.Link} (hij : i ≠ j) + (hpositive : 0 < dist (position (P.sender i)) (position (P.receiver i))) : + P.sender j ≠ P.receiver i := by + intro hsame + have h := P.protocol i j hij + rw [hsame, dist_self] at h + nlinarith + +@[capacity_test] +theorem wireless_zero_bandwidth_delivers_zero {V : Type} {position : V → Point} {Δ : ℝ} + (E : Execution V position Δ 0) : E.transportRate = 0 := by + have hband (b : Fin E.schedule.bands) : E.schedule.bandRate b = 0 := by + apply le_antisymm _ (E.schedule.bandRate_nonneg b) + exact (Finset.single_le_sum (fun b _ => E.schedule.bandRate_nonneg b) + (Finset.mem_univ b)).trans E.schedule.bandRate_sum + apply le_antisymm _ E.transportRate_nonneg + simpa [Schedule.available, hband] using E.transportRate_le_hopWork + +end + +end CapacityAtlas.Tests diff --git a/lean/CapacityAtlasForMathlib.lean b/lean/CapacityAtlasForMathlib.lean index dd5f993..bbdb09a 100644 --- a/lean/CapacityAtlasForMathlib.lean +++ b/lean/CapacityAtlasForMathlib.lean @@ -94,3 +94,4 @@ import CapacityAtlasForMathlib.InformationTheory.MeasureRandomBinning.SequenceDe import CapacityAtlasForMathlib.InformationTheory.GaussianMIMOBroadcast.BlockEntropy import CapacityAtlasForMathlib.InformationTheory.GaussianMIMOBroadcast.Converse import CapacityAtlasForMathlib.InformationTheory.GaussianMIMOBroadcast.Achievability +import CapacityAtlasForMathlib.Network.WirelessTransport.Capacity diff --git a/lean/CapacityAtlasForMathlib/Network/WirelessTransport/Basic.lean b/lean/CapacityAtlasForMathlib/Network/WirelessTransport/Basic.lean new file mode 100644 index 0000000..b45054c --- /dev/null +++ b/lean/CapacityAtlasForMathlib/Network/WirelessTransport/Basic.lean @@ -0,0 +1,115 @@ +/- +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 CapacityAtlasForMathlib.Network.WirelessTransport.Geometry +import CapacityAtlasUtil + +open scoped BigOperators + +namespace CapacityAtlas.WirelessTransport + +noncomputable section + +attribute [local instance] Classical.propDecidable + +/-- Simultaneous unicast links on one frequency band. -/ +structure Pattern (V : Type) (position : V → Point) (Δ : ℝ) where + Link : Type + finiteLink : Fintype Link + sender : Link → V + receiver : Link → V + sender_injective : Function.Injective sender + protocol : ∀ i j, i ≠ j → + (1 + Δ) * dist (position (sender i)) (position (receiver i)) ≤ + dist (position (sender j)) (position (receiver i)) + +attribute [instance] Pattern.finiteLink + +/-- Slot durations are fractions of the observation interval; unused time is idle. -/ +structure Schedule (V : Type) (position : V → Point) (Δ W : ℝ) where + slots : ℕ + bands : ℕ + duration : Fin slots → ℝ + duration_nonneg : ∀ s, 0 ≤ duration s + duration_sum : ∑ s, duration s ≤ 1 + bandRate : Fin bands → ℝ + bandRate_nonneg : ∀ b, 0 ≤ bandRate b + bandRate_sum : ∑ b, bandRate b ≤ W + pattern : Fin slots → Fin bands → Pattern V position Δ + +namespace Schedule + +variable {V : Type} {position : V → Point} {Δ W : ℝ} + +abbrev Resource (S : Schedule V position Δ W) := + (s : Fin S.slots) × (b : Fin S.bands) × (S.pattern s b).Link + +instance (S : Schedule V position Δ W) : Fintype S.Resource := + inferInstanceAs (Fintype ((s : Fin S.slots) × (b : Fin S.bands) × (S.pattern s b).Link)) + +def sender (S : Schedule V position Δ W) (r : S.Resource) : V := + (S.pattern r.1 r.2.1).sender r.2.2 + +def receiver (S : Schedule V position Δ W) (r : S.Resource) : V := + (S.pattern r.1 r.2.1).receiver r.2.2 + +def length (S : Schedule V position Δ W) (r : S.Resource) : ℝ := + dist (position (S.sender r)) (position (S.receiver r)) + +def available (S : Schedule V position Δ W) (r : S.Resource) : ℝ := + S.duration r.1 * S.bandRate r.2.1 + +end Schedule + +/-- A finite collection of delivered packets with causal store-and-forward routes. +Amounts are bit counts divided by a common positive observation time. -/ +@[capacity_problem "wireless-network-transport-capacity", capacity_definition] +structure Execution (V : Type) (position : V → Point) (Δ W : ℝ) where + schedule : Schedule V position Δ W + Packet : Type + finitePacket : Fintype Packet + amount : Packet → ℝ + amount_nonneg : ∀ p, 0 ≤ amount p + integralAmounts : ∃ T : ℝ, 0 < T ∧ ∀ p, ∃ k : ℕ, amount p * T = k + destination : V → V + hops : Packet → ℕ + route : Packet → ℕ → V + delivered : ∀ p, route p (hops p) = destination (route p 0) + resource : (p : Packet) → Fin (hops p) → schedule.Resource + causal : ∀ p, StrictMono fun h => (resource p h).1 + hop_sender : ∀ p h, schedule.sender (resource p h) = route p h.val + hop_receiver : ∀ p h, schedule.receiver (resource p h) = route p (h.val + 1) + load_le : ∀ r : schedule.Resource, + (∑ p, ∑ h : Fin (hops p), if resource p h = r then amount p else 0) ≤ + schedule.available r + +attribute [instance] Execution.finitePacket + +namespace Execution + +variable {V : Type} {position : V → Point} {Δ W : ℝ} + +/-- Each packet is credited once, using its endpoints rather than its route length. -/ +def transportRate (E : Execution V position Δ W) : ℝ := + ∑ p, E.amount p * dist (position (E.route p 0)) (position (E.route p (E.hops p))) + +theorem transportRate_nonneg (E : Execution V position Δ W) : 0 ≤ E.transportRate := by + exact Finset.sum_nonneg fun p _ => mul_nonneg (E.amount_nonneg p) dist_nonneg + +end Execution + +/-- The node budget includes unused nodes, which may be added without changing a schedule. -/ +def Achievable (n : ℕ) (R Δ W t : ℝ) : Prop := + ∃ (V : Type) (_ : Fintype V), Fintype.card V ≤ n ∧ + ∃ position : V → Point, (∀ v, ‖position v‖ ≤ R) ∧ + ∃ E : Execution V position Δ W, E.transportRate = t + +@[capacity_problem "wireless-network-transport-capacity", capacity_definition] +def capacity (n : ℕ) (R Δ W : ℝ) : ℝ := sSup {t | Achievable n R Δ W t} + +end + +end CapacityAtlas.WirelessTransport diff --git a/lean/CapacityAtlasForMathlib/Network/WirelessTransport/Capacity.lean b/lean/CapacityAtlasForMathlib/Network/WirelessTransport/Capacity.lean new file mode 100644 index 0000000..54a5217 --- /dev/null +++ b/lean/CapacityAtlasForMathlib/Network/WirelessTransport/Capacity.lean @@ -0,0 +1,43 @@ +/- +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 CapacityAtlasForMathlib.Network.WirelessTransport.Operations +import CapacityAtlasForMathlib.Network.WirelessTransport.OneHop +import CapacityAtlasForMathlib.Network.WirelessTransport.Grid +import CapacityAtlasForMathlib.Network.WirelessTransport.Rounding + +namespace CapacityAtlas.WirelessTransport + +theorem capacity_lower {n : ℕ} {R Δ W : ℝ} + (hn : 4 ≤ n) (hR : 0 < R) (hΔ : 0 < Δ) (hW : 0 ≤ W) : + W * R * Real.sqrt n / (32 * (1 + Δ)) ≤ capacity n R Δ W := by + 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) + (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 + Δ)) ≤ + W * (R * (m : ℝ) / (8 * (1 + Δ))) := by + have hden : 0 < 32 * (1 + Δ) := by positivity + apply (div_le_iff₀ hden).2 + have he : W * (R * (m : ℝ) / (8 * (1 + Δ))) * (32 * (1 + Δ)) = + W * R * (4 * (m : ℝ)) := by + have hd : 1 + Δ ≠ 0 := by positivity + field_simp + 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) + +/-- Nonsharp constants give matching order bounds for every node count at least four. -/ +theorem capacity_bounds {n : ℕ} {R Δ W : ℝ} + (hn : 4 ≤ n) (hR : 0 < R) (hΔ : 0 < Δ) (hW : 0 ≤ W) : + W * R * Real.sqrt n / (32 * (1 + Δ)) ≤ capacity n R Δ W ∧ + capacity n R Δ W ≤ W * (2 * (1 + Δ) * R / Δ) * Real.sqrt n := + ⟨capacity_lower hn hR hΔ hW, capacity_le hR.le hΔ hW⟩ + +end CapacityAtlas.WirelessTransport diff --git a/lean/CapacityAtlasForMathlib/Network/WirelessTransport/Geometry.lean b/lean/CapacityAtlasForMathlib/Network/WirelessTransport/Geometry.lean new file mode 100644 index 0000000..808cecc --- /dev/null +++ b/lean/CapacityAtlasForMathlib/Network/WirelessTransport/Geometry.lean @@ -0,0 +1,82 @@ +/- +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 Mathlib.MeasureTheory.Measure.Lebesgue.VolumeOfBalls +import Mathlib.MeasureTheory.Measure.Real +import Mathlib.Analysis.Real.Sqrt +import Mathlib.Tactic + +open scoped BigOperators +open MeasureTheory Metric + +namespace CapacityAtlas.WirelessTransport + +abbrev Point := EuclideanSpace ℝ (Fin 2) + +/-- Packing disjoint planar disks bounds the sum of their radii. -/ +theorem sum_radii_le {I : Type*} [Fintype I] (c : I → Point) (r : I → ℝ) + (B : ℝ) (hB : 0 ≤ B) (hr : ∀ i, 0 ≤ r i) + (hcontained : ∀ i, ‖c i‖ + r i ≤ B) + (hdisjoint : Pairwise fun i j => Disjoint (ball (c i) (r i)) (ball (c j) (r j))) : + ∑ i, r i ≤ B * Real.sqrt (Fintype.card I) := by + classical + have hsubset : (⋃ i, ball (c i) (r i)) ⊆ ball (0 : Point) B := by + refine Set.iUnion_subset fun i x hx => ?_ + rw [mem_ball, dist_zero_right] + have hx' := mem_ball.mp hx + have htri : ‖x‖ ≤ dist x (c i) + ‖c i‖ := by + simpa using dist_triangle x (c i) (0 : Point) + linarith [hcontained i] + have hmeasure : ∑ i, volume.real (ball (c i) (r i)) ≤ + volume.real (ball (0 : Point) B) := by + calc + ∑ i, volume.real (ball (c i) (r i)) = + volume.real (⋃ i, ball (c i) (r i)) := by + simpa using (measureReal_biUnion_finset (μ := volume) (s := Finset.univ) + (fun i _ j _ hij => hdisjoint hij) (fun _ _ => measurableSet_ball)).symm + _ ≤ volume.real (ball (0 : Point) B) := measureReal_mono hsubset + have harea : ∑ i, r i ^ 2 * Real.pi ≤ B ^ 2 * Real.pi := by + simpa [Measure.real, EuclideanSpace.volume_ball_fin_two, ENNReal.toReal_mul, + ENNReal.toReal_pow, ENNReal.toReal_ofReal, hr, hB, Real.pi_pos.le] using hmeasure + have hsquare : ∑ i, r i ^ 2 ≤ B ^ 2 := by + rw [← Finset.sum_mul] at harea + nlinarith [Real.pi_pos] + have hsqrt : Real.sqrt (∑ i, r i ^ 2) ≤ B := by + exact (Real.sqrt_le_iff).2 ⟨hB, hsquare⟩ + calc + ∑ i, r i ≤ Real.sqrt (∑ i, r i ^ 2) * Real.sqrt (Fintype.card I) := by + simpa using Real.sum_mul_le_sqrt_mul_sqrt Finset.univ r (fun _ => (1 : ℝ)) + _ ≤ B * Real.sqrt (Fintype.card I) := mul_le_mul_of_nonneg_right hsqrt (Real.sqrt_nonneg _) + +/-- The protocol exclusion inequalities separate receiver guard disks. -/ +theorem guard_disks_disjoint {I : Type*} (tx rx : I → Point) (Δ : ℝ) + (hprotocol : ∀ i j, i ≠ j → (1 + Δ) * dist (tx i) (rx i) ≤ dist (tx j) (rx i)) : + Pairwise fun i j => Disjoint (ball (rx i) (Δ / 2 * dist (tx i) (rx i))) + (ball (rx j) (Δ / 2 * dist (tx j) (rx j))) := by + intro i j hij + apply ball_disjoint_ball + have h₁ := (hprotocol i j hij).trans (dist_triangle (tx j) (rx j) (rx i)) + have h₂ := (hprotocol j i hij.symm).trans (dist_triangle (tx i) (rx i) (rx j)) + rw [dist_comm (rx j) (rx i)] at h₁ + linarith + +/-- A simultaneous protocol-model schedule has at most square-root total hop length. -/ +theorem sum_linkLength_le {I : Type*} [Fintype I] (tx rx : I → Point) (R Δ : ℝ) + (hR : 0 ≤ R) (hΔ : 0 < Δ) (htx : ∀ i, ‖tx i‖ ≤ R) (hrx : ∀ i, ‖rx i‖ ≤ R) + (hprotocol : ∀ i j, i ≠ j → (1 + Δ) * dist (tx i) (rx i) ≤ dist (tx j) (rx i)) : + ∑ i, dist (tx i) (rx i) ≤ (2 * (1 + Δ) * R / Δ) * Real.sqrt (Fintype.card I) := by + have hlink : ∀ i, dist (tx i) (rx i) ≤ 2 * R := by + intro i + exact (dist_le_norm_add_norm _ _).trans (by linarith [htx i, hrx i]) + have hpacking := sum_radii_le rx (fun i => Δ / 2 * dist (tx i) (rx i)) + (R * (1 + Δ)) (by positivity) (fun _ => by positivity) + (fun i => by nlinarith [hrx i, hlink i]) (guard_disks_disjoint tx rx Δ hprotocol) + rw [← Finset.mul_sum] at hpacking + rw [div_mul_eq_mul_div] + apply (le_div_iff₀ hΔ).2 + nlinarith [hpacking] + +end CapacityAtlas.WirelessTransport diff --git a/lean/CapacityAtlasForMathlib/Network/WirelessTransport/Grid.lean b/lean/CapacityAtlasForMathlib/Network/WirelessTransport/Grid.lean new file mode 100644 index 0000000..7ee74ed --- /dev/null +++ b/lean/CapacityAtlasForMathlib/Network/WirelessTransport/Grid.lean @@ -0,0 +1,162 @@ +/- +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 Mathlib.Analysis.InnerProductSpace.PiL2 +import Mathlib.Tactic + +/-! A separated square grid of simultaneous protocol-model links. -/ + +noncomputable section + +namespace CapacityAtlas.WirelessTransport + +abbrev GridIndex (m : ℕ) := Fin m × Fin m + +def gridStep (R : ℝ) (m : ℕ) : ℝ := R / (2 * (m : ℝ)) + +def gridHop (R Δ : ℝ) (m : ℕ) : ℝ := R / (8 * (1 + Δ) * (m : ℝ)) + +def gridTx (R _Δ : ℝ) (m : ℕ) (i : GridIndex m) : EuclideanSpace ℝ (Fin 2) := + WithLp.toLp 2 ![(i.1.val : ℝ) * gridStep R m, (i.2.val : ℝ) * gridStep R m] + +def gridRx (R Δ : ℝ) (m : ℕ) (i : GridIndex m) : EuclideanSpace ℝ (Fin 2) := + WithLp.toLp 2 ![(i.1.val : ℝ) * gridStep R m + gridHop R Δ m, + (i.2.val : ℝ) * gridStep R m] + +theorem gridStep_pos {R : ℝ} {m : ℕ} (hR : 0 < R) (hm : 0 < m) : + 0 < gridStep R m := by + unfold gridStep + positivity + +theorem gridHop_pos {R Δ : ℝ} {m : ℕ} (hR : 0 < R) (hΔ : 0 < Δ) (hm : 0 < m) : + 0 < gridHop R Δ m := by + unfold gridHop + positivity + +theorem gridHop_mul {R Δ : ℝ} {m : ℕ} (hΔ : 0 < Δ) : + (1 + Δ) * gridHop R Δ m = gridStep R m / 4 := by + unfold gridHop gridStep + have hd : 1 + Δ ≠ 0 := ne_of_gt (by linarith) + field_simp + ring + +theorem gridHop_le_step {R Δ : ℝ} {m : ℕ} + (hR : 0 < R) (hΔ : 0 < Δ) (hm : 0 < m) : + gridHop R Δ m ≤ gridStep R m / 4 := by + have hp := gridHop_pos hR hΔ hm + have he := gridHop_mul (R := R) (m := m) hΔ + nlinarith + +theorem grid_hop_length {R Δ : ℝ} {m : ℕ} + (hR : 0 < R) (hΔ : 0 < Δ) (hm : 0 < m) (i : GridIndex m) : + dist (gridTx R Δ m i) (gridRx R Δ m i) = gridHop R Δ m := by + have hp := gridHop_pos hR hΔ hm + rw [EuclideanSpace.dist_eq] + 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) : + 0 ≤ (i.val : ℝ) * gridStep R m ∧ + (i.val : ℝ) * gridStep R m + gridStep R m ≤ R / 2 := by + have hs := gridStep_pos hR hm + 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 + 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 + 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 + EuclideanSpace.real_norm_sq_eq (gridTx R Δ m i) + have hxx := mul_nonneg hx.1 (show 0 ≤ R / 2 - (i.1.val : ℝ) * gridStep R m by linarith) + have hyy := mul_nonneg hy.1 (show 0 ≤ R / 2 - (i.2.val : ℝ) * gridStep R m by linarith) + nlinarith + +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 hs := gridStep_pos hR hm + have hp := gridHop_pos hR hΔ hm + have hps := gridHop_le_step hR hΔ hm + have he : ‖gridRx R Δ m i‖ ^ 2 = + ((i.1.val : ℝ) * gridStep R m + gridHop R Δ m) ^ 2 + + ((i.2.val : ℝ) * gridStep R m) ^ 2 := by + simpa [gridRx, Fin.sum_univ_two] using + EuclideanSpace.real_norm_sq_eq (gridRx R Δ m i) + have hx' : 0 ≤ (i.1.val : ℝ) * gridStep R m + gridHop R Δ m ∧ + (i.1.val : ℝ) * gridStep R m + gridHop R Δ m ≤ R / 2 := by + constructor <;> linarith + have hxx := mul_nonneg hx'.1 (show 0 ≤ R / 2 - + ((i.1.val : ℝ) * gridStep R m + gridHop R Δ m) by linarith) + have hyy := mul_nonneg hy.1 (show 0 ≤ R / 2 - (i.2.val : ℝ) * gridStep R m by linarith) + nlinarith + +theorem grid_coord_separation {R : ℝ} {m : ℕ} (hR : 0 < R) (hm : 0 < m) + {i j : Fin m} (hij : i ≠ j) : + gridStep R m ≤ dist ((i.val : ℝ) * gridStep R m) ((j.val : ℝ) * gridStep R m) := by + have hs := gridStep_pos hR hm + have hne : i.val ≠ j.val := fun h => hij (Fin.ext h) + rw [Real.dist_eq] + rcases lt_or_gt_of_ne hne with hlt | hgt + · have h : (i.val : ℝ) + 1 ≤ (j.val : ℝ) := by exact_mod_cast hlt + have hp := mul_le_mul_of_nonneg_right h hs.le + have ha := neg_le_abs ((i.val : ℝ) * gridStep R m - (j.val : ℝ) * gridStep R m) + nlinarith + · have h : (j.val : ℝ) + 1 ≤ (i.val : ℝ) := by exact_mod_cast hgt + have hp := mul_le_mul_of_nonneg_right h hs.le + have ha := le_abs_self ((i.val : ℝ) * gridStep R m - (j.val : ℝ) * gridStep R m) + nlinarith + +theorem grid_tx_separation {R Δ : ℝ} {m : ℕ} (hR : 0 < R) (hm : 0 < m) + {i j : GridIndex m} (hij : i ≠ j) : + gridStep R m ≤ dist (gridTx R Δ m i) (gridTx R Δ m j) := by + by_cases hfirst : i.1 = j.1 + · have hsecond : i.2 ≠ j.2 := fun h => hij (Prod.ext hfirst h) + have hc := PiLp.dist_apply_le (gridTx R Δ m i) (gridTx R Δ m j) (1 : Fin 2) + change dist ((i.2.val : ℝ) * gridStep R m) ((j.2.val : ℝ) * gridStep R m) ≤ + dist (gridTx R Δ m i) (gridTx R Δ m j) at hc + exact (grid_coord_separation hR hm hsecond).trans hc + · have hc := PiLp.dist_apply_le (gridTx R Δ m i) (gridTx R Δ m j) (0 : Fin 2) + change dist ((i.1.val : ℝ) * gridStep R m) ((j.1.val : ℝ) * gridStep R m) ≤ + dist (gridTx R Δ m i) (gridTx R Δ m j) at hc + exact (grid_coord_separation hR hm hfirst).trans hc + +theorem grid_protocol {R Δ : ℝ} {m : ℕ} + (hR : 0 < R) (hΔ : 0 < Δ) (hm : 0 < m) {i j : GridIndex m} (hij : i ≠ j) : + (1 + Δ) * dist (gridTx R Δ m i) (gridRx R Δ m i) ≤ + dist (gridTx R Δ m j) (gridRx R Δ m i) := by + have hs := gridStep_pos hR hm + have hsep := grid_tx_separation (Δ := Δ) hR hm hij.symm + have ht := dist_triangle (gridTx R Δ m j) (gridRx R Δ m i) (gridTx R Δ m i) + rw [dist_comm (gridRx R Δ m i), grid_hop_length hR hΔ hm] at ht + rw [grid_hop_length hR hΔ hm] + have hp := gridHop_le_step hR hΔ hm + have he := gridHop_mul (R := R) (m := m) hΔ + nlinarith + +theorem grid_total_length {R Δ : ℝ} {m : ℕ} + (hR : 0 < R) (hΔ : 0 < Δ) (hm : 0 < m) : + ∑ i : GridIndex m, dist (gridTx R Δ m i) (gridRx R Δ m i) = + R * (m : ℝ) / (8 * (1 + Δ)) := by + simp only [grid_hop_length hR hΔ hm, Finset.sum_const, Finset.card_univ, + Fintype.card_prod, Fintype.card_fin, nsmul_eq_mul, Nat.cast_mul] + have hm' : (m : ℝ) ≠ 0 := by exact_mod_cast Nat.ne_of_gt hm + have hd : 1 + Δ ≠ 0 := ne_of_gt (by linarith) + unfold gridHop + field_simp + +end CapacityAtlas.WirelessTransport diff --git a/lean/CapacityAtlasForMathlib/Network/WirelessTransport/OneHop.lean b/lean/CapacityAtlasForMathlib/Network/WirelessTransport/OneHop.lean new file mode 100644 index 0000000..6ea512e --- /dev/null +++ b/lean/CapacityAtlasForMathlib/Network/WirelessTransport/OneHop.lean @@ -0,0 +1,88 @@ +/- +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 CapacityAtlasForMathlib.Network.WirelessTransport.Basic + +open scoped BigOperators + +noncomputable section + +namespace CapacityAtlas.WirelessTransport + +/-- Any finite feasible collection of direct links can run for the whole interval. -/ +theorem oneHop_achievable {n : ℕ} (I : Type) [Fintype I] (tx rx : I → Point) + (R Δ W : ℝ) (hcard : 2 * Fintype.card I ≤ n) (hW : 0 ≤ W) + (htx : ∀ i, ‖tx i‖ ≤ R) (hrx : ∀ i, ‖rx i‖ ≤ R) + (hprotocol : ∀ i j, i ≠ j → (1 + Δ) * dist (tx i) (rx i) ≤ dist (tx j) (rx i)) : + Achievable n R Δ W (W * ∑ i, dist (tx i) (rx i)) := by + classical + let position : I ⊕ I → Point := Sum.elim tx rx + let P : Pattern (I ⊕ I) position Δ := { + Link := I + finiteLink := inferInstance + sender := Sum.inl + receiver := Sum.inr + sender_injective := Sum.inl_injective + protocol := hprotocol } + let S : Schedule (I ⊕ I) position Δ W := { + slots := 1 + bands := 1 + duration := fun _ => 1 + duration_nonneg := fun _ => zero_le_one + duration_sum := by simp + bandRate := fun _ => W + bandRate_nonneg := fun _ => hW + bandRate_sum := by simp + pattern := fun _ _ => P } + have hintegral : ∃ T : ℝ, 0 < T ∧ ∀ _ : I, ∃ k : ℕ, W * T = k := by + by_cases hz : W = 0 + · exact ⟨1, zero_lt_one, fun _ => ⟨0, by simp [hz]⟩⟩ + · exact ⟨1 / W, by positivity, fun _ => ⟨1, by simp [hz]⟩⟩ + let E : Execution (I ⊕ I) position Δ W := { + schedule := S + Packet := I + finitePacket := inferInstance + amount := fun _ => W + amount_nonneg := fun _ => hW + integralAmounts := hintegral + destination := Sum.elim Sum.inr Sum.inr + hops := fun _ => 1 + route := fun i k => if k = 0 then Sum.inl i else Sum.inr i + delivered := by intro i; simp + resource := fun i _ => ⟨0, ⟨0, i⟩⟩ + causal := by + intro i a b hab + have he : a = b := Subsingleton.elim _ _ + subst b + exact (lt_irrefl _ hab).elim + hop_sender := by intro i h; simp [Schedule.sender, S, P, Fin.eq_zero h] + hop_receiver := by intro i h; simp [Schedule.receiver, S, P] + load_le := by + intro r + rcases r with ⟨s, b, j⟩ + have hs : s = 0 := Subsingleton.elim _ _ + have hb : b = 0 := Subsingleton.elim _ _ + subst s b + simp only [Fin.sum_univ_one] + change (∑ x : I, if (⟨0, ⟨0, x⟩⟩ : S.Resource) = ⟨0, ⟨0, j⟩⟩ + then W else 0) ≤ 1 * W + have heq (x : I) : (⟨0, ⟨0, x⟩⟩ : S.Resource) = ⟨0, ⟨0, j⟩⟩ ↔ x = j := by + constructor + · intro h + exact congrArg (fun r : S.Resource => (r.2.2 : I)) h + · intro h + subst x + rfl + simp [heq] } + refine ⟨I ⊕ I, inferInstance, ?_, position, ?_, E, ?_⟩ + · simpa [Fintype.card_sum, two_mul] using hcard + · intro i + cases i with + | inl i => exact htx i + | inr i => exact hrx i + · simp [Execution.transportRate, E, position, Finset.mul_sum] + +end CapacityAtlas.WirelessTransport diff --git a/lean/CapacityAtlasForMathlib/Network/WirelessTransport/Operations.lean b/lean/CapacityAtlasForMathlib/Network/WirelessTransport/Operations.lean new file mode 100644 index 0000000..33f78c4 --- /dev/null +++ b/lean/CapacityAtlasForMathlib/Network/WirelessTransport/Operations.lean @@ -0,0 +1,177 @@ +/- +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 CapacityAtlasForMathlib.Network.WirelessTransport.Basic + +open scoped BigOperators + +namespace CapacityAtlas.WirelessTransport + +noncomputable section + +def upperConstant (R Δ : ℝ) : ℝ := 2 * (1 + Δ) * R / Δ + +theorem upperConstant_nonneg {R Δ : ℝ} (hR : 0 ≤ R) (hΔ : 0 < Δ) : + 0 ≤ upperConstant R Δ := by unfold upperConstant; positivity + +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) + (hposition : ∀ v, ‖position v‖ ≤ R) : + ∑ r : S.Resource, S.available r * S.length r ≤ + W * upperConstant R Δ * Real.sqrt n := by + classical + let U := upperConstant R Δ * Real.sqrt n + have hU : 0 ≤ U := mul_nonneg (upperConstant_nonneg hR hΔ) (Real.sqrt_nonneg _) + have hp (s : Fin S.slots) (b : Fin S.bands) : + ∑ l : (S.pattern s b).Link, + dist (position ((S.pattern s b).sender l)) + (position ((S.pattern s b).receiver l)) ≤ U := by + have hc : Fintype.card (S.pattern s b).Link ≤ n := + (Fintype.card_le_of_injective _ (S.pattern s b).sender_injective).trans hn + exact (sum_linkLength_le _ _ R Δ hR hΔ + (fun l => hposition ((S.pattern s b).sender l)) + (fun l => hposition ((S.pattern s b).receiver l)) (S.pattern s b).protocol).trans + (mul_le_mul_of_nonneg_left (Real.sqrt_le_sqrt (by exact_mod_cast hc)) + (upperConstant_nonneg hR hΔ)) + have hd : 0 ≤ ∑ s, S.duration s := Finset.sum_nonneg fun s _ => S.duration_nonneg s + have hb : 0 ≤ ∑ b, S.bandRate b := Finset.sum_nonneg fun b _ => S.bandRate_nonneg b + calc + ∑ r : S.Resource, S.available r * S.length r = + ∑ s, ∑ b, S.duration s * S.bandRate b * + ∑ l : (S.pattern s b).Link, + dist (position ((S.pattern s b).sender l)) + (position ((S.pattern s b).receiver l)) := by + simp only [Fintype.sum_sigma, available, length, sender, receiver, Finset.mul_sum] + _ ≤ ∑ s, ∑ b, S.duration s * S.bandRate b * U := by + apply Finset.sum_le_sum + intro s _ + apply Finset.sum_le_sum + intro b _ + exact mul_le_mul_of_nonneg_left (hp s b) + (mul_nonneg (S.duration_nonneg s) (S.bandRate_nonneg b)) + _ = (∑ s, S.duration s) * (∑ b, S.bandRate b) * U := by + simp only [Finset.sum_mul, Finset.mul_sum] + exact Finset.sum_comm + _ ≤ 1 * W * U := by + exact mul_le_mul_of_nonneg_right + (mul_le_mul S.duration_sum S.bandRate_sum hb (by norm_num)) hU + _ = W * upperConstant R Δ * Real.sqrt n := by dsimp [U]; ring + +end Schedule + +namespace Execution + +variable {V : Type} {position : V → Point} {Δ W : ℝ} + +theorem endpoint_le_hops (E : Execution V position Δ W) (p : E.Packet) : + dist (position (E.route p 0)) (position (E.route p (E.hops p))) ≤ + ∑ h : Fin (E.hops p), E.schedule.length (E.resource p h) := by + have ht := dist_le_range_sum_dist (fun k => position (E.route p k)) (E.hops p) + simpa only [← Fin.sum_univ_eq_sum_range, Schedule.length, E.hop_sender, + E.hop_receiver] using ht + +theorem transportRate_le_hopWork (E : Execution V position Δ W) : + E.transportRate ≤ ∑ r : E.schedule.Resource, + E.schedule.available r * E.schedule.length r := by + classical + have haccount : + (∑ p, ∑ h : Fin (E.hops p), E.amount p * E.schedule.length (E.resource p h)) = + ∑ r : E.schedule.Resource, + (∑ p, ∑ h : Fin (E.hops p), if E.resource p h = r then E.amount p else 0) * + E.schedule.length r := by + simp_rw [Finset.sum_mul, ite_mul, zero_mul] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro p _ + rw [Finset.sum_comm] + simp + calc + E.transportRate ≤ + ∑ p, E.amount p * ∑ h : Fin (E.hops p), E.schedule.length (E.resource p h) := by + exact Finset.sum_le_sum fun p _ => + mul_le_mul_of_nonneg_left (E.endpoint_le_hops p) (E.amount_nonneg p) + _ = ∑ p, ∑ h : Fin (E.hops p), E.amount p * E.schedule.length (E.resource p h) := by + simp only [Finset.mul_sum] + _ = _ := haccount + _ ≤ _ := Finset.sum_le_sum fun r _ => + 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) + (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) + +end Execution + +theorem achievable_le {n : ℕ} {R Δ W t : ℝ} (ht : Achievable n R Δ W t) + (hR : 0 ≤ R) (hΔ : 0 < Δ) (hW : 0 ≤ W) : + 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 + +theorem achievable_bddAbove {n : ℕ} {R Δ W : ℝ} + (hR : 0 ≤ R) (hΔ : 0 < Δ) (hW : 0 ≤ W) : + BddAbove {t | Achievable n R Δ W t} := + ⟨W * upperConstant R Δ * Real.sqrt n, fun _ ht => achievable_le ht hR hΔ hW⟩ + +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 + +theorem zero_achievable (n : ℕ) (R Δ W : ℝ) (hW : 0 ≤ W) : + Achievable n R Δ W 0 := by + classical + let S : Schedule Empty Empty.elim Δ W := { + slots := 0 + bands := 0 + duration := Fin.elim0 + duration_nonneg := fun s => Fin.elim0 s + duration_sum := by simp + bandRate := Fin.elim0 + bandRate_nonneg := fun b => Fin.elim0 b + bandRate_sum := by simpa using hW + pattern := fun s => Fin.elim0 s } + let E : Execution Empty Empty.elim Δ W := { + schedule := S + Packet := Empty + finitePacket := inferInstance + amount := Empty.elim + amount_nonneg := fun p => p.elim + integralAmounts := ⟨1, by norm_num, fun p => p.elim⟩ + destination := Empty.elim + hops := Empty.elim + route := Empty.elim + delivered := fun p => p.elim + resource := fun p => p.elim + causal := fun p => p.elim + hop_sender := fun p => p.elim + hop_receiver := fun p => p.elim + load_le := fun r => Fin.elim0 r.1 } + exact ⟨Empty, inferInstance, by simp, Empty.elim, fun v => v.elim, E, + by simp [Execution.transportRate, E]⟩ + +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 + +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 + +theorem capacity_zero_bandwidth {n : ℕ} {R Δ : ℝ} (hR : 0 ≤ R) (hΔ : 0 < Δ) : + capacity n R Δ 0 = 0 := by + exact le_antisymm (by simpa using capacity_le (n := n) hR hΔ (le_refl 0)) + (capacity_nonneg hR hΔ (le_refl 0)) + +end + +end CapacityAtlas.WirelessTransport diff --git a/lean/CapacityAtlasForMathlib/Network/WirelessTransport/Rounding.lean b/lean/CapacityAtlasForMathlib/Network/WirelessTransport/Rounding.lean new file mode 100644 index 0000000..b4d39cc --- /dev/null +++ b/lean/CapacityAtlasForMathlib/Network/WirelessTransport/Rounding.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 Mathlib.Data.Nat.Sqrt +import Mathlib.Analysis.SpecialFunctions.Sqrt +import Mathlib.Tactic + +namespace CapacityAtlas.WirelessTransport + +/-- A square grid of pairs fits every node budget, including nonsquares. -/ +theorem exists_grid_size {n : ℕ} (hn : 4 ≤ n) : + ∃ m : ℕ, 0 < m ∧ 2 * (m * m) ≤ n ∧ Real.sqrt n ≤ 4 * (m : ℝ) := by + let m := Nat.sqrt n / 2 + have hs : 2 ≤ Nat.sqrt n := Nat.le_sqrt.mpr (by omega) + have hm : 0 < m := by dsimp [m]; omega + have hms : 2 * m ≤ Nat.sqrt n := by dsimp [m]; omega + have hsm : Nat.sqrt n + 1 ≤ 4 * m := by dsimp [m]; omega + have hsq := Nat.sqrt_le n + have hnlt := Nat.lt_succ_sqrt n + refine ⟨m, hm, by nlinarith, ?_⟩ + have hnreal : (n : ℝ) < ((Nat.sqrt n : ℝ) + 1) ^ 2 := by + exact_mod_cast (show n < (Nat.sqrt n + 1) ^ 2 by simpa [pow_two] using hnlt) + have hsmreal : (Nat.sqrt n : ℝ) + 1 ≤ 4 * (m : ℝ) := by exact_mod_cast hsm + have hroot := Real.sq_sqrt (show (0 : ℝ) ≤ n by positivity) + have hn0 := Real.sqrt_nonneg (n : ℝ) + have hm0 : (0 : ℝ) ≤ m := by positivity + nlinarith + +end CapacityAtlas.WirelessTransport diff --git a/tests/test_data.py b/tests/test_data.py index 687c5fa..66e097f 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -234,6 +234,7 @@ def test_registered_statement_inventory_matches_expected_problems() -> None: "two-user-discrete-memoryless-mac", "two-user-gaussian-mac", "two-user-gaussian-mac-with-feedback", + "wireless-network-transport-capacity", } stated = {