Cortex.Pulse.DAG
On this page
Imports
import Cortex.Graph.Safety
import Mathlib.Data.Finset.Basic
import Mathlib.Order.WellFoundedSetOverview
This module gives the Paper 1 Pulse kernel its static topology model.
Context
The live runtime stores materialized node identifiers and relation-style
edges. The proof kernel deliberately uses an extensional finite-node
model instead: a node type ν, a finite topology domain, a boolean edge
predicate, and strict reachability derived as the transitive closure of
that edge predicate.
Theorem Split
The page first defines edge-derived paths and the fixed topology record, then exposes reachability facts used by the frontier antichain, failure-closure, and recovered-state domain proofs in later modules.
namespace Cortex.PulseEdge Paths
EdgePath edge a b is non-empty reachability from a to b through
the direct edge predicate.
inductive EdgePath {ν : Type u} (edge : ν → ν → Bool) : ν → ν → Prop where
| direct {a b : ν} : edge a b = true → EdgePath edge a b
| trans {a b c : ν} : EdgePath edge a b → EdgePath edge b c → EdgePath edge a cnamespace EdgePathvariable {ν : Type u} {edge : ν → ν → Bool} {nodes : Finset ν}
source_mem lifts direct-edge source membership through an EdgePath.
theorem source_mem
(hSource : ∀ {a b : ν}, edge a b = true → a ∈ nodes)
{a b : ν}
(hPath : EdgePath edge a b) :
a ∈ nodes := ν:Type uedge:ν → ν → Boolnodes:Finset νhSource:∀ {a b : ν}, edge a b = true → a ∈ nodesa:νb:νhPath:EdgePath edge a b⊢ a ∈ nodes
induction hPath with
ν:Type uedge:ν → ν → Boolnodes:Finset νhSource:∀ {a b : ν}, edge a b = true → a ∈ nodesa:νb:νa✝:νb✝:νhEdge:edge a✝ b✝ = true⊢ a✝ ∈ nodes All goals completed! 🐙
ν:Type uedge:ν → ν → Boolnodes:Finset νhSource:∀ {a b : ν}, edge a b = true → a ∈ nodesa:νb:νa✝²:νb✝:νc✝:νa✝¹:EdgePath edge a✝² b✝a✝:EdgePath edge b✝ c✝ihLeft:a✝² ∈ nodesa_ih✝:b✝ ∈ nodes⊢ a✝² ∈ nodes All goals completed! 🐙
target_mem lifts direct-edge target membership through an EdgePath.
theorem target_mem
(hTarget : ∀ {a b : ν}, edge a b = true → b ∈ nodes)
{a b : ν}
(hPath : EdgePath edge a b) :
b ∈ nodes := ν:Type uedge:ν → ν → Boolnodes:Finset νhTarget:∀ {a b : ν}, edge a b = true → b ∈ nodesa:νb:νhPath:EdgePath edge a b⊢ b ∈ nodes
induction hPath with
ν:Type uedge:ν → ν → Boolnodes:Finset νhTarget:∀ {a b : ν}, edge a b = true → b ∈ nodesa:νb:νa✝:νb✝:νhEdge:edge a✝ b✝ = true⊢ b✝ ∈ nodes All goals completed! 🐙
ν:Type uedge:ν → ν → Boolnodes:Finset νhTarget:∀ {a b : ν}, edge a b = true → b ∈ nodesa:νb:νa✝²:νb✝:νc✝:νa✝¹:EdgePath edge a✝² b✝a✝:EdgePath edge b✝ c✝a_ih✝:b✝ ∈ nodesihRight:c✝ ∈ nodes⊢ c✝ ∈ nodes All goals completed! 🐙
last_step decomposes a non-empty path into its final direct edge.
theorem last_step {a b : ν}
(hPath : EdgePath edge a b) :
edge a b = true ∨ ∃ c : ν, EdgePath edge a c ∧ edge c b = true := ν:Type uedge:ν → ν → Boola:νb:νhPath:EdgePath edge a b⊢ edge a b = true ∨ ∃ c, EdgePath edge a c ∧ edge c b = true
induction hPath with
ν:Type uedge:ν → ν → Boola:νb:νa✝:νb✝:νhEdge:edge a✝ b✝ = true⊢ edge a✝ b✝ = true ∨ ∃ c, EdgePath edge a✝ c ∧ edge c b✝ = true All goals completed! 🐙
ν:Type uedge:ν → ν → Boola:νb:νa✝:νb✝:νc✝:νhLeft:EdgePath edge a✝ b✝hRight:EdgePath edge b✝ c✝a_ih✝:edge a✝ b✝ = true ∨ ∃ c, EdgePath edge a✝ c ∧ edge c b✝ = trueihRight:edge b✝ c✝ = true ∨ ∃ c, EdgePath edge b✝ c ∧ edge c c✝ = true⊢ edge a✝ c✝ = true ∨ ∃ c, EdgePath edge a✝ c ∧ edge c c✝ = true
ν:Type uedge:ν → ν → Boola:νb:νa✝:νb✝:νc✝:νhLeft:EdgePath edge a✝ b✝hRight:EdgePath edge b✝ c✝a_ih✝:edge a✝ b✝ = true ∨ ∃ c, EdgePath edge a✝ c ∧ edge c b✝ = truehDirect:edge b✝ c✝ = true⊢ edge a✝ c✝ = true ∨ ∃ c, EdgePath edge a✝ c ∧ edge c c✝ = trueν:Type uedge:ν → ν → Boola:νb:νa✝:νb✝:νc✝:νhLeft:EdgePath edge a✝ b✝hRight:EdgePath edge b✝ c✝a_ih✝:edge a✝ b✝ = true ∨ ∃ c, EdgePath edge a✝ c ∧ edge c b✝ = truec:νhPrefix:EdgePath edge b✝ chEdge:edge c c✝ = true⊢ edge a✝ c✝ = true ∨ ∃ c, EdgePath edge a✝ c ∧ edge c c✝ = true
ν:Type uedge:ν → ν → Boola:νb:νa✝:νb✝:νc✝:νhLeft:EdgePath edge a✝ b✝hRight:EdgePath edge b✝ c✝a_ih✝:edge a✝ b✝ = true ∨ ∃ c, EdgePath edge a✝ c ∧ edge c b✝ = truehDirect:edge b✝ c✝ = true⊢ edge a✝ c✝ = true ∨ ∃ c, EdgePath edge a✝ c ∧ edge c c✝ = true All goals completed! 🐙
ν:Type uedge:ν → ν → Boola:νb:νa✝:νb✝:νc✝:νhLeft:EdgePath edge a✝ b✝hRight:EdgePath edge b✝ c✝a_ih✝:edge a✝ b✝ = true ∨ ∃ c, EdgePath edge a✝ c ∧ edge c b✝ = truec:νhPrefix:EdgePath edge b✝ chEdge:edge c c✝ = true⊢ edge a✝ c✝ = true ∨ ∃ c, EdgePath edge a✝ c ∧ edge c c✝ = true All goals completed! 🐙end EdgePathRelation Bridges
namespace EdgePathvariable {ν : Type} [DecidableEq ν]
of_relationPath_edgeBool lowers relation reachability to boolean-edge reachability.
theorem of_relationPath_edgeBool
{relation : Cortex.Graph.Relation ν}
{source target : ν}
(hPath : Cortex.Graph.Relation.Path relation source target) :
EdgePath (Cortex.Graph.Relation.edgeBool relation) source target := ν:Typeinst✝:DecidableEq νrelation:Graph.Relation νsource:νtarget:νhPath:relation.Path source target⊢ EdgePath relation.edgeBool source target
induction hPath with
ν:Typeinst✝:DecidableEq νrelation:Graph.Relation νsource:νtarget:νsource✝:νtarget✝:νhEdge:(source✝, target✝) ∈ relation.edges⊢ EdgePath relation.edgeBool source✝ target✝
All goals completed! 🐙
ν:Typeinst✝:DecidableEq νrelation:Graph.Relation νsource:νtarget:νsource✝:νmiddle✝:νtarget✝:νa✝¹:relation.Path source✝ middle✝a✝:relation.Path middle✝ target✝ihLeft:EdgePath relation.edgeBool source✝ middle✝ihRight:EdgePath relation.edgeBool middle✝ target✝⊢ EdgePath relation.edgeBool source✝ target✝
All goals completed! 🐙
to_relationPath_edgeBool lifts boolean-edge reachability to relation reachability.
theorem to_relationPath_edgeBool
{relation : Cortex.Graph.Relation ν}
{source target : ν}
(hPath : EdgePath (Cortex.Graph.Relation.edgeBool relation) source target) :
Cortex.Graph.Relation.Path relation source target := ν:Typeinst✝:DecidableEq νrelation:Graph.Relation νsource:νtarget:νhPath:EdgePath relation.edgeBool source target⊢ relation.Path source target
induction hPath with
ν:Typeinst✝:DecidableEq νrelation:Graph.Relation νsource:νtarget:νa✝:νb✝:νhEdge:relation.edgeBool a✝ b✝ = true⊢ relation.Path a✝ b✝
All goals completed! 🐙
ν:Typeinst✝:DecidableEq νrelation:Graph.Relation νsource:νtarget:νa✝²:νb✝:νc✝:νa✝¹:EdgePath relation.edgeBool a✝² b✝a✝:EdgePath relation.edgeBool b✝ c✝ihLeft:relation.Path a✝² b✝ihRight:relation.Path b✝ c✝⊢ relation.Path a✝² c✝
All goals completed! 🐙
edgeBool_iff_relationPath equates Pulse paths with relation paths.
theorem edgeBool_iff_relationPath
(relation : Cortex.Graph.Relation ν)
(source target : ν) :
EdgePath (Cortex.Graph.Relation.edgeBool relation) source target ↔
Cortex.Graph.Relation.Path relation source target :=
⟨to_relationPath_edgeBool, of_relationPath_edgeBool⟩end EdgePathFixed Topology
DAG ν is the fixed Pulse topology for the Paper 1 kernel.
edge a b = true means that a is a direct dependency of b.
DAG.reaches G a b is the non-empty transitive closure of that direct
edge relation. The structure packages only the concrete edge topology and
the laws needed to rule out off-topology edges and cycles, without
committing the model to UUIDs, database rows, or a concrete graph
container.
structure DAG (ν : Type u) where
nodes is the finite set of materialized nodes in the topology.
nodes : Finset ν
edge a b means source a must complete before target b can run.
edge : ν → ν → Bool
edge_source_mem keeps every direct-edge source inside the topology.
edge_source_mem : ∀ {a b : ν}, edge a b = true → a ∈ nodes
edge_target_mem keeps every direct-edge target inside the topology.
edge_target_mem : ∀ {a b : ν}, edge a b = true → b ∈ nodes
acyclic rules out non-empty paths from a node back to itself.
acyclic : ∀ a : ν, ¬ EdgePath edge a aReachability Facts
namespace DAGvariable {ν : Type u} (G : DAG ν)
G.reaches a b is edge-derived strict reachability.
def reaches (a b : ν) : Prop :=
EdgePath G.edge a b
G.predecessor a b says a is a direct predecessor of b.
def predecessor (a b : ν) : Prop :=
G.edge a b = true
reaches_of_edge turns a direct edge into a strict reachability witness.
theorem reaches_of_edge {a b : ν} (hEdge : G.predecessor a b) :
G.reaches a b :=
EdgePath.direct hEdge
reaches_trans composes two edge-derived reachability witnesses.
theorem reaches_trans {a b c : ν}
(hLeft : G.reaches a b)
(hRight : G.reaches b c) :
G.reaches a c :=
EdgePath.trans hLeft hRight
reaches_source_mem keeps reachable sources inside the finite topology.
theorem reaches_source_mem {a b : ν} (hReach : G.reaches a b) :
a ∈ G.nodes :=
EdgePath.source_mem G.edge_source_mem hReach
reaches_target_mem keeps reachable targets inside the finite topology.
theorem reaches_target_mem {a b : ν} (hReach : G.reaches a b) :
b ∈ G.nodes :=
EdgePath.target_mem G.edge_target_mem hReach
not_reaches_self states strict reachability is irreflexive in a DAG.
theorem not_reaches_self (a : ν) :
¬ G.reaches a a :=
G.acyclic a
not_reaches_reverse rules out strict reachability in both directions.
theorem not_reaches_reverse {a b : ν} (hReach : G.reaches a b) :
¬ G.reaches b a := ν:Type uG:DAG νa:νb:νhReach:G.reaches a b⊢ ¬G.reaches b a
ν:Type uG:DAG νa:νb:νhReach:G.reaches a bhBack:G.reaches b a⊢ False
All goals completed! 🐙
exists_reaches_minimal finds a reachability-minimal member of a finite set.
theorem exists_reaches_minimal
(nodes : Finset ν)
(hNonempty : nodes.Nonempty) :
∃ node ∈ nodes, ∀ predecessor ∈ nodes, ¬ G.reaches predecessor node := ν:Type uG:DAG νnodes:Finset νhNonempty:nodes.Nonempty⊢ ∃ node ∈ nodes, ∀ predecessor ∈ nodes, ¬G.reaches predecessor node
classical
ν:Type uG:DAG νnodes:Finset νhNonempty:nodes.NonemptynodeSet:Set ν := {node | node ∈ nodes}⊢ ∃ node ∈ nodes, ∀ predecessor ∈ nodes, ¬G.reaches predecessor node
have hFinite : nodeSet.Finite := ν:Type uG:DAG νnodes:Finset νhNonempty:nodes.Nonempty⊢ ∃ node ∈ nodes, ∀ predecessor ∈ nodes, ¬G.reaches predecessor node
All goals completed! 🐙
ν:Type uG:DAG νnodes:Finset νhNonempty:nodes.NonemptynodeSet:Set ν := {node | node ∈ nodes}hFinite:nodeSet.Finitethis:IsStrictOrder ν G.reaches := ···⊢ ∃ node ∈ nodes, ∀ predecessor ∈ nodes, ¬G.reaches predecessor node
ν:Type uG:DAG νnodes:Finset νhNonempty:nodes.NonemptynodeSet:Set ν := {node | node ∈ nodes}hFinite:nodeSet.Finitethis:IsStrictOrder ν G.reaches := ···hWFOn:nodeSet.WellFoundedOn G.reaches⊢ ∃ node ∈ nodes, ∀ predecessor ∈ nodes, ¬G.reaches predecessor node
ν:Type uG:DAG νnodes:Finset νhNonempty:nodes.NonemptynodeSet:Set ν := {node | node ∈ nodes}hFinite:nodeSet.Finitethis:IsStrictOrder ν G.reaches := ···hWFOn:WellFounded fun a b => G.reaches a b ∧ a ∈ nodeSet ∧ b ∈ nodeSet⊢ ∃ node ∈ nodes, ∀ predecessor ∈ nodes, ¬G.reaches predecessor node
have hSetNonempty : nodeSet.Nonempty := ν:Type uG:DAG νnodes:Finset νhNonempty:nodes.Nonempty⊢ ∃ node ∈ nodes, ∀ predecessor ∈ nodes, ¬G.reaches predecessor node
ν:Type uG:DAG νnodes:Finset νnodeSet:Set ν := {node | node ∈ nodes}hFinite:nodeSet.Finitethis:IsStrictOrder ν G.reaches := ···hWFOn:WellFounded fun a b => G.reaches a b ∧ a ∈ nodeSet ∧ b ∈ nodeSetnode:νhNode:node ∈ nodes⊢ nodeSet.Nonempty
exact ⟨node, ν:Type uG:DAG νnodes:Finset νnodeSet:Set ν := {node | node ∈ nodes}hFinite:nodeSet.Finitethis:IsStrictOrder ν G.reaches := ···hWFOn:WellFounded fun a b => G.reaches a b ∧ a ∈ nodeSet ∧ b ∈ nodeSetnode:νhNode:node ∈ nodes⊢ node ∈ nodeSet All goals completed! 🐙⟩
ν:Type uG:DAG νnodes:Finset νhNonempty:nodes.NonemptynodeSet:Set ν := {node | node ∈ nodes}hFinite:nodeSet.Finitethis:IsStrictOrder ν G.reaches := ···hWFOn:WellFounded fun a b => G.reaches a b ∧ a ∈ nodeSet ∧ b ∈ nodeSethSetNonempty:nodeSet.Nonemptynode:νhNode:node ∈ nodeSethMinimal:∀ x ∈ nodeSet, ¬(G.reaches x node ∧ x ∈ nodeSet ∧ node ∈ nodeSet)⊢ ∃ node ∈ nodes, ∀ predecessor ∈ nodes, ¬G.reaches predecessor node
refine ⟨node, ν:Type uG:DAG νnodes:Finset νhNonempty:nodes.NonemptynodeSet:Set ν := {node | node ∈ nodes}hFinite:nodeSet.Finitethis:IsStrictOrder ν G.reaches := ···hWFOn:WellFounded fun a b => G.reaches a b ∧ a ∈ nodeSet ∧ b ∈ nodeSethSetNonempty:nodeSet.Nonemptynode:νhNode:node ∈ nodeSethMinimal:∀ x ∈ nodeSet, ¬(G.reaches x node ∧ x ∈ nodeSet ∧ node ∈ nodeSet)⊢ node ∈ nodes All goals completed! 🐙, ?_⟩
intro predecessor ν:Type uG:DAG νnodes:Finset νhNonempty:nodes.NonemptynodeSet:Set ν := {node | node ∈ nodes}hFinite:nodeSet.Finitethis:IsStrictOrder ν G.reaches := ···hWFOn:WellFounded fun a b => G.reaches a b ∧ a ∈ nodeSet ∧ b ∈ nodeSethSetNonempty:nodeSet.Nonemptynode:νhNode:node ∈ nodeSethMinimal:∀ x ∈ nodeSet, ¬(G.reaches x node ∧ x ∈ nodeSet ∧ node ∈ nodeSet)predecessor:νhPredecessor:predecessor ∈ nodes⊢ ¬G.reaches predecessor node ν:Type uG:DAG νnodes:Finset νhNonempty:nodes.NonemptynodeSet:Set ν := {node | node ∈ nodes}hFinite:nodeSet.Finitethis:IsStrictOrder ν G.reaches := ···hWFOn:WellFounded fun a b => G.reaches a b ∧ a ∈ nodeSet ∧ b ∈ nodeSethSetNonempty:nodeSet.Nonemptynode:νhNode:node ∈ nodeSethMinimal:∀ x ∈ nodeSet, ¬(G.reaches x node ∧ x ∈ nodeSet ∧ node ∈ nodeSet)predecessor:νhPredecessor:predecessor ∈ nodeshReach:G.reaches predecessor node⊢ False
have hPredecessorSet : predecessor ∈ nodeSet := ν:Type uG:DAG νnodes:Finset νhNonempty:nodes.Nonempty⊢ ∃ node ∈ nodes, ∀ predecessor ∈ nodes, ¬G.reaches predecessor node
All goals completed! 🐙
All goals completed! 🐙Relation Construction
section RelationConstructionvariable {ν : Type} [DecidableEq ν]
ofRelation constructs a Pulse DAG from an endpoint-closed acyclic relation.
def ofRelation
(relation : Cortex.Graph.Relation ν)
(hEndpoints : Cortex.Graph.Relation.EdgeEndpointsInVertices relation)
(hAcyclic : Cortex.Graph.Relation.Acyclic relation) :
DAG ν :=
{ nodes := relation.vertices
edge := Cortex.Graph.Relation.edgeBool relation
edge_source_mem := fun hEdge =>
Cortex.Graph.Relation.edgeBool_source_mem hEndpoints hEdge
edge_target_mem := fun hEdge =>
Cortex.Graph.Relation.edgeBool_target_mem hEndpoints hEdge
acyclic := fun node hPath =>
hAcyclic node (EdgePath.to_relationPath_edgeBool hPath) }
ofRelation_edge_true_iff identifies the constructed DAG edge predicate.
theorem ofRelation_edge_true_iff
(relation : Cortex.Graph.Relation ν)
(hEndpoints : Cortex.Graph.Relation.EdgeEndpointsInVertices relation)
(hAcyclic : Cortex.Graph.Relation.Acyclic relation)
(source target : ν) :
(ofRelation relation hEndpoints hAcyclic).edge source target = true ↔
(source, target) ∈ relation.edges :=
Cortex.Graph.Relation.edgeBool_true_iff relation source target
ofRelation_reaches_iff_path identifies constructed DAG reachability.
theorem ofRelation_reaches_iff_path
(relation : Cortex.Graph.Relation ν)
(hEndpoints : Cortex.Graph.Relation.EdgeEndpointsInVertices relation)
(hAcyclic : Cortex.Graph.Relation.Acyclic relation)
(source target : ν) :
(ofRelation relation hEndpoints hAcyclic).reaches source target ↔
Cortex.Graph.Relation.Path relation source target :=
EdgePath.edgeBool_iff_relationPath relation source targetend RelationConstructionend DAGend Cortex.Pulse