Documentation

LeanPool.FullyDynamicMatching.FD1D.Transport

Transport #

Dyadic Haar transport on the unit interval #

This file isolates the analytic part of Section 2. A DyadicMass L is a binary tree with exactly 2^L leaf masses. Its recursive CDF is the CDF of the measure which spreads every leaf mass uniformly over its dyadic cell.

The second half of the file proves the finite-family Haar calculation. Tree symmetry is expressed by mass-preserving child-swap equivalences on the finite state space. This is exactly the property used to kill a nested cross term; disjoint tents vanish pointwise.

inductive FD1D.DyadicMass :
ℕ → Type

A complete binary tree of 2^L real leaf masses.

Instances For

    Total mass below the root.

    Equations
    Instances For

      Leaf masses, in their left-to-right spatial order.

      Equations
      Instances For
        @[simp]
        def FD1D.DyadicMass.ofLeafVector (L : ℕ) :
        (Fin (2 ^ L) → ℝ) → DyadicMass L

        Build the complete dyadic mass tree from its left-to-right vector of 2^L leaf masses.

        Equations
        Instances For
          @[simp]
          theorem FD1D.DyadicMass.total_ofLeafVector (L : ℕ) (f : Fin (2 ^ L) → ℝ) :
          (ofLeafVector L f).total = ∑ i : Fin (2 ^ L), f i

          Every leaf mass is nonnegative.

          Equations
          Instances For
            theorem FD1D.DyadicMass.allNonneg_ofLeafVector (L : ℕ) (f : Fin (2 ^ L) → ℝ) (hf : ∀ (i : Fin (2 ^ L)), 0 ≤ f i) :

            The hypotheses saying that the 2^L leaf masses form a probability vector.

            Instances For
              theorem FD1D.DyadicMass.isProbability_ofLeafVector (L : ℕ) (f : Fin (2 ^ L) → ℝ) (hf : ∀ (i : Fin (2 ^ L)), 0 ≤ f i) (hsum : ∑ i : Fin (2 ^ L), f i = 1) :

              The explicit piecewise-linear CDF. Outside [0,1] this is merely a piecewise-linear extension; all CDF statements below are restricted to the unit interval.

              Equations
              Instances For
                theorem FD1D.DyadicMass.piecewiseCDF_nonneg {L : ℕ} (q : DyadicMass L) (hq : q.allNonneg) {z : ℝ} (hz0 : 0 ≤ z) (hz1 : z ≤ 1) :
                theorem FD1D.DyadicMass.piecewiseCDF_le_total {L : ℕ} (q : DyadicMass L) (hq : q.allNonneg) {z : ℝ} (hz0 : 0 ≤ z) (hz1 : z ≤ 1) :

                Nonnegative leaf masses make the explicit CDF monotone on [0,1].

                The explicit generalized inverse in mass coordinates. Its input ranges from 0 to q.total; at a branch the interval is split at the left mass.

                Equations
                Instances For

                  The actual selected-leaf policy. It returns the left endpoint of the leaf whose cumulative-mass interval contains u.

                  Equations
                  Instances For
                    theorem FD1D.DyadicMass.quantile_mem_unit {L : ℕ} (q : DyadicMass L) (hq : q.allNonneg) {u : ℝ} (hu0 : 0 ≤ u) (hu1 : u ≤ q.total) :

                    The explicit generalized inverse takes mass coordinates into [0,1].

                    theorem FD1D.DyadicMass.selectedLeaf_mem_unit {L : ℕ} (q : DyadicMass L) (hq : q.allNonneg) {u : ℝ} (hu0 : 0 ≤ u) (hu1 : u ≤ q.total) :

                    The selected point is an endpoint in the unit interval.

                    theorem FD1D.DyadicMass.quantile_pos {L : ℕ} (q : DyadicMass L) (hq : q.allNonneg) {u : ℝ} (hu0 : 0 < u) (hu1 : u ≤ q.total) :
                    0 < q.quantile u

                    Positive mass coordinates have a strictly positive generalized inverse.

                    theorem FD1D.DyadicMass.quantile_le_iff {L : ℕ} (q : DyadicMass L) (hq : q.allNonneg) {u z : ℝ} (hu0 : 0 ≤ u) (hu1 : u ≤ q.total) (hz0 : 0 ≤ z) (hz1 : z ≤ 1) :

                    Generalized-inverse relation for the explicit recursive map. This includes zero-mass leaves and therefore does not require strict positivity.

                    theorem FD1D.DyadicMass.selectedLeaf_sub_quantile_le {L : ℕ} (q : DyadicMass L) (hq : q.allNonneg) {u : ℝ} (hu0 : 0 ≤ u) (hu1 : u ≤ q.total) :
                    |q.selectedLeaf u - q.quantile u| ≤ 1 / ↑(2 ^ L)

                    The selected leaf endpoint and the continuous quantile lie in the same depth-L dyadic cell.

                    noncomputable def FD1D.DyadicMass.unitTent (z : ℝ) :

                    The height-1/2 tent on the unit interval, in local coordinates.

                    Equations
                    Instances For

                      The integrated Haar series, written recursively. At a branch it adds the root imbalance and then evaluates the unique child series whose support contains z.

                      Equations
                      Instances For
                        theorem FD1D.DyadicMass.cdf_sub_linear_eq_haar {L : ℕ} (q : DyadicMass L) {z : ℝ} (hz0 : 0 ≤ z) (hz1 : z ≤ 1) :

                        Pointwise integrated Haar expansion of the explicit piecewise-linear CDF.

                        Dyadic tents and their elementary integrals #

                        noncomputable def FD1D.dyadicTent (l p z : ℝ) :

                        The height-1/2 tent on [l,l+p]. Splitting into Icc and Ioc makes the two affine pieces disjoint without changing any Lebesgue integral.

                        Equations
                        Instances For
                          theorem FD1D.dyadicTent_eq_zero_of_not_mem {l p z : ℝ} (hp : 0 ≤ p) (hz : z ∉ Set.Icc l (l + p)) :
                          dyadicTent l p z = 0
                          theorem FD1D.dyadicTent_ne_zero_mem_Ioo {l p z : ℝ} (hp : 0 < p) (hz : dyadicTent l p z ≠ 0) :
                          z ∈ Set.Ioo l (l + p)

                          A nonzero tent value lies in the interior of its supporting interval.

                          theorem FD1D.dyadicTent_sq_integral (l p : ℝ) (hp : 0 < p) :
                          ∫ (z : ℝ), dyadicTent l p z ^ 2 = p / 12

                          The exact tent normalization used in Section 2: ∫ tau_v² = p_v/12.

                          theorem FD1D.dyadicTent_mul_eq_zero_of_separated {l₁ p₁ l₂ p₂ z : ℝ} (hp₁ : 0 < p₁) (hp₂ : 0 < p₂) (hsep : l₁ + p₁ ≤ l₂ ∨ l₂ + p₂ ≤ l₁) :
                          dyadicTent l₁ p₁ z * dyadicTent l₂ p₂ z = 0

                          Tents with separated interiors have zero pointwise product.

                          theorem FD1D.abs_dyadicTent_le_half (l p z : ℝ) (hp : 0 < p) :
                          |dyadicTent l p z| ≤ 1 / 2
                          theorem FD1D.dyadicTent_mul_integrable (l₁ p₁ l₂ p₂ : ℝ) (hp₁ : 0 < p₁) :

                          Flattening the recursive Haar series #

                          structure FD1D.HaarTerm :

                          One internal-node term in the integrated Haar expansion.

                          • left : ℝ

                            Left endpoint of the dyadic interval supporting the Haar term.

                          • width : ℝ

                            Width of the interval supporting the Haar term.

                          • coeff : ℝ

                            Coefficient multiplying the integrated Haar tent.

                          Instances For
                            noncomputable def FD1D.HaarTerm.value (t : HaarTerm) (z : ℝ) :

                            Pointwise value of one geometric integrated Haar term.

                            Equations
                            Instances For
                              noncomputable def FD1D.haarTermSum (ts : List HaarTerm) (z : ℝ) :

                              Pointwise value of a finite list of integrated Haar terms.

                              Equations
                              Instances For
                                @[simp]
                                @[simp]
                                theorem FD1D.haarTermSum_cons (t : HaarTerm) (ts : List HaarTerm) (z : ℝ) :
                                haarTermSum (t :: ts) z = t.value z + haarTermSum ts z
                                @[simp]

                                List every internal node, placing the root on [a,a+p] and recursively placing the two child lists on its two halves. The coefficient at each node is exactly its left-subtree mass minus its right-subtree mass.

                                Equations
                                Instances For
                                  noncomputable def FD1D.DyadicMass.haarTerms {L : ℕ} (q : DyadicMass L) :

                                  The internal-node Haar terms in their geometric locations in [0,1].

                                  Equations
                                  Instances For
                                    @[simp]
                                    theorem FD1D.DyadicMass.length_haarTermsAt {L : ℕ} (q : DyadicMass L) (a p : ℝ) :
                                    (haarTermsAt a p q).length = 2 ^ L - 1
                                    @[simp]
                                    theorem FD1D.DyadicMass.haarTermsAt_width_pos {L : ℕ} (q : DyadicMass L) {a p : ℝ} (hp : 0 < p) {t : HaarTerm} (ht : t ∈ haarTermsAt a p q) :
                                    0 < t.width
                                    theorem FD1D.DyadicMass.haarSeries_eq_haarTermSumAt {L : ℕ} (q : DyadicMass L) {a p z : ℝ} (hp : 0 < p) (hz0 : a ≤ z) (hz1 : z ≤ a + p) :
                                    q.haarSeries ((z - a) / p) = haarTermSum (haarTermsAt a p q) z

                                    The recursive integrated Haar series is the sum of every internal-node coefficient times its geometric tent, on any positive ambient interval.

                                    theorem FD1D.DyadicMass.haarSeries_eq_haarTermSum {L : ℕ} (q : DyadicMass L) {z : ℝ} (hz0 : 0 ≤ z) (hz1 : z ≤ 1) :

                                    Pointwise finite internal-node expansion on [0,1].

                                    Geometric support and nesting vocabulary #

                                    @[reducible, inline]

                                    Internal nodes of a depth-L complete binary tree.

                                    Equations
                                    Instances For
                                      noncomputable def FD1D.haarNodeLeft {L : ℕ} (v : CompleteHaarNode L) :

                                      Left endpoint of the dyadic interval indexed by a complete Haar node.

                                      Equations
                                      Instances For
                                        noncomputable def FD1D.haarNodeWidth {L : ℕ} (v : CompleteHaarNode L) :

                                        Width of the dyadic interval indexed by a complete Haar node.

                                        Equations
                                        Instances For
                                          noncomputable def FD1D.haarNodeTent {L : ℕ} (v : CompleteHaarNode L) :
                                          ℝ → ℝ

                                          Integrated Haar tent on the interval indexed by the node.

                                          Equations
                                          Instances For

                                            Geometric nesting of two dyadic node supports.

                                            Equations
                                            Instances For

                                              Canonical complete-tree indexing #

                                              The masses of the two children of an internal node v = ⟨d,k⟩. At positive depth, k selects the appropriate half-tree recursively.

                                              Equations
                                              Instances For

                                                The Haar coefficient at a node is its left-child mass minus its right-child mass.

                                                Equations
                                                Instances For

                                                  Embed a node into the left half-tree one level below a new root.

                                                  Equations
                                                  Instances For

                                                    Embed a node into the right half-tree one level below a new root.

                                                    Equations
                                                    Instances For
                                                      def FD1D.DyadicMass.childFinEquiv (d : ℕ) :
                                                      Fin (2 ^ d + 2 ^ d) ≃ Fin (2 ^ (d + 1))

                                                      Identification of the two child index blocks with the next dyadic level.

                                                      Equations
                                                      Instances For
                                                        theorem FD1D.DyadicMass.succNode_castAdd_eq_leftNode {L : ℕ} (d : Fin L) (v : Fin (2 ^ ↑d)) :
                                                        theorem FD1D.DyadicMass.succNode_natAdd_eq_rightNode {L : ℕ} (d : Fin L) (v : Fin (2 ^ ↑d)) :

                                                        Finite tree symmetry and cancellation of cross terms #

                                                        def FD1D.FiniteLaw.InvariantUnder {Ω : Type u_1} [Fintype Ω] (μ : FiniteLaw Ω) (e : Ω ≃ Ω) :

                                                        A finite law is invariant under a state-space equivalence.

                                                        Equations
                                                        Instances For
                                                          def FD1D.FiniteLaw.OddSymmetry {Ω : Type u_1} [Fintype Ω] (μ : FiniteLaw Ω) (f : Ω → ℝ) :

                                                          An observable has an odd symmetry if a mass-preserving child swap changes its sign. A local tree automorphism supplies precisely such an equivalence for an ancestor-descendant coefficient product.

                                                          Equations
                                                          Instances For
                                                            theorem FD1D.FiniteLaw.expect_comp_equiv {Ω : Type u_1} [Fintype Ω] (μ : FiniteLaw Ω) (e : Ω ≃ Ω) (he : μ.InvariantUnder e) (f : Ω → ℝ) :
                                                            (μ.expect fun (ω : Ω) => f (e ω)) = μ.expect f
                                                            theorem FD1D.FiniteLaw.expect_eq_zero_of_oddSymmetry {Ω : Type u_1} [Fintype Ω] (μ : FiniteLaw Ω) (f : Ω → ℝ) (hodd : μ.OddSymmetry f) :
                                                            μ.expect f = 0

                                                            A mass-preserving sign flip forces expectation zero.

                                                            def FD1D.IntervalsSeparated {ι : Type u_1} (l p : ι → ℝ) (i j : ι) :

                                                            The interiors of two tent supports are disjoint (endpoints may coincide).

                                                            Equations
                                                            Instances For
                                                              noncomputable def FD1D.haarCombination {ι : Type u_1} [Fintype ι] (l p b : ι → ℝ) (z : ℝ) :

                                                              A finite integrated Haar expansion.

                                                              Equations
                                                              Instances For
                                                                theorem FD1D.DyadicMass.dyadicTent_scale_left (l p z : ℝ) (hp : p ≠ 0) :
                                                                dyadicTent (l / 2) (p / 2) z = dyadicTent l p (2 * z)
                                                                theorem FD1D.DyadicMass.dyadicTent_scale_right (l p z : ℝ) (hp : p ≠ 0) :
                                                                dyadicTent (1 / 2 + l / 2) (p / 2) z = dyadicTent l p (2 * z - 1)
                                                                theorem FD1D.DyadicMass.branch_root_fiber {L : ℕ} (l r : DyadicMass L) (z : ℝ) :
                                                                ∑ y : Fin (2 ^ ↑0), (l.branch r).nodeCoefficient ⟨0, y⟩ * dyadicTent (haarNodeLeft ⟨0, y⟩) (haarNodeWidth ⟨0, y⟩) z = (l.total - r.total) * dyadicTent 0 1 z

                                                                The recursive Haar series is exactly the canonical finite sum over all internal nodes ⟨d,k⟩ of the complete depth-L tree.

                                                                The canonical node sum is the CDF deviation on the unit interval.

                                                                noncomputable def FD1D.haarL2 {ι : Type u_1} [Fintype ι] (l p b : ι → ℝ) :

                                                                Squared L² norm of a finite integrated Haar expansion.

                                                                Equations
                                                                Instances For
                                                                  theorem FD1D.haarL2_eq_gram {ι : Type u_1} [Fintype ι] (l p b : ι → ℝ) (hp : ∀ (i : ι), 0 < p i) :
                                                                  haarL2 l p b = ∑ i : ι, ∑ j : ι, b i * b j * ∫ (z : ℝ), dyadicTent (l i) (p i) z * dyadicTent (l j) (p j) z
                                                                  theorem FD1D.expected_haarL2 {ι : Type u_1} {Ω : Type u_2} [Fintype ι] [Fintype Ω] (μ : FiniteLaw Ω) (l p : ι → ℝ) (b : Ω → ι → ℝ) (hp : ∀ (i : ι), 0 < p i) (hsym : ∀ (i j : ι), i ≠ j → IntervalsSeparated l p i j ∨ μ.OddSymmetry fun (ω : Ω) => b ω i * b ω j) :
                                                                  (μ.expect fun (ω : Ω) => haarL2 l p (b ω)) = 1 / 12 * ∑ i : ι, p i * μ.expect fun (ω : Ω) => b ω i ^ 2

                                                                  Expected Parseval identity for integrated Haar functions. For unequal nodes, either their interiors are disjoint or a tree child swap makes the coefficient product odd. Thus every cross term vanishes.

                                                                  Quantile/CDF cost and Cauchy--Schwarz #

                                                                  noncomputable def FD1D.cdfTransportArea (f : ℝ → ℝ) :

                                                                  The elementary one-dimensional monotone-transport cost: the area between the source and target CDFs. This representation avoids introducing a separate Wasserstein API.

                                                                  Equations
                                                                  Instances For
                                                                    theorem FD1D.integral_abs_quantile_sub_id_eq_integral_abs_cdf_sub_id {F T : ℝ → ℝ} (_hF : Measurable F) (hT : Measurable T) (hF01 : Set.MapsTo F (Set.Icc 0 1) (Set.Icc 0 1)) (hT01 : Set.MapsTo T (Set.Icc 0 1) (Set.Icc 0 1)) (hgc : ∀ u ∈ Set.Icc 0 1, ∀ z ∈ Set.Icc 0 1, T u ≤ z ↔ u ≤ F z) :
                                                                    ∫ (u : ℝ) in Set.Icc 0 1, |T u - u| = ∫ (z : ℝ) in Set.Icc 0 1, |F z - z|

                                                                    The one-dimensional quantile/CDF identity, proved directly by expressing absolute displacement as an integral of threshold disagreements and swapping the two unit-interval integrals.

                                                                    An actual quantile map together with an actual selected point.

                                                                    Instances For

                                                                      Actual cost of the selected-point policy against a uniform request.

                                                                      Equations
                                                                      Instances For

                                                                        Cost of the continuous generalized inverse before leaf rounding.

                                                                        Equations
                                                                        Instances For

                                                                          The explicit dyadic CDF, inverse, and leaf endpoint form an actual policy.

                                                                          Equations
                                                                          • One or more equations did not get rendered due to their size.
                                                                          Instances For

                                                                            The actual selected-leaf endpoint has cost at most the exact quantile cost plus one depth-L cell width.

                                                                            For probability leaf masses, the CDF discrepancy used by the quantile policy is exactly the recursively defined integrated Haar series.

                                                                            theorem FD1D.haarCombination_sq_integrable {ι : Type u_1} [Fintype ι] (l p b : ι → ℝ) (hp : ∀ (i : ι), 0 < p i) :

                                                                            Cauchy--Schwarz on the unit interval, proved by Jensen for x ↦ x².

                                                                            theorem FD1D.cdfTransportArea_sq_le_haarL2 {ι : Type u_1} [Fintype ι] (l p b : ι → ℝ) (hp : ∀ (i : ι), 0 < p i) :
                                                                            theorem FD1D.FiniteLaw.expect_sq_le_expect_sq {Ω : Type u_2} [Fintype Ω] (μ : FiniteLaw Ω) (f : Ω → ℝ) :
                                                                            μ.expect f ^ 2 ≤ μ.expect fun (ω : Ω) => f ω ^ 2

                                                                            Weighted Cauchy--Schwarz for the project's finite-law expectation.

                                                                            theorem FD1D.FiniteLaw.expect_le_sqrt_expect_sq {Ω : Type u_2} [Fintype Ω] (μ : FiniteLaw Ω) (f g : Ω → ℝ) (hf : ∀ (ω : Ω), 0 ≤ f ω) (hg : ∀ (ω : Ω), 0 ≤ g ω) (hfg : ∀ (ω : Ω), f ω ^ 2 ≤ g ω) :
                                                                            μ.expect f ≤ √(μ.expect g)
                                                                            theorem FD1D.expected_area_le_sqrt_l2 {ι : Type u_1} {Ω : Type u_2} [Fintype ι] [Fintype Ω] (μ : FiniteLaw Ω) (l p : ι → ℝ) (b : Ω → ι → ℝ) (hp : ∀ (i : ι), 0 < p i) :
                                                                            (μ.expect fun (ω : Ω) => cdfTransportArea (haarCombination l p (b ω))) ≤ √(μ.expect fun (ω : Ω) => haarL2 l p (b ω))

                                                                            CDF-area transport followed by Cauchy--Schwarz in space and in state.

                                                                            gap below is the abstract hazard telescope E[H_L] - m⁻². The hypothesis htelescope is equation (2): Σ p_v E[b_v²] ≤ 2 a² gap.

                                                                            theorem FD1D.transport_cost_equation_three {ι : Type u_1} {Ω : Type u_2} [Fintype ι] [Fintype Ω] (μ : FiniteLaw Ω) (l p : ι → ℝ) (b : Ω → ι → ℝ) (cost : Ω → ℝ) (n a gap : ℝ) (_hn : 0 < n) (ha : 0 ≤ a) (hgap : 0 ≤ gap) (hp : ∀ (i : ι), 0 < p i) (hcost : ∀ (ω : Ω), cost ω ≤ 1 / n + cdfTransportArea (haarCombination l p (b ω))) (hsym : ∀ (i j : ι), i ≠ j → IntervalsSeparated l p i j ∨ μ.OddSymmetry fun (ω : Ω) => b ω i * b ω j) (htelescope : (∑ i : ι, p i * μ.expect fun (ω : Ω) => b ω i ^ 2) ≤ 2 * a ^ 2 * gap) :
                                                                            μ.expect cost ≤ 1 / n + a / √6 * √gap

                                                                            Equation (3), with the exact constant. hcost is the conditional monotone quantile bound plus the deterministic within-cell error 1/n.