Subgraph Isomorphism

Lax799700.SubgraphIso · concepts/Lax799700/SubgraphIso.lean · lax-799700

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

    Theorem

    SUBGRAPH ISOMORPHISM: does the host graph contain a subgraph isomorphic to the pattern graph, that is, is there an injective homomorphism of the pattern into the host (SubgraphIsoOn)? Non-edges of the pattern are unconstrained, the standard reading and the one that makes Clique a special case. An instance carries two graphs in one universe: two unary marks separate the pattern vertices from the host vertices, and two binary relations are their adjacencies; elements outside both marks are junk no condition mentions. Membership is by an existential second-order definition guessing the map; hardness is a quantifier-free first-order reduction from Clique, the host being the input graph and the pattern the complete graph on its marked set.

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

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

    Lean source view on GitHub

    1import Mathlib.ModelTheory.Syntax
    2import Mathlib.ModelTheory.Semantics
    3import Mathlib.Data.Fintype.Lattice
    4import Mathlib.ModelTheory.Order
    5import Mathlib.ModelTheory.Complexity
    6import Mathlib.Tactic.FinCases
    7import Mathlib.Logic.Equiv.Fin.Basic
    8import Mathlib.Order.PiLex
    9import Mathlib.Data.Prod.Lex
    10import Mathlib.Data.Fintype.EquivFin
    11import Mathlib.Data.Finite.Sigma
    12import Mathlib.Data.Set.Finite.Lemmas
    13import Mathlib.Data.Set.Card
    14import Mathlib.SetTheory.Cardinal.Finite
    15import Mathlib.Logic.Equiv.Prod
    16import Lax904597.Classes
    17import Lax799700.Problems
    18
    19/-!
    20---
    21title: Subgraph Isomorphism
    22type: theorem
    23---
    24SUBGRAPH ISOMORPHISM: does the host graph contain a subgraph isomorphic
    25to the pattern graph, that is, is there an injective homomorphism of the
    26pattern into the host (SubgraphIsoOn)? Non-edges of the pattern are
    27unconstrained, the standard reading and the one that makes Clique a
    28special case. An instance carries two graphs in one universe: two unary
    29marks separate the pattern vertices from the host vertices, and two
    30binary relations are their adjacencies; elements outside both marks are
    31junk no condition mentions. Membership is by an existential second-order
    32definition guessing the map; hardness is a quantifier-free first-order
    33reduction from Clique, the host being the input graph and the pattern
    34the complete graph on its marked set.
    35
    36-/
    37
    38namespace Lax799700.SubgraphIso
    39
    40open FirstOrder
    41
    42open FirstOrder.Language
    43
    44/-- The relation symbols of the language. -/
    45inductive twoGraphsRel : ℕ → Type where
    46/-- `patV a`: `a` is a vertex of the pattern graph. -/
    47 | patV : twoGraphsRel 1
    48/-- `hostV a`: `a` is a vertex of the host graph. -/
    49 | hostV : twoGraphsRel 1
    50/-- `patE a b`: there is an edge of the pattern from `a` to `b`. -/
    51 | patE : twoGraphsRel 2
    52/-- `hostE a b`: there is an edge of the host from `a` to `b`. -/
    53 | hostE : twoGraphsRel 2
    54 deriving DecidableEq
    55
    56/-- The relational language of pattern-and-host graphs: two graphs sharing a
    57universe, each with its own vertex mark and adjacency relation. -/
    58def twoGraphs : FirstOrder.Language :=
    59 ⟨fun _ => Empty, twoGraphsRel⟩
    60
    61instance instIsRelationalTwoGraphs : FirstOrder.Language.IsRelational twoGraphs := fun _ =>
    62 (inferInstance : IsEmpty Empty)
    63
    64/-- `patV a`: `a` is a vertex of the pattern graph. -/
    65abbrev tgPatV : twoGraphs.Relations 1 :=
    66 .patV
    67
    68/-- `hostV a`: `a` is a vertex of the host graph. -/
    69abbrev tgHostV : twoGraphs.Relations 1 :=
    70 .hostV
    71
    72/-- `patE a b`: there is an edge of the pattern from `a` to `b`. -/
    73abbrev tgPatE : twoGraphs.Relations 2 :=
    74 .patE
    75
    76/-- `hostE a b`: there is an edge of the host from `a` to `b`. -/
    77abbrev tgHostE : twoGraphs.Relations 2 :=
    78 .hostE
    79
    80open FirstOrder
    81
    82open Language Structure Lax904597.SecondOrder.SOBlock
    83
    84section Generic
    85
    86variable {A : Type}
    87
    88/-- Some map sends the `PV`-vertices injectively into the `HV`-vertices,
    89carrying `PE`-edges to `HE`-edges: an injective homomorphism of the pattern
    90into the host. -/
    91def SubgraphIsoOn (PV HV : A → Prop) (PE HE : A → A → Prop) : Prop :=
    92 ∃ f : A → A, (∀ x, PV x → HV (f x)) ∧
    93 (∀ x y, PV x → PV y → f x = f y → x = y) ∧
    94 ∀ x y, PV x → PV y → PE x y → HE (f x) (f y)
    95
    96end Generic
    97
    98section Problem
    99
    100section Shorthands
    101
    102variable {A : Type} [twoGraphs.Structure A]
    103
    104/-- `patV a`: `a` is a vertex of the pattern graph. -/
    105def TGPatV {A : Type} [twoGraphs.Structure A] (a0 : A) : Prop :=
    106 FirstOrder.Language.Structure.RelMap tgPatV ![a0]
    107
    108/-- `hostV a`: `a` is a vertex of the host graph. -/
    109def TGHostV {A : Type} [twoGraphs.Structure A] (a0 : A) : Prop :=
    110 FirstOrder.Language.Structure.RelMap tgHostV ![a0]
    111
    112/-- `patE a b`: there is an edge of the pattern from `a` to `b`. -/
    113def TGPatE {A : Type} [twoGraphs.Structure A] (a0 : A) (a1 : A) : Prop :=
    114 FirstOrder.Language.Structure.RelMap tgPatE ![a0, a1]
    115
    116/-- `hostE a b`: there is an edge of the host from `a` to `b`. -/
    117def TGHostE {A : Type} [twoGraphs.Structure A] (a0 : A) (a1 : A) : Prop :=
    118 FirstOrder.Language.Structure.RelMap tgHostE ![a0, a1]
    119
    120end Shorthands
    121
    122variable (A : Type) [twoGraphs.Structure A]
    123
    124/-- The host graph contains a subgraph isomorphic to the pattern graph.
    125(Finiteness of the universe is required only for uniformity with the rest of
    126the catalog; the property itself makes sense in general.) -/
    127def HasSubgraphIso : Prop :=
    128 Finite A ∧ SubgraphIsoOn (TGPatV (A := A)) TGHostV TGPatE TGHostE
    129
    130end Problem
    131
    132open Lax904597.Problems Lax904597.Classes Lax799700.Problems
    133
    134/-- The property `HasSubgraphIso` is isomorphism-invariant. -/
    135axiom hasSubgraphIso_iso : ∀ {A B : Type} [Lax799700.SubgraphIso.twoGraphs.Structure A] [Lax799700.SubgraphIso.twoGraphs.Structure B],
    136 (A ≃[Lax799700.SubgraphIso.twoGraphs] B) → (HasSubgraphIso A ↔ HasSubgraphIso B)
    137
    138/-- The problem SubgraphIso: does the structure satisfy `HasSubgraphIso`? -/
    139def SubgraphIso : DecisionProblem Lax799700.SubgraphIso.twoGraphs :=
    140 DecisionProblem.ofPred HasSubgraphIso
    141
    142/-- The yes-instances of SubgraphIso are exactly the structures satisfying
    143`HasSubgraphIso`. -/
    144axiom subgraphIso_iff : ∀ (A : Type) [Lax799700.SubgraphIso.twoGraphs.Structure A], SubgraphIso A ↔ HasSubgraphIso A
    145
    146/-- SubgraphIso is NP-complete. -/
    147axiom subgraphIso_NP_complete : NP.Complete SubgraphIso
    148
    149end Lax799700.SubgraphIso
    150
    Show ProofShow ProofShow Proof

    Discussion

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

    Loading discussion…