Cortex.Wire.Admission
On this page
Imports
import Cortex.Wire.Rewrite
import Mathlib.Data.Finset.Basic
import Mathlib.Data.Finset.ProdOverview
Runtime-admission bridge for Wire rewrites.
Context
Cortex.Wire.Rewrite proves safety for proof-carrying rewrites: if a
rewrite carries preservation certificates and consumes budget, then rewrite
chains preserve the stated invariants. The Haskell runtime, however, admits
rewrites through planGraphRewrite, consumeRewriteBudget, and
admitRewriteDelta.
This module names the proof-side shape of those runtime checks. It does not
execute Haskell. Instead, it records the obligations an accepted planned
rewrite must establish: the final topology must match the relation-level
planner construction, relation-diff sets must agree with the final topology,
anchor disposition must agree with the rewrite form, structural costs must
match the planned delta, definition-domain updates must follow the runtime
delete-or-retain formula, and budget admission must consume budget pointwise.
Under those obligations, an accepted plan instantiates the abstract Rewrite
certificate surface.
Theorem Split
The page defines runtime-shaped rewrite inputs, subgraph validity, a relation-level planner model, planned rewrite checks, budget admission, and the bridge theorem from admitted planned deltas to abstract admissible rewrites.
namespace Cortex.Wireopen Cortex.GraphRuntime-Shaped Inputs
ExpansionMode mirrors the runtime's node-expansion mode.
inductive ExpansionMode : Type where
| replaceNode
| retainNodeAsEnvelope
deriving DecidableEq, Repr
RewriteAnchorDisposition records whether the anchor remains materialized.
inductive RewriteAnchorDisposition : Type where
| removed
| retained
deriving DecidableEq, Repr
SubgraphSpec node is the proof-side shape of a proposed inserted subgraph.
structure SubgraphSpec (node : Type) whereTopology of the proposed inserted subgraph.
topology : Graph nodeDomain of the stage definitions supplied for the inserted subgraph.
definitions : Finset nodeEntry nodes exposed by the inserted subgraph.
entryNodes : Finset nodeExit nodes exposed by the inserted subgraph.
exitNodes : Finset node
GraphRewrite node mirrors the runtime rewrite forms currently admitted.
inductive GraphRewrite (node : Type) : Type where
| expandNode : node → ExpansionMode → SubgraphSpec node → GraphRewrite node
| appendAfter : node → SubgraphSpec node → GraphRewrite nodenamespace GraphRewrite
anchor rewrite is the node around which the runtime plans the rewrite.
def anchor {node : Type} : GraphRewrite node → node
| GraphRewrite.expandNode anchorNode _mode _spec => anchorNode
| GraphRewrite.appendAfter anchorNode _spec => anchorNode
spec rewrite is the inserted subgraph proposed by the rewrite.
def spec {node : Type} : GraphRewrite node → SubgraphSpec node
| GraphRewrite.expandNode _anchor _mode subgraph => subgraph
| GraphRewrite.appendAfter _anchor subgraph => subgraph
anchorDisposition rewrite mirrors the runtime anchor-retention decision.
def anchorDisposition {node : Type} : GraphRewrite node → RewriteAnchorDisposition
| GraphRewrite.expandNode _anchor ExpansionMode.replaceNode _spec =>
RewriteAnchorDisposition.removed
| GraphRewrite.expandNode _anchor ExpansionMode.retainNodeAsEnvelope _spec =>
RewriteAnchorDisposition.retained
| GraphRewrite.appendAfter _anchor _spec =>
RewriteAnchorDisposition.retainedend GraphRewriteRelation-Level Planner Model
This section transcribes the Haskell planGraphRewrite topology construction
(src/Cortex/Pulse/Rewrite.hs) into a relation-level Lean model. The runtime
plan proceeds in five stages:
- Resolve the anchor's predecessors and successors in the current topology.
-
Form the base topology by either deleting the anchor (
replaceNode) or stripping its outgoing edges (retainNodeAsEnvelope,appendAfter). - Overlay the inserted subgraph.
- Wire the entry sources to the inserted entry nodes. The entry source set is the anchor's predecessors when the anchor is removed and the anchor itself when the anchor is retained.
- Wire the inserted exit nodes to the anchor's successors.
plannedFinalRelation carries out exactly those five stages on the relation
denotation. The bridge theorem topologyMatches requires delta.topology to
match this construction; relationAddedNodes, relationRemovedNodes, and
relationAddedEdges recover the runtime relationDiff outputs from the same
relation.
The planner takes the inserted subgraph as already living in the final node
namespace. The runtime obtains that shape through namespaceSubgraph; a later
executable correspondence theorem must connect that function to this
proof-side input.
section PlannerRelationvariable {node : Type}variable [DecidableEq node]
predecessorsOf relation target extracts direct predecessors of target.
def predecessorsOf (relation : Relation node) (target : node) : Finset node :=
(relation.edges.filter (fun edge => edge.2 = target)).image Prod.fst
successorsOf relation source extracts direct successors of source.
def successorsOf (relation : Relation node) (source : node) : Finset node :=
(relation.edges.filter (fun edge => edge.1 = source)).image Prod.snd
removeVertexFromRelation relation vertex removes a vertex and incident edges.
def removeVertexFromRelation (relation : Relation node) (vertex : node) : Relation node :=
{ vertices := relation.vertices.erase vertex
edges := relation.edges.filter (fun edge => edge.1 ≠ vertex ∧ edge.2 ≠ vertex) }
removeOutgoingFromRelation relation vertex removes all outgoing edges from a vertex.
def removeOutgoingFromRelation (relation : Relation node) (vertex : node) : Relation node :=
{ vertices := relation.vertices
edges := relation.edges.filter (fun edge => edge.1 ≠ vertex) }
addEdgesToRelation relation edges adds edges and their endpoint vertices.
def addEdgesToRelation (relation : Relation node) (edges : Finset (node × node)) :
Relation node :=
{ vertices := relation.vertices ∪ edges.image Prod.fst ∪ edges.image Prod.snd
edges := relation.edges ∪ edges }
plannedFinalRelation context rewrite mirrors the runtime topology construction.
The subgraph is assumed to already live in the final node namespace. The Haskell
planner obtains that shape through namespaceSubgraph; a later executable
correspondence theorem must connect that function to this proof-side input.
def plannedFinalRelation (context : Graph node) (rewrite : GraphRewrite node) :
Relation node :=
let oldRelation := denote context
let anchorNode := rewrite.anchor
let insertedRelation := denote rewrite.spec.topology
let predecessors := predecessorsOf oldRelation anchorNode
let successors := successorsOf oldRelation anchorNode
let baseRelation :=
match rewrite with
| GraphRewrite.expandNode _anchor ExpansionMode.replaceNode _spec =>
removeVertexFromRelation oldRelation anchorNode
| GraphRewrite.expandNode _anchor ExpansionMode.retainNodeAsEnvelope _spec =>
removeOutgoingFromRelation oldRelation anchorNode
| GraphRewrite.appendAfter _anchor _spec =>
removeOutgoingFromRelation oldRelation anchorNode
let withSubgraph := Relation.overlay baseRelation insertedRelation
let entrySources :=
match rewrite.anchorDisposition with
| RewriteAnchorDisposition.removed => predecessors
| RewriteAnchorDisposition.retained => {anchorNode}
let withEntries :=
addEdgesToRelation withSubgraph (entrySources ×ˢ rewrite.spec.entryNodes)
addEdgesToRelation withEntries (rewrite.spec.exitNodes ×ˢ successors)
Nodes added by moving from oldRelation to newRelation.
def relationAddedNodes (oldRelation newRelation : Relation node) : Finset node :=
newRelation.vertices \ oldRelation.vertices
Nodes removed by moving from oldRelation to newRelation.
def relationRemovedNodes (oldRelation newRelation : Relation node) : Finset node :=
oldRelation.vertices \ newRelation.vertices
Edges added by moving from oldRelation to newRelation.
def relationAddedEdges
(oldRelation newRelation : Relation node) :
Finset (node × node) :=
newRelation.edges \ oldRelation.edgesend PlannerRelationPlanning Predicates
section PlanningPredicatesvariable {node : Type}variable [DecidableEq node]
DefinitionCoverage topology definitions says definitions exactly cover topology vertices.
def DefinitionCoverage (topology : Graph node) (definitions : Finset node) : Prop :=
definitions = (denote topology).vertices
NodesInside nodes topology says every listed node appears in the topology.
def NodesInside (nodes : Finset node) (topology : Graph node) : Prop :=
∀ node, node ∈ nodes → node ∈ (denote topology).vertices
ReachableOrSame g source target matches runtime reachability, including the root itself.
def ReachableOrSame (g : Graph node) (source target : node) : Prop :=
source = target ∨ GraphPath g source target
OrphanFree spec says each inserted node lies on an entry-to-exit path.
def OrphanFree (spec : SubgraphSpec node) : Prop :=
∀ node,
node ∈ (denote spec.topology).vertices →
(∃ entry, entry ∈ spec.entryNodes ∧ ReachableOrSame spec.topology entry node) ∧
∃ exit, exit ∈ spec.exitNodes ∧ ReachableOrSame spec.topology node exit
GraphPathNodeCount g source target count counts vertices along a non-branching path.
inductive GraphPathNodeCount (g : Graph node) : node → node → Nat → Prop where
| same {node : node} :
node ∈ (denote g).vertices →
GraphPathNodeCount g node node 1
| direct {source target : node} :
(source, target) ∈ (denote g).edges →
GraphPathNodeCount g source target 2
| cons {source next target : node} {count : Nat} :
(source, next) ∈ (denote g).edges →
GraphPathNodeCount g next target count →
GraphPathNodeCount g source target (count + 1)
EntryExitPathNodeCount spec count witnesses an entry-to-exit path with count nodes.
def EntryExitPathNodeCount (spec : SubgraphSpec node) (count : Nat) : Prop :=
∃ entry exit,
entry ∈ spec.entryNodes ∧
exit ∈ spec.exitNodes ∧
GraphPathNodeCount spec.topology entry exit count
LongestInsertedPathNodeCount spec depth mirrors the runtime inserted-depth computation.
def LongestInsertedPathNodeCount (spec : SubgraphSpec node) (depth : Nat) : Prop :=
(∀ count, EntryExitPathNodeCount spec count → count ≤ depth) ∧
(depth = 0 ∨ EntryExitPathNodeCount spec depth)
SubgraphSpec.Valid spec collects the runtime's inserted-subgraph checks.
structure SubgraphSpec.Valid (spec : SubgraphSpec node) : Prop whereThe inserted subgraph itself is acyclic.
acyclic : Acyclic spec.topologyInserted definitions exactly cover inserted topology nodes.
definitionsCover : DefinitionCoverage spec.topology spec.definitionsInserted subgraphs must expose at least one entry node.
entryNodesNonempty : spec.entryNodes.NonemptyInserted subgraphs must expose at least one exit node.
exitNodesNonempty : spec.exitNodes.NonemptyEvery entry node belongs to the inserted topology.
entryNodesInside : NodesInside spec.entryNodes spec.topologyEvery exit node belongs to the inserted topology.
exitNodesInside : NodesInside spec.exitNodes spec.topologyEvery inserted node is reachable from an entry and can reach an exit.
orphanFree : OrphanFree spec
PlanningContext is the current runtime topology plus definition domain.
structure PlanningContext (node : Type) whereCurrent materialized topology before the rewrite is applied.
topology : Graph nodeDomain of current stage definitions.
definitions : Finset node
plannedFinalDefinitions context rewrite mirrors the runtime definition-domain update.
Replacing an anchor deletes its current definition before overlaying the inserted definitions. Retaining an anchor and appending after an anchor keep the old definition domain and overlay the inserted definitions. The inserted subgraph is assumed to already live in the final namespace.
def plannedFinalDefinitions
(context : PlanningContext node)
(rewrite : GraphRewrite node) :
Finset node :=
match rewrite.anchorDisposition with
| RewriteAnchorDisposition.removed =>
context.definitions.erase rewrite.anchor ∪ rewrite.spec.definitions
| RewriteAnchorDisposition.retained =>
context.definitions ∪ rewrite.spec.definitions
PlannedRewriteDelta mirrors the runtime's planned rewrite output.
structure PlannedRewriteDelta (node : Type) whereFinal topology after applying the planned rewrite.
topology : Graph nodeFinal definition domain after applying the planned rewrite.
definitions : Finset nodeNodes newly introduced by the planned rewrite.
newNodes : Finset nodeNodes removed by the planned rewrite.
removedNodes : Finset nodeEdges newly introduced by the planned rewrite.
addedEdges : Finset (node × node)Entry nodes of the inserted subgraph after namespacing.
entryNodes : Finset nodeExit nodes of the inserted subgraph after namespacing.
exitNodes : Finset nodeAnchor node that produced the rewrite.
anchorNode : nodeWhether the anchor remains in the final topology.
anchorDisposition : RewriteAnchorDispositionStructural cost computed for this rewrite.
cost : RewriteCost
SubgraphContainedInFinal rewrite delta records that the inserted subgraph was inserted.
structure SubgraphContainedInFinal
(rewrite : GraphRewrite node)
(delta : PlannedRewriteDelta node) :
Prop whereEvery inserted vertex appears in the final topology.
verticesInside :
∀ node,
node ∈ (denote rewrite.spec.topology).vertices →
node ∈ (denote delta.topology).verticesEvery inserted edge appears in the final topology.
edgesInside :
∀ edge,
edge ∈ (denote rewrite.spec.topology).edges →
edge ∈ (denote delta.topology).edges
EntryExitMatches rewrite delta ties delta entry/exit sets to the inserted subgraph.
structure EntryExitMatches
(rewrite : GraphRewrite node)
(delta : PlannedRewriteDelta node) :
Prop whereDelta entry nodes are exactly the inserted subgraph entry nodes.
entryNodes_eq : delta.entryNodes = rewrite.spec.entryNodesDelta exit nodes are exactly the inserted subgraph exit nodes.
exitNodes_eq : delta.exitNodes = rewrite.spec.exitNodes
AnchorDispositionMatches rewrite delta couples the runtime disposition to topology.
structure AnchorDispositionMatches
(rewrite : GraphRewrite node)
(delta : PlannedRewriteDelta node) :
Prop whereDelta disposition agrees with the rewrite form.
disposition_eq : delta.anchorDisposition = rewrite.anchorDispositionRemoved anchors are absent from the final topology.
removed_absent :
delta.anchorDisposition = RewriteAnchorDisposition.removed →
rewrite.anchor ∉ (denote delta.topology).verticesRetained anchors remain in the final topology.
retained_present :
delta.anchorDisposition = RewriteAnchorDisposition.retained →
rewrite.anchor ∈ (denote delta.topology).vertices
TopologyDiffMatches context delta ties delta sets to the relation diff.
structure TopologyDiffMatches
(context : PlanningContext node)
(delta : PlannedRewriteDelta node) :
Prop whereNew nodes are exactly final vertices absent from the old topology.
newNodes_eq :
delta.newNodes =
relationAddedNodes (denote context.topology) (denote delta.topology)Removed nodes are exactly old vertices absent from the final topology.
removedNodes_eq :
delta.removedNodes =
relationRemovedNodes (denote context.topology) (denote delta.topology)Added edges are exactly final edges absent from the old topology.
addedEdges_eq :
delta.addedEdges =
relationAddedEdges (denote context.topology) (denote delta.topology)
DefinitionUpdateMatches context rewrite delta ties definitions to the planner update.
structure DefinitionUpdateMatches
(context : PlanningContext node)
(rewrite : GraphRewrite node)
(delta : PlannedRewriteDelta node) :
Prop whereFinal definition-domain keys match the runtime delete-or-retain update formula.
definitions_eq : delta.definitions = plannedFinalDefinitions context rewrite
PlannedRewriteCostMatches rewrite delta ties every budget dimension to the delta.
structure PlannedRewriteCostMatches
(rewrite : GraphRewrite node)
(delta : PlannedRewriteDelta node) :
Prop whereAdded-node cost equals the relation-diff node count.
addedNodes_eq : delta.cost.addedNodes = delta.newNodes.cardAdded-edge cost equals the relation-diff edge count.
addedEdges_eq : delta.cost.addedEdges = delta.addedEdges.cardAdded-depth cost is computed from the inserted entry-to-exit longest path.
addedDepth_eq :
∃ insertedDepth,
LongestInsertedPathNodeCount rewrite.spec insertedDepth ∧
delta.cost.addedDepth =
match delta.anchorDisposition with
| RewriteAnchorDisposition.removed => insertedDepth - 1
| RewriteAnchorDisposition.retained => insertedDepthFrontier delta is the number of inserted entries beyond the first.
frontierDelta_eq : delta.cost.frontierDelta = delta.entryNodes.card - 1Each planned graph rewrite consumes one rewrite-operation unit.
rewriteOps_eq : delta.cost.rewriteOps = 1
PlanGraphRewriteChecks context rewrite delta is the Lean-side runtime planning contract.
structure PlanGraphRewriteChecks
(context : PlanningContext node)
(rewrite : GraphRewrite node)
(delta : PlannedRewriteDelta node) :
Prop whereThe delta records the rewrite anchor.
anchorMatches : delta.anchorNode = rewrite.anchorThe anchor exists in the current topology.
anchorInTopology : rewrite.anchor ∈ (denote context.topology).verticesThe anchor has a current stage definition.
anchorHasDefinition : rewrite.anchor ∈ context.definitionsThe inserted subgraph satisfies the runtime subgraph checks.
subgraphValid : rewrite.spec.ValidThe final topology matches the proof-side relation-level planner construction.
topologyMatches :
denote delta.topology = plannedFinalRelation context.topology rewriteThe inserted subgraph is present in the final topology.
subgraphContained : SubgraphContainedInFinal rewrite deltaDelta entry/exit nodes are the inserted subgraph entry/exit nodes.
entryExitMatches : EntryExitMatches rewrite deltaDelta anchor disposition agrees with the rewrite and final anchor membership.
anchorDispositionMatches : AnchorDispositionMatches rewrite deltaDelta new/removed/added sets agree with relation-level topology diffs.
topologyDiffMatches : TopologyDiffMatches context deltaDelta cost agrees with every structural budget dimension.
costMatches : PlannedRewriteCostMatches rewrite deltaDelta definitions agree with the runtime delete-or-retain update formula.
definitionUpdateMatches : DefinitionUpdateMatches context rewrite deltaThe final topology has a definition for each materialized node and no extras.
finalDefinitionsCover : DefinitionCoverage delta.topology delta.definitionsThe runtime validates the final topology as acyclic.
finalAcyclic : Acyclic delta.topologyend PlanningPredicatesRegistry Boundary Preservation
section RegistryBoundaryPreservationvariable {executor config contract authority : Type}variable [DecidableEq contract]variable [DecidableEq (StagedExecutorNode executor config authority)]
RegistryBoundaryDeltaAdmitted registry delta bundles the per-delta registry obligations that
are not inherited from the source graph boundary.
This witness is load-bearing only when paired with a TopologyDiffMatches proof for the same
delta, which ties delta.newNodes and delta.addedEdges to the final topology.
structure RegistryBoundaryDeltaAdmitted
(registry : ExecutorRegistry executor config contract authority)
(delta : PlannedRewriteDelta (StagedExecutorNode executor config authority)) :
Prop whereEvery genuinely added vertex is admitted by the registry.
newNodes :
∀ node,
node ∈ delta.newNodes →
nodeAdmittedBy registry nodeEvery genuinely added edge has registry-compatible endpoints.
addedEdges :
∀ source target,
(source, target) ∈ delta.addedEdges →
edgeAdmittedBy registry source targetA planned delta preserves the registry boundary when every genuinely added vertex and edge is explicitly admitted.
Existing vertices and edges reuse the source boundary witness. Vertices in delta.newNodes and
edges in delta.addedEdges are the only new obligations, with edge compatibility kept separate
from vertex admission.
theorem registryBoundary_preserved_of_addedNodes_addedEdges_admitted
(registry : ExecutorRegistry executor config contract authority)
{context : PlanningContext (StagedExecutorNode executor config authority)}
{delta : PlannedRewriteDelta (StagedExecutorNode executor config authority)}
(hDiff : TopologyDiffMatches context delta)
(hBoundary : registryBoundary registry context.topology)
(hNewNodes :
∀ node,
node ∈ delta.newNodes →
nodeAdmittedBy registry node)
(hAddedEdges :
∀ source target,
(source, target) ∈ delta.addedEdges →
edgeAdmittedBy registry source target) :
registryBoundary registry delta.topology := executor:Typeconfig:Typecontract:Typeauthority:Typeinst✝¹:DecidableEq contractinst✝:DecidableEq (StagedExecutorNode executor config authority)registry:ExecutorRegistry executor config contract authoritycontext:PlanningContext (StagedExecutorNode executor config authority)delta:PlannedRewriteDelta (StagedExecutorNode executor config authority)hDiff:TopologyDiffMatches context deltahBoundary:registryBoundary registry context.topologyhNewNodes:∀ node ∈ delta.newNodes, nodeAdmittedBy registry nodehAddedEdges:∀ (source target : StagedExecutorNode executor config authority),
(source, target) ∈ delta.addedEdges → edgeAdmittedBy registry source target⊢ registryBoundary registry delta.topology
executor:Typeconfig:Typecontract:Typeauthority:Typeinst✝¹:DecidableEq contractinst✝:DecidableEq (StagedExecutorNode executor config authority)registry:ExecutorRegistry executor config contract authoritycontext:PlanningContext (StagedExecutorNode executor config authority)delta:PlannedRewriteDelta (StagedExecutorNode executor config authority)hDiff:TopologyDiffMatches context deltahBoundary:registryBoundary registry context.topologyhNewNodes:∀ node ∈ delta.newNodes, nodeAdmittedBy registry nodehAddedEdges:∀ (source target : StagedExecutorNode executor config authority),
(source, target) ∈ delta.addedEdges → edgeAdmittedBy registry source target⊢ registryVerticesAdmitted registry delta.topologyexecutor:Typeconfig:Typecontract:Typeauthority:Typeinst✝¹:DecidableEq contractinst✝:DecidableEq (StagedExecutorNode executor config authority)registry:ExecutorRegistry executor config contract authoritycontext:PlanningContext (StagedExecutorNode executor config authority)delta:PlannedRewriteDelta (StagedExecutorNode executor config authority)hDiff:TopologyDiffMatches context deltahBoundary:registryBoundary registry context.topologyhNewNodes:∀ node ∈ delta.newNodes, nodeAdmittedBy registry nodehAddedEdges:∀ (source target : StagedExecutorNode executor config authority),
(source, target) ∈ delta.addedEdges → edgeAdmittedBy registry source target⊢ registryEdgesAdmitted registry delta.topology
executor:Typeconfig:Typecontract:Typeauthority:Typeinst✝¹:DecidableEq contractinst✝:DecidableEq (StagedExecutorNode executor config authority)registry:ExecutorRegistry executor config contract authoritycontext:PlanningContext (StagedExecutorNode executor config authority)delta:PlannedRewriteDelta (StagedExecutorNode executor config authority)hDiff:TopologyDiffMatches context deltahBoundary:registryBoundary registry context.topologyhNewNodes:∀ node ∈ delta.newNodes, nodeAdmittedBy registry nodehAddedEdges:∀ (source target : StagedExecutorNode executor config authority),
(source, target) ∈ delta.addedEdges → edgeAdmittedBy registry source target⊢ registryVerticesAdmitted registry delta.topology intro node executor:Typeconfig:Typecontract:Typeauthority:Typeinst✝¹:DecidableEq contractinst✝:DecidableEq (StagedExecutorNode executor config authority)registry:ExecutorRegistry executor config contract authoritycontext:PlanningContext (StagedExecutorNode executor config authority)delta:PlannedRewriteDelta (StagedExecutorNode executor config authority)hDiff:TopologyDiffMatches context deltahBoundary:registryBoundary registry context.topologyhNewNodes:∀ node ∈ delta.newNodes, nodeAdmittedBy registry nodehAddedEdges:∀ (source target : StagedExecutorNode executor config authority),
(source, target) ∈ delta.addedEdges → edgeAdmittedBy registry source targetnode:StagedExecutorNode executor config authorityhFinalNode:node ∈ (denote delta.topology).vertices⊢ nodeAdmittedBy registry node
executor:Typeconfig:Typecontract:Typeauthority:Typeinst✝¹:DecidableEq contractinst✝:DecidableEq (StagedExecutorNode executor config authority)registry:ExecutorRegistry executor config contract authoritycontext:PlanningContext (StagedExecutorNode executor config authority)delta:PlannedRewriteDelta (StagedExecutorNode executor config authority)hDiff:TopologyDiffMatches context deltahBoundary:registryBoundary registry context.topologyhNewNodes:∀ node ∈ delta.newNodes, nodeAdmittedBy registry nodehAddedEdges:∀ (source target : StagedExecutorNode executor config authority),
(source, target) ∈ delta.addedEdges → edgeAdmittedBy registry source targetnode:StagedExecutorNode executor config authorityhFinalNode:node ∈ (denote delta.topology).verticeshOldNode:node ∈ (denote context.topology).vertices⊢ nodeAdmittedBy registry nodeexecutor:Typeconfig:Typecontract:Typeauthority:Typeinst✝¹:DecidableEq contractinst✝:DecidableEq (StagedExecutorNode executor config authority)registry:ExecutorRegistry executor config contract authoritycontext:PlanningContext (StagedExecutorNode executor config authority)delta:PlannedRewriteDelta (StagedExecutorNode executor config authority)hDiff:TopologyDiffMatches context deltahBoundary:registryBoundary registry context.topologyhNewNodes:∀ node ∈ delta.newNodes, nodeAdmittedBy registry nodehAddedEdges:∀ (source target : StagedExecutorNode executor config authority),
(source, target) ∈ delta.addedEdges → edgeAdmittedBy registry source targetnode:StagedExecutorNode executor config authorityhFinalNode:node ∈ (denote delta.topology).verticeshOldNode:node ∉ (denote context.topology).vertices⊢ nodeAdmittedBy registry node
executor:Typeconfig:Typecontract:Typeauthority:Typeinst✝¹:DecidableEq contractinst✝:DecidableEq (StagedExecutorNode executor config authority)registry:ExecutorRegistry executor config contract authoritycontext:PlanningContext (StagedExecutorNode executor config authority)delta:PlannedRewriteDelta (StagedExecutorNode executor config authority)hDiff:TopologyDiffMatches context deltahBoundary:registryBoundary registry context.topologyhNewNodes:∀ node ∈ delta.newNodes, nodeAdmittedBy registry nodehAddedEdges:∀ (source target : StagedExecutorNode executor config authority),
(source, target) ∈ delta.addedEdges → edgeAdmittedBy registry source targetnode:StagedExecutorNode executor config authorityhFinalNode:node ∈ (denote delta.topology).verticeshOldNode:node ∈ (denote context.topology).vertices⊢ nodeAdmittedBy registry node All goals completed! 🐙
executor:Typeconfig:Typecontract:Typeauthority:Typeinst✝¹:DecidableEq contractinst✝:DecidableEq (StagedExecutorNode executor config authority)registry:ExecutorRegistry executor config contract authoritycontext:PlanningContext (StagedExecutorNode executor config authority)delta:PlannedRewriteDelta (StagedExecutorNode executor config authority)hDiff:TopologyDiffMatches context deltahBoundary:registryBoundary registry context.topologyhNewNodes:∀ node ∈ delta.newNodes, nodeAdmittedBy registry nodehAddedEdges:∀ (source target : StagedExecutorNode executor config authority),
(source, target) ∈ delta.addedEdges → edgeAdmittedBy registry source targetnode:StagedExecutorNode executor config authorityhFinalNode:node ∈ (denote delta.topology).verticeshOldNode:node ∉ (denote context.topology).vertices⊢ nodeAdmittedBy registry node have hAddedNode : node ∈ delta.newNodes := executor:Typeconfig:Typecontract:Typeauthority:Typeinst✝¹:DecidableEq contractinst✝:DecidableEq (StagedExecutorNode executor config authority)registry:ExecutorRegistry executor config contract authoritycontext:PlanningContext (StagedExecutorNode executor config authority)delta:PlannedRewriteDelta (StagedExecutorNode executor config authority)hDiff:TopologyDiffMatches context deltahBoundary:registryBoundary registry context.topologyhNewNodes:∀ node ∈ delta.newNodes, nodeAdmittedBy registry nodehAddedEdges:∀ (source target : StagedExecutorNode executor config authority),
(source, target) ∈ delta.addedEdges → edgeAdmittedBy registry source target⊢ registryBoundary registry delta.topology
executor:Typeconfig:Typecontract:Typeauthority:Typeinst✝¹:DecidableEq contractinst✝:DecidableEq (StagedExecutorNode executor config authority)registry:ExecutorRegistry executor config contract authoritycontext:PlanningContext (StagedExecutorNode executor config authority)delta:PlannedRewriteDelta (StagedExecutorNode executor config authority)hDiff:TopologyDiffMatches context deltahBoundary:registryBoundary registry context.topologyhNewNodes:∀ node ∈ delta.newNodes, nodeAdmittedBy registry nodehAddedEdges:∀ (source target : StagedExecutorNode executor config authority),
(source, target) ∈ delta.addedEdges → edgeAdmittedBy registry source targetnode:StagedExecutorNode executor config authorityhFinalNode:node ∈ (denote delta.topology).verticeshOldNode:node ∉ (denote context.topology).vertices⊢ node ∈ relationAddedNodes (denote context.topology) (denote delta.topology)
executor:Typeconfig:Typecontract:Typeauthority:Typeinst✝¹:DecidableEq contractinst✝:DecidableEq (StagedExecutorNode executor config authority)registry:ExecutorRegistry executor config contract authoritycontext:PlanningContext (StagedExecutorNode executor config authority)delta:PlannedRewriteDelta (StagedExecutorNode executor config authority)hDiff:TopologyDiffMatches context deltahBoundary:registryBoundary registry context.topologyhNewNodes:∀ node ∈ delta.newNodes, nodeAdmittedBy registry nodehAddedEdges:∀ (source target : StagedExecutorNode executor config authority),
(source, target) ∈ delta.addedEdges → edgeAdmittedBy registry source targetnode:StagedExecutorNode executor config authorityhFinalNode:node ∈ (denote delta.topology).verticeshOldNode:node ∉ (denote context.topology).vertices⊢ node ∈ (denote delta.topology).vertices ∧ node ∉ (denote context.topology).vertices
All goals completed! 🐙
All goals completed! 🐙
executor:Typeconfig:Typecontract:Typeauthority:Typeinst✝¹:DecidableEq contractinst✝:DecidableEq (StagedExecutorNode executor config authority)registry:ExecutorRegistry executor config contract authoritycontext:PlanningContext (StagedExecutorNode executor config authority)delta:PlannedRewriteDelta (StagedExecutorNode executor config authority)hDiff:TopologyDiffMatches context deltahBoundary:registryBoundary registry context.topologyhNewNodes:∀ node ∈ delta.newNodes, nodeAdmittedBy registry nodehAddedEdges:∀ (source target : StagedExecutorNode executor config authority),
(source, target) ∈ delta.addedEdges → edgeAdmittedBy registry source target⊢ registryEdgesAdmitted registry delta.topology intro source executor:Typeconfig:Typecontract:Typeauthority:Typeinst✝¹:DecidableEq contractinst✝:DecidableEq (StagedExecutorNode executor config authority)registry:ExecutorRegistry executor config contract authoritycontext:PlanningContext (StagedExecutorNode executor config authority)delta:PlannedRewriteDelta (StagedExecutorNode executor config authority)hDiff:TopologyDiffMatches context deltahBoundary:registryBoundary registry context.topologyhNewNodes:∀ node ∈ delta.newNodes, nodeAdmittedBy registry nodehAddedEdges:∀ (source target : StagedExecutorNode executor config authority),
(source, target) ∈ delta.addedEdges → edgeAdmittedBy registry source targetsource:StagedExecutorNode executor config authoritytarget:StagedExecutorNode executor config authority⊢ (source, target) ∈ (denote delta.topology).edges → edgeAdmittedBy registry source target executor:Typeconfig:Typecontract:Typeauthority:Typeinst✝¹:DecidableEq contractinst✝:DecidableEq (StagedExecutorNode executor config authority)registry:ExecutorRegistry executor config contract authoritycontext:PlanningContext (StagedExecutorNode executor config authority)delta:PlannedRewriteDelta (StagedExecutorNode executor config authority)hDiff:TopologyDiffMatches context deltahBoundary:registryBoundary registry context.topologyhNewNodes:∀ node ∈ delta.newNodes, nodeAdmittedBy registry nodehAddedEdges:∀ (source target : StagedExecutorNode executor config authority),
(source, target) ∈ delta.addedEdges → edgeAdmittedBy registry source targetsource:StagedExecutorNode executor config authoritytarget:StagedExecutorNode executor config authorityhFinalEdge:(source, target) ∈ (denote delta.topology).edges⊢ edgeAdmittedBy registry source target
executor:Typeconfig:Typecontract:Typeauthority:Typeinst✝¹:DecidableEq contractinst✝:DecidableEq (StagedExecutorNode executor config authority)registry:ExecutorRegistry executor config contract authoritycontext:PlanningContext (StagedExecutorNode executor config authority)delta:PlannedRewriteDelta (StagedExecutorNode executor config authority)hDiff:TopologyDiffMatches context deltahBoundary:registryBoundary registry context.topologyhNewNodes:∀ node ∈ delta.newNodes, nodeAdmittedBy registry nodehAddedEdges:∀ (source target : StagedExecutorNode executor config authority),
(source, target) ∈ delta.addedEdges → edgeAdmittedBy registry source targetsource:StagedExecutorNode executor config authoritytarget:StagedExecutorNode executor config authorityhFinalEdge:(source, target) ∈ (denote delta.topology).edgeshOldEdge:(source, target) ∈ (denote context.topology).edges⊢ edgeAdmittedBy registry source targetexecutor:Typeconfig:Typecontract:Typeauthority:Typeinst✝¹:DecidableEq contractinst✝:DecidableEq (StagedExecutorNode executor config authority)registry:ExecutorRegistry executor config contract authoritycontext:PlanningContext (StagedExecutorNode executor config authority)delta:PlannedRewriteDelta (StagedExecutorNode executor config authority)hDiff:TopologyDiffMatches context deltahBoundary:registryBoundary registry context.topologyhNewNodes:∀ node ∈ delta.newNodes, nodeAdmittedBy registry nodehAddedEdges:∀ (source target : StagedExecutorNode executor config authority),
(source, target) ∈ delta.addedEdges → edgeAdmittedBy registry source targetsource:StagedExecutorNode executor config authoritytarget:StagedExecutorNode executor config authorityhFinalEdge:(source, target) ∈ (denote delta.topology).edgeshOldEdge:(source, target) ∉ (denote context.topology).edges⊢ edgeAdmittedBy registry source target
executor:Typeconfig:Typecontract:Typeauthority:Typeinst✝¹:DecidableEq contractinst✝:DecidableEq (StagedExecutorNode executor config authority)registry:ExecutorRegistry executor config contract authoritycontext:PlanningContext (StagedExecutorNode executor config authority)delta:PlannedRewriteDelta (StagedExecutorNode executor config authority)hDiff:TopologyDiffMatches context deltahBoundary:registryBoundary registry context.topologyhNewNodes:∀ node ∈ delta.newNodes, nodeAdmittedBy registry nodehAddedEdges:∀ (source target : StagedExecutorNode executor config authority),
(source, target) ∈ delta.addedEdges → edgeAdmittedBy registry source targetsource:StagedExecutorNode executor config authoritytarget:StagedExecutorNode executor config authorityhFinalEdge:(source, target) ∈ (denote delta.topology).edgeshOldEdge:(source, target) ∈ (denote context.topology).edges⊢ edgeAdmittedBy registry source target All goals completed! 🐙
executor:Typeconfig:Typecontract:Typeauthority:Typeinst✝¹:DecidableEq contractinst✝:DecidableEq (StagedExecutorNode executor config authority)registry:ExecutorRegistry executor config contract authoritycontext:PlanningContext (StagedExecutorNode executor config authority)delta:PlannedRewriteDelta (StagedExecutorNode executor config authority)hDiff:TopologyDiffMatches context deltahBoundary:registryBoundary registry context.topologyhNewNodes:∀ node ∈ delta.newNodes, nodeAdmittedBy registry nodehAddedEdges:∀ (source target : StagedExecutorNode executor config authority),
(source, target) ∈ delta.addedEdges → edgeAdmittedBy registry source targetsource:StagedExecutorNode executor config authoritytarget:StagedExecutorNode executor config authorityhFinalEdge:(source, target) ∈ (denote delta.topology).edgeshOldEdge:(source, target) ∉ (denote context.topology).edges⊢ edgeAdmittedBy registry source target have hAddedEdge : (source, target) ∈ delta.addedEdges := executor:Typeconfig:Typecontract:Typeauthority:Typeinst✝¹:DecidableEq contractinst✝:DecidableEq (StagedExecutorNode executor config authority)registry:ExecutorRegistry executor config contract authoritycontext:PlanningContext (StagedExecutorNode executor config authority)delta:PlannedRewriteDelta (StagedExecutorNode executor config authority)hDiff:TopologyDiffMatches context deltahBoundary:registryBoundary registry context.topologyhNewNodes:∀ node ∈ delta.newNodes, nodeAdmittedBy registry nodehAddedEdges:∀ (source target : StagedExecutorNode executor config authority),
(source, target) ∈ delta.addedEdges → edgeAdmittedBy registry source target⊢ registryBoundary registry delta.topology
executor:Typeconfig:Typecontract:Typeauthority:Typeinst✝¹:DecidableEq contractinst✝:DecidableEq (StagedExecutorNode executor config authority)registry:ExecutorRegistry executor config contract authoritycontext:PlanningContext (StagedExecutorNode executor config authority)delta:PlannedRewriteDelta (StagedExecutorNode executor config authority)hDiff:TopologyDiffMatches context deltahBoundary:registryBoundary registry context.topologyhNewNodes:∀ node ∈ delta.newNodes, nodeAdmittedBy registry nodehAddedEdges:∀ (source target : StagedExecutorNode executor config authority),
(source, target) ∈ delta.addedEdges → edgeAdmittedBy registry source targetsource:StagedExecutorNode executor config authoritytarget:StagedExecutorNode executor config authorityhFinalEdge:(source, target) ∈ (denote delta.topology).edgeshOldEdge:(source, target) ∉ (denote context.topology).edges⊢ (source, target) ∈ relationAddedEdges (denote context.topology) (denote delta.topology)
executor:Typeconfig:Typecontract:Typeauthority:Typeinst✝¹:DecidableEq contractinst✝:DecidableEq (StagedExecutorNode executor config authority)registry:ExecutorRegistry executor config contract authoritycontext:PlanningContext (StagedExecutorNode executor config authority)delta:PlannedRewriteDelta (StagedExecutorNode executor config authority)hDiff:TopologyDiffMatches context deltahBoundary:registryBoundary registry context.topologyhNewNodes:∀ node ∈ delta.newNodes, nodeAdmittedBy registry nodehAddedEdges:∀ (source target : StagedExecutorNode executor config authority),
(source, target) ∈ delta.addedEdges → edgeAdmittedBy registry source targetsource:StagedExecutorNode executor config authoritytarget:StagedExecutorNode executor config authorityhFinalEdge:(source, target) ∈ (denote delta.topology).edgeshOldEdge:(source, target) ∉ (denote context.topology).edges⊢ (source, target) ∈ (denote delta.topology).edges ∧ (source, target) ∉ (denote context.topology).edges
All goals completed! 🐙
All goals completed! 🐙A planned delta preserves the registry boundary from its bundled delta-admission evidence.
theorem registryBoundary_preserved_of_delta_admitted
(registry : ExecutorRegistry executor config contract authority)
{context : PlanningContext (StagedExecutorNode executor config authority)}
{delta : PlannedRewriteDelta (StagedExecutorNode executor config authority)}
(hDiff : TopologyDiffMatches context delta)
(hBoundary : registryBoundary registry context.topology)
(hDelta : RegistryBoundaryDeltaAdmitted registry delta) :
registryBoundary registry delta.topology :=
registryBoundary_preserved_of_addedNodes_addedEdges_admitted
registry
hDiff
hBoundary
hDelta.newNodes
hDelta.addedEdgesend RegistryBoundaryPreservationBudget Admission
section BudgetAdmissionvariable {node : Type}
AdmittedRewriteDelta budget delta remaining mirrors admitRewriteDelta.
structure AdmittedRewriteDelta
(budget : RewriteBudget)
(delta : PlannedRewriteDelta node)
(remaining : RewriteBudget) :
Prop whereThe planned cost fits every remaining budget dimension.
fits : delta.cost.fitsIn budgetThe runtime returns the pointwise-decremented remaining budget.
remaining_eq : remaining = budget.consume delta.costBudget admission never replenishes any structural budget dimension.
theorem admittedRewriteDelta_remaining_le_initial
{budget remaining : RewriteBudget}
{delta : PlannedRewriteDelta node}
(hAdmitted : AdmittedRewriteDelta budget delta remaining) :
remaining.le budget := node:Typebudget:RewriteBudgetremaining:RewriteBudgetdelta:PlannedRewriteDelta nodehAdmitted:AdmittedRewriteDelta budget delta remaining⊢ remaining.le budget
node:Typebudget:RewriteBudgetremaining:RewriteBudgetdelta:PlannedRewriteDelta nodehAdmitted:AdmittedRewriteDelta budget delta remaining⊢ (budget.consume delta.cost).le budget
All goals completed! 🐙Budget admission exposes the rewrite-operation bound needed by chain termination.
theorem admittedRewriteDelta_rewriteOps_bound
{budget remaining : RewriteBudget}
{delta : PlannedRewriteDelta node}
(hAdmitted : AdmittedRewriteDelta budget delta remaining) :
delta.cost.rewriteOps ≤ budget.rewriteOps :=
hAdmitted.fits.2.2.2.2end BudgetAdmissionBridge To Proof-Carrying Rewrites
section Bridgevariable {node : Type}variable [DecidableEq node]variable {contractOk : Graph node → Prop}
PlannedRewriteSafety supplies the non-structural certificate for a planned delta.
structure PlannedRewriteSafety
(source : Graph node)
(delta : PlannedRewriteDelta node)
(contractOk : Graph node → Prop) :
Prop where
The final topology is acyclic. Usually projected from PlanGraphRewriteChecks.
finalAcyclic : Acyclic delta.topologyCaller-specific contract validity is preserved by this planned rewrite.
preservesContracts :
∀ g, denote g = denote source → contractOk g → contractOk delta.topologyThe planned delta consumes at least one rewrite operation.
rewriteOpsPositive : 0 < delta.cost.rewriteOpsPlanning checks provide the acyclicity and operation-budget parts of rewrite safety.
theorem plannedRewriteSafety_of_checks
{context : PlanningContext node}
{rewrite : GraphRewrite node}
{delta : PlannedRewriteDelta node}
(hChecks : PlanGraphRewriteChecks context rewrite delta)
(hContracts :
∀ g, denote g = denote context.topology → contractOk g → contractOk delta.topology) :
PlannedRewriteSafety context.topology delta contractOk := node:Typeinst✝:DecidableEq nodecontractOk:Graph node → Propcontext:PlanningContext noderewrite:GraphRewrite nodedelta:PlannedRewriteDelta nodehChecks:PlanGraphRewriteChecks context rewrite deltahContracts:∀ (g : Graph node), denote g = denote context.topology → contractOk g → contractOk delta.topology⊢ PlannedRewriteSafety context.topology delta contractOk
node:Typeinst✝:DecidableEq nodecontractOk:Graph node → Propcontext:PlanningContext noderewrite:GraphRewrite nodedelta:PlannedRewriteDelta nodehChecks:PlanGraphRewriteChecks context rewrite deltahContracts:∀ (g : Graph node), denote g = denote context.topology → contractOk g → contractOk delta.topology⊢ 0 < delta.cost.rewriteOps
node:Typeinst✝:DecidableEq nodecontractOk:Graph node → Propcontext:PlanningContext noderewrite:GraphRewrite nodedelta:PlannedRewriteDelta nodehChecks:PlanGraphRewriteChecks context rewrite deltahContracts:∀ (g : Graph node), denote g = denote context.topology → contractOk g → contractOk delta.topology⊢ 0 < 1
All goals completed! 🐙namespace PlannedRewriteDelta
toRewrite source delta safety turns an accepted plan into a proof-carrying rewrite.
def toRewrite
(source : Graph node)
(delta : PlannedRewriteDelta node)
(hSafety : PlannedRewriteSafety source delta contractOk) :
Rewrite node contractOk :=
{ apply := fun g =>
if denote g = denote source then
some delta.topology
else
none
cost := delta.cost
rewriteOps_positive := hSafety.rewriteOpsPositive
preserves_acyclic := node:Typeinst✝:DecidableEq nodecontractOk:Graph node → Propsource:Graph nodedelta:PlannedRewriteDelta nodehSafety:PlannedRewriteSafety source delta contractOk⊢ ∀ {g g' : Graph node},
(if denote g = denote source then some delta.topology else none) = some g' → Acyclic g → Acyclic g'
intro g node:Typeinst✝:DecidableEq nodecontractOk:Graph node → Propsource:Graph nodedelta:PlannedRewriteDelta nodehSafety:PlannedRewriteSafety source delta contractOkg:Graph nodeg':Graph node⊢ (if denote g = denote source then some delta.topology else none) = some g' → Acyclic g → Acyclic g' node:Typeinst✝:DecidableEq nodecontractOk:Graph node → Propsource:Graph nodedelta:PlannedRewriteDelta nodehSafety:PlannedRewriteSafety source delta contractOkg:Graph nodeg':Graph nodehApply:(if denote g = denote source then some delta.topology else none) = some g'⊢ Acyclic g → Acyclic g' node:Typeinst✝:DecidableEq nodecontractOk:Graph node → Propsource:Graph nodedelta:PlannedRewriteDelta nodehSafety:PlannedRewriteSafety source delta contractOkg:Graph nodeg':Graph nodehApply:(if denote g = denote source then some delta.topology else none) = some g'_hAcyclic:Acyclic g⊢ Acyclic g'
node:Typeinst✝:DecidableEq nodecontractOk:Graph node → Propsource:Graph nodedelta:PlannedRewriteDelta nodehSafety:PlannedRewriteSafety source delta contractOkg:Graph nodeg':Graph nodehApply:(if denote g = denote source then some delta.topology else none) = some g'_hAcyclic:Acyclic ghSource:denote g = denote source⊢ Acyclic g'node:Typeinst✝:DecidableEq nodecontractOk:Graph node → Propsource:Graph nodedelta:PlannedRewriteDelta nodehSafety:PlannedRewriteSafety source delta contractOkg:Graph nodeg':Graph nodehApply:(if denote g = denote source then some delta.topology else none) = some g'_hAcyclic:Acyclic ghSource:¬denote g = denote source⊢ Acyclic g'
node:Typeinst✝:DecidableEq nodecontractOk:Graph node → Propsource:Graph nodedelta:PlannedRewriteDelta nodehSafety:PlannedRewriteSafety source delta contractOkg:Graph nodeg':Graph nodehApply:(if denote g = denote source then some delta.topology else none) = some g'_hAcyclic:Acyclic ghSource:denote g = denote source⊢ Acyclic g' node:Typeinst✝:DecidableEq nodecontractOk:Graph node → Propsource:Graph nodedelta:PlannedRewriteDelta nodehSafety:PlannedRewriteSafety source delta contractOkg:Graph nodeg':Graph node_hAcyclic:Acyclic ghSource:denote g = denote sourcehApply:delta.topology = g'⊢ Acyclic g'
node:Typeinst✝:DecidableEq nodecontractOk:Graph node → Propsource:Graph nodedelta:PlannedRewriteDelta nodehSafety:PlannedRewriteSafety source delta contractOkg:Graph node_hAcyclic:Acyclic ghSource:denote g = denote source⊢ Acyclic delta.topology
All goals completed! 🐙
node:Typeinst✝:DecidableEq nodecontractOk:Graph node → Propsource:Graph nodedelta:PlannedRewriteDelta nodehSafety:PlannedRewriteSafety source delta contractOkg:Graph nodeg':Graph nodehApply:(if denote g = denote source then some delta.topology else none) = some g'_hAcyclic:Acyclic ghSource:¬denote g = denote source⊢ Acyclic g' All goals completed! 🐙
preserves_contracts := node:Typeinst✝:DecidableEq nodecontractOk:Graph node → Propsource:Graph nodedelta:PlannedRewriteDelta nodehSafety:PlannedRewriteSafety source delta contractOk⊢ ∀ {g g' : Graph node},
(if denote g = denote source then some delta.topology else none) = some g' → contractOk g → contractOk g'
intro g node:Typeinst✝:DecidableEq nodecontractOk:Graph node → Propsource:Graph nodedelta:PlannedRewriteDelta nodehSafety:PlannedRewriteSafety source delta contractOkg:Graph nodeg':Graph node⊢ (if denote g = denote source then some delta.topology else none) = some g' → contractOk g → contractOk g' node:Typeinst✝:DecidableEq nodecontractOk:Graph node → Propsource:Graph nodedelta:PlannedRewriteDelta nodehSafety:PlannedRewriteSafety source delta contractOkg:Graph nodeg':Graph nodehApply:(if denote g = denote source then some delta.topology else none) = some g'⊢ contractOk g → contractOk g' node:Typeinst✝:DecidableEq nodecontractOk:Graph node → Propsource:Graph nodedelta:PlannedRewriteDelta nodehSafety:PlannedRewriteSafety source delta contractOkg:Graph nodeg':Graph nodehApply:(if denote g = denote source then some delta.topology else none) = some g'hContracts:contractOk g⊢ contractOk g'
node:Typeinst✝:DecidableEq nodecontractOk:Graph node → Propsource:Graph nodedelta:PlannedRewriteDelta nodehSafety:PlannedRewriteSafety source delta contractOkg:Graph nodeg':Graph nodehApply:(if denote g = denote source then some delta.topology else none) = some g'hContracts:contractOk ghSource:denote g = denote source⊢ contractOk g'node:Typeinst✝:DecidableEq nodecontractOk:Graph node → Propsource:Graph nodedelta:PlannedRewriteDelta nodehSafety:PlannedRewriteSafety source delta contractOkg:Graph nodeg':Graph nodehApply:(if denote g = denote source then some delta.topology else none) = some g'hContracts:contractOk ghSource:¬denote g = denote source⊢ contractOk g'
node:Typeinst✝:DecidableEq nodecontractOk:Graph node → Propsource:Graph nodedelta:PlannedRewriteDelta nodehSafety:PlannedRewriteSafety source delta contractOkg:Graph nodeg':Graph nodehApply:(if denote g = denote source then some delta.topology else none) = some g'hContracts:contractOk ghSource:denote g = denote source⊢ contractOk g' node:Typeinst✝:DecidableEq nodecontractOk:Graph node → Propsource:Graph nodedelta:PlannedRewriteDelta nodehSafety:PlannedRewriteSafety source delta contractOkg:Graph nodeg':Graph nodehContracts:contractOk ghSource:denote g = denote sourcehApply:delta.topology = g'⊢ contractOk g'
node:Typeinst✝:DecidableEq nodecontractOk:Graph node → Propsource:Graph nodedelta:PlannedRewriteDelta nodehSafety:PlannedRewriteSafety source delta contractOkg:Graph nodehContracts:contractOk ghSource:denote g = denote source⊢ contractOk delta.topology
All goals completed! 🐙
node:Typeinst✝:DecidableEq nodecontractOk:Graph node → Propsource:Graph nodedelta:PlannedRewriteDelta nodehSafety:PlannedRewriteSafety source delta contractOkg:Graph nodeg':Graph nodehApply:(if denote g = denote source then some delta.topology else none) = some g'hContracts:contractOk ghSource:¬denote g = denote source⊢ contractOk g' All goals completed! 🐙 }end PlannedRewriteDeltaThe planned rewrite applies to the source topology it was planned against.
theorem plannedRewrite_applicable
{source : Graph node}
{delta : PlannedRewriteDelta node}
{hSafety : PlannedRewriteSafety source delta contractOk} :
applicable (delta.toRewrite source hSafety) source := node:Typeinst✝:DecidableEq nodecontractOk:Graph node → Propsource:Graph nodedelta:PlannedRewriteDelta nodehSafety:PlannedRewriteSafety source delta contractOk⊢ applicable (PlannedRewriteDelta.toRewrite source delta hSafety) source
exact ⟨delta.topology, node:Typeinst✝:DecidableEq nodecontractOk:Graph node → Propsource:Graph nodedelta:PlannedRewriteDelta nodehSafety:PlannedRewriteSafety source delta contractOk⊢ (PlannedRewriteDelta.toRewrite source delta hSafety).apply source = some delta.topology All goals completed! 🐙⟩
Admitted planned deltas instantiate the abstract admissible rewrite predicate.
theorem admittedPlannedRewrite_admissible
{source : Graph node}
{budget remaining : RewriteBudget}
{delta : PlannedRewriteDelta node}
{hSafety : PlannedRewriteSafety source delta contractOk}
(hAdmitted : AdmittedRewriteDelta budget delta remaining) :
admissible (delta.toRewrite source hSafety) source budget :=
⟨hAdmitted.fits, plannedRewrite_applicable⟩Runtime planning checks plus budget admission give an abstract admissible rewrite.
theorem planGraphRewriteChecks_admissible
{context : PlanningContext node}
{rewrite : GraphRewrite node}
{budget remaining : RewriteBudget}
{delta : PlannedRewriteDelta node}
(hChecks : PlanGraphRewriteChecks context rewrite delta)
(hAdmitted : AdmittedRewriteDelta budget delta remaining)
(hContracts :
∀ g, denote g = denote context.topology → contractOk g → contractOk delta.topology) :
admissible
(delta.toRewrite context.topology (plannedRewriteSafety_of_checks hChecks hContracts))
context.topology
budget :=
admittedPlannedRewrite_admissible hAdmittedRuntime planning checks expose the final DAG certificate used by rewrite safety.
theorem planGraphRewriteChecks_final_acyclic
{context : PlanningContext node}
{rewrite : GraphRewrite node}
{delta : PlannedRewriteDelta node}
(hChecks : PlanGraphRewriteChecks context rewrite delta) :
Acyclic delta.topology :=
hChecks.finalAcyclicRuntime planning checks expose the final topology construction equation.
theorem planGraphRewriteChecks_topology_matches
{context : PlanningContext node}
{rewrite : GraphRewrite node}
{delta : PlannedRewriteDelta node}
(hChecks : PlanGraphRewriteChecks context rewrite delta) :
denote delta.topology = plannedFinalRelation context.topology rewrite :=
hChecks.topologyMatchesRuntime planning checks expose the relation-diff equations for delta sets.
theorem planGraphRewriteChecks_topologyDiffMatches
{context : PlanningContext node}
{rewrite : GraphRewrite node}
{delta : PlannedRewriteDelta node}
(hChecks : PlanGraphRewriteChecks context rewrite delta) :
TopologyDiffMatches context delta :=
hChecks.topologyDiffMatchesRuntime planning checks expose the structural cost equations.
theorem planGraphRewriteChecks_costMatches
{context : PlanningContext node}
{rewrite : GraphRewrite node}
{delta : PlannedRewriteDelta node}
(hChecks : PlanGraphRewriteChecks context rewrite delta) :
PlannedRewriteCostMatches rewrite delta :=
hChecks.costMatchesRuntime planning checks expose anchor-disposition agreement.
theorem planGraphRewriteChecks_anchorDispositionMatches
{context : PlanningContext node}
{rewrite : GraphRewrite node}
{delta : PlannedRewriteDelta node}
(hChecks : PlanGraphRewriteChecks context rewrite delta) :
AnchorDispositionMatches rewrite delta :=
hChecks.anchorDispositionMatchesRuntime planning checks expose the exact definition-domain update equation.
theorem planGraphRewriteChecks_definitionUpdateMatches
{context : PlanningContext node}
{rewrite : GraphRewrite node}
{delta : PlannedRewriteDelta node}
(hChecks : PlanGraphRewriteChecks context rewrite delta) :
DefinitionUpdateMatches context rewrite delta :=
hChecks.definitionUpdateMatchesRuntime planning checks expose final definitions as the planned update formula.
theorem planGraphRewriteChecks_definitions_eq
{context : PlanningContext node}
{rewrite : GraphRewrite node}
{delta : PlannedRewriteDelta node}
(hChecks : PlanGraphRewriteChecks context rewrite delta) :
delta.definitions = plannedFinalDefinitions context rewrite :=
hChecks.definitionUpdateMatches.definitions_eqend Bridgeend Cortex.Wire