Documentation

LeanPool.FullyDynamicMatching.FD1D.Spatial

Spatial #

Concrete spatial inventory and dyadic quantile selection #

This module connects the recursive transport construction to an inventory of actual points. A supply configuration retains both each real location and its certified depth-L cell label. The recursive quantile selector is given a finite leaf index, and its law under Lebesgue-uniform demand is computed exactly, including zero-mass leaves.

Split the left-to-right leaves of a depth-L + 1 tree into two blocks.

Equations
Instances For
    @[simp]
    @[simp]
    theorem FD1D.dyadicLeafSumEquiv_inr_val {L : ℕ} (i : DyadicNode L) :
    ↑((dyadicLeafSumEquiv L) (Sum.inr i)) = 2 ^ L + ↑i

    The mass of a specified leaf, indexed from left to right.

    Equations
    Instances For

      Total mass strictly to the left of a specified leaf.

      Equations
      Instances For

        The finite leaf index selected by the same recursive mass comparisons as selectedLeaf and quantile.

        Equations
        Instances For
          @[simp]
          theorem FD1D.DyadicMass.leafMass_left {L : ℕ} (left right : DyadicMass L) (i : DyadicNode L) :
          (left.branch right).leafMass ((dyadicLeafSumEquiv L) (Sum.inl i)) = left.leafMass i
          @[simp]
          theorem FD1D.DyadicMass.leafMass_right {L : ℕ} (left right : DyadicMass L) (i : DyadicNode L) :
          (left.branch right).leafMass ((dyadicLeafSumEquiv L) (Sum.inr i)) = right.leafMass i
          @[simp]
          theorem FD1D.DyadicMass.lowerMass_left {L : ℕ} (left right : DyadicMass L) (i : DyadicNode L) :
          (left.branch right).lowerMass ((dyadicLeafSumEquiv L) (Sum.inl i)) = left.lowerMass i
          @[simp]
          theorem FD1D.DyadicMass.lowerMass_right {L : ℕ} (left right : DyadicMass L) (i : DyadicNode L) :
          (left.branch right).lowerMass ((dyadicLeafSumEquiv L) (Sum.inr i)) = left.total + right.lowerMass i
          theorem FD1D.DyadicMass.selectedLeaf_eq_selectedIndex {L : ℕ} (q : DyadicMass L) (u : ℝ) :
          q.selectedLeaf u = ↑↑(q.selectedIndex u) / ↑(2 ^ L)

          The real endpoint returned by selectedLeaf is the indexed cell's left endpoint.

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

          The selected endpoint never lies to the right of the continuous quantile.

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

          Away from the single boundary point u = 0, a leaf is selected exactly on its right-closed cumulative-mass interval. This formulation handles zero-mass leaves without any positivity assumption on individual masses.

          Lebesgue-uniform demand on the unit interval.

          Equations
          Instances For

            Raw singleton mass of the finite pushforward by selectedIndex.

            Equations
            Instances For

              The pushforward of Lebesgue-uniform demand assigns exactly the declared mass to every leaf. The only discrepancy between recursive ≤ tie-breaking and the half-open mass intervals is the null singleton u = 0.

              The finite law induced by the demand-driven recursive leaf selector.

              Equations
              Instances For

                Exact spatial configurations #

                noncomputable def FD1D.dyadicCellWidth (L : ℕ) :

                Width of one depth-L dyadic cell.

                Equations
                Instances For
                  noncomputable def FD1D.dyadicCellLeft {L : ℕ} (i : DyadicNode L) :

                  Left endpoint of a depth-L dyadic cell.

                  Equations
                  Instances For
                    def FD1D.dyadicCell {L : ℕ} (i : DyadicNode L) :

                    The closed cell certified for a labeled supply point.

                    Equations
                    Instances For
                      structure FD1D.SupplyConfiguration (L m : ℕ) :

                      An exact finite supply configuration: m labeled real points, each in the unit interval and carrying a certified depth-L leaf label.

                      Instances For

                        Number of configured supply points carrying one leaf label.

                        Equations
                        Instances For

                          Count projection from exact locations to the finite inventory chain.

                          Equations
                          Instances For
                            noncomputable def FD1D.SupplyConfiguration.representative {L m : ℕ} (C : SupplyConfiguration L m) (fallback : Fin m) (i : DyadicNode L) :
                            Fin m

                            A total representative of a leaf. If the leaf is empty, the supplied fallback is returned; the later a.e. feasibility theorem proves that this case occurs only on the null exceptional demand set.

                            Equations
                            Instances For
                              theorem FD1D.SupplyConfiguration.representative_leaf {L m : ℕ} (C : SupplyConfiguration L m) (fallback : Fin m) (i : DyadicNode L) (h : ∃ (j : Fin m), C.leaf j = i) :
                              C.leaf (C.representative fallback i) = i

                              Every positive-mass leaf contains an actual configured supply point.

                              Equations
                              Instances For
                                theorem FD1D.SupplyConfiguration.supports_of_emptyMass {L m : ℕ} (C : SupplyConfiguration L m) (q : DyadicMass L) (hempty : ∀ (i : DyadicNode L), C.leafCount i = 0 → q.leafMass i = 0) :
                                noncomputable def FD1D.SupplyConfiguration.selectedSupplyIndex {L m : ℕ} (C : SupplyConfiguration L m) (q : DyadicMass L) (fallback : Fin m) (u : ℝ) :
                                Fin m

                                The supply label selected by a uniform demand coordinate.

                                Equations
                                Instances For
                                  noncomputable def FD1D.SupplyConfiguration.selectedSupplyPoint {L m : ℕ} (C : SupplyConfiguration L m) (q : DyadicMass L) (fallback : Fin m) (u : ℝ) :

                                  The actual configured supply location selected by the policy.

                                  Equations
                                  Instances For
                                    theorem FD1D.SupplyConfiguration.selectedSupplyIndex_leaf_of_ne_zero {L m : ℕ} (C : SupplyConfiguration L m) (q : DyadicMass L) (hq : q.IsProbability) (hsupport : C.Supports q) (fallback : Fin m) {u : ℝ} (hu : u ∈ Set.Icc 0 1) (hu0 : u ≠ 0) :
                                    C.leaf (C.selectedSupplyIndex q fallback u) = q.selectedIndex u

                                    Except at the zero demand boundary, the total representative really carries the recursively selected leaf label.

                                    The selected configured item is feasible for almost every uniform demand.

                                    The continuous quantile belongs to the cell indexed by selectedIndex.

                                    theorem FD1D.SupplyConfiguration.selectedSupplyPoint_sub_quantile_le_of_ne_zero {L m : ℕ} (C : SupplyConfiguration L m) (q : DyadicMass L) (hq : q.IsProbability) (hsupport : C.Supports q) (fallback : Fin m) {u : ℝ} (hu : u ∈ Set.Icc 0 1) (hu0 : u ≠ 0) :

                                    For every nonexceptional demand, the actual selected point and continuous quantile lie in one and the same depth-L cell.

                                    The one-cell coupling bound holds almost everywhere under uniform demand.

                                    noncomputable def FD1D.SupplyConfiguration.expectedActualDistance {L m : ℕ} (C : SupplyConfiguration L m) (q : DyadicMass L) (fallback : Fin m) :

                                    Expected distance from a uniform demand to the actual selected supply point.

                                    Equations
                                    Instances For

                                      Selecting an actual occupied point costs at most the exact CDF quantile area plus one cell width. There is only one discretization term.

                                      Matching the finite deletion kernel #

                                      If the dyadic leaf masses are a deletion rule's probabilities at the count projection, support by occupied concrete leaves follows automatically.

                                      The selected leaf marginal is exactly the deletion marginal.

                                      theorem FD1D.SupplyConfiguration.selectedIndex_transition_eq_kernel {L m : ℕ} (C : SupplyConfiguration L m) (q : DyadicMass L) (hq : q.IsProbability) (R : DeletionRule (DyadicNode L) m) (hmass : ∀ (i : DyadicNode L), q.leafMass i = R.prob C.countState i) (y : InventoryState (DyadicNode L) m) :
                                      (∑ deleted : DyadicNode L, ∑ arrived : DyadicNode L, if C.countState.move deleted arrived = y then (q.selectedIndexLaw hq).mass deleted * (1 / ↑(Fintype.card (DyadicNode L))) else 0) = R.kernel.trans C.countState y

                                      After an independent uniform arrival leaf, the concrete selected-leaf marginal produces exactly the count transition kernel.

                                      Actual-point transport for a configuration realizing a deletion rule: the empty-leaf condition needed for feasibility is discharged by the rule.

                                      def FD1D.appendDyadicNode {d r : ℕ} (v : DyadicNode d) (w : DyadicNode r) :

                                      Prefix a relative dyadic node by an absolute node.

                                      Equations
                                      Instances For