AFTD Auto-Formalizing Theoretical Domains

arrival_exact_departure_counts_eq_ceil_discounted

theoremverifiedformalization

In a periodic routing network with finite internal vertex type V with decidable equality, absorbing terminal type S, origin o : V, positive period lengths d : V → ℕ satisfying 1 ≤ d v for all v : V, and routing outflow function r : V → ℝ → Sum V S → ℝ, let u : V → ℕ be a departure count vector satisfying ∑ v, u v ≤ Fintype.card V * ∏ v : V, d v. Let q : ℝ be the discount factor q = 1 - 1 / (4 * ((Fintype.card V * ∏ v : V, d v : ℝ) ^ 2)), and let x : V → ℝ satisfy x = Pi.single o 1 + q • arrival_routing_inflow_map r x, x ≤ fun v => (u v : ℝ), and (∑ v : V, ((u v : ℝ) - x v)) ≤ (1 - q) * ((∑ v, u v : ℝ) * ((∑ v, u v : ℝ) - 1) / 2). Then u v = Nat.ceil (x v) for every v : V.

Statement

theorem arrival_exact_departure_counts_eq_ceil_discounted
    {V S : Type*} [Fintype V] [DecidableEq V]
    (o : V) (d : V → ℕ) (hd : ∀ v, 1 ≤ d v)
    (r : V → ℝ → Sum V S → ℝ)
    (u : V → ℕ)
    (x : V → ℝ)
    (q : ℝ)
    (hq : q = 1 - 1 / (4 * ((Fintype.card V * ∏ v : V, d v : ℝ) ^ 2)))
    (hT : ∑ v, u v ≤ Fintype.card V * ∏ v : V, d v)
    (hx : x = Pi.single o 1 + q • arrival_routing_inflow_map r x)
    (hle_u : x ≤ fun v => (u v : ℝ))
    (herr : (∑ v : V, ((u v : ℝ) - x v)) ≤
      (1 - q) * ((∑ v, u v : ℝ) * ((∑ v, u v : ℝ) - 1) / 2)) :
    ∀ v : V, u v = Nat.ceil (x v)
Formalizes
arXiv:2611.33785 Lemma 2.2
Verified
29 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 3
  • arrival_walk_error_bound_lt_one_eighthFor any natural numbers M and T such that 1 ≤ M and T ≤ M, the quantity (1 - (1 - 1 / (4 * (M : ℝ)^2))) * ((T : ℝ) * ((T : ℝ) - 1) / 2) is…
  • arrival_nat_ceil_of_dist_lt_oneFor any natural number u and real number x such that x ≤ u and (u : ℝ) - x < 1, u equals Nat.ceil x.
  • arrival_routing_inflow_mapFor finite types V and S, a routing outflow function r : V → ℝ → Sum V S → ℝ, and departure counts z : V → ℝ, arrival_routing_inflow_map r…

Read back from the Lean

Let $V$ and $S$ be types, with $V$ finite and having decidable equality. Let $o \in V$, and let $d : V \to \mathbb{N}$ satisfy $1 \le d(v)$ for all $v \in V$. Let $r : V \to \mathbb{R} \to (V \oplus S) \to \mathbb{R}$, $u : V \to \mathbb{N}$, $x : V \to \mathbb{R}$, and $q \in \mathbb{R}$. Assume: 1. $q = 1 - \frac{1}{4 (|V| \prod_{v \in V} d(v))^2}$ (where the product and cardinality are coerced to $\mathbb{R}$); 2. $\sum_{v \in V} u(v) \le |V| \prod_{v \in V} d(v)$ in $\mathbb{N}$; 3. $x = \text{single}_o(1) + q \cdot \text{arrival\_routing\_inflow\_map}(r, x)$, where $\text{single}_o(1)$ is the function taking value $1$ at $o$ and $0$ elsewhere; 4. $x(v) \le u(v)$ for all $v \in V$; 5. $\sum_{v \in V} (u(v) - x(v)) \le (1 - q) \cdot \frac{(\sum_{v \in V} u(v)) ((\sum_{v \in V} u(v)) - 1)}{2}$ in $\mathbb{R}$. Then for all $v \in V$, $u(v) = \lceil x(v) \rceil$ (where $\lceil \cdot \rceil$ is Nat.ceil).

Written by a model that saw only the Lean, never the English above. If the two disagree, that is worth a challenge.

The proof, explained

The theorem establishes that the exact departure count u v at every vertex v equals the ceiling of the discounted arrival flow x v. Using the total departure bound ∑ v, u v ≤ |V| ∏ v, d v and the definition of the discount factor q, an error-bound lemma implies that the total discrepancy ∑ v, (u v - x v) is strictly less than 1/8. Since x ≤ u pointwise, each individual term u v - x v is nonnegative and bounded by this total sum, hence strictly less than 1. Because u v is an integer upper bound on x v within distance less than 1, it must be the ceiling ⌈x v⌉.

  1. The bound M = |V| * ∏ v, d v satisfies 1 ≤ M.

    Since the network has an origin vertex o ∈ V, the type V is nonempty, so its cardinality satisfies 1 ≤ |V| by Fintype.card_pos_iff.mpr. Because each vertex period satisfies 1 ≤ d v, the product over all vertices satisfies 1 ≤ ∏ v, d v by Finset.one_le_prod'. Multiplying these inequalities with Nat.mul_le_mul establishes 1 ≤ |V| * ∏ v, d v.

    lines 16–18

    uses Fintype.card_pos_iff.mpr, Finset.one_le_prod', Nat.mul_le_mul

      have hV : 1 ≤ Fintype.card V := Fintype.card_pos_iff.mpr ⟨o⟩
      have hd_prod : 1 ≤ ∏ v : V, d v := Finset.one_le_prod' (fun v _ => hd v)
      have hM : 1 ≤ Fintype.card V * ∏ v : V, d v := Nat.mul_le_mul hV hd_prod
  2. The sum of the differences ∑ v, (u v - x v) is strictly less than 1/8.

    Letting M = |V| * ∏ v, d v and T = ∑ v, u v, we have 1 ≤ M from the previous step and T ≤ M from hypothesis hT. Applying arrival_walk_error_bound_lt_one_eighth yields (1 - (1 - 1/(4*M^2))) * (T*(T - 1)/2) < 1/8. Substituting the definition of q (hq) into hypothesis herr and rewriting the natural casts (Nat.cast_mul, Nat.cast_sum), the right-hand side of herr matches the left-hand side of this bound. By lt_of_le_of_lt, the total difference ∑ v, (u v - x v) is strictly less than 1/8.

    lines 19–22

    uses arrival_walk_error_bound_lt_one_eighth, Nat.cast_mul, Nat.cast_sum, lt_of_le_of_lt

      have hbound := arrival_walk_error_bound_lt_one_eighth (Fintype.card V * ∏ v : V, d v) (∑ v, u v) hM hT
      rw [hq] at herr
      rw [Nat.cast_mul, Nat.cast_sum] at hbound
      have h_sum_lt : ∑ v : V, ((u v : ℝ) - x v) < 1 / 8 := lt_of_le_of_lt herr hbound
  3. For every vertex w ∈ V, the difference u w - x w is nonnegative.

    We introduce an arbitrary vertex v for the outer goal. For any vertex w, the assumption x ≤ u (hle_u) implies x w ≤ u w, so linear arithmetic shows 0 ≤ u w - x w.

    lines 23–27

      intro v
      have hnonneg : ∀ w : V, 0 ≤ (u w : ℝ) - x w := by
        intro w
        have := hle_u w
        linarith
  4. The difference at vertex v satisfies u v - x v < 1.

    Since each term u w - x w is nonnegative, the single summand u v - x v is at most the full sum over all vertices (Finset.single_le_sum, Finset.mem_univ). Because that total sum is strictly less than 1/8, linear arithmetic immediately implies u v - x v < 1.

    lines 28–30

    uses Finset.single_le_sum, Finset.mem_univ

      have hle_sum : (u v : ℝ) - x v ≤ ∑ w : V, ((u w : ℝ) - x w) :=
        Finset.single_le_sum (fun w _ => hnonneg w) (Finset.mem_univ v)
      have hlt_one : (u v : ℝ) - x v < 1 := by linarith
  5. The departure count at v equals the ceiling of the discounted flow: u v = ⌈x v⌉.

    Having established both x v ≤ u v (from hle_u v) and u v - x v < 1, the lemma arrival_nat_ceil_of_dist_lt_one concludes that u v = Nat.ceil (x v).

    line 31

    uses arrival_nat_ceil_of_dist_lt_one

      exact arrival_nat_ceil_of_dist_lt_one (u v) (x v) (hle_u v) hlt_one
Fintype.card_pos_iff.mpr
A finite type with at least one element has strictly positive cardinality (at least 1).
Finset.one_le_prod'
A finite product of elements that are each at least 1 is itself at least 1.
Nat.mul_le_mul
Multiplication of natural numbers preserves non-strict inequalities: if n₁ ≤ n₂ and m₁ ≤ m₂, then n₁ * m₁ ≤ n₂ * m₂.
arrival_walk_error_bound_lt_one_eighth
For natural numbers 1 ≤ M and T ≤ M, the expression (1 - (1 - 1 / (4 * M^2))) * (T * (T - 1) / 2) is strictly less than 1/8.
Nat.cast_mul
The coercion from natural numbers to a semiring preserves multiplication: ↑(m * n) = ↑m * ↑n.
Nat.cast_sum
The coercion from natural numbers to an additive monoid distributes over finite sums: ↑(∑ x ∈ s, f x) = ∑ x ∈ s, ↑(f x).
lt_of_le_of_lt
Transitivity of non-strict and strict inequalities: if a ≤ b and b < c, then a < c.
Finset.single_le_sum
In a finite sum of nonnegative terms, any single summand is less than or equal to the total sum.
Finset.mem_univ
Every element of a finite type belongs to its universal finset univ.
arrival_nat_ceil_of_dist_lt_one
If a real number x and a natural number u satisfy x ≤ u and u - x < 1, then u = ⌈x⌉.

Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.

Lean source view module on GitHub

/-- On a stopping periodic routing network with discount q = 1 - 1/(4*M^2), exact departure counts equal the ceiling of the discounted fixed point. -/theorem arrival_exact_departure_counts_eq_ceil_discounted    {V S : Type*} [Fintype V] [DecidableEq V]    (o : V) (d : V → ℕ) (hd : ∀ v, 1 ≤ d v)    (r : V → ℝ → Sum V S → ℝ)    (u : V → ℕ)    (x : V → ℝ)    (q : ℝ)    (hq : q = 1 - 1 / (4 * ((Fintype.card V * ∏ v : V, d v : ℝ) ^ 2)))    (hT : ∑ v, u v ≤ Fintype.card V * ∏ v : V, d v)    (hx : x = Pi.single o 1 + q • arrival_routing_inflow_map r x)    (hle_u : x ≤ fun v => (u v : ℝ))    (herr : (∑ v : V, ((u v : ℝ) - x v)) ≤      (1 - q) * ((∑ v, u v : ℝ) * ((∑ v, u v : ℝ) - 1) / 2)) :    ∀ v : V, u v = Nat.ceil (x v) := by  have hV : 1 ≤ Fintype.card V := Fintype.card_pos_iff.mpr ⟨o⟩  have hd_prod : 1 ≤ ∏ v : V, d v := Finset.one_le_prod' (fun v _ => hd v)  have hM : 1 ≤ Fintype.card V * ∏ v : V, d v := Nat.mul_le_mul hV hd_prod  have hbound := arrival_walk_error_bound_lt_one_eighth (Fintype.card V * ∏ v : V, d v) (∑ v, u v) hM hT  rw [hq] at herr  rw [Nat.cast_mul, Nat.cast_sum] at hbound  have h_sum_lt : ∑ v : V, ((u v : ℝ) - x v) < 1 / 8 := lt_of_le_of_lt herr hbound  intro v  have hnonneg : ∀ w : V, 0 ≤ (u w : ℝ) - x w := by    intro w    have := hle_u w    linarith  have hle_sum : (u v : ℝ) - x v ≤ ∑ w : V, ((u w : ℝ) - x w) :=    Finset.single_le_sum (fun w _ => hnonneg w) (Finset.mem_univ v)  have hlt_one : (u v : ℝ) - x v < 1 := by linarith  exact arrival_nat_ceil_of_dist_lt_one (u v) (x v) (hle_u v) hlt_one
See it in the graphDiscuss this resultChallenge it