While this submission is a draft, it cannot be used by other submissions.

Saturating and Perfect Matchings, Decided in the Same Time

Lax117284.BipartiteDecision · concepts/Lax117284/BipartiteDecision.lean · lax-117284

proven

Loading review…

Sign in with ORCID

Community review

Flags

Each flag is tied to a public ORCID identity and explains why this concept may be incorrect.

No flags have been submitted.

    Community review

    Flag this concept

    State precisely what appears incorrect. This explanation will be public under your ORCID name.

    No source line selected.

    Natural Language Statement

    Corollary

    Whether a bipartite graph split at nn has a matching saturating its left side, and whether it has a perfect matching, are decided within the same bound c (n+1) (∣x∣+1)c\,(n+1)\,(|x|+1). The saturating question is also decided on every word, well formed or not, in the same time and in the sense of polynomial time on the word RAM of lax-759944, which is the form another submission can compose with its own reductions.

    Concept map
    9 concepts
    100%
    Proven claimDefinitionThis conceptRelated conceptA → B: B builds on A
    Evidence

    This concept declares 4 statements. Each proof establishes one of them relative to its assumptions.

    Lean source view on GitHub

    1import Lax117284.BipartiteKuhnTime
    2import Lax759944.RamPolytime
    3
    4/-!
    5---
    6title: Saturating and Perfect Matchings, Decided in the Same Time
    7type: corollary
    8---
    9Whether a bipartite graph split at nn has a matching saturating its left side, and whether it
    10has a perfect matching, are decided within the same bound c (n+1) (∣x∣+1)c\,(n+1)\,(|x|+1). The saturating
    11question is also decided *on every word*, well formed or not, in the same time and in the sense
    12of polynomial time on the word RAM of [lax-759944](https://laxarchive.org/lax-759944/), which is
    13the form another submission can compose with its own reductions.
    14
    15# Formalization Notes
    16
    17Both are comparisons of the matching number with a number the word carries: a matching
    18saturating the left side exists exactly when the matching number is nn, since a matching of a
    19graph split at nn has at most one edge at each left vertex, and a perfect matching exists exactly
    20when twice the matching number is the number of vertices. The programs compute the matching
    21number and compare.
    22
    23The total statements need a notion of a *well-formed* word that a program can check in linear
    24time: the counts, the offsets, the targets and the split are as the encoding demands, and every
    25listed edge crosses the split. Symmetry of the adjacency lists is *not* demanded, because the
    26graph a word denotes (`wordGraph`) is the symmetric closure of its lists, so the program may
    27symmetrize the lists itself in linear time; every word encoding a bipartite graph is well formed.
    28On a well-formed word the answer is that of `decides_saturating`; on any other word it is `0`.
    29The word `saturatingAnswer` is the function the total program computes, and
    30`ramPolytime_saturating` states it in the archive's polynomial-time form on a length-prefixed
    31input, at every word length in which the word fits.
    32-/
    33
    34namespace Lax117284.BipartiteDecision
    35
    36open Lax808846.Ram Lax808846.RamComputes Lax117284.BipartiteGraph Lax117284.BipartiteMatching
    37open Lax271696.GraphEncoding
    38
    39/-- The admissible words: encodings of bipartite graphs split at their last entry, fitting the
    40word length. -/
    41def Dom (c w : ℕ) : Set (List ℕ) :=
    42 {x | (∃ (V : ℕ) (G : SimpleGraph (Fin V)) (n : ℕ), EncodesBipartite x V G n) ∧
    43 c * (x.length + 1) ≤ 2 ^ w}
    44
    45open scoped Classical in
    46/-- **A matching saturating the left side is decided within `c · (n + 1) · (|x| + 1)`
    47instructions.** -/
    48axiom decides_saturating : ∃ (prog : Program) (c : ℕ), ∀ w : ℕ,
    49 ComputesInTime w prog (Dom c w)
    50 (fun x => if ∃ M : (wordGraph x).Subgraph, M.IsMatching ∧
    51 Saturates (wordGraph x) M (leftSide (vertexCount x) (leftCount x)) then [1] else [0])
    52 (fun x => c * (leftCount x + 1) * (x.length + 1))
    53
    54open scoped Classical in
    55/-- **A perfect matching is decided within `c · (n + 1) · (|x| + 1)` instructions.** -/
    56axiom decides_perfect : ∃ (prog : Program) (c : ℕ), ∀ w : ℕ,
    57 ComputesInTime w prog (Dom c w)
    58 (fun x => if ∃ M : (wordGraph x).Subgraph, M.IsPerfectMatching then [1] else [0])
    59 (fun x => c * (leftCount x + 1) * (x.length + 1))
    60
    61/-- **A well-formed bipartite word**: at least as many vertices as left vertices, the length of
    62a compressed sparse row block plus the split, offsets starting at `0`, ending at twice the edge
    63count and nondecreasing, every target a vertex, and every listed edge crossing the split. -/
    64structure WellFormed (x : List ℕ) : Prop where
    65 /-- The left vertices are among the vertices. -/
    66 left_le : leftCount x ≤ vertexCount x
    67 /-- The compressed sparse row block, then the split. -/
    68 length_eq : x.length = 4 + vertexCount x + 2 * edgeCount x
    69 /-- The first offset is `0`. -/
    70 offset_zero : offset x 0 = 0
    71 /-- The last offset is twice the edge count. -/
    72 offset_last : offset x (vertexCount x) = 2 * edgeCount x
    73 /-- The offsets are nondecreasing. -/
    74 offset_mono : ∀ i < vertexCount x, offset x i ≤ offset x (i + 1)
    75 /-- Every target is a vertex. -/
    76 target_lt : ∀ j < 2 * edgeCount x, target x j < vertexCount x
    77 /-- Every listed edge crosses the split. -/
    78 crosses : ∀ u < vertexCount x, ∀ j, offset x u ≤ j → j < offset x (u + 1) →
    79 (u < leftCount x ↔ leftCount x ≤ target x j)
    80
    81open scoped Classical in
    82/-- The answer of the total program: `1` on a well-formed word whose graph has a matching
    83saturating its left side, `0` on every other word. -/
    84noncomputable def saturatingAnswer (x : List ℕ) : List ℕ :=
    85 if WellFormed x ∧ ∃ M : (wordGraph x).Subgraph, M.IsMatching ∧
    86 Saturates (wordGraph x) M (leftSide (vertexCount x) (leftCount x)) then [1] else [0]
    87
    88/-- **On every word whose length and entries fit the word length, a matching saturating the
    89left side is decided within `c · (n + 1) · (|x| + 1)` instructions**, `n` the last entry of the
    90word, well-formedness included. The entries must fit: the machine holds every entry modulo
    91`2 ^ w`, so a word with an entry beyond a word is indistinguishable from the well-formed word it
    92reduces to, and no program could answer both. -/
    93axiom decides_saturating_all : ∃ (prog : Program) (c : ℕ), ∀ w : ℕ,
    94 ComputesInTime w prog {x | c * (x.length + 1) ≤ 2 ^ w ∧ ∀ v ∈ x, c * (v + 1) ≤ 2 ^ w}
    95 saturatingAnswer (fun x => c * (leftCount x + 1) * (x.length + 1))
    96
    97/-- **The same, as polynomial time on the word RAM** in the sense of `lax-759944`: one program
    98reads the length-prefixed word and writes `saturatingAnswer` within a polynomial in the bit size
    99of the word, at every word length in which the word fits. -/
    100axiom ramPolytime_saturating : Lax759944.RamPolytime.RamPolytime saturatingAnswer
    101
    102end Lax117284.BipartiteDecision
    103
    Show ProofShow ProofShow ProofShow Proof
    Formalization Notes

    Both are comparisons of the matching number with a number the word carries: a matching saturating the left side exists exactly when the matching number is nn, since a matching of a graph split at nn has at most one edge at each left vertex, and a perfect matching exists exactly when twice the matching number is the number of vertices. The programs compute the matching number and compare.

    The total statements need a notion of a well-formed word that a program can check in linear time: the counts, the offsets, the targets and the split are as the encoding demands, and every listed edge crosses the split. Symmetry of the adjacency lists is not demanded, because the graph a word denotes (wordGraphwordGraph) is the symmetric closure of its lists, so the program may symmetrize the lists itself in linear time; every word encoding a bipartite graph is well formed. On a well-formed word the answer is that of decidessaturatingdecides_saturating; on any other word it is 00. The word saturatingAnswersaturatingAnswer is the function the total program computes, and ramPolytimesaturatingramPolytime_saturating states it in the archive's polynomial-time form on a length-prefixed input, at every word length in which the word fits.

    Builds on
    Used by

    none

    From Mathlib

    none

    Discussion

    Ask a question or add context. Endorsements and structured flags are kept in the review panel above.

    Loading discussion…