Reachability and unreachability in directed graphs
Lax485149.Reachability · concepts/Lax485149/Reachability.lean · lax-485149
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Definition
An instance is a directed graph with marked source vertices and marked target vertices: a structure over the vocabulary with a binary relation of edges and two unary relations of sources and targets. It is a yes-instance of REACH when some marked target is reachable from some marked source by a directed path, possibly empty; REACH is the decision problem of the structures isomorphic to such an instance. UNREACH is the complement of REACH: no marked target is reachable from a marked source.
Concept map
Lean source view on GitHub
| 1 | import Mathlib.ModelTheory.Semantics |
| 2 | import Mathlib.Logic.Relation |
| 3 | import Lax904597.Problems |
| 4 | import Lax485149.Problems |
| 5 | import Lax485149.Complement |
| 6 | |
| 7 | /-! |
| 8 | --- |
| 9 | title: Reachability and unreachability in directed graphs |
| 10 | type: definition |
| 11 | --- |
| 12 | An instance is a directed graph with marked source vertices and marked target |
| 13 | vertices: a structure over the vocabulary with a binary relation of edges |
| 14 | and two unary relations of sources and targets. It is a yes-instance of |
| 15 | REACH when some marked target is reachable from some marked source by a |
| 16 | directed path, possibly empty; REACH is the decision problem of the |
| 17 | structures isomorphic to such an instance. UNREACH is the complement of |
| 18 | REACH: no marked target is reachable from a marked source. |
| 19 | -/ |
| 20 | |
| 21 | namespace Lax485149.Reachability |
| 22 | |
| 23 | open FirstOrder FirstOrder.Language FirstOrder.Language.Structure |
| 24 | open Lax904597.Problems Lax485149.Problems Lax485149.Complement |
| 25 | |
| 26 | /-- The relation symbols of graphs with marked sources and targets. -/ |
| 27 | inductive stGraphRel : ℕ → Type where |
| 28 | /-- `edge a b`: there is an edge from `a` to `b`. -/ |
| 29 | | edge : stGraphRel 2 |
| 30 | /-- `source a`: the vertex `a` is a marked source. -/ |
| 31 | | source : stGraphRel 1 |
| 32 | /-- `target a`: the vertex `a` is a marked target. -/ |
| 33 | | target : stGraphRel 1 |
| 34 | deriving DecidableEq |
| 35 | |
| 36 | /-- The relational vocabulary of directed graphs with marked sources and |
| 37 | targets. -/ |
| 38 | def stGraph : Language := |
| 39 | ⟨fun _ => Empty, stGraphRel⟩ |
| 40 | |
| 41 | instance instIsRelationalStGraph : IsRelational stGraph := fun _ => |
| 42 | (inferInstance : IsEmpty Empty) |
| 43 | |
| 44 | /-- `edge a b`: there is an edge from `a` to `b`. -/ |
| 45 | abbrev sgEdge : stGraph.Relations 2 := .edge |
| 46 | |
| 47 | /-- `source a`: the vertex `a` is a marked source. -/ |
| 48 | abbrev sgSource : stGraph.Relations 1 := .source |
| 49 | |
| 50 | /-- `target a`: the vertex `a` is a marked target. -/ |
| 51 | abbrev sgTarget : stGraph.Relations 1 := .target |
| 52 | |
| 53 | /-- `edge a b`: there is an edge from `a` to `b`. -/ |
| 54 | def SGEdge {A : Type} [stGraph.Structure A] (a0 : A) (a1 : A) : Prop := |
| 55 | RelMap sgEdge ![a0, a1] |
| 56 | |
| 57 | /-- `source a`: the vertex `a` is a marked source. -/ |
| 58 | def SGSource {A : Type} [stGraph.Structure A] (a0 : A) : Prop := |
| 59 | RelMap sgSource ![a0] |
| 60 | |
| 61 | /-- `target a`: the vertex `a` is a marked target. -/ |
| 62 | def SGTarget {A : Type} [stGraph.Structure A] (a0 : A) : Prop := |
| 63 | RelMap sgTarget ![a0] |
| 64 | |
| 65 | /-- Some marked target is reachable from some marked source, along a |
| 66 | (possibly empty) directed path. -/ |
| 67 | def Reachable (A : Type) [stGraph.Structure A] : Prop := |
| 68 | ∃ s t : A, SGSource s ∧ SGTarget t ∧ Relation.ReflTransGen SGEdge s t |
| 69 | |
| 70 | /-- REACH: is some marked target reachable from some marked source? -/ |
| 71 | def REACH : DecisionProblem stGraph := DecisionProblem.ofPred fun A _ => Reachable A |
| 72 | |
| 73 | /-- UNREACH, the complement of REACH: no marked target is reachable from a |
| 74 | marked source. -/ |
| 75 | def UNREACH : DecisionProblem stGraph := DecisionProblem.compl REACH |
| 76 | |
| 77 | end Lax485149.Reachability |
| 78 |
Used by
Lax485149.DeterministicReachabilityLax485149.DeterministicReachabilityInvarianceLax485149.FirstOrderInTransitiveClosureLax485149.ImmermanSzelepcsenyiLax485149.KromAndTransitiveClosureLax485149.LByAutomataLax485149.LClosureLax485149.LEqCoLLax485149.LSubsetNLLax485149.NLByAutomataLax485149.NLClosureLax485149.NLEqCoNLLax485149.NLIsTransitiveClosureLax485149.NLSubsetNPLax485149.ReachabilityInvarianceLax485149.ReachdLCompleteLax485149.ReachNLCompleteLax485149.TransitiveClosureClosureLax485149.TwoSatInvarianceLax485149.TwoSatNLCompleteLax485149.UnreachdLCompleteLax485149.UnreachNLComplete
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments