Appendix B: Master List of Definitions & Theorems - Chapter 2
This appendix serves as a centralized, rigorous catalog of the foundational mathematical postulates, definitions, axioms, lemmas, and theorems introduced in Chapter 2 of the Quantum Braid Dynamics (QBD) monograph.
2.1.1 Definition: Axiom 1 Directed Causal Link
It is herein established that the fundamental unit of relation within the Causal Graph Substrate §1.4.1 shall be the Directed Causal Link, denoted as the ordered pair , acting upon the set of Abstract Events . The validity of the edge set is strictly conditioned upon the absolute satisfaction of the following two invariant properties for all elements within the domain:
- Strict Irreflexivity: The relation shall not, under any circumstance, connect a vertex to itself. For every vertex contained within the set , the edge is categorically excluded from the set . This prohibition enforces the requirement that no event may serve as its own causal antecedent.
- Strict Asymmetry: The relation shall not permit immediate reciprocity. For every distinct pair of vertices and contained within , the existence of the direct edge within necessitates the absolute absence of the inverse edge from . This prohibition enforces the local directionality of causal influence.
The existence of an edge constitutes the physical encoding of the proposition that event acts as the necessary causal antecedent of event within the local reference frame.
Lean 4 (QBD.Ch02.Defs):
/-- §2.1.1 Axiom 1. Each active edge has distinct endpoints and excludes its reverse. -/
def DirectedCausalLink {V : Type u} (E : V → V → Prop) : Prop :=
∀ u v, E u v → u ≠ v ∧ ¬ E v u
In Plain English:
A directed causal link represents the primitive cause-and-effect relation, acting as a one-way temporal ratchet that drives cosmic updates.
2.2.1 Theorem: Insufficiency of Antisymmetry
Let the condition of Antisymmetry be defined conventionally by the proposition . This condition is formally insufficient to satisfy the requirements of the Directed Causal Link §2.1.1, as it is satisfied vacuously by the reflexive relation whereas the Causal Primitive mandates Strict Irreflexivity. Consequently, a causal structure governed solely by Antisymmetry physically permits Directed Cycles of length , which are prohibited otherwise.
In Plain English:
Section 2.2.1 formalizes the properties of the QBD theorem regarding insufficiency of antisymmetry.
2.2.2 Lemma: Pathology of Self-Loops
Let a self-loop incident to a vertex be denoted by , which constitutes a directed cycle of length representing a Cycle §1.2.6. Consequently, this configuration is excluded under Directed Acyclic Graph (DAG) §1.2.1.
In Plain English:
Section 2.2.2 formalizes the properties of the QBD lemma regarding pathology of self-loops.
2.2.2.1 Proof: Pathology of Self-Loops
I. Cycle Witness
Suppose . A directed cycle of positive length has successive edges for and closure (Cycle §1.2.6). Set
II. Evaluation of Every Condition
The index set for the edge condition has exactly one element:
At that index,
The endpoint condition is also satisfied:
There is one traversed edge, so the length is one. If distinctness of the nonterminal cycle vertices is required, the list has one element and the condition is vacuous.
III. Exclusion from the DAG Class
A graph in the directed acyclic class has no directed cycle of any positive length (Directed Acyclic Graph (DAG) §1.2.1). If were in that class, its acyclicity condition applied to the witness would give
contradicting the initial membership. Thus
Q.E.D.
In Plain English:
Section 2.2.2.1 formalizes the properties of the QBD proof regarding pathology of self-loops.
2.2.2.2 Type-Theoretic Validation via Lean 4 Core
Type-theoretic certification of the self-loop exclusion and asymmetry equivalence established in Pathology of Self-Loops §2.2.2 proceeds via the following verification strategy:
- Model: Directed binary relations on an arbitrary vertex type, one-edge closed walks, directed acyclic graphs, and strict asymmetry predicates represent local causal links and self-loops.
- Certified Claims: The module certifies that a self-loop forms a directed one-cycle, that every directed acyclic graph excludes self-loops, that strict asymmetry implies irreflexivity, and that strict asymmetry is logically equivalent to combined irreflexivity and antisymmetry in Pathology of Self-Loops §2.2.2.1.
- Scope Boundary: The certificate operates on abstract directed relations without dynamical update probabilities. Physical interpretations of causal inertia remain outside this relational logic check.
import QBD.Ch02.Defs
namespace QBD.Ch02
universe u
-- Define a Causal Relation as a binary predicate mapping pairs to a Proposition
def CausalRelation (V : Type) := V → V → Prop
-- Define standard mathematical Antisymmetry
def IsAntisymmetric (V : Type) (R : CausalRelation V) : Prop :=
∀ u v : V, R u v → R v u → u = v
-- Define Strict Irreflexivity
def IsIrreflexive (V : Type) (R : CausalRelation V) : Prop :=
∀ v : V, ¬ R v v
-- Define Strict Asymmetry
def IsAsymmetric (V : Type) (R : CausalRelation V) : Prop :=
∀ u v : V, R u v → ¬ R v u
/--
THEOREM 2: Asymmetry Implies Irreflexivity
Proves the internal cohesion of Axiom 1: if a relation is asymmetric,
it is topologically impossible for an event to act as its own antecedent.
-/
theorem asymmetry_implies_irreflexivity (R : CausalRelation V) (h_asym : IsAsymmetric V R) :
IsIrreflexive V R := by
intro v h_loop
-- Asymmetry on the same node (v, v) yields a direct contradiction
exact h_asym v v h_loop h_loop
/--
THEOREM 3: Relational Completeness of the Primitive
Formally seals the logic of Chapter 2 by proving that Asymmetry is the exact
algebraic conjunction of Irreflexivity and Antisymmetry.
-/
theorem asymmetry_equiv_irreflexive_and_antisymmetric (R : CausalRelation V) :
IsAsymmetric V R ↔ (IsIrreflexive V R ∧ IsAntisymmetric V R) := by
constructor
· intro h_asym
constructor
· -- Forward Direction: Asymmetry implies Irreflexivity
intro v h_loop
exact h_asym v v h_loop h_loop
· -- Forward Direction: Asymmetry implies Antisymmetry vacuously via contradiction
intro u v h_fwd h_rev
have h_contra : False := h_asym u v h_fwd h_rev
exact False.elim h_contra
· intro h_conj
intro u v h_fwd h_rev
-- Reverse Direction: Unpack the conjunction
have h_irref := h_conj.left
have h_anti := h_conj.right
-- Antisymmetry forces the endpoints to be identical
have h_eq : u = v := h_anti u v h_fwd h_rev
rw [h_eq] at h_fwd
-- Irreflexivity annihilates the resulting self-loop
exact h_irref v h_fwd
/-- A self-edge is a simple closed walk of length one. -/
theorem self_loop_is_one_cycle {V : Type u} (G : DiGraph V) (x : V) (loop : G.Adj x x) :
∃ walk : Walk G x x, walk.IsCycle ∧ walk.length = 1 := by
exact ⟨.cons loop (.nil x), ⟨Nat.zero_lt_succ 0, by simp [Walk.vertices]⟩, rfl⟩
theorem dag_excludes_self_loop {V : Type u} {G : DiGraph V} (dag : G.DAG) (x : V) : ¬ G.Adj x x := by
intro loop
obtain ⟨walk, cycle, _⟩ := self_loop_is_one_cycle G x loop
exact Walk.no_cycle_in_dag dag walk cycle
end QBD.Ch02
#print axioms QBD.Ch02.self_loop_is_one_cycle
#print axioms QBD.Ch02.dag_excludes_self_loop
#print axioms QBD.Ch02.asymmetry_implies_irreflexivity
#print axioms QBD.Ch02.asymmetry_equiv_irreflexive_and_antisymmetric
Verification Summary:
The machine-checked proofs confirm that any self-loop forms a one-edge directed cycle incompatible with acyclicity, and that strict asymmetry is equivalent to irreflexivity combined with antisymmetry. Dynamical stability and physical inertia interpretations remain outside this relational module. The Lean 4 kernel accepts all closed proof terms using only standard axioms, certifying the logical claims of Pathology of Self-Loops §2.2.2.
In Plain English:
Machine-checked Lean 4 proofs certify the discrete claims formalized in Section 2.2.2.4.
2.2.3 Lemma: Thermodynamic Nullity
Let count a family of simple directed paths specified by their vertex and edge sequences. This family is unchanged by adding a self-loop, so its logarithmic path entropy is unchanged on the domain .
In Plain English:
Section 2.2.3 formalizes the properties of the QBD lemma regarding thermodynamic nullity.
2.2.3.1 Proof: Thermodynamic Nullity
I. Path Families
For , define the counted family by the specified path-selection predicate and the conditions
These are conditions on a simple path (Directed Path §1.2.3). Let .
II. Inclusions
If , then every edge of lies in . The vertex sequence and its selection predicate are unchanged, so . Conversely, for , an edge of in would satisfy
contrary to pairwise distinctness. Hence every edge of lies in , so . It follows that
III. Logarithmic Entropy on Its Domain
For , both logarithms exist and the count equality gives
For , the equal families are both empty (Thermodynamic Nullity §2.2.3).
Q.E.D.
In Plain English:
Section 2.2.3.1 formalizes the properties of the QBD proof regarding thermodynamic nullity.
2.2.3.2 Type-Theoretic Validation via Lean 4 Core
Type-theoretic certification of the simple-path invariance under self-loop removal established in Thermodynamic Nullity §2.2.3 proceeds via the following verification strategy:
- Model: Directed graphs on a fixed vertex type, loop-pruned adjacency relations, simple directed paths, and finite families of selected simple paths represent path-counting invariance under self-loop excision.
- Certified Claims: The module certifies that removing all self-loops preserves the exact set of simple directed paths and leaves the finite count of selected simple paths unchanged in Thermodynamic Nullity §2.2.3.1.
- Scope Boundary: The certificate verifies bijection and cardinality equality of simple-path families. Bijection invariance of real-valued Shannon entropy under self-loop excision is certified in Type-Theoretic Validation via Lean 4 and Mathlib §1.3.5.3, while thermodynamic interpretations remain outside this combinatorial Core module.
import QBD.Ch02.Defs
namespace QBD.Ch02
universe u
/-- Adding a self-edge leaves every selected simple directed path unchanged. -/
theorem self_loop_simple_path_equivalence {V : Type u} (E : Edge V → Prop) (x a b : V)
(path : List (Edge V)) (simple : IsSimple a path) :
DirectedEdgePath (fun e => E e ∨ e = (x, x)) a b path ↔ DirectedEdgePath E a b path := by
induction path generalizing a with
| nil => rfl
| cons e rest ih =>
have separated := (List.nodup_cons.mp simple).1
have tailSimple : IsSimple e.2 rest := (List.nodup_cons.mp simple).2
constructor
· rintro ⟨present | loop, source, tail⟩
· exact ⟨present, source, (ih _ tailSimple).mp tail⟩
· subst e
exact False.elim (separated (by simp [← source]))
· exact fun ⟨present, source, tail⟩ => ⟨Or.inl present, source, (ih _ tailSimple).mpr tail⟩
/-- Equal path families give equal counts in any finite catalog, including the empty family. -/
theorem self_loop_selected_path_count {V : Type u} (E : Edge V → Prop) (x a b : V)
(catalog : List (List (Edge V))) (select : List (Edge V) → Prop)
[DecidablePred E] [DecidablePred select] [DecidableEq V] :
(catalog.filter (fun p => decide (select p ∧ IsSimple a p ∧
DirectedEdgePath (fun e => E e ∨ e = (x, x)) a b p))).length =
(catalog.filter (fun p => decide (select p ∧ IsSimple a p ∧ DirectedEdgePath E a b p))).length := by
unfold IsSimple
congr 1
apply List.filter_congr
intro path _
apply Bool.eq_iff_iff.mpr
simp only [decide_eq_true_eq]
exact ⟨fun ⟨h, simple, directed⟩ =>
⟨h, simple, (self_loop_simple_path_equivalence E x a b path simple).mp directed⟩,
fun ⟨h, simple, directed⟩ =>
⟨h, simple, (self_loop_simple_path_equivalence E x a b path simple).mpr directed⟩⟩
end QBD.Ch02
#print axioms QBD.Ch02.self_loop_simple_path_equivalence
#print axioms QBD.Ch02.self_loop_selected_path_count
Verification Summary:
The machine-checked proofs establish that every simple directed path avoids self-loops, so pruning all diagonal loops preserves both simple-path membership and finite selected path counts exactly. Real-valued Shannon entropy invariance for self-loop excision is established separately in the Chapter 1 Mathlib certificate. The Lean 4 kernel accepts all closed proof terms using only standard axioms, certifying the counting claims of Thermodynamic Nullity §2.2.3.
In Plain English:
Machine-checked Lean 4 proofs certify the formal claims verified in Section 2.2.3.3.
2.2.4 Proof: Insufficiency of Antisymmetry
I. Countermodel
Take and . For every , the consequent holds, so
The edge is present and violates irreflexivity (Pathology of Self-Loops §2.2.2).
II. Path Count
Adding this loop leaves the simple-path family unchanged (Thermodynamic Nullity §2.2.3). If the family is nonempty, its logarithmic entropy difference is zero. In the empty case the equality of families holds directly.
III. Directed-Link Condition
In the countermodel antisymmetry is true and irreflexivity is false. The directed-link restriction excludes the exhibited relation by its explicit irreflexivity condition (Directed Causal Link §2.1.1).
Q.E.D.
In Plain English:
Section 2.2.4 formalizes the properties of the QBD proof regarding insufficiency of antisymmetry.
2.2.4.1 Type-Theoretic Validation via Lean 4 Core
Type-theoretic certification of the logical insufficiency of antisymmetry established in Insufficiency of Antisymmetry §2.2.1 proceeds via the following verification strategy:
- Model: The assembly module imports the certified self-loop pathology and thermodynamic-nullity modules to construct a reflexive counter-model separating antisymmetry from strict asymmetry.
- Certified Claims: The module certifies that antisymmetry alone permits self-loops and therefore fails to imply strict asymmetry, while combining the cycle-exclusion and path-count invariants of Insufficiency of Antisymmetry §2.2.4.
- Scope Boundary: The certificate operates on abstract directed relations and finite simple-path counts. Real-valued entropy interpretations remain outside this relational Core assembly.
import QBD.Ch02.L2_2_2_PathologyOfSelfLoops
import QBD.Ch02.L2_2_3_ThermodynamicNullity
namespace QBD.Ch02
/--
THEOREM: Insufficiency of Antisymmetry
Formal counter-model proving that order-theoretic antisymmetry is physically
insufficient: the reflexive equality relation satisfies antisymmetry yet
contains a self-loop, demonstrating that irreflexivity is an independent axiom.
-/
theorem antisymmetry_insufficient :
∃ (V : Type) (R : CausalRelation V), IsAntisymmetric V R ∧ ¬ (IsIrreflexive V R) := by
exact ⟨Bool, Eq, by
intro u v h_fwd h_rev
exact h_fwd
, by
intro h_irref
have h_loop : ¬ (true = true) := h_irref true
exact h_loop rfl
⟩
/-- An antisymmetric graph can contain a simple one-edge cycle which contributes no simple open path. -/
theorem insufficiency_of_antisymmetry :
let E : Bool → Bool → Prop := Eq
IsAntisymmetric Bool E ∧ ¬ DirectedCausalLink E ∧
(∃ w : Walk ⟨E⟩ true true, w.IsCycle ∧ w.length = 1) ∧
(∀ a b p, IsSimple a p →
(DirectedEdgePath (fun e : Edge Bool => False ∨ e = (true, true)) a b p ↔
DirectedEdgePath (fun _ => False) a b p)) := by
exact ⟨fun _ _ eq _ => eq, fun directed => (directed true true rfl).1 rfl,
self_loop_is_one_cycle ⟨Eq⟩ true rfl, fun a b p simple =>
self_loop_simple_path_equivalence (fun _ => False) true a b p simple⟩
end QBD.Ch02
#print axioms QBD.Ch02.antisymmetry_insufficient
#print axioms QBD.Ch02.insufficiency_of_antisymmetry
Verification Summary:
The machine-checked proofs assemble the self-loop pathology and path-count invariance modules to exhibit an antisymmetric reflexive relation that violates strict asymmetry, establishing that antisymmetry is strictly weaker than irreflexive asymmetry. Real-valued entropic interpretations remain outside this discrete assembly. The Lean 4 kernel accepts all closed proof terms using only standard axioms, certifying the assembled claims of Insufficiency of Antisymmetry §2.2.4.
In Plain English:
Section 2.2.4.1 formalizes the properties of the QBD type-theoretic regarding validation via lean 4 core.
2.3.1 Definition: Axiom 2 Geometric Constructibility
Let Geometric Constructibility constrain candidate edge additions by two distinct requirements.
- Elementary closure: A geometric addition is a return chord across a simple directed two-path , creating the elementary directed triangle .
- Candidate-relative uniqueness: The candidate passes PUC precisely when there is no direct edge and no other intermediate vertex with .
The candidate path itself is not an alternative path. Absence of the proposed chord, irreflexivity, asymmetry, and the causal-admission check remain additional requirements. This is a rule on proposals and their elementary closure, not a theorem that every larger simple cycle in a spatial graph is absent.
Lean 4 (QBD.Ch02.Defs):
/-- Exclude a direct bypass and alternative middle vertices. -/
def UniqueTwoPathSupport {V : Type u} (E : V → V → Prop) (v w u : V) : Prop :=
¬ E v u ∧ (∀ x, E v x ∧ E x u → x = w)
/-- §2.3.1 Axiom 2. The return chord of this simple two-path passes candidate-relative PUC. -/
def GeometricConstructibility {V : Type u} (G : DiGraph V) (v w u : V) : Prop :=
G.TwoPath v w u ∧ UniqueTwoPathSupport G.Adj v w u
In Plain English:
Section 2.3.1 formalizes the properties of the QBD definition regarding axiom 2 geometric constructibility.
2.3.2 Theorem: Geometric Constructibility
Let a sequence of reduction states have strictly decreasing natural-number cycle potential at every step. Then the sequence is finite; candidate-relative PUC and elementary triangle closure specify the local addition rule, while strict descent of a particular scheduler is an additional hypothesis (Axiom 2 Geometric Constructibility §2.3.1).
In Plain English:
A 3-cycle represents the minimal closed loop of causality, constituting the fundamental 'geometric quantum' or atom of physical space.
2.3.3 Lemma: Geometric Quantum
Let the Geometric Quantum denote the subgraph induced by the ordered triplet of vertices such that the edge set contains exactly . Then this structure constitutes the minimal closed cycle compatible with the Directed Causal Link §2.1.1, excluding cycles of length 1 and 2, and the set of all constitutes the basis for emergent spatial area.
In Plain English:
Section 2.3.3 formalizes the properties of the QBD lemma regarding geometric quantum.
2.3.3.1 Proof: Geometric Quantum
I. Positive Cycle Lengths
Let a closed simple directed cycle have length (Cycle §1.2.6). The causal-link conditions required here are
(Directed Causal Link §2.1.1).
II. Exclusion of Lengths One and Two
For , closure and the edge condition give
contradicting irreflexivity. For , simplicity gives and closure gives . The two cycle edges are
contradicting asymmetry. Therefore every cycle compatible with these two conditions has .
III. Explicit Compatible Length-Three Model
For three pairwise distinct vertices , the length-three witness has the following vertex and edge sets.
Each outgoing set is a singleton, so the complete two-edge path family is
The endpoint inequalities , , exclude each possible self-loop. Reversing the three edges gives
The intersection is empty because equality of any ordered pair in the two lists would identify two of the three distinct vertices. Thus all irreflexivity and asymmetry conditions hold. The sequence
has three edges and supplies a compatible cycle. Combining existence at three with exclusion below three yields
IV. Geometric Designation
The geometric designation of this minimal cycle as an elementary area unit is supplied by the positive-construction clause (Axiom 2 Geometric Constructibility §2.3.1). Consequently the designated elementary area supports are precisely the copies of the specified ; the preceding count establishes their minimal cycle length under the causal primitive.
Q.E.D.
In Plain English:
Section 2.3.3.1 formalizes the properties of the QBD proof regarding geometric quantum.
2.3.3.2 Type-Theoretic Validation via Lean 4 Core
Type-theoretic certification of the minimal cycle length and triangle attainment established in Geometric Quantum §2.3.3 proceeds via the following verification strategy:
- Model: Directed graphs satisfying irreflexivity and asymmetry, simple directed cycles, and an explicit three-vertex directed triangle witness represent minimal closed spatial motifs.
- Certified Claims: The module certifies that simple directed cycles of length one and two are impossible under Axiom 1 Directed Causal Link §2.1.1, that every simple cycle has length at least three, and that a directed three-cycle attains this minimum in Geometric Quantum §2.3.3.1.
- Scope Boundary: The bound applies to directed simple cycles under irreflexivity and asymmetry. Emergent area calibration and continuum geometric interpretations remain outside this graph-theoretic certificate.
import QBD.Ch02.Defs
namespace QBD.Ch02
universe u
variable {V : Type u}
def triangleEdges (v w : Fin 3) : Prop :=
(v = 0 ∧ w = 1) ∨ (v = 1 ∧ w = 2) ∨ (v = 2 ∧ w = 0)
-- Counting edges of a vertex sequence.
/-- A walk built from a starting vertex contributes one edge per later vertex. -/
private theorem edgesFrom_length (start : V) (rest : List V) :
(edgesFrom start rest).length = rest.length := by
induction rest generalizing start with
| nil => rfl
| cons next rest ih => simp [edgesFrom, ih]
-- Cycle length in the closing-edge representation.
/-- The number of recorded vertices equals the edge count, including the closing edge. -/
theorem cycle_edges_length (vertices : List V) : (cycleEdges vertices).length = vertices.length := by
cases vertices <;> simp [cycleEdges, edgesFrom_length]
-- Exclusion of a one-edge simple cycle.
/-- The only edge of a one-vertex cycle is the self-loop forbidden by irreflexivity. -/
theorem no_simple_cycle_length_one {E : V → V → Prop} (axiom1 : DirectedCausalLink E)
{vertices : List V} (cycle : IsSimpleCycle (fun e => E e.1 e.2) vertices) : vertices.length ≠ 1 := by
intro length
rcases vertices with _ | ⟨v, _ | ⟨w, rest⟩⟩
· simp at length
· exact (axiom1 v v (cycle.2.2 (v, v) (by simp [cycleEdges, edgesFrom]))).1 rfl
· simp at length
-- Exclusion of a two-edge simple cycle.
/-- Traversing the two edges would give an edge and its reverse, forbidden by asymmetry. -/
theorem no_simple_cycle_length_two {E : V → V → Prop} (axiom1 : DirectedCausalLink E)
{vertices : List V} (cycle : IsSimpleCycle (fun e => E e.1 e.2) vertices) : vertices.length ≠ 2 := by
intro length
rcases vertices with _ | ⟨v, _ | ⟨w, _ | ⟨x, rest⟩⟩⟩
· simp at length
· simp at length
· exact (axiom1 v w (cycle.2.2 (v, w) (by simp [cycleEdges, edgesFrom]))).2
(cycle.2.2 (w, v) (by simp [cycleEdges, edgesFrom]))
· simp at length
-- Universal lower bound on compatible simple-cycle length.
/-- Positive cycle length and the two local exclusions force at least three edges. -/
theorem simple_cycle_length_ge_three {E : V → V → Prop} (axiom1 : DirectedCausalLink E)
{vertices : List V} (cycle : IsSimpleCycle (fun e => E e.1 e.2) vertices) : 3 ≤ vertices.length := by
have positive := List.length_pos_iff.mpr cycle.1
have notOne := no_simple_cycle_length_one axiom1 cycle
have notTwo := no_simple_cycle_length_two axiom1 cycle
omega
-- The lower bound is attained by the geometric quantum.
/-- The three cyclic orientations obey Axiom 1 and close the simple cycle 0, 1, 2. -/
theorem geometric_quantum_attains_minimum :
DirectedCausalLink triangleEdges ∧ IsSimpleCycle (fun e => triangleEdges e.1 e.2) [0, 1, 2] ∧
(cycleEdges ([0, 1, 2] : List (Fin 3))).length = 3 := by
have directed (v w : Fin 3) : triangleEdges v w → v ≠ w ∧ ¬ triangleEdges w v := by
rintro (⟨rfl, rfl⟩ | ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩) <;> (unfold triangleEdges; decide)
refine ⟨directed,
⟨by decide, by decide, ?_⟩, rfl⟩
intro e member
have listed : e = (0, 1) ∨ e = (1, 2) ∨ e = (2, 0) := by
simpa [cycleEdges, edgesFrom] using member
rcases listed with rfl | rfl | rfl <;> (unfold triangleEdges; decide)
end QBD.Ch02
#print axioms QBD.Ch02.simple_cycle_length_ge_three
#print axioms QBD.Ch02.geometric_quantum_attains_minimum
Verification Summary:
The machine-checked proofs establish that irreflexivity excludes length-one cycles, asymmetry excludes length-two cycles, every simple directed cycle has length at least three, and a concrete three-vertex triangle attains this lower bound. Continuum area interpretations remain outside this combinatorial formalization. The Lean 4 kernel accepts all closed proof terms using only standard axioms, certifying the minimal-cycle claims of Geometric Quantum §2.3.3.
In Plain English:
Machine-checked Lean 4 proofs certify the discrete claims formalized in Section 2.3.3.4.
2.3.4 Lemma: Principle of Unique Causality (PUC)
Let be a simple directed two-path and let contain all simple directed paths of length one or two from to . Then the candidate passes PUC if and only if , with the sole path (Axiom 2 Geometric Constructibility §2.3.1).
In Plain English:
Section 2.3.4 formalizes the properties of the QBD lemma regarding principle of unique causality (puc).
2.3.4.1 Proof: Principle of Unique Causality (PUC)
I. Complete Short-Path Classification
The construction uses candidate-relative geometric admission (Axiom 2 Geometric Constructibility §2.3.1).
For distinct , every simple path of length at most two has exactly one of the forms
The first exists exactly when . The second exists exactly when . Different intermediate vertices give different vertex sequences.
II. Cardinality Decomposition
Put . The two path classes are disjoint, so
The candidate supplies and hence .
III. Both Implications
If PUC holds (Principle of Unique Causality (PUC) §2.3.4), its first clause gives and its uniqueness clause gives . Together with ,
Conversely, suppose . The candidate gives , so
Thus and . These are the two PUC clauses.
IV. Conclusion
Q.E.D.
In Plain English:
Section 2.3.4.1 formalizes the properties of the QBD proof regarding principle of unique causality (puc).
2.3.4.2 Type-Theoretic Validation via Lean 4 Core
Type-theoretic certification of the unique-support characterization and triangle closure established in Principle of Unique Causality (PUC) §2.3.4 proceeds via the following verification strategy:
- Model: Finite directed graphs, middle-vertex neighbor lists, candidate-relative unique two-path support predicates, and single-edge chord insertions represent local geometric constructibility.
- Certified Claims: The module certifies the equivalence between candidate-relative unique support and having exactly one short path of length at most two between the endpoints, together with uniqueness of the mediating vertex and closure into a directed three-cycle in Principle of Unique Causality (PUC) §2.3.4.1.
- Scope Boundary: The certificate checks the local candidate-relative predicate on a frozen snapshot. Global cycle absence and dynamical proposal weights remain outside this local structural check.
import QBD.Ch02.Defs
namespace QBD.Ch02
universe u
variable {V : Type u}
variable {n : Nat}
-- Filter the finite vertex set to the intermediate vertices of simple two-edge paths.
def middleVertices (E : Fin n → Fin n → Prop) [DecidableRel E] (v u : Fin n) : List (Fin n) :=
(List.finRange n).filter (fun x => decide (x ≠ v ∧ x ≠ u ∧ E v x ∧ E x u))
-- List the direct path first when present, followed by one path per intermediate vertex.
def shortPaths (E : Fin n → Fin n → Prop) [DecidableRel E] (v u : Fin n) : List (List (Fin n)) :=
if v = u then [] else
(if E v u then [[v, u]] else []) ++ (middleVertices E v u).map (fun x => [v, x, u])
-- Exact membership in the list of possible middle vertices.
/-- Enumeration retains exactly the nonendpoint vertices with both directed support edges. -/
theorem mem_middleVertices {E : Fin n → Fin n → Prop} [DecidableRel E] {v u x : Fin n} :
x ∈ middleVertices E v u ↔ x ≠ v ∧ x ≠ u ∧ E v x ∧ E x u := by
simp only [middleVertices, List.mem_filter, decide_eq_true_eq]
exact ⟨And.right, fun support => ⟨List.mem_finRange x, support⟩⟩
-- Complete classification of the short-path list.
/-- For distinct endpoints the only paths are the direct edge and the two-edge paths
through a different vertex with both support edges. -/
theorem mem_shortPaths {E : Fin n → Fin n → Prop} [DecidableRel E]
{v u : Fin n} (distinct : v ≠ u) {p : List (Fin n)} :
p ∈ shortPaths E v u ↔ (E v u ∧ p = [v, u]) ∨
∃ x, x ≠ v ∧ x ≠ u ∧ E v x ∧ E x u ∧ p = [v, x, u] := by
simp only [shortPaths, ite_eq_right distinct, List.mem_append, List.mem_map, mem_middleVertices]
constructor
· rintro (direct | ⟨x, support, eq⟩)
· by_cases edge : E v u
· exact Or.inl ⟨edge, by simpa [edge] using direct⟩
· simp [edge] at direct
· exact Or.inr ⟨x, support.1, support.2.1, support.2.2.1, support.2.2.2, eq.symm⟩
· rintro (⟨edge, rfl⟩ | ⟨x, fromStart, fromEnd, first, second, rfl⟩)
· exact Or.inl (by simp [edge])
· exact Or.inr ⟨x, ⟨fromStart, fromEnd, first, second⟩, rfl⟩
-- Cardinality of the short-path list.
/-- The direct edge contributes zero or one path, and each admissible middle contributes one. -/
theorem short_paths_cardinality {E : Fin n → Fin n → Prop} [DecidableRel E]
{v u : Fin n} (distinct : v ≠ u) :
(shortPaths E v u).length = (if E v u then 1 else 0) + (middleVertices E v u).length := by
simp only [shortPaths, ite_eq_right distinct, List.length_append, List.length_map]
split <;> rfl
-- Uniqueness of enumerated middle vertices.
/-- Filtering the duplicate-free vertex enumeration preserves the absence of duplicates. -/
private theorem middle_vertices_nodup (E : Fin n → Fin n → Prop) [DecidableRel E] (v u : Fin n) :
(middleVertices E v u).Nodup :=
(List.nodup_finRange n).filter _
-- The short-path representation is duplicate-free.
/-- Distinct intermediate vertices give distinct lists, and the direct path
has a different length from every two-edge path. -/
theorem short_paths_nodup (E : Fin n → Fin n → Prop) [DecidableRel E] (v u : Fin n) :
(shortPaths E v u).Nodup := by
by_cases distinct : v = u
· simp [shortPaths, distinct]
· have twoEdge : ((middleVertices E v u).map (fun x => [v, x, u])).Nodup :=
List.pairwise_map.mpr ((middle_vertices_nodup E v u).imp (fun ne eq =>
ne (List.cons.inj (List.cons.inj eq).2).1))
by_cases direct : E v u
· simp only [shortPaths, ite_eq_right distinct, ite_eq_left direct, List.singleton_append,
List.nodup_cons]
refine ⟨?_, twoEdge⟩
intro member
obtain ⟨x, _, eq⟩ := List.mem_map.mp member
have len := congrArg List.length eq
simp at len
· simpa [shortPaths, distinct, direct] using twoEdge
-- A list of length one equals the singleton of any member.
/-- Membership fixes the unique element once the length fixes the list shape. -/
private theorem singleton_of_length_one {l : List V} {p : V} (length : l.length = 1)
(member : p ∈ l) : l = [p] := by
rcases l with _ | ⟨first, _ | ⟨second, rest⟩⟩
· simp at length
· have eq : p = first := List.mem_singleton.mp member
subst first
rfl
· simp at length
-- PUC is exactly the short-path count of one.
/-- The candidate supplies one two-edge path. PUC excludes both a direct edge
and any other middle vertex, and the count of one enforces both exclusions. -/
theorem puc_iff_short_paths_cardinality {E : Fin n → Fin n → Prop} [DecidableRel E]
{v w u : Fin n} (distinct : ThreeDistinct v w u) (first : E v w) (second : E w u) :
IsCompliant2Path E v w u ↔ (shortPaths E v u).length = 1 := by
obtain ⟨vw, vu, wu⟩ := distinct
have inMiddle : w ∈ middleVertices E v u :=
mem_middleVertices.mpr ⟨vw.symm, wu, first, second⟩
have candidate : [v, w, u] ∈ shortPaths E v u :=
(mem_shortPaths vu).mpr (Or.inr ⟨w, vw.symm, wu, first, second, rfl⟩)
constructor
· intro compliant
have contained : middleVertices E v u ⊆ [w] := by
intro x hx
obtain ⟨_, _, into, out⟩ := mem_middleVertices.mp hx
exact List.mem_singleton.mpr (compliant.2.2.2 x ⟨into, out⟩)
have upper := (middle_vertices_nodup E v u).length_le_of_subset contained
have lower := List.length_pos_iff.mpr (List.ne_nil_of_mem inMiddle)
rw [short_paths_cardinality vu, ite_eq_right compliant.2.2.1]
simp only [List.length_singleton] at upper
omega
· intro count
have only := singleton_of_length_one count candidate
have noDirect : ¬ E v u := by
intro edge
have direct : [v, u] ∈ shortPaths E v u := (mem_shortPaths vu).mpr (Or.inl ⟨edge, rfl⟩)
rw [only] at direct
have len := congrArg List.length (List.mem_singleton.mp direct)
simp at len
refine ⟨first, second, noDirect, fun x support => ?_⟩
have xv : x ≠ v := fun eq => noDirect (eq ▸ support.2)
have xu : x ≠ u := fun eq => noDirect (eq ▸ support.1)
have member : [v, x, u] ∈ shortPaths E v u :=
(mem_shortPaths vu).mpr (Or.inr ⟨x, xv, xu, support.1, support.2, rfl⟩)
rw [only] at member
exact (List.cons.inj (List.cons.inj (List.mem_singleton.mp member)).2).1
-- PUC identifies the sole short path.
/-- Whenever the count is one, the candidate is its unique member, so PUC
is also equivalent to having exactly the singleton list of the specified support. -/
theorem puc_iff_short_paths_singleton {E : Fin n → Fin n → Prop} [DecidableRel E]
{v w u : Fin n} (distinct : ThreeDistinct v w u) (first : E v w) (second : E w u) :
IsCompliant2Path E v w u ↔ shortPaths E v u = [[v, w, u]] := by
rw [puc_iff_short_paths_cardinality distinct first second]
constructor
· intro count
apply singleton_of_length_one count
exact (mem_shortPaths distinct.2.1).mpr
(Or.inr ⟨w, distinct.1.symm, distinct.2.2, first, second, rfl⟩)
· intro only
rw [only]
rfl
/--
THEOREM 3: PUC Precludes Alternative Intermediate Nodes
Proves that under the Principle of Unique Causality, no alternative intermediate node z ≠ w
can form a 2-path from u to v, certifying that 2-path routing channels are unique.
-/
theorem puc_precludes_alternative_intermediate :
∀ (R : (V → V → Prop)) (u w v : V),
IsCompliant2Path R u w v →
∀ z : V, R u z → R z v → z = w := by
intro R u w v h_puc z h_uz h_zv
exact h_puc.2.2.2 z ⟨h_uz, h_zv⟩
/-- An admissible geometric support becomes a directed triangle when its return chord is added. -/
theorem geometric_closure_triangle {V : Type u} {G : DiGraph V} {v w u : V}
(admitted : GeometricConstructibility G v w u) :
(DiGraph.mk (fun a b => G.Adj a b ∨ (a, b) = (u, v))).ThreeCycle v w u := by
obtain ⟨⟨vw, wu, vu, first, second⟩, _⟩ := admitted
exact ⟨⟨vw, wu, vu, Or.inl first, Or.inl second⟩, Or.inr rfl⟩
end QBD.Ch02
#print axioms QBD.Ch02.puc_iff_short_paths_cardinality
#print axioms QBD.Ch02.puc_iff_short_paths_singleton
#print axioms QBD.Ch02.puc_precludes_alternative_intermediate
#print axioms QBD.Ch02.geometric_closure_triangle
Verification Summary:
The machine-checked proofs establish that candidate-relative unique two-path support is equivalent to a singleton short-path set of length at most two, uniquely identifies the mediating vertex, and yields a closed directed three-cycle upon chord insertion. Global topology and dynamical selection probabilities remain outside this local formalization. The Lean 4 kernel accepts all closed proof terms using only standard axioms, certifying the logical claims of Principle of Unique Causality (PUC) §2.3.4.
In Plain English:
Machine-checked Lean 4 proofs certify the discrete claims formalized in Section 2.3.4.4.
2.3.5 Lemma: Lexicographic Potential
Let the Lexicographic Potential be the ordered pair mapping a finite graph to the state space ordered lexicographically. The relation on constitutes a strict order satisfying irreflexivity, asymmetry, and transitivity.
In Plain English:
Section 2.3.5 formalizes the properties of the QBD lemma regarding lexicographic potential.
2.3.5.1 Proof: Lexicographic Potential
I. Lexicographic Relation
For and in , define
(Lexicographic Potential §2.3.5). For finite cycle sets, the potential coordinates and are natural numbers; the argument applies to all pairs in the codomain (Cycle §1.2.6).
II. Irreflexivity and Asymmetry
Substitution of gives
whose two alternatives are both false. Now suppose . If , then both and are false, excluding both alternatives of . If and , then is false and is false, again excluding both alternatives. Hence
III. All Four Transitivity Cases
Let and suppose . Distributivity gives
The comparisons in each disjunct give the following consequences.
The first three cases give the first alternative of . The last gives its second alternative, since . Thus
Q.E.D.
In Plain English:
Section 2.3.5.1 formalizes the properties of the QBD proof regarding lexicographic potential.
2.3.5.2 Type-Theoretic Validation via Lean 4 Core
Type-theoretic certification of the lexicographic descent criterion established in Lexicographic Potential §2.3.5 proceeds via the following verification strategy:
- Model: Natural-number pairs recording maximal cycle length and maximal-cycle multiplicity, equipped with the strict lexicographic order, represent the termination potential.
- Certified Claims: The module certifies that either strictly decreasing maximal cycle length or preserving maximal cycle length while strictly decreasing its multiplicity yields strict lexicographic descent in Lexicographic Potential §2.3.5.1.
- Scope Boundary: The certificate verifies the order-theoretic descent criterion on abstract potential pairs. Linking concrete graph rewrites to strict descent is delegated to the cycle-reduction modules.
import QBD.Ch02.Defs
namespace QBD.Ch02
variable {n : Nat} {V : Type}
-- A simple cycle starts at its least vertex, so cyclic rotations are counted once.
def IsCanonicalCycle (cycle : List (Fin n)) : Prop :=
cycle.Nodup ∧ ∃ start rest, cycle = start :: rest ∧ ∀ v ∈ rest, start.val ≤ v.val
-- Check simplicity and the canonical starting vertex on the finite list.
def simpleCycleCheck (cycle : List (Fin n)) : Bool :=
decide cycle.Nodup && match cycle with
| [] => false
| start :: rest => rest.all (fun v => decide (start.val ≤ v.val))
-- Include the closing edge by taking successor indices modulo the cycle length.
def indexedCycleEdges (cycle : List V) : List (Edge V) :=
List.ofFn fun i : Fin cycle.length =>
(cycle[i.val], cycle[(i.val + 1) % cycle.length]'(Nat.mod_lt _ (Nat.zero_lt_of_lt i.isLt)))
-- The finite catalog enumerates all canonical simple cycles on the fixed vertex set.
def cycleCatalog (n : Nat) : List (List (Fin n)) :=
(boundedLists (List.finRange n) n).filter simpleCycleCheck
-- Detect whether a cycle uses a particular edge.
def usesEdge (e : Edge (Fin n)) (cycle : List (Fin n)) : Bool :=
decide (e ∈ indexedCycleEdges cycle)
-- A cycle is active exactly when all of its edges are present.
def activeCycles (edges : List (Edge (Fin n))) : List (List (Fin n)) :=
(cycleCatalog n).filter (fun cycle => (indexedCycleEdges cycle).all (fun e => decide (e ∈ edges)))
-- Restrict the active cycles to one length.
def cyclesAt (edges : List (Edge (Fin n))) (length : Nat) : List (List (Fin n)) :=
(activeCycles edges).filter (fun cycle => decide (cycle.length = length))
-- The longest active simple-cycle length is zero on an empty cycle list.
def longestCycle (edges : List (Edge (Fin n))) : Nat :=
((activeCycles edges).map List.length).max?.getD 0
-- The potential records the longest length and the number of active cycles of that length.
def potential (edges : List (Edge (Fin n))) : Nat × Nat :=
(longestCycle edges, (cyclesAt edges (longestCycle edges)).length)
/-- Cycle potential compares maximal length, then the number at that length. -/
abbrev CyclePotentialLess : (Nat × Nat) → (Nat × Nat) → Prop := Prod.Lex (· < ·) (· < ·)
/--
THEOREM 2: Lexicographic Descent is Admissible
Proves that any update step reducing either the maximum cycle length
or its multiplicity transitions the state space along a strictly decreasing chain.
-/
theorem lexicographic_descent_admissible :
∀ (L1 N1 L2 N2 : Nat),
(L2 < L1 ∨ (L2 = L1 ∧ N2 < N1)) →
Prod.Lex (fun (a b : Nat) => a < b) (fun (a b : Nat) => a < b) (L2, N2) (L1, N1) := by
intro L1 N1 L2 N2 h
cases h with
| inl h_left =>
exact Prod.Lex.left N2 N1 h_left
| inr h_right_and =>
cases h_right_and with
| intro h_eq h_right =>
subst h_eq
exact Prod.Lex.right _ h_right
end QBD.Ch02
#print axioms QBD.Ch02.lexicographic_descent_admissible
Verification Summary:
The machine-checked proof confirms that reducing maximal cycle length or holding it constant while reducing maximal-cycle multiplicity strictly lowers the lexicographic potential pair. Concrete graph rewrite mechanics remain outside this abstract order module. The Lean 4 kernel accepts the closed proof term using only standard axioms, certifying the descent criterion of Lexicographic Potential §2.3.5.
In Plain English:
Machine-checked Lean 4 proofs certify the discrete claims formalized in Section 2.3.5.3.
2.3.6 Lemma: Well-Foundedness
Let denote the Lexicographic Potential §2.3.5 of a finite graph . Then the codomain of is well-ordered, and any trajectory satisfying the descent condition constitutes a finite sequence.
In Plain English:
Section 2.3.6 formalizes the properties of the QBD lemma regarding well-foundedness.
2.3.6.1 Proof: Well-Foundedness
I. Least Element of a Nonempty Set
Let be nonempty, with the lexicographic relation (Lexicographic Potential §2.3.5). Its first-coordinate projection
is nonempty. The natural-number well-order supplies . Its nonempty fiber has a least second coordinate:
Then . For every , either , or and . In the latter case either or the pairs are equal. Therefore is a least element of .
II. Exclusion of Infinite Descent
Suppose an infinite sequence satisfies . Its range
is nonempty. Let be its least element, whose existence follows from Section I. The next term satisfies
contradicting leastness. Hence no such infinite sequence exists.
III. Application to Graph Potentials
For each finite graph , the cycle length and cycle count are finite, so (Well-Foundedness §2.3.6). If an infinite graph trajectory satisfied the strict-descent condition, the sequence would be the forbidden sequence of Section II. Thus
Q.E.D.
In Plain English:
Section 2.3.6.1 formalizes the properties of the QBD proof regarding well-foundedness.
2.3.6.2 Type-Theoretic Validation via Lean 4 Core
Type-theoretic certification of the well-foundedness and exclusion of infinite descending chains established in Well-Foundedness §2.3.6 proceeds via the following verification strategy:
- Model: The strict lexicographic relation on pairs of natural numbers and infinite sequence maps represent potential trajectories under iterative reduction.
- Certified Claims: The module certifies that the lexicographic order on natural-number pairs is well-founded and admits no infinite strictly descending sequence in Well-Foundedness §2.3.6.1.
- Scope Boundary: Well-foundedness holds for the abstract pair order independently of how a rewrite step decreases the potential. Concrete termination bounds depend on establishing per-step descent in the graph dynamics.
import QBD.Ch02.L2_3_5_LexicographicPotential
namespace QBD.Ch02
/--
THEOREM 1: Lexicographic Potential Relation is Well-Founded
Formally establishes that Prod.Lex on Nat × Nat is well-founded,
guaranteeing the existence of no infinite descending chains in the state space.
-/
theorem lexicographic_relation_wf :
WellFounded (Prod.Lex (fun (a b : Nat) => a < b) (fun (a b : Nat) => a < b)) :=
(inferInstance : WellFoundedRelation (Nat × Nat)).wf
/-- A reduction with strict lexicographic descent admits no infinite sequence. -/
theorem no_infinite_cycle_descent (state : Nat → Nat × Nat)
(decreases : ∀ tick, CyclePotentialLess (state (tick + 1)) (state tick)) : False := by
have impossible (p : Nat × Nat) (acc : Acc CyclePotentialLess p) :
∀ tick, state tick = p → False := by
induction acc with
| intro current below ih =>
intro tick equal
exact ih (state (tick + 1)) (equal ▸ decreases tick) (tick + 1) rfl
exact impossible (state 0) (lexicographic_relation_wf.apply _) 0 rfl
end QBD.Ch02
#print axioms QBD.Ch02.lexicographic_relation_wf
#print axioms QBD.Ch02.no_infinite_cycle_descent
Verification Summary:
The machine-checked proofs establish that the strict lexicographic order on natural-number pairs is well-founded and cannot support any infinite strictly descending sequence. Concrete graph-level descent verification remains outside this order-theoretic module. The Lean 4 kernel accepts all closed proof terms using only standard axioms, certifying the termination foundation of Well-Foundedness §2.3.6.
In Plain English:
Machine-checked Lean 4 proofs certify the discrete claims formalized in Section 2.3.6.3.
2.3.7 Proof: Geometric Constructibility
I. Elementary Candidate Rule
Irreflexive asymmetric links have minimum directed cycle length three (Geometric Quantum §2.3.3). Candidate-relative uniqueness is equivalent to exactly one short path, namely the candidate (Principle of Unique Causality (PUC) §2.3.4).
II. Decreasing Potential Hypothesis
The cycle potential is a natural-number pair in lexicographic order (Lexicographic Potential §2.3.5). For the stipulated reduction sequence, at every step.
III. Termination
An infinite sequence would be an infinite descending chain in the well-founded lexicographic order, which is impossible (Well-Foundedness §2.3.6). Therefore the stated strictly descending sequence is finite. This conditional result does not supply a descent estimate for the physical stochastic scheduler.
Q.E.D.
In Plain English:
Section 2.3.7 formalizes the properties of the QBD proof regarding geometric constructibility.
2.3.7.1 Type-Theoretic Validation via Lean 4 Core
Type-theoretic certification of the minimal-cycle, unique-support, and well-foundedness synthesis established in Geometric Constructibility §2.3.2 proceeds via the following verification strategy:
- Model: The assembly module imports the certified geometric-quantum, unique-causality, lexicographic-potential, and well-foundedness modules into a unified structural theorem.
- Certified Claims: The module assembles the length-three cycle minimum, triangle attainment, candidate-relative unique-support equivalence, lexicographic descent criterion, and well-foundedness of the termination order in Geometric Constructibility §2.3.7.
- Scope Boundary: The assembly certifies the structural and order-theoretic pillars of the second axiom under candidate-relative support. Concrete multi-step cycle decomposition is assembled separately in the next section.
import QBD.Ch02.L2_3_3_GeometricQuantum
import QBD.Ch02.L2_3_4_PrincipleOfUniqueCausality
import QBD.Ch02.L2_3_5_LexicographicPotential
import QBD.Ch02.L2_3_6_WellFoundedness
namespace QBD.Ch02
universe u
/-- Local triangle closure and the finite-descent conclusion under the scheduler's hypothesis. -/
theorem geometric_constructibility :
(∀ {V : Type u} {G : DiGraph V} {v w u : V}, GeometricConstructibility G v w u →
(DiGraph.mk (fun a b => G.Adj a b ∨ (a, b) = (u, v))).ThreeCycle v w u) ∧
(∀ {V : Type u} {E : V → V → Prop}, DirectedCausalLink E →
∀ {vertices}, IsSimpleCycle (fun e => E e.1 e.2) vertices → 3 ≤ vertices.length) ∧
(∀ state : Nat → Nat × Nat,
(∀ t, (state (t + 1)).1 < (state t).1 ∨
((state (t + 1)).1 = (state t).1 ∧ (state (t + 1)).2 < (state t).2)) → False) := by
refine ⟨@geometric_closure_triangle, fun ax _ cycle => simple_cycle_length_ge_three ax cycle, ?_⟩
intro state descent
exact no_infinite_cycle_descent state fun t => lexicographic_descent_admissible _ _ _ _ (descent t)
end QBD.Ch02
#print axioms QBD.Ch02.geometric_constructibility
Verification Summary:
The machine-checked proof combines minimal simple-cycle length, candidate-relative unique two-path support, lexicographic descent admissibility, and well-foundedness into a single closed assembly theorem. General multi-step cycle reduction is certified in the subsequent decomposition section. The Lean 4 kernel accepts the closed proof term using only standard axioms, certifying the logical synthesis of Geometric Constructibility §2.3.7.
In Plain English:
Section 2.3.7.1 formalizes the properties of the QBD type-theoretic regarding validation via lean 4 core.
2.4.1 Theorem: General Cycle Decomposition
Let the kinematic reduction benchmark start from an isolated directed cycle , , insert the frozen perimeter two-path chords once, and then delete an edge from a cycle longer than three until none remains. Then it terminates with after at most edge mutations; for the output is asymmetric, while the unguarded four-cycle benchmark need not be.
In Plain English:
Section 2.4.1 formalizes the properties of the QBD theorem regarding general cycle decomposition.
2.4.2 Lemma: Confluence of the Constructor
Let legal proposals and their new heights be fixed from one input snapshot. Then merging the resulting directed edge-height pairs is independent of their accumulation order, with any reciprocal rejection evaluated on the same complete proposal set.
In Plain English:
Section 2.4.2 formalizes the properties of the QBD lemma regarding confluence of the constructor.
2.4.2.1 Proof: Confluence of the Constructor
I. Heights Computed Once
Let be the input and the sets of proposed edges absent from . If an edge belongs to both sets, both assign the same value (Creation Timestamp §1.4.4)
Thus the two assignments define a common function on .
II. Directed-Pair Membership and Reciprocal Rejection
For an ordered pair write . Accumulating the sets in the two orders gives
For , the reciprocal-pair example has and . Then
Neither proposal survives the filter on the complete set, so .
III. Equality of the Height Fields
Let . Pointwise equality of retained membership gives . For in this common edge set,
The vertex set is fixed, so (Confluence of the Constructor §2.4.2).
IV. Worked Example of Vertex Sharing
The two support paths are and . They share vertex . The old adjacency and the complete short-path families at their endpoint pairs are
Indeed, has successors , of which only has an edge to , and has only successor , which has an edge to . Neither endpoint pair has a direct edge. Thus each path passes the short-path uniqueness test (Principle of Unique Causality (PUC) §2.3.4).
If is inserted first, the successors of become and both have an edge to . The updated count is
Thus reevaluating PUC at the second path rejects it. For a frozen batch consisting of these two proposals, the filter instead acts on . The reverse pairs and are both absent from , so and both accumulation orders produce with the same snapshot-assigned heights.
Q.E.D.
In Plain English:
Section 2.4.2.1 formalizes the properties of the QBD proof regarding confluence of the constructor.
2.4.2.2 Type-Theoretic Validation via Lean 4 Core
Type-theoretic certification of the frozen-snapshot confluence and reciprocal cancellation established in Confluence of the Constructor §2.4.2 proceeds via the following verification strategy:
- Model: Finite timestamped graphs, source-side creation heights, frozen-snapshot candidate chord batches, reciprocal-conflict cancellation filters, and a four-vertex shared-vertex witness represent synchronous parallel merges.
- Certified Claims: The module certifies uniqueness of source-side creation heights, order-independence of frozen-snapshot batch merges, exact exclusion of reciprocal chord pairs by conflict cancellation, and order-sensitivity in the shared-vertex sequential counterexample in Confluence of the Constructor §2.4.2.1.
- Scope Boundary: Confluence applies to synchronous evaluation against a frozen input snapshot. Asynchronous scheduling without conflict cancellation or sequential evaluation is explicitly separated by the shared-vertex witness.
import QBD.Ch02.Defs
namespace QBD.Ch02
variable {V : Type}
-- Edges are ordered pairs, and an edge set is their membership predicate.
def EdgeSet (V : Type) := V × V → Prop
-- Accumulate two sets of directed edges.
def edgeUnion (A B : EdgeSet V) : EdgeSet V := fun e => A e ∨ B e
-- Reverse an ordered edge.
def reverseEdge (e : V × V) : V × V := (e.2, e.1)
-- Retain exactly the nonloop proposals whose reversals are absent from the entire batch.
def reciprocalFilter (B : EdgeSet V) : EdgeSet V :=
fun e => B e ∧ e.1 ≠ e.2 ∧ ¬ B (reverseEdge e)
-- Both proposal sets consist of absent edges and share heights computed in the active snapshot.
structure FrozenBatch (G : RelTimestampedGraph V) (B₁ B₂ : EdgeSet V) where
absent : ∀ e, edgeUnion B₁ B₂ e → ¬ G.edges e
height : (e : V × V) → edgeUnion B₁ B₂ e → Nat
creationHeight : ∀ e he, IsCreationHeight G e.1 (height e he)
-- The merge keeps an active edge's height and uses the frozen height for a retained proposal.
noncomputable def mergedHeight (G : RelTimestampedGraph V) (B : EdgeSet V)
(h : (e : V × V) → B e → Nat) (e : V × V)
(he : edgeUnion G.edges (reciprocalFilter B) e) : Nat := by
classical
exact if old : G.edges e then G.height e else
h e (he.elim (fun active => False.elim (old active)) And.left)
-- The five-vertex snapshot from §2.4.2.1 Part IV.
def sharingEdges : EdgeSet (Fin 5) :=
fun e => e ∈ ([(0, 1), (1, 2), (2, 3), (3, 4), (0, 4)] : List (Fin 5 × Fin 5))
-- The two return-edge proposals obtained in the five-vertex snapshot.
def sharingBatch : EdgeSet (Fin 5) :=
edgeUnion (fun e => e = (2, 0)) (fun e => e = (4, 2))
-- Uniqueness of a snapshot creation height.
/-- Independent computations at the same source agree, including on overlapping proposals. -/
theorem creationHeight_unique {G : RelTimestampedGraph V} {u : V} {h₁ h₂ : Nat}
(first : IsCreationHeight G u h₁) (second : IsCreationHeight G u h₂) : h₁ = h₂ := by
obtain ⟨m₁, rfl, upper₁, attained₁⟩ := first
obtain ⟨m₂, rfl, upper₂, attained₂⟩ := second
have le₁₂ : m₁ ≤ m₂ := attained₁.elim (fun eq => eq.symm ▸ Nat.zero_le m₂)
(fun ⟨x, hx, eq⟩ => eq.symm ▸ upper₂ x hx)
have le₂₁ : m₂ ≤ m₁ := attained₂.elim (fun eq => eq.symm ▸ Nat.zero_le m₁)
(fun ⟨x, hx, eq⟩ => eq.symm ▸ upper₁ x hx)
rw [Nat.le_antisymm le₁₂ le₂₁]
-- Frozen constructor confluence.
/-- Swapping the two proposals preserves the filtered set, merged edges, and each merged height. -/
theorem frozen_constructor_confluence (G : RelTimestampedGraph V) (B₁ B₂ : EdgeSet V)
(batch : FrozenBatch G B₁ B₂) :
reciprocalFilter (edgeUnion B₁ B₂) = reciprocalFilter (edgeUnion B₂ B₁) ∧
edgeUnion G.edges (reciprocalFilter (edgeUnion B₁ B₂)) =
edgeUnion G.edges (reciprocalFilter (edgeUnion B₂ B₁)) ∧
(∀ e
(h₁₂ : edgeUnion G.edges (reciprocalFilter (edgeUnion B₁ B₂)) e)
(h₂₁ : edgeUnion G.edges (reciprocalFilter (edgeUnion B₂ B₁)) e),
mergedHeight G (edgeUnion B₁ B₂) batch.height e h₁₂ =
mergedHeight G (edgeUnion B₂ B₁) (fun x hx => batch.height x hx.symm) e h₂₁) := by
have filtered : reciprocalFilter (edgeUnion B₁ B₂) =
reciprocalFilter (edgeUnion B₂ B₁) := by
funext e
apply propext
exact ⟨fun ⟨inBatch, nonloop, noReverse⟩ =>
⟨inBatch.symm, nonloop, fun reverse => noReverse reverse.symm⟩,
fun ⟨inBatch, nonloop, noReverse⟩ =>
⟨inBatch.symm, nonloop, fun reverse => noReverse reverse.symm⟩⟩
refine ⟨filtered, congrArg (edgeUnion G.edges) filtered, ?_⟩
intro e h₁₂ h₂₁
classical
by_cases old : G.edges e <;> simp [mergedHeight, old]
-- A reciprocal pair cancels on its complete proposal set.
/-- Neither of two distinct reverse proposals survives the symmetric filter. -/
theorem reciprocal_pair_cancellation (u v : V) (_distinct : u ≠ v) :
reciprocalFilter (edgeUnion (fun e => e = (u, v)) (fun e => e = (v, u))) =
(fun _ => False) := by
funext e
apply propext
constructor
· rintro ⟨incoming, _, noReverse⟩
rcases incoming with eq | eq
· subst e
exact noReverse (Or.inr rfl)
· subst e
exact noReverse (Or.inl rfl)
· exact False.elim
-- Vertex sharing in frozen and sequential evaluation.
/-- The old paths pass PUC, inserting (2,0) creates exactly two competing two-paths
from 2 to 4, and the complete frozen batch retains both new edges. -/
theorem vertex_sharing_example :
let old := fun u v => sharingEdges (u, v)
let inserted := fun u v => edgeUnion sharingEdges (fun e => e = (2, 0)) (u, v)
IsCompliant2Path old 0 1 2 ∧ IsCompliant2Path old 2 3 4 ∧
(∀ e, sharingBatch e → ¬ sharingEdges e) ∧
¬ inserted 2 4 ∧
(∀ z, inserted 2 z ∧ inserted z 4 ↔ z = 0 ∨ z = 3) ∧
¬ IsCompliant2Path inserted 2 3 4 ∧ reciprocalFilter sharingBatch = sharingBatch := by
dsimp only
have first : IsCompliant2Path (fun u v => sharingEdges (u, v)) 0 1 2 := by
refine ⟨?_, ?_, ?_, ?_⟩
· unfold sharingEdges
decide
· unfold sharingEdges
decide
· unfold sharingEdges
decide
· intro z hz
simp (config := { decide := true }) [sharingEdges] at hz
exact hz.2
have second : IsCompliant2Path (fun u v => sharingEdges (u, v)) 2 3 4 := by
refine ⟨?_, ?_, ?_, ?_⟩
· unfold sharingEdges
decide
· unfold sharingEdges
decide
· unfold sharingEdges
decide
· intro z hz
simp (config := { decide := true }) [sharingEdges] at hz
exact hz.1
have paths (z : Fin 5) :
edgeUnion sharingEdges (fun e => e = (2, 0)) (2, z) ∧
edgeUnion sharingEdges (fun e => e = (2, 0)) (z, 4) ↔ z = 0 ∨ z = 3 := by
constructor
· intro hz
simp (config := { decide := true }) [edgeUnion, sharingEdges] at hz
exact hz.symm
· rintro (rfl | rfl) <;> (unfold edgeUnion sharingEdges; decide)
refine ⟨first, second, ?_, ?_, paths, ?_, ?_⟩
· intro e he
rcases he with rfl | rfl <;> (unfold sharingEdges; decide)
· unfold edgeUnion sharingEdges
decide
· intro compliant
have impossible := compliant.2.2.2 0 ((paths 0).mpr (Or.inl rfl))
exact (by decide : (0 : Fin 5) ≠ 3) impossible
· funext e
apply propext
refine ⟨And.left, ?_⟩
intro he
rcases he with rfl | rfl
· exact ⟨Or.inl rfl, by decide, by unfold sharingBatch edgeUnion reverseEdge; decide⟩
· exact ⟨Or.inr rfl, by decide, by unfold sharingBatch edgeUnion reverseEdge; decide⟩
end QBD.Ch02
#print axioms QBD.Ch02.creationHeight_unique
#print axioms QBD.Ch02.frozen_constructor_confluence
#print axioms QBD.Ch02.reciprocal_pair_cancellation
#print axioms QBD.Ch02.vertex_sharing_example
Verification Summary:
The machine-checked proofs confirm that frozen-snapshot candidate evaluation produces a unique merged graph independent of processing order, that reciprocal cancellation enforces asymmetry across concurrent proposals, and that sequential evaluation can depend on order at a shared vertex. Dynamical selection probabilities remain outside this kinematic formalization. The Lean 4 kernel accepts all closed proof terms using only standard axioms, certifying the confluence claims of Confluence of the Constructor §2.4.2.
In Plain English:
Machine-checked Lean 4 proofs certify the discrete claims formalized in Section 2.4.2.3.
2.4.3 Lemma: Chordlessness of Maximal Cycles
Let the input be exactly the isolated directed cycle with edges , . Then this initial maximal cycle is chordless and each of its perimeter two-paths passes candidate-relative PUC (Principle of Unique Causality (PUC) §2.3.4).
In Plain English:
Section 2.4.3 formalizes the properties of the QBD lemma regarding chordlessness of maximal cycles.
2.4.3.1 Proof: Chordlessness of Maximal Cycles
I. Perimeter Adjacency
Let with and . The outgoing set of vertex is exactly . Hence a directed edge joining nonconsecutive perimeter vertices would require its target to equal , contrary to nonconsecutiveness.
II. Path Existence and Uniqueness
For fixed , the ordered path has two edges of . The congruences and give pairwise distinctness. Also
both impossible for . If , the first condition gives and the second then gives . Thus the unique path of length one or two from to is the displayed two-path (Principle of Unique Causality (PUC) §2.3.4).
III. Enumeration of Candidates
Every simple two-path beginning at must use and then , since both outgoing sets are singletons. For the associated chord map,
by equality of target coordinates. Therefore the full frozen list contains exactly distinct candidate chords (Chordlessness of Maximal Cycles §2.4.3).
Q.E.D.
In Plain English:
Section 2.4.3.1 formalizes the properties of the QBD proof regarding chordlessness of maximal cycles.
2.4.3.2 Type-Theoretic Validation via Lean 4 Core
Type-theoretic certification of the chordlessness and perimeter constructibility established in Chordlessness of Maximal Cycles §2.4.3 proceeds via the following verification strategy:
- Model: Isolated directed cycles of length at least four, perimeter two-paths, candidate-relative unique support checks, and reciprocal-chord thresholds represent maximal chordless cycles.
- Certified Claims: The module certifies that isolated cycles are chordless, that every perimeter two-path passes candidate-relative unique support, that reciprocal chord collisions occur precisely at length four, and that all candidate chords remain asymmetric for lengths at least five in Chordlessness of Maximal Cycles §2.4.3.1.
- Scope Boundary: The certificate analyzes isolated directed cycles and their immediate perimeter chords. Ambient edges outside the cycle can alter local support and are treated separately in general graphs.
import QBD.Ch02.L2_4_2_ConstructorConfluence
namespace QBD.Ch02
-- Advance a vertex by a given offset around an isolated cycle.
def cycleShift {k : Nat} (i : Fin k) (offset : Nat) : Fin k :=
⟨(i.val + offset) % k, Nat.mod_lt _ (Nat.zero_lt_of_lt i.isLt)⟩
-- The only outgoing perimeter edge advances by one modulo the cycle length.
def PerimeterEdge {k : Nat} (u v : Fin k) : Prop :=
v.val = (u.val + 1) % k
-- The return chord closes the perimeter path with two edges.
def returnChord {k : Nat} (i : Fin k) : Fin k × Fin k := (cycleShift i 2, i)
-- The isolated cycle after adjoining every candidate return chord.
def ChordedCycleEdge {k : Nat} (u v : Fin k) : Prop :=
PerimeterEdge u v ∨ ∃ i, returnChord i = (u, v)
/-- Successive displacements compose by adding their offsets before modular reduction. -/
private theorem cycleShift_add {k : Nat} (i : Fin k) (a b : Nat) :
cycleShift (cycleShift i a) b = cycleShift i (a + b) := by
apply Fin.ext
simp [cycleShift, Nat.add_assoc]
-- Nontrivial displacements within one circuit.
/-- An offset strictly between zero and a full circuit changes the vertex. -/
private theorem cycleShift_ne_self {k : Nat} (i : Fin k) {offset : Nat}
(positive : 0 < offset) (short : offset < k) : cycleShift i offset ≠ i := by
intro eq
have same : (i.val + offset) % k = i.val := congrArg Fin.val eq
have bound := i.isLt
by_cases wraps : k ≤ i.val + offset
· rw [Nat.mod_eq_sub_mod wraps, Nat.mod_eq_of_lt (by omega : i.val + offset - k < k)] at same
omega
· rw [Nat.mod_eq_of_lt (by omega : i.val + offset < k)] at same
omega
-- Outgoing adjacency on the perimeter.
/-- Perimeter membership is equivalent to being the unique one-step successor. -/
private theorem perimeter_iff {k : Nat} {u v : Fin k} :
PerimeterEdge u v ↔ v = cycleShift u 1 :=
⟨fun edge => Fin.ext edge, fun eq => congrArg Fin.val eq⟩
-- Chordlessness of the isolated perimeter.
/-- Vertices nonconsecutive in either direction have no perimeter edge between them. -/
theorem isolated_cycle_chordless {k : Nat} (_size : 4 ≤ k) (u v : Fin k)
(notNext : v ≠ cycleShift u 1) (notPrevious : u ≠ cycleShift v 1) :
¬ PerimeterEdge u v ∧ ¬ PerimeterEdge v u :=
⟨fun edge => notNext (perimeter_iff.mp edge),
fun edge => notPrevious (perimeter_iff.mp edge)⟩
-- Distinctness and PUC for the isolated perimeter.
/-- Every perimeter two-path has distinct vertices, has neither endpoint shortcut,
and is the unique path of length at most two between its endpoints. -/
theorem isolated_cycle_two_path {k : Nat} (size : 4 ≤ k) (i : Fin k) :
let next := cycleShift i 1
let last := cycleShift i 2
i ≠ next ∧ i ≠ last ∧ next ≠ last ∧ ¬ PerimeterEdge last i ∧
IsCompliant2Path PerimeterEdge i next last := by
dsimp only
have distinct₁ : i ≠ cycleShift i 1 := Ne.symm (cycleShift_ne_self i (by decide) (by omega))
have distinct₂ : i ≠ cycleShift i 2 := Ne.symm (cycleShift_ne_self i (by decide) (by omega))
have steps : cycleShift (cycleShift i 1) 1 = cycleShift i 2 := cycleShift_add i 1 1
have distinct₃ : cycleShift i 1 ≠ cycleShift i 2 := by
rw [← steps]
exact Ne.symm (cycleShift_ne_self _ (by decide) (by omega))
refine ⟨distinct₁, distinct₂, distinct₃, ?_, ?_⟩
· intro reverse
have third : i = cycleShift i 3 := (perimeter_iff.mp reverse).trans (cycleShift_add i 2 1)
exact cycleShift_ne_self i (by decide) (by omega) third.symm
· exact ⟨perimeter_iff.mpr rfl, perimeter_iff.mpr steps.symm,
fun direct => distinct₃ (perimeter_iff.mp direct).symm,
fun _ path => perimeter_iff.mp path.1⟩
-- Enumeration of candidate return chords.
/-- The target coordinate recovers the index, giving exactly one distinct candidate per vertex. -/
theorem return_chord_injective {k : Nat} : Function.Injective (@returnChord k) :=
fun _ _ eq => congrArg Prod.snd eq
-- Exact threshold for reciprocal return chords.
/-- Two candidates are reversals precisely at length four for indices two steps apart. -/
theorem reciprocal_chord_threshold {k : Nat} (size : 4 ≤ k) (i j : Fin k) :
returnChord i = reverseEdge (returnChord j) ↔ k = 4 ∧ j.val = (i.val + 2) % 4 := by
constructor
· intro reverse
have ahead : cycleShift i 2 = j := congrArg Prod.fst reverse
have back : i = cycleShift j 2 := congrArg Prod.snd reverse
have circuit : i = cycleShift i 4 := back.trans ((congrArg (fun x => cycleShift x 2)
ahead.symm).trans (cycleShift_add i 2 2))
have four : k = 4 := by
by_cases equal : k = 4
· exact equal
· exact False.elim (cycleShift_ne_self i (by decide) (by omega) circuit.symm)
exact ⟨four, by simpa [cycleShift, four] using congrArg Fin.val ahead.symm⟩
· rintro ⟨rfl, ahead⟩
have next : j = cycleShift i 2 := Fin.ext ahead
have circuit : cycleShift i 4 = i := by
apply Fin.ext
exact (Nat.add_mod_right i.val 4).trans (Nat.mod_eq_of_lt i.isLt)
subst j
exact Prod.ext rfl ((cycleShift_add i 2 2).trans circuit).symm
-- Reciprocal candidates above the four-cycle threshold.
/-- At length five or above, the reversal of a return chord is never another candidate. -/
theorem no_reciprocal_return_chords {k : Nat} (size : 5 ≤ k) (i j : Fin k) :
returnChord i ≠ reverseEdge (returnChord j) := by
intro reverse
have four := ((reciprocal_chord_threshold (by omega) i j).mp reverse).1
omega
-- Reciprocal perimeter and return edges.
/-- The reverse of a return chord skips one perimeter step for every cycle of length at least four. -/
theorem return_chord_not_reciprocal_to_perimeter {k : Nat} (size : 4 ≤ k) (i : Fin k) :
¬ PerimeterEdge (returnChord i).2 (returnChord i).1 := by
obtain ⟨_, _, _, _, _, _, noShortcut, _⟩ := isolated_cycle_two_path size i
exact noShortcut
-- Asymmetry and irreflexivity of the fully chorded isolated cycle.
/-- At length five or above, the perimeter together with all return chords has
neither opposite directed edges nor loops. -/
theorem chorded_cycle_asymmetric_irreflexive {k : Nat} (size : 5 ≤ k) :
(∀ u v : Fin k, ChordedCycleEdge u v → ¬ ChordedCycleEdge v u) ∧
(∀ u : Fin k, ¬ ChordedCycleEdge u u) := by
have atLeastFour : 4 ≤ k := by omega
have asymmetric (u v : Fin k) (forward : ChordedCycleEdge u v)
(backward : ChordedCycleEdge v u) : False := by
rcases forward with perimeter | ⟨i, chord⟩
· rcases backward with backPerimeter | ⟨j, backChord⟩
· have first := perimeter_iff.mp perimeter
have second := perimeter_iff.mp backPerimeter
rw [first, cycleShift_add] at second
exact cycleShift_ne_self u (offset := 2) (by decide) (by omega) second.symm
· exact return_chord_not_reciprocal_to_perimeter atLeastFour j
(by simpa only [backChord] using perimeter)
· rcases backward with backPerimeter | ⟨j, backChord⟩
· exact return_chord_not_reciprocal_to_perimeter atLeastFour i
(by simpa only [chord] using backPerimeter)
· exact no_reciprocal_return_chords size i j (by rw [chord, backChord]; rfl)
exact ⟨asymmetric, fun u loop => asymmetric u u loop loop⟩
end QBD.Ch02
#print axioms QBD.Ch02.isolated_cycle_chordless
#print axioms QBD.Ch02.isolated_cycle_two_path
#print axioms QBD.Ch02.reciprocal_chord_threshold
#print axioms QBD.Ch02.chorded_cycle_asymmetric_irreflexive
Verification Summary:
The machine-checked proofs establish that isolated directed cycles of length at least four are chordless, that every perimeter two-path satisfies candidate-relative unique support, and that reciprocal chord pairs arise exclusively at length four while cycles of length five or more yield asymmetric chord sets. Ambient external edges remain outside this isolated-cycle module. The Lean 4 kernel accepts all closed proof terms using only standard axioms, certifying the structural claims of Chordlessness of Maximal Cycles §2.4.3.
In Plain English:
Machine-checked Lean 4 proofs certify the discrete claims formalized in Section 2.4.3.3.
2.4.4 Lemma: Reduction via Deletion
Let denote an edge belonging to a simple cycle of maximal length within a graph characterized by the state valuation (Lexicographic Potential §2.3.5). Then the deletion of yields a graph satisfying the strict descent condition .
In Plain English:
Section 2.4.4 formalizes the properties of the QBD lemma regarding reduction via deletion.
2.4.4.1 Proof: Reduction via Deletion
I. Cycle Families Before Deletion
Let have maximal simple-cycle length and cycles of that length (Lexicographic Potential §2.3.5). Fix one maximal cycle and . For each length , define
In particular , so .
II. Exact Cycle-Set Identity
Deletion gives (Edge Deletion Task §1.5.3). If , all its edges lie in , so and . Conversely, if and , all its edges remain in , so . Thus
No cycle of length greater than can appear, since every remaining cycle already belonged to .
III. The Two Potential Cases
At length ,
If this number is positive, then and
If it is zero, no length- cycle survives, and none longer exists. Thus ; use if no cycles remain. The first coordinate then gives regardless of the second coordinate.
Q.E.D.
In Plain English:
Section 2.4.4.1 formalizes the properties of the QBD proof regarding reduction via deletion.
2.4.4.2 Type-Theoretic Validation via Lean 4 Core
Type-theoretic certification of the deletion-based cycle reduction and finite termination established in Reduction via Deletion §2.4.4 proceeds via the following verification strategy:
- Model: Finite directed graphs, exact catalogs of simple directed cycles, single-edge deletion filters, lexicographic cycle potentials, and finite reduction prefixes represent iterative cycle pruning.
- Certified Claims: The module certifies exactness of the finite cycle catalog, strict lexicographic potential descent whenever an edge on a maximal cycle is deleted, finite termination of strictly descending deletion sequences, and prefix completion to a maximal-cycle-free state in Reduction via Deletion §2.4.4.1.
- Scope Boundary: Strict descent is certified for deletions targeting edges of maximal cycles. General addition steps that create longer cycles are analyzed separately in the parallel-update module.
import QBD.Ch02.L2_3_5_LexicographicPotential
namespace QBD.Ch02
variable {n : Nat} {V : Type}
-- Delete an ordered edge from the finite edge set.
def deleteEdge (edges : List (Edge (Fin n))) (e : Edge (Fin n)) : List (Edge (Fin n)) :=
edges.filter (fun a => decide (a ≠ e))
-- One pruning step removes any edge of any active cycle longer than three.
inductive PruneStep {n : Nat} : List (Edge (Fin n)) → List (Edge (Fin n)) → Prop where
| remove {edges : List (Edge (Fin n))} {cycle : List (Fin n)} {e : Edge (Fin n)}
(active : cycle ∈ activeCycles edges) (long : 3 < cycle.length)
(onCycle : e ∈ indexedCycleEdges cycle) : PruneStep edges (deleteEdge edges e)
-- A counted run can follow any sequence of legal pruning choices.
inductive PruneRun {n : Nat} : Nat → List (Edge (Fin n)) → List (Edge (Fin n)) → Prop where
| zero (edges : List (Edge (Fin n))) : PruneRun 0 edges edges
| next {j : Nat} {start middle finish : List (Edge (Fin n))}
(step : PruneStep start middle) (rest : PruneRun j middle finish) :
PruneRun (j + 1) start finish
/-- Every list of allowed vertices appears at each bound at least as large as its length. -/
private theorem mem_vertexLists {vertices : List V} {bound : Nat} {cycle : List V}
(length : cycle.length ≤ bound) (allowed : cycle ⊆ vertices) :
cycle ∈ boundedLists vertices bound := by
induction bound generalizing cycle with
| zero =>
have empty : cycle = [] := List.length_eq_zero_iff.mp (Nat.eq_zero_of_le_zero length)
simp [empty, boundedLists]
| succ bound ih =>
cases cycle with
| nil => simp [boundedLists]
| cons v rest =>
apply List.mem_cons_of_mem
exact List.mem_flatMap.mpr ⟨v, allowed (by simp), List.mem_map.mpr
⟨rest, ih (by simpa using length) (fun _ h => allowed (List.mem_cons_of_mem _ h)), rfl⟩⟩
-- Uniqueness in the bounded enumeration.
/-- Different first vertices give disjoint blocks, with no duplicates in any block. -/
private theorem vertexLists_nodup {vertices : List V} (unique : vertices.Nodup) (bound : Nat) :
(boundedLists vertices bound).Nodup := by
induction bound with
| zero => simp [boundedLists]
| succ bound ih =>
simp only [boundedLists, List.nodup_cons, List.mem_flatMap, List.mem_map, List.cons_ne_nil,
and_false, exists_false, not_false_eq_true, true_and]
apply List.pairwise_flatMap.mpr
constructor
· intro v _
apply List.pairwise_map.mpr
exact ih.imp (fun ne eq => ne (List.cons.inj eq).2)
· exact unique.imp fun ne _ hx _ hy eq => by
obtain ⟨xs, _, rfl⟩ := List.mem_map.mp hx
obtain ⟨ys, _, rfl⟩ := List.mem_map.mp hy
exact ne (List.cons.inj eq).1
-- The size of a simple cycle on Fin n is at most n.
/-- Distinct vertices inject into the full finite vertex enumeration. -/
theorem simpleCycle_length_le {cycle : List (Fin n)} (simple : IsCanonicalCycle cycle) :
cycle.length ≤ n := by
simpa using simple.1.length_le_of_subset (fun a _ => List.mem_finRange a)
-- Exactness of the cycle catalog.
/-- The catalog lists precisely the canonical simple cycles and lists each once. -/
theorem cycle_catalog_exact (n : Nat) :
(cycleCatalog n).Nodup ∧
(∀ cycle, cycle ∈ cycleCatalog n ↔ IsCanonicalCycle cycle) := by
constructor
· exact (vertexLists_nodup (List.nodup_finRange n) n).filter _
· intro cycle
have check : simpleCycleCheck cycle = true ↔ IsCanonicalCycle cycle := by
cases cycle with
| nil => simp [simpleCycleCheck, IsCanonicalCycle]
| cons start rest =>
simp only [simpleCycleCheck, Bool.and_eq_true, List.all_eq_true, decide_eq_true_eq,
IsCanonicalCycle]
exact ⟨fun ⟨distinct, minimum⟩ => ⟨distinct, start, rest, rfl, minimum⟩,
fun ⟨distinct, a, tail, eq, minimum⟩ => by cases eq; exact ⟨distinct, minimum⟩⟩
simp only [cycleCatalog, List.mem_filter, check]
exact ⟨And.right, fun simple =>
⟨mem_vertexLists (simpleCycle_length_le simple) (fun a _ => List.mem_finRange a), simple⟩⟩
-- Active cycle membership.
/-- An active cycle is simple, canonical, and uses only active edges. -/
theorem mem_activeCycles {edges : List (Edge (Fin n))} {cycle : List (Fin n)} :
cycle ∈ activeCycles edges ↔ IsCanonicalCycle cycle ∧ ∀ e ∈ indexedCycleEdges cycle, e ∈ edges := by
simp [activeCycles, (cycle_catalog_exact n).2, List.all_eq_true]
-- Edge membership after deletion.
/-- Deletion keeps precisely the old edges other than the selected pair. -/
theorem mem_deleteEdge {edges : List (Edge (Fin n))} {e a : Edge (Fin n)} :
a ∈ deleteEdge edges e ↔ a ∈ edges ∧ a ≠ e := by
simp [deleteEdge]
-- Exact cycle survival under edge deletion.
/-- A cycle remains active precisely when it was active and did not traverse the deleted edge. -/
theorem deletion_cycle_filter (edges : List (Edge (Fin n))) (e : Edge (Fin n))
(cycle : List (Fin n)) :
cycle ∈ activeCycles (deleteEdge edges e) ↔ cycle ∈ activeCycles edges ∧
e ∉ indexedCycleEdges cycle := by
simp only [mem_activeCycles, mem_deleteEdge]
constructor
· rintro ⟨simple, keep⟩
exact ⟨⟨simple, fun a ha => (keep a ha).1⟩, fun he => (keep e he).2 rfl⟩
· rintro ⟨⟨simple, old⟩, avoids⟩
exact ⟨simple, fun a ha => ⟨old a ha, fun eq => avoids (eq ▸ ha)⟩⟩
-- Preservation of the order of surviving length classes.
/-- Filtering a length class by the deleted edge yields the new length class as a list. -/
private theorem cyclesAt_deleteEdge (edges : List (Edge (Fin n))) (e : Edge (Fin n)) (k : Nat) :
cyclesAt (deleteEdge edges e) k = (cyclesAt edges k).filter (fun c => !usesEdge e c) := by
simp only [cyclesAt, activeCycles, List.filter_filter]
apply List.filter_congr
intro cycle _
apply Bool.eq_iff_iff.mpr
simp only [Bool.and_eq_true, Bool.not_eq_true', usesEdge, decide_eq_true_eq, decide_eq_false_iff_not,
List.all_eq_true, mem_deleteEdge]
constructor
· rintro ⟨length, keep⟩
exact ⟨fun he => (keep e he).2 rfl, length, fun a ha => (keep a ha).1⟩
· rintro ⟨avoid, length, old⟩
exact ⟨length, fun a ha => ⟨old a ha, fun eq => avoid (eq ▸ ha)⟩⟩
-- Every length-class count loses exactly the cycles through the deleted edge.
/-- The new count is the old count minus the count of active cycles of that length through the edge. -/
theorem deletion_cycle_count (edges : List (Edge (Fin n))) (e : Edge (Fin n)) (k : Nat) :
(cyclesAt (deleteEdge edges e) k).length =
(cyclesAt edges k).length - ((cyclesAt edges k).filter (usesEdge e)).length := by
rw [cyclesAt_deleteEdge]
have partition := List.countP_eq_countP_filter_add (cyclesAt edges k) (fun _ => true) (usesEdge e)
simp only [List.countP_true] at partition
omega
-- The longest length is bounded by any common bound on active lengths.
/-- This includes the empty graph, whose longest-cycle length is zero. -/
theorem longestCycle_le {edges : List (Edge (Fin n))} {bound : Nat}
(upper : ∀ c ∈ activeCycles edges, c.length ≤ bound) : longestCycle edges ≤ bound := by
unfold longestCycle
cases h : ((activeCycles edges).map List.length).max? with
| none => exact Nat.zero_le _
| some m => exact (List.max?_le_iff h).mpr (by simpa using upper)
-- Every active cycle is bounded by the maximum.
/-- Membership supplies a lower bound on the longest active length. -/
theorem length_le_longestCycle {edges : List (Edge (Fin n))} {c : List (Fin n)}
(active : c ∈ activeCycles edges) : c.length ≤ longestCycle edges :=
List.le_max?_getD_of_mem (List.mem_map_of_mem active)
-- Removing an edge cannot increase the longest cycle.
/-- Every surviving cycle belonged to the old graph, so no greater length appears. -/
theorem longest_cycle_nonincrease (edges : List (Edge (Fin n))) (e : Edge (Fin n)) :
longestCycle (deleteEdge edges e) ≤ longestCycle edges :=
longestCycle_le fun c hc => length_le_longestCycle ((deletion_cycle_filter edges e c).mp hc).1
-- Strict lexicographic descent at a maximal-cycle deletion.
/-- If a maximal cycle is hit, the maximal length drops or its multiplicity strictly decreases. -/
theorem maximal_cycle_deletion_descends {edges : List (Edge (Fin n))}
{e : Edge (Fin n)} {c : List (Fin n)} (active : c ∈ activeCycles edges)
(maximal : c.length = longestCycle edges) (hit : e ∈ indexedCycleEdges c) :
Prod.Lex (· < ·) (· < ·) (potential (deleteEdge edges e)) (potential edges) := by
let L := longestCycle edges
let new := deleteEdge edges e
have positive : 0 < L := by
obtain ⟨_, start, rest, eq, _⟩ := (mem_activeCycles.mp active).1
change 0 < longestCycle edges
rw [← maximal, eq]
simp
have destroyed : 0 < ((cyclesAt edges L).filter (usesEdge e)).length := by
apply List.length_pos_iff.mpr
exact List.ne_nil_of_mem (a := c) (by simp [cyclesAt, active, maximal, L, usesEdge, hit])
by_cases survivors : 0 < (cyclesAt new L).length
· obtain ⟨d, hd⟩ := List.exists_mem_of_ne_nil _ (List.length_pos_iff.mp survivors)
have data : d ∈ activeCycles new ∧ d.length = L := by simpa [cyclesAt] using hd
have same : longestCycle new = L := by
have lower := length_le_longestCycle data.1
exact Nat.le_antisymm (longest_cycle_nonincrease edges e) (data.2 ▸ lower)
have count := deletion_cycle_count edges e L
change (cyclesAt new L).length =
(cyclesAt edges L).length - ((cyclesAt edges L).filter (usesEdge e)).length at count
change Prod.Lex (· < ·) (· < ·)
(longestCycle new, (cyclesAt new (longestCycle new)).length) (L, (cyclesAt edges L).length)
rw [same]
exact Prod.Lex.right L (by change (cyclesAt new L).length < _; omega)
· have lower : longestCycle new ≤ L - 1 := longestCycle_le fun d hd => by
have upper := length_le_longestCycle ((deletion_cycle_filter edges e d).mp hd).1
have ne : d.length ≠ L := by
intro eq
have member : d ∈ cyclesAt new L := by simp [cyclesAt, hd, eq]
exact survivors (List.length_pos_iff.mpr (List.ne_nil_of_mem member))
omega
exact Prod.Lex.left _ _ (show longestCycle new < L by omega)
-- The pruning edge budget for arbitrary legal prefixes.
/-- Each legal step removes one existing edge and keeps the edge list free of duplicates. -/
theorem pruning_edge_count {start finish : List (Edge (Fin n))} {j : Nat}
(run : PruneRun j start finish) (unique : start.Nodup) :
finish.length = start.length - j ∧ j ≤ start.length ∧ finish.Nodup := by
induction run with
| zero => exact ⟨by simp, Nat.zero_le _, unique⟩
| @next j edges middle finish step rest ih =>
cases step with
| @remove cycle e active _ onCycle =>
have present := (mem_activeCycles.mp active).2 e onCycle
have nonempty := List.length_pos_iff.mpr (List.ne_nil_of_mem present)
have filtered : (deleteEdge edges e).Nodup := unique.filter _
have one : (deleteEdge edges e).length = edges.length - 1 := by
have erase : edges.erase e = deleteEdge edges e := by
rw [unique.erase_eq_filter]
rfl
rw [← erase, List.length_erase_of_mem present]
obtain ⟨count, bounded, finishUnique⟩ := ih filtered
exact ⟨by omega, by omega, finishUnique⟩
-- A nonterminal graph always supplies a pruning edge.
/-- Any active cycle longer than three has an edge that can legally be removed. -/
theorem pruning_progress {edges : List (Edge (Fin n))} (long : 3 < longestCycle edges) :
∃ finish, PruneStep edges finish := by
by_cases existsLong : ∃ c ∈ activeCycles edges, 3 < c.length
· obtain ⟨cycle, active, size⟩ := existsLong
have nonempty : indexedCycleEdges cycle ≠ [] := by
apply List.length_pos_iff.mp
simpa [indexedCycleEdges] using (show 0 < cycle.length by omega)
obtain ⟨e, he⟩ := List.exists_mem_of_ne_nil _ nonempty
exact ⟨_, .remove active size he⟩
· have bound := longestCycle_le (edges := edges) (bound := 3) fun c hc => by
exact Nat.le_of_not_gt (fun size => existsLong ⟨c, hc, size⟩)
exact False.elim (Nat.not_lt_of_ge bound long)
-- Termination of deletion-only pruning.
/-- Every finite state can reach a graph with longest cycle at most three within its edge budget.
The same theorem applies after any legal prefix, using the remaining edge count. -/
theorem pruning_terminates (edges : List (Edge (Fin n))) (unique : edges.Nodup) :
∃ j finish, PruneRun j edges finish ∧ j ≤ edges.length ∧ longestCycle finish ≤ 3 := by
by_cases done : longestCycle edges ≤ 3
· exact ⟨0, edges, .zero edges, Nat.zero_le _, done⟩
· obtain ⟨next, step⟩ := pruning_progress (Nat.lt_of_not_ge done)
obtain ⟨count, positive, nextUnique⟩ := pruning_edge_count (.next step (.zero next)) unique
have decreases : next.length < edges.length := by omega
obtain ⟨j, finish, rest, bounded, terminal⟩ := pruning_terminates next nextUnique
exact ⟨j + 1, finish, .next step rest, by omega, terminal⟩
termination_by edges.length
-- Completion after arbitrary legal pruning choices.
/-- Every legal prefix can be extended to a terminal state within the original edge budget. -/
theorem pruning_prefix_completes {start current : List (Edge (Fin n))} {j : Nat}
(run : PruneRun j start current) (unique : start.Nodup) :
∃ extra finish, PruneRun extra current finish ∧ j + extra ≤ start.length ∧
longestCycle finish ≤ 3 := by
obtain ⟨remaining, used, currentUnique⟩ := pruning_edge_count run unique
obtain ⟨extra, finish, suffix, bounded, terminal⟩ := pruning_terminates current currentUnique
exact ⟨extra, finish, suffix, by omega, terminal⟩
end QBD.Ch02
#print axioms QBD.Ch02.cycle_catalog_exact
#print axioms QBD.Ch02.deletion_cycle_filter
#print axioms QBD.Ch02.maximal_cycle_deletion_descends
#print axioms QBD.Ch02.pruning_terminates
#print axioms QBD.Ch02.pruning_prefix_completes
Verification Summary:
The machine-checked proofs confirm that deleting an edge belonging to a maximal simple cycle strictly decreases the lexicographic cycle potential, ensuring finite termination and prefix completion to a state free of cycles above the target length. Concurrent chord accretion is treated separately from pure deletion. The Lean 4 kernel accepts all closed proof terms using only standard axioms, certifying the reduction claims of Reduction via Deletion §2.4.4.
In Plain English:
Machine-checked Lean 4 proofs certify the discrete claims formalized in Section 2.4.4.3.
2.4.5 Lemma: Decrease in Parallel Updates
Let the isolated-cycle benchmark perform its single chord-addition phase followed by deletion-only pruning of cycles longer than three. Then it uses at most additions and deletions, and its final cycle potential is smaller than that of its initial (Chordlessness of Maximal Cycles §2.4.3).
In Plain English:
Section 2.4.5 formalizes the properties of the QBD lemma regarding decrease in parallel updates.
2.4.5.1 Proof: Decrease in Parallel Updates
I. Finite Edge Budget
The input has edges. The frozen perimeter list has distinct proposed chords, so the addition phase leaves at most edges.
II. Deletion Termination
Each pruning step selects an existing edge of a cycle longer than three and removes it. If is the current edge count, then . After removals the edge count is
Thus . A remaining cycle of length greater than three supplies an edge for one more deletion. At there are no edges, so the loop must stop by then with no cycle longer than three.
III. Final Potential
The initial longest cycle has length . The final graph has . Hence its lexicographic cycle potential is strictly smaller regardless of its remaining cycle multiplicity. The separate maximal-cycle edge-deletion lemma supplies strict lexicographic descent when that more specific deletion choice is used (Reduction via Deletion §2.4.4). The implementation's arbitrary long-cycle choice is certified here by edge count instead.
IV. Mutation Bound
These are the claimed mutation and final-potential bounds (Decrease in Parallel Updates §2.4.5).
Q.E.D.
In Plain English:
Section 2.4.5.1 formalizes the properties of the QBD proof regarding decrease in parallel updates.
2.4.5.2 Type-Theoretic Validation via Lean 4 Core
Type-theoretic certification of the parallel-update bounds and isolated-cycle termination established in Decrease in Parallel Updates §2.4.5 proceeds via the following verification strategy:
- Model: Finite chord addition budgets, isolated-cycle benchmark progressions, and lexicographic potential bounds represent synchronous parallel accretion and pruning cycles.
- Certified Claims: The module certifies the finite addition budget bound, exact potential progression on the isolated-cycle benchmark, and finite termination of the benchmark update schedule in Decrease in Parallel Updates §2.4.5.1.
- Scope Boundary: Termination is certified under the stated addition budget and isolated-cycle benchmark hypotheses. Arbitrary concurrent merges in general ambient graphs can transiently increase potential as noted in the commentary.
import QBD.Ch02.L2_4_4_ReductionViaDeletion
import QBD.Ch02.L2_4_3_ChordlessnessOfMaximalCycles
namespace QBD.Ch02
variable {n : Nat}
-- The perimeter of the isolated cycle is the increasing enumeration with a closing edge.
def perimeter (n : Nat) : List (Edge (Fin n)) := indexedCycleEdges (List.finRange n)
-- Return chords are indexed by the target vertex.
def indexedReturnChord (i : Fin n) : Edge (Fin n) :=
(⟨(i.val + 2) % n, Nat.mod_lt _ (Nat.zero_lt_of_lt i.isLt)⟩, i)
-- Phase one inserts the selected subset of the frozen return-chord candidates.
def chordedPerimeter (selected : List (Fin n)) : List (Edge (Fin n)) :=
perimeter n ++ selected.map indexedReturnChord
/-- Its edge list has length n and the source coordinate recovers the perimeter index. -/
private theorem perimeter_size (n : Nat) : (perimeter n).length = n ∧ (perimeter n).Nodup := by
constructor
· simp [perimeter, indexedCycleEdges]
· apply List.nodup_iff_eq_of_getElem_eq.mpr
intro i j hi hj eq
simpa [perimeter, indexedCycleEdges] using congrArg (fun e : Edge (Fin n) => e.1.val) eq
-- The isolated perimeter itself witnesses the initial maximum.
/-- The full canonical cycle has length n, and simplicity bounds every other length by n. -/
theorem isolated_perimeter_longest (size : 4 ≤ n) : longestCycle (perimeter n) = n := by
have simple : IsCanonicalCycle (List.finRange n) := by
obtain ⟨m, rfl⟩ := Nat.exists_eq_succ_of_ne_zero (by omega : n ≠ 0)
exact ⟨List.nodup_finRange _, 0, _, List.finRange_succ, fun v _ => Nat.zero_le v.val⟩
have active : List.finRange n ∈ activeCycles (perimeter n) :=
mem_activeCycles.mpr ⟨simple, fun _ he => he⟩
exact Nat.le_antisymm
(longestCycle_le fun _ hc => simpleCycle_length_le (mem_activeCycles.mp hc).1)
(by simpa using length_le_longestCycle active)
-- Return chords are fresh relative to the perimeter.
/-- A perimeter edge and a return chord cannot coincide when the perimeter has length at least four. -/
private theorem returnChord_not_perimeter (size : 4 ≤ n) (i : Fin n) :
indexedReturnChord i ∉ perimeter n := by
intro member
obtain ⟨j, eq⟩ := List.mem_ofFn.mp member
have source := congrArg (fun e : Edge (Fin n) => e.1.val) eq
have target := congrArg (fun e : Edge (Fin n) => e.2.val) eq
simp [indexedReturnChord] at source target
rw [source, Nat.mod_add_mod] at target
have within := i.isLt
by_cases wraps : n ≤ i.val + 2 + 1
· rw [Nat.mod_eq_sub_mod wraps,
Nat.mod_eq_of_lt (by omega : i.val + 2 + 1 - n < n)] at target
omega
· rw [Nat.mod_eq_of_lt (by omega : i.val + 2 + 1 < n)] at target
omega
-- Phase-one addition and edge budgets.
/-- A subset of the n indexed return chords supplies at most n distinct new edges,
and the resulting graph has at most twice the perimeter's edge count. -/
theorem parallel_addition_budget (size : 4 ≤ n) (selected : List (Fin n))
(distinct : selected.Nodup) :
selected.length ≤ n ∧ (chordedPerimeter selected).Nodup ∧
(chordedPerimeter selected).length = n + selected.length ∧
(chordedPerimeter selected).length ≤ 2 * n := by
have bounded : selected.length ≤ n := by
simpa using distinct.length_le_of_subset (fun a _ => List.mem_finRange a)
have chordsUnique : (selected.map indexedReturnChord).Nodup :=
List.pairwise_map.mpr (distinct.imp (fun ne eq => ne (congrArg Prod.snd eq)))
have unique : (chordedPerimeter selected).Nodup := by
apply List.nodup_append.mpr
refine ⟨(perimeter_size n).2, chordsUnique, ?_⟩
intro e old a added eq
obtain ⟨i, _, rfl⟩ := List.mem_map.mp added
exact returnChord_not_perimeter size i (eq ▸ old)
have count : (chordedPerimeter selected).length = n + selected.length := by
simp [chordedPerimeter, (perimeter_size n).1]
exact ⟨bounded, unique, count, by omega⟩
-- Guarantees for every terminal result of the two-phase benchmark.
/-- Every completed deletion run meets the deletion and total mutation budgets
and ends at a strictly smaller potential than the original isolated perimeter. -/
theorem parallel_benchmark_bounds (size : 4 ≤ n) {selected : List (Fin n)}
(distinct : selected.Nodup) {j : Nat} {finish : List (Edge (Fin n))}
(run : PruneRun j (chordedPerimeter selected) finish) (terminal : longestCycle finish ≤ 3) :
finish.length = (chordedPerimeter selected).length - j ∧
j ≤ (chordedPerimeter selected).length ∧ (chordedPerimeter selected).length ≤ 2 * n ∧
selected.length + j ≤ 3 * n ∧
Prod.Lex (· < ·) (· < ·) (potential finish) (potential (perimeter n)) := by
obtain ⟨adds, unique, _, budget⟩ := parallel_addition_budget size selected distinct
obtain ⟨count, deletes, _⟩ := pruning_edge_count run unique
refine ⟨count, deletes, budget, by omega, Prod.Lex.left _ _ ?_⟩
rw [isolated_perimeter_longest size]
omega
-- Termination of the two-phase benchmark within the perimeter budget.
/-- Every permissible chord selection has a completed pruning run in at most 2n deletions.
Every legal prefix obeys the same bound by the pruning edge count. -/
theorem parallel_benchmark_terminates (size : 4 ≤ n) (selected : List (Fin n))
(distinct : selected.Nodup) :
∃ j finish, PruneRun j (chordedPerimeter selected) finish ∧ j ≤ 2 * n ∧
longestCycle finish ≤ 3 := by
obtain ⟨_, unique, _, budget⟩ := parallel_addition_budget size selected distinct
obtain ⟨j, finish, run, deletes, terminal⟩ := pruning_terminates _ unique
exact ⟨j, finish, run, Nat.le_trans deletes budget, terminal⟩
end QBD.Ch02
#print axioms QBD.Ch02.parallel_addition_budget
#print axioms QBD.Ch02.parallel_benchmark_bounds
#print axioms QBD.Ch02.parallel_benchmark_terminates
Verification Summary:
The machine-checked proofs establish the finite chord addition budget and verify exact potential bounds and finite termination for the isolated-cycle parallel update benchmark. Unrestricted concurrent merges on general ambient graphs remain outside this benchmark certificate. The Lean 4 kernel accepts all closed proof terms using only standard axioms, certifying the update claims of Decrease in Parallel Updates §2.4.5.
In Plain English:
Machine-checked Lean 4 proofs certify the discrete claims formalized in Section 2.4.5.3.
2.4.6 Lemma: Sequential Constructor Diamond
Let the four endpoints be distinct with , both paths and pass PUC and the bounded reverse-witness guard, and the chord heights dominate old outgoing heights at their respective targets. Then both candidate admissions are preserved in either sequential order and the final active timestamped graph is the same.
In Plain English:
Section 2.4.6 formalizes the properties of the QBD lemma regarding sequential constructor diamond.
2.4.6.1 Proof: Sequential Constructor Diamond
I. Candidate Paths and Source Maxima
Write , , and let . A new two-path from to in must use either as or as . The first alternative forces and the second . Both contradict distinctness. Neither nor equals . Thus the candidate and both endpoint exclusions are unchanged (Geometric Constructibility §2.3.1).
For a new two-path from to in , would force and would force . Again neither is possible, and differs from both and . The source maxima satisfy
The retained old heights on these incoming sets are the same, so the height assigned to after is , and that assigned to after is .
II. Exclusion of New Reverse Witnesses
If a reverse witness from to after inserting uses , that edge enters , so the witness has a next edge . Strict increase would require
Similarly a new reverse witness from to using must leave along , requiring
Both inequalities are impossible. All other witnesses use only old edges, whose heights and common vertex-count cutoff are unchanged.
III. Equality of the Two Outputs
In both orders the output edge set is . At any output edge , both height functions equal
This proves equality as active timestamped graphs (Sequential Constructor Diamond §2.4.6).
Q.E.D.
In Plain English:
Section 2.4.6.1 formalizes the properties of the QBD proof regarding sequential constructor diamond.
2.4.6.2 Type-Theoretic Validation via Lean 4 Core
Type-theoretic certification of the sequential constructor diamond and monotone-path preservation established in Sequential Constructor Diamond §2.4.6 proceeds via the following verification strategy:
- Model: Timestamped directed graphs, two non-interfering sequential chord insertions, strictly increasing edge paths, and source-side creation heights represent sequential commutation.
- Certified Claims: The module certifies that non-interfering sequential insertions preserve strictly increasing edge paths and satisfy the sequential constructor diamond yielding identical adjacency and heights regardless of insertion order in Sequential Constructor Diamond §2.4.6.1.
- Scope Boundary: Commutation requires the explicit non-interference hypotheses between the two candidate chords. Interfering proposals sharing endpoints can yield order-dependent heights as separated in the confluence module.
import QBD.Ch02.L2_4_2_ConstructorConfluence
namespace QBD.Ch02
variable {V : Type}
-- Insert one fresh chord at its computed height.
def insertChord [DecidableEq V] (G : RelTimestampedGraph V) (chord : Edge V)
(h : Nat) : RelTimestampedGraph V where
E := fun e => G.edges e ∨ e = chord
H := fun e => if e = chord then h else G.height e
-- Strictly increasing timestamps along successive edges, as in the asymmetry baseline.
-- The bounded constructor guard uses simple reverse paths ending below the proposed height.
def HasReverseWitness (G : RelTimestampedGraph V) (cutoff : Nat) (start finish : V)
(height : Nat) : Prop :=
∃ (path : List (Edge V)) (last : Edge V),
2 ≤ path.length ∧ path.length ≤ cutoff ∧
DirectedEdgePath G.edges start finish path ∧ IsAdjacentHeightIncreasing G.height path ∧
(start :: path.map Prod.snd).Nodup ∧ path.getLast? = some last ∧ G.height last < height
-- Admission includes an absent return chord, PUC, the snapshot height, and the reverse guard.
structure AdmissibleChord (G : RelTimestampedGraph V) (cutoff : Nat)
(start middle finish : V) (height : Nat) : Prop where
fresh : ¬ G.edges (finish, start)
puc : IsCompliant2Path (fun a b => G.edges (a, b)) start middle finish
creation : IsCreationHeight G finish height
guard : ¬ HasReverseWitness G cutoff start finish height
-- Membership and height of an ordered pair unaffected by an insertion.
/-- Every pair distinct from the inserted chord keeps its old membership and height. -/
private theorem insertChord_other [DecidableEq V] (G : RelTimestampedGraph V)
{chord pair : Edge V} (h : Nat) (different : pair ≠ chord) :
((insertChord G chord h).edges pair ↔ G.edges pair) ∧
(insertChord G chord h).height pair = G.height pair := by
simp [insertChord, RelTimestampedGraph.edges, RelTimestampedGraph.height, different]
/-- Every strictly increasing path ending away from the new chord's target avoids that chord
and remains the same strictly increasing path in the old snapshot, at any path length. -/
theorem increasing_path_after_insert [DecidableEq V] (G : RelTimestampedGraph V)
(chord : Edge V) (h : Nat) (finish : V) (different : chord.2 ≠ finish)
(dominates : ∀ z, G.edges (chord.2, z) → G.height (chord.2, z) ≤ h)
(path : List (Edge V)) (start : V)
(directed : DirectedEdgePath (insertChord G chord h).edges start finish path)
(monotone : IsAdjacentHeightIncreasing (insertChord G chord h).height path) :
(∀ e ∈ path, e ≠ chord) ∧
DirectedEdgePath G.edges start finish path ∧ IsAdjacentHeightIncreasing G.height path := by
induction path generalizing start with
| nil => exact ⟨by simp, directed, trivial⟩
| cons e rest ih =>
obtain ⟨active, linked, tailPath⟩ := directed
have tailMonotone : IsAdjacentHeightIncreasing (insertChord G chord h).height rest := by
cases rest with
| nil => trivial
| cons => exact monotone.2
obtain ⟨avoids, oldTail, oldMonotone⟩ := ih e.2 tailPath tailMonotone
have firstOther : e ≠ chord := by
intro eq
subst e
cases rest with
| nil => exact different tailPath
| cons next more =>
obtain ⟨nextOld, nextSource, _⟩ := oldTail
have nextOther := avoids next (by simp)
have comparison := monotone.1
have upper : G.height next ≤ h := by
cases next
cases nextSource
exact dominates _ nextOld
change (insertChord G chord h).height chord < (insertChord G chord h).height next
at comparison
rw [(insertChord_other G h nextOther).2] at comparison
have chordHeight : (insertChord G chord h).height chord = h := by simp [insertChord, RelTimestampedGraph.height]
rw [chordHeight] at comparison
exact Nat.not_lt_of_ge upper comparison
have firstOld := insertChord_other G h firstOther
refine ⟨?_, ⟨firstOld.1.mp active, linked, oldTail⟩, ?_⟩
· intro a ha
rcases List.mem_cons.mp ha with eq | tail
· exact eq.symm ▸ firstOther
· exact avoids a tail
· cases rest with
| nil => trivial
| cons next more =>
have comparison := monotone.1
change (insertChord G chord h).height e < (insertChord G chord h).height next
at comparison
rw [firstOld.2, (insertChord_other G h (avoids next (by simp))).2] at comparison
exact ⟨comparison, oldMonotone⟩
-- Preserve the other candidate's local data after a single insertion.
/-- A chord away from the relevant incoming and outgoing sets preserves the candidate,
including its original height and its bounded reverse-witness guard. -/
private theorem admission_after_insert [DecidableEq V] (G : RelTimestampedGraph V)
{a b start middle finish : V} {cutoff h hOther : Nat}
(differentStart : a ≠ start) (differentSource : a ≠ finish)
(differentTarget : b ≠ finish)
(dominates : ∀ z, G.edges (b, z) → G.height (b, z) ≤ h)
(candidate : AdmissibleChord G cutoff start middle finish hOther) :
AdmissibleChord (insertChord G (a, b) h) cutoff start middle finish hOther ∧
(∀ z, ((insertChord G (a, b) h).edges (z, finish) ↔ G.edges (z, finish)) ∧
(insertChord G (a, b) h).height (z, finish) = G.height (z, finish)) := by
let updated := insertChord G (a, b) h
have outgoing (z : V) : updated.edges (start, z) ↔ G.edges (start, z) :=
(insertChord_other G h (fun eq => differentStart (congrArg Prod.fst eq).symm)).1
have incoming (z : V) : (updated.edges (z, finish) ↔ G.edges (z, finish)) ∧
updated.height (z, finish) = G.height (z, finish) :=
insertChord_other G h (fun eq => differentTarget (congrArg Prod.snd eq).symm)
have unchangedReturn : updated.edges (finish, start) ↔ G.edges (finish, start) :=
(insertChord_other G h (fun eq => differentSource (congrArg Prod.fst eq).symm)).1
refine ⟨⟨fun present => candidate.fresh (unchangedReturn.mp present), ?_, ?_, ?_⟩, incoming⟩
· obtain ⟨first, second, noBypass, unique⟩ := candidate.puc
exact ⟨(outgoing middle).mpr first, (incoming middle).1.mpr second,
fun bypass => noBypass ((outgoing finish).mp bypass), fun z path =>
unique z ⟨(outgoing z).mp path.1, (incoming z).1.mp path.2⟩⟩
· have creation := candidate.creation
change IsCreationHeight updated finish hOther
simpa only [IsCreationHeight, fun z => (incoming z).1, fun z => (incoming z).2] using creation
· rintro ⟨path, last, minimum, bound, directed, mono, simple, endpoint, below⟩
obtain ⟨avoids, oldPath, oldMono⟩ :=
increasing_path_after_insert G (a, b) h finish differentTarget dominates path start
directed mono
have lastOther := avoids last (List.mem_of_getLast? endpoint)
rw [(insertChord_other G h lastOther).2] at below
exact candidate.guard ⟨path, last, minimum, bound, oldPath, oldMono, simple, endpoint, below⟩
-- Sequential constructor diamond for the two overlapping support paths.
/-- Inserting either candidate preserves the other's PUC, both endpoint exclusions,
incoming heights, and bounded guard. The two completed orders have the same union and heights. -/
theorem sequential_constructor_diamond [DecidableEq V] (G : RelTimestampedGraph V)
(v w u x : V) (distinct : FourDistinct v w u x) (_noCross : ¬ G.edges (v, x))
(cutoff h₁ h₂ : Nat)
(first : AdmissibleChord G cutoff v w u h₁)
(second : AdmissibleChord G cutoff w u x h₂)
(dominates₁ : ∀ z, G.edges (v, z) → G.height (v, z) ≤ h₁)
(dominates₂ : ∀ z, G.edges (w, z) → G.height (w, z) ≤ h₂) :
let G₁ := insertChord G (u, v) h₁
let G₂ := insertChord G (x, w) h₂
let G₁₂ := insertChord G₁ (x, w) h₂
let G₂₁ := insertChord G₂ (u, v) h₁
AdmissibleChord G₁ cutoff w u x h₂ ∧ AdmissibleChord G₂ cutoff v w u h₁ ∧
(∀ z, (G₁.edges (z, x) ↔ G.edges (z, x)) ∧ G₁.height (z, x) = G.height (z, x)) ∧
(∀ z, (G₂.edges (z, u) ↔ G.edges (z, u)) ∧ G₂.height (z, u) = G.height (z, u)) ∧
(∀ h, IsCreationHeight G₁ x h → h = h₂) ∧
(∀ h, IsCreationHeight G₂ u h → h = h₁) ∧
G₁₂.edges = (fun e => G.edges e ∨ e = (u, v) ∨ e = (x, w)) ∧
G₁₂.edges = G₂₁.edges ∧ (∀ e, G₁₂.height e = G₂₁.height e) := by
obtain ⟨secondAfter, incomingX⟩ :=
admission_after_insert G distinct.wu.symm distinct.ux distinct.vx dominates₁ second
obtain ⟨firstAfter, incomingU⟩ :=
admission_after_insert G distinct.vx.symm distinct.ux.symm distinct.wu dominates₂ first
refine ⟨secondAfter, firstAfter, incomingX, incomingU,
fun _ height => creationHeight_unique height secondAfter.creation,
fun _ height => creationHeight_unique height firstAfter.creation, ?_, ?_, ?_⟩
· funext e
exact propext or_assoc
· funext e
apply propext
change (G.edges e ∨ e = (u, v)) ∨ e = (x, w) ↔
(G.edges e ∨ e = (x, w)) ∨ e = (u, v)
rw [or_assoc, or_assoc]
exact or_congr Iff.rfl or_comm
· intro e
have different : (u, v) ≠ (x, w) := fun eq => distinct.ux (congrArg Prod.fst eq)
by_cases eq₁ : e = (u, v)
· subst e
simp [insertChord, RelTimestampedGraph.edges, RelTimestampedGraph.height, different]
· by_cases eq₂ : e = (x, w)
· simp only [insertChord, RelTimestampedGraph.edges, RelTimestampedGraph.height, ite_eq_right eq₁, ite_eq_left eq₂]
· simp only [insertChord, RelTimestampedGraph.edges, RelTimestampedGraph.height, ite_eq_right eq₁, ite_eq_right eq₂]
end QBD.Ch02
#print axioms QBD.Ch02.increasing_path_after_insert
#print axioms QBD.Ch02.sequential_constructor_diamond
Verification Summary:
The machine-checked proofs confirm that non-interfering sequential chord insertions commute on both active adjacency and assigned creation heights while preserving strictly increasing edge paths. Interfering proposals that share incidence endpoints remain outside the diamond hypothesis. The Lean 4 kernel accepts all closed proof terms using only standard axioms, certifying the commutation claims of Sequential Constructor Diamond §2.4.6.
In Plain English:
Machine-checked Lean 4 proofs certify the discrete claims formalized in Section 2.4.6.3.
2.4.7 Proof: General Cycle Decomposition
I. Initial Accessibility and Merge
The isolated input has the PUC-compliant perimeter paths (Chordlessness of Maximal Cycles §2.4.3). Its frozen proposal union has the stated accumulation-order property (Confluence of the Constructor §2.4.2).
II. Pruning and Termination
The maximal-cycle deletion identity is valid independently of chordlessness (Reduction via Deletion §2.4.4). For the actual benchmark's arbitrary long-cycle choices, the decreasing edge budget gives termination, the mutation bound and final (Decrease in Parallel Updates §2.4.5).
III. Reciprocal-Chord Cases
Two proposed chords and are reciprocal exactly when and modulo . These equations imply , so among only admits such a pair. No proposed chord is reciprocal to a perimeter edge for . Thus for no two-cycle is created; deletions cannot create one later.
IV. Scope of the Conclusion
For , absence of loops and reciprocal pairs together with leaves only directed three-cycles if any cycles remain. For , the asserted stopping condition alone is (General Cycle Decomposition §2.4.1).
The sequential diamond applies to its two individually admissible proposals under the height-dominance premises (Sequential Constructor Diamond §2.4.6).
Q.E.D.
In Plain English:
Section 2.4.7 formalizes the properties of the QBD proof regarding general cycle decomposition.
2.4.7.1 Type-Theoretic Validation via Lean 4 Core
Type-theoretic certification of the cycle decomposition, confluence, and four-cycle reciprocity synthesis established in General Cycle Decomposition §2.4.1 proceeds via the following verification strategy:
- Model: The assembly module imports all five certified Chapter 2 confluence, chordlessness, deletion-reduction, parallel-update, and sequential-diamond modules alongside unguarded four-cycle pruning witnesses.
- Certified Claims: The module assembles frozen-snapshot confluence, isolated-cycle chordlessness, deletion termination, parallel benchmark bounds, and sequential commutation in General Cycle Decomposition §2.4.7, and certifies Axiom-1 preservation under chorded pruning alongside unguarded four-cycle reciprocity.
- Scope Boundary: Termination and confluence apply under the stated frozen-snapshot, isolated-cycle, and non-interference hypotheses. The four-cycle witness explicitly uses unguarded chords to document retained reciprocity after pruning.
import QBD.Ch02.L2_4_2_ConstructorConfluence
import QBD.Ch02.L2_4_3_ChordlessnessOfMaximalCycles
import QBD.Ch02.L2_4_4_ReductionViaDeletion
import QBD.Ch02.L2_4_5_DecreaseInParallelUpdates
import QBD.Ch02.L2_4_6_SequentialConstructorDiamond
namespace QBD.Ch02
private theorem prune_subset {n j : Nat} {start finish : List (Edge (Fin n))}
(run : PruneRun j start finish) : finish ⊆ start := by
induction run with
| zero => exact fun _ present => present
| next step _ ih =>
cases step
exact fun _ present => (mem_deleteEdge.mp (ih present)).1
private theorem chorded_perimeter_membership {n : Nat} (selected : List (Fin n)) (u v : Fin n)
(member : (u, v) ∈ chordedPerimeter selected) : ChordedCycleEdge u v := by
rcases List.mem_append.mp member with old | added
· obtain ⟨i, edge⟩ := List.mem_ofFn.mp old
left
have source := congrArg (fun e : Edge (Fin n) => e.1.val) edge
have target := congrArg (fun e : Edge (Fin n) => e.2.val) edge
simp at source target
exact target.symm.trans (congrArg (fun x => (x + 1) % n) source)
· obtain ⟨i, _, edge⟩ := List.mem_map.mp added
exact Or.inr ⟨i, edge⟩
/-- Every pruned output of the chord-addition benchmark on at least five vertices satisfies Axiom 1. -/
theorem pruning_preserves_chorded_perimeter_axiom1 {n j : Nat} (size : 5 ≤ n)
{selected : List (Fin n)} {finish : List (Edge (Fin n))}
(run : PruneRun j (chordedPerimeter selected) finish) :
DirectedCausalLink (fun a b => (a, b) ∈ finish) := by
obtain ⟨asymmetric, irreflexive⟩ := chorded_cycle_asymmetric_irreflexive size
intro u v forward
have chorded := chorded_perimeter_membership selected u v (prune_subset run forward)
refine ⟨fun same => irreflexive u (same ▸ chorded), ?_⟩
exact fun backward => asymmetric u v chorded
(chorded_perimeter_membership selected v u (prune_subset run backward))
/-- The four-cycle's unguarded phase can produce opposite return chords. -/
theorem unguarded_four_cycle_reciprocity :
((0, 2) : Edge (Fin 4)) ∈ chordedPerimeter [0, 2] ∧
((2, 0) : Edge (Fin 4)) ∈ chordedPerimeter [0, 2] := by decide
/-- A completed four-cycle run can keep both opposite chords. -/
theorem unguarded_four_cycle_terminal_reciprocity :
∃ finish, PruneRun 1 (chordedPerimeter ([0, 2] : List (Fin 4))) finish ∧
longestCycle finish ≤ 3 ∧ ((0, 2) : Edge (Fin 4)) ∈ finish ∧ ((2, 0) : Edge (Fin 4)) ∈ finish := by
let start := chordedPerimeter ([0, 2] : List (Fin 4))
let finish := deleteEdge start (0, 1)
have prune : PruneStep start finish :=
.remove (cycle := [0, 1, 2, 3]) (by decide) (by decide) (by decide)
refine ⟨finish, .next prune (.zero finish), ?_, ?_, ?_⟩ <;> dsimp only [finish, start] <;> decide
/-- §2.4.1. The isolated-cycle benchmark reaches length at most three within `3n` mutations. -/
theorem general_cycle_decomposition {n : Nat} (size : 4 ≤ n)
(selected : List (Fin n)) (distinct : selected.Nodup) :
∃ j finish, PruneRun j (chordedPerimeter selected) finish ∧ longestCycle finish ≤ 3 ∧
selected.length + j ≤ 3 * n ∧ CyclePotentialLess (potential finish) (potential (perimeter n)) ∧
(5 ≤ n → DirectedCausalLink (fun a b => (a, b) ∈ finish)) := by
obtain ⟨j, finish, run, _, terminal⟩ := parallel_benchmark_terminates size selected distinct
obtain ⟨_, _, _, total, descent⟩ := parallel_benchmark_bounds size distinct run terminal
exact ⟨j, finish, run, terminal, total, descent, fun large =>
pruning_preserves_chorded_perimeter_axiom1 large run⟩
end QBD.Ch02
#print axioms QBD.Ch02.general_cycle_decomposition
#print axioms QBD.Ch02.pruning_preserves_chorded_perimeter_axiom1
#print axioms QBD.Ch02.unguarded_four_cycle_reciprocity
#print axioms QBD.Ch02.unguarded_four_cycle_terminal_reciprocity
Verification Summary:
The machine-checked proofs assemble frozen confluence, isolated chordlessness, strict deletion descent, parallel benchmark termination, and sequential commutation while certifying Axiom-1 preservation under pruning and explicit unguarded four-cycle reciprocity. Unrestricted concurrent merges on general ambient graphs remain outside the benchmark hypotheses. The Lean 4 kernel accepts all closed proof terms using only standard axioms, certifying the assembled claims of General Cycle Decomposition §2.4.7.
In Plain English:
Section 2.4.7.1 formalizes the properties of the QBD type-theoretic regarding validation via lean 4 core.
2.4.11 Calculation: Simulation Verification
Verification of finite isolated-cycle termination (General Cycle Decomposition §2.4.7) (Confluence of the Constructor §2.4.2) is based on the following protocols:
- Defect Initialization: The algorithm constructs isolated directed cycles of length to serve as standardized topological defects. This mapping represents the initialization of unstable macroscopic loops within the vacuum.
- Topological Reduction: The protocol simulates an unweighted topological reduction by instantiating chords across open 2-paths and subsequently pruning macro-cycles () via entropic deletion to resolve topological tension.
- Operation Counting: The metric tracks the total additions and deletions required for the system to reach the simplicial ground state (), checking the benchmark’s terminal reduction in (Lexicographic Potential §2.3.5).
(Pedagogical Benchmark vs. Physical Dynamic Execution):
The script below is a topological demonstrator of cycle-length reduction on unweighted defect graphs. In the physical QBD substrate, graph rewriting executes via the timestamp-aware atomic scheduler with the Symmetric Reciprocal Filter (shown in atomic_cycle_reduction_step), strictly preventing reciprocal 2-cycles during parallel collapse.
"""
Pedagogical Topological Cycle Digestion Demonstrator (§2.4.11).
Demonstrates cycle-length reduction on unweighted directed k-cycles
to verify termination at simplicial ground states (L_max <= 3).
Physical rewrites use the timestamp-aware atomic scheduler (Axioms 1-3).
"""
import networkx as nx
import pandas as pd
import math
def create_directed_cycle(k):
"""Creates a simple directed $k$-cycle graph: the initial topological defect."""
G = nx.DiGraph()
nodes = list(range(k))
for i in range(k):
G.add_edge(nodes[i], nodes[(i + 1) % k])
return G
def get_max_cycle_len(G):
"""Returns the length of the longest simple cycle, or 0 if acyclic."""
try:
cycles = list(nx.simple_cycles(G))
if not cycles:
return 0
return max(len(c) for c in cycles)
except nx.NetworkXNoCycle:
return 0
def find_compliant_2_paths(G):
"""
Identifies all open 2-paths (v→w→u) that satisfy the
Principle of Unique Causality (PUC) for chord addition.
This is the recognition phase of the rewrite rule.
"""
paths = []
for v in G.nodes():
for w in G.successors(v):
for u in G.successors(w):
if u == v:
continue # Prevent trivial loops
# Constraint 1: Direct chord must not exist
if G.has_edge(v, u):
continue
# Constraint 2: No parallel 2-path (PUC)
redundant = False
for x in G.successors(v):
if x != w and G.has_edge(x, u):
redundant = True
break
if not redundant:
paths.append((v, w, u))
return paths
def phase_1_add_chords(G):
"""Phase 1: Exhaustive chord insertion on all compliant sites (parallel update)."""
paths = find_compliant_2_paths(G) # Collect all sites first, simulating parallel application
ops = 0
for v, w, u in paths:
if not G.has_edge(u, v): # Direction: close with (u → v)
G.add_edge(u, v)
ops += 1
return ops
def phase_2_delete_cycles(G):
"""Phase 2: Entropic deletion: break remaining macro-cycles by removing perimeter edges."""
ops = 0
while True:
max_len = get_max_cycle_len(G)
if max_len <= 3:
break
# Find and break one macro-cycle
target_cycle = None
for c in nx.simple_cycles(G):
if len(c) > 3:
target_cycle = c
break
if target_cycle:
# Delete the first edge of the detected cycle: thermodynamic pruning
u, v = target_cycle[0], target_cycle[1]
if G.has_edge(u, v):
G.remove_edge(u, v)
ops += 1
else:
break
return ops
def run_reduction_protocol(k):
"""Full reduction protocol for a single $k$-cycle, returning (add_ops, del_ops)."""
if k <= 3:
return 0, 0
G = create_directed_cycle(k)
add_ops = phase_1_add_chords(G)
del_ops = phase_2_delete_cycles(G)
return add_ops, del_ops
def atomic_cycle_reduction_step(G):
"""
Companion reference: Timestamp-aware atomic cycle reduction step (Lemma 2.4.5).
Applies chord addition and perimeter deletion in a single atomic rewrite step,
filtering reciprocal collision pairs to strictly preserve Axiom 1 (no 2-cycles).
"""
paths = find_compliant_2_paths(G)
if not paths:
return 0, 0
proposals_add = {(u, v) for v, w, u in paths}
# Symmetric Reciprocal Filter (Corollary 2.2): drop colliding pairs and self-loops
filtered_add = {
(u, v) for (u, v) in proposals_add
if (v, u) not in proposals_add and u != v
}
proposals_del = set()
for c in nx.simple_cycles(G):
if len(c) > 3:
proposals_del.add((c[0], c[1]))
break
for u, v in filtered_add:
G.add_edge(u, v)
for u, v in proposals_del:
if G.has_edge(u, v):
G.remove_edge(u, v)
return len(filtered_add), len(proposals_del)
# === Execution and Verification ===
results = []
for k in range(4, 13):
adds, dels = run_reduction_protocol(k)
results.append({
"Cycle Length (k)": k,
"Add Ops": adds,
"Del Ops": dels,
"Total Steps": adds + dels
})
df = pd.DataFrame(results)
print(df.to_markdown(index=False))
Simulation Results:
| Cycle Length (k) | Add Ops | Del Ops | Total Steps |
|---|---|---|---|
| 4 | 4 | 1 | 5 |
| 5 | 5 | 3 | 8 |
| 6 | 6 | 2 | 8 |
| 7 | 7 | 3 | 10 |
| 8 | 8 | 3 | 11 |
| 9 | 9 | 3 | 12 |
| 10 | 10 | 3 | 13 |
| 11 | 11 | 3 | 14 |
| 12 | 12 | 3 | 15 |
Conclusion: The tabulated data establishes a linear correlation between the initial cycle length and the addition count (). The deletion count stabilizes at a constant value () for all topologies with . This finite scaling confirms that the algorithmic reduction complexity is proportional to the defect size , validating the termination logic of the proof.
In Plain English:
Section 2.4.11 formalizes the properties of the QBD calculation regarding simulation verification.
2.5.1 Theorem: Independence of Axioms 1 and 2
Let the raw universe consist of finite timestamped directed graphs permitting loops and reciprocal pairs. The static geometric diagnostic requires all simple cycles of length at least two to be triangles and each simple two-path to be unique among paths of length at most two, while the constructive predicate starts from a base with no such cycles and the same two-path uniqueness and accretes PUC return chords at constructor heights without creating simple cycles of length at least four. For each geometric predicate, it and Axiom 1 are logically independent even with Axiom 3 imposed.
In Plain English:
Section 2.5.1 formalizes the properties of the QBD theorem regarding independence of axioms 1 and 2.
2.5.2 Lemma: Independence Case A
Let be a directed four-cycle with all heights zero. It satisfies Axioms 1 and 3 and fails the static diagnostic and constructive accretion predicates.
In Plain English:
Section 2.5.2 formalizes the properties of the QBD lemma regarding independence case a.
2.5.2.1 Proof: Independence Case A
I. Directed-Link and Mediated Conditions
The residue model has all heights zero and the edge sets
The loop and reciprocity tests reduce to
both false. A spatial path of length at least two has first two heights , failing . Hence and all its nonempty powers are empty.
II. Failure of the Static Predicate
The perimeter has all its directed edges in and its first four vertices are pairwise distinct. Thus
The static predicate requires all simple cycles of length at least two to have length three (Independence of Axioms 1 and 2 §2.5.1).
III. Failure of the Accretion Predicate
For a hypothetical constructive sequence , the base has . At each accretion step a four-cycle would either consist wholly of old edges or contain the new chord. The former would lie in and the latter is prohibited by the accretion rule. Therefore
Induction gives , contradicting the exhibited perimeter (Independence Case A §2.5.2).
Q.E.D.
In Plain English:
Section 2.5.2.1 formalizes the properties of the QBD proof regarding independence case a.
2.5.2.2 Type-Theoretic Validation via Lean 4 Core
Type-theoretic certification of the finite witness separating the first two axioms established in Independence Case A §2.5.2 proceeds via the following verification strategy:
- Model: Explicit finite timestamped directed graphs, irreflexivity and asymmetry predicates, mediated acyclicity checks, and geometric-constructibility failure witnesses represent logical independence.
- Certified Claims: The module certifies empty mediation on the witness graph and verifies a concrete finite graph satisfying directed-link and acyclic-causality constraints while violating geometric constructibility in Independence Case A §2.5.2.1.
- Scope Boundary: The witness demonstrates logical independence on a finite static graph. Dynamical reachability from a specific initial state is not claimed by this independence countermodel.
import QBD.Ch02.FiniteModels
namespace QBD.Ch02
-- Closed data for the uniform-height directed square.
def G_A : FinTimestampedGraph 4 := graphFrom [((0, 1), 0), ((1, 2), 0), ((2, 3), 0), ((3, 0), 0)]
-- The Case A cycle witness.
/-- The four distinct perimeter vertices close to the starting vertex. -/
private theorem square_cycle : FinSimpleCycle G_A [0, 1, 2, 3] := by decide
-- Case A has no mediated pairs.
/-- The square's uniform height prevents every increasing two-edge prefix. -/
theorem case_a_mediated_empty : ∀ a b, ¬ FinMediated G_A a b :=
uniform_no_mediated (height := 0) (by decide)
-- Independence Case A.
/-- The uniform-height square satisfies Axioms 1 and 3 but its four-cycle
violates both the static and constructive geometry predicates. -/
theorem independence_case_a :
SatisfiesAxiom1 G_A ∧ SatisfiesAxiom3 G_A ∧
¬ SatisfiesStaticAxiom2 G_A ∧ ¬ SatisfiesConstructiveAxiom2 G_A := by
refine ⟨?_, axiom3_of_empty case_a_mediated_empty, ?_, ?_⟩
· unfold SatisfiesAxiom1 DirectedCausalLink TimestampedGraph.toDiGraph
decide
· intro static
exact (by decide : ([0, 1, 2, 3] : List (Fin 4)).length ≠ 3)
(static.1 _ square_cycle (by decide))
· intro built
exact accretion_no_long_cycle built _ square_cycle (by decide)
end QBD.Ch02
#print axioms QBD.Ch02.case_a_mediated_empty
#print axioms QBD.Ch02.independence_case_a
Verification Summary:
The machine-checked proofs construct an explicit finite graph satisfying directed-link irreflexivity, asymmetry, and acyclic effective causality while violating geometric constructibility, proving that the first axiom does not entail the second. Dynamical reachability from arbitrary initial seeds remains outside this independence witness. The Lean 4 kernel accepts all closed proof terms using only standard axioms, certifying the logical separation of Independence Case A §2.5.2.
In Plain English:
Machine-checked Lean 4 proofs certify the discrete claims formalized in Section 2.5.2.3.
2.5.3 Lemma: Independence Case B
Let consist of a directed triangle with successive heights and a disjoint self-loop. It satisfies both geometric predicates and Axiom 3 and fails Axiom 1.
In Plain English:
Section 2.5.3 formalizes the properties of the QBD lemma regarding independence case b.
2.5.3.1 Proof: Independence Case B
I. Complete Static Path Enumeration
Let with heights in the listed order. The successor map is and . For each of the first return is at step three, so their cycles differ only by rotation. The first edge from already repeats , so it cannot start a simple two-path. The full two-path set and the direct edges at its endpoint pairs are
Each ordered endpoint pair appears exactly once. This establishes both clauses of the static predicate (Independence of Axioms 1 and 2 §2.5.1).
II. Constructive Witness
Let . Its only simple two-path is and its only cycle is the isolated length-one loop. For the candidate the incoming height set at is , and
The only simple cycle created by the chord is , so this is a valid accretion sequence.
III. Directed-Link and Mediated Conditions
The edge fails irreflexivity. There are no simple paths of length at least three. For the three two-paths the comparisons are
Hence and , since no mediated edge leaves . The closure has no diagonal (Independence Case B §2.5.3).
Q.E.D.
In Plain English:
Section 2.5.3.1 formalizes the properties of the QBD proof regarding independence case b.
2.5.3.2 Type-Theoretic Validation via Lean 4 Core
Type-theoretic certification of the finite witness separating the second axiom from the first established in Independence Case B §2.5.3 proceeds via the following verification strategy:
- Model: Finite timestamped graphs, mediated reachability relations, accretion steps, a reciprocal-violating constructible witness, and a consistent initial tree represent independence and joint satisfiability.
- Certified Claims: The module certifies the mediated relation and accretion witness satisfying geometric constructibility while violating Axiom 1 Directed Causal Link §2.1.1, alongside a consistent initial tree satisfying all three axioms in Independence Case B §2.5.3.1.
- Scope Boundary: The certificate establishes logical independence and consistency via finite witnesses. General dynamical attractors and infinite-graph behavior remain outside this model-theoretic check.
import QBD.Ch02.FiniteModels
namespace QBD.Ch02
-- The two-edge base and the disjoint loop in Case B.
def G_B_base : FinTimestampedGraph 4 := graphFrom [((0, 1), 0), ((1, 2), 0), ((3, 3), 0)]
-- The Case B triangle is closed at height one.
def G_B : FinTimestampedGraph 4 := insertFiniteChord G_B_base (2, 0) 1
-- The initial tree also supplies the pre-state of the first raw proposal.
def initialTree : FinTimestampedGraph 4 := graphFrom [((0, 1), 0), ((1, 2), 0), ((2, 3), 0)]
-- Case B has exactly one mediated arrow.
/-- The only simple increasing edge list of length at least two runs from vertex 1 to vertex 0. -/
theorem case_b_mediated_relation : ∀ a b, FinMediated G_B a b ↔ a = 1 ∧ b = 0 := by decide
-- Allow kernel reduction through the full list of bounded vertex sequences.
set_option maxRecDepth 4096
-- The Case B constructive sequence.
/-- The base passes the two-path rule and has no cycles of length at least two.
The fresh return chord has source-maximum height one and adds no long simple cycle. -/
theorem case_b_accretion : SatisfiesConstructiveAxiom2 G_B := by
have base : SatisfiesConstructiveAxiom2 G_B_base := by
apply SatisfiesConstructiveAxiom2.base
· exact certify_cycles (by decide)
· unfold AllSimple2PathsCompliant
decide
change SatisfiesConstructiveAxiom2 (insertFiniteChord G_B_base (2, 0) (creationHeight G_B_base 2))
exact .accrete base 0 1 2 (by decide) (by decide) (by decide) (certify_cycles (by decide))
-- Independence Case B.
/-- The triangle with an isolated loop satisfies both geometry predicates and
has acyclic mediated closure. The loop violates Axiom 1. -/
theorem independence_case_b :
¬ SatisfiesAxiom1 G_B ∧ SatisfiesStaticAxiom2 G_B ∧
SatisfiesConstructiveAxiom2 G_B ∧ SatisfiesAxiom3 G_B := by
refine ⟨?_, ⟨certify_cycles (by decide), ?_⟩, case_b_accretion,
axiom3_of_single_arrow (by decide) (fun a b => (case_b_mediated_relation a b).mp)⟩
· intro directed
exact (directed 3 3 (by decide)).1 rfl
· unfold AllSimple2PathsCompliant
decide
-- Consistency row of the independence matrix.
/-- The zero-height directed initial tree satisfies the directed-link, static,
constructive, and mediated-closure predicates simultaneously. -/
theorem initial_tree_all_axioms :
SatisfiesAxiom1 initialTree ∧ SatisfiesStaticAxiom2 initialTree ∧
SatisfiesConstructiveAxiom2 initialTree ∧ SatisfiesAxiom3 initialTree := by
have noCycle : ∀ c, FinSimpleCycle initialTree c → 2 ≤ c.length → False :=
certify_cycles (by decide)
have puc : AllSimple2PathsCompliant initialTree := by
unfold AllSimple2PathsCompliant
decide
refine ⟨?_, ⟨fun c simple long => (noCycle c simple long).elim, puc⟩,
.base noCycle puc, axiom3_of_empty (uniform_no_mediated (height := 0) (by decide))⟩
unfold SatisfiesAxiom1 DirectedCausalLink TimestampedGraph.toDiGraph
decide
end QBD.Ch02
#print axioms QBD.Ch02.case_b_mediated_relation
#print axioms QBD.Ch02.case_b_accretion
#print axioms QBD.Ch02.independence_case_b
#print axioms QBD.Ch02.initial_tree_all_axioms
Verification Summary:
The machine-checked proofs exhibit a concrete finite witness that satisfies geometric constructibility while violating directed-link constraints, together with a consistent initial tree satisfying all axioms simultaneously. Infinite-graph dynamics remain outside this finite model-theoretic certificate. The Lean 4 kernel accepts all closed proof terms using only standard axioms, certifying the logical separation of Independence Case B §2.5.3.
In Plain English:
Machine-checked Lean 4 proofs certify the discrete claims formalized in Section 2.5.3.3.
2.5.4 Lemma: Raw Proposal Independence
Let a raw proposal specify a graph, a triple and an absent chord at its source-maximum height, with a reverse-witness horizon of at least two. The output Axiom 1 test, geometric admission of the specified support and either causal test (bounded reverse witness or full output closure) are mutually independent in the sense that each can fail while the other two pass.
In Plain English:
Section 2.5.4 formalizes the properties of the QBD lemma regarding raw proposal independence.
2.5.4.1 Proof: Raw Proposal Independence
I. Failure of Geometric Admission
Geometric admission evaluates the candidate-relative two-path test (Raw Proposal Independence §2.5.4) (Axiom 2 Geometric Constructibility §2.3.1).
On propose at height one with specified middle vertex . The edge is absent, so the support fails. The added edge produces no loop or reciprocal pair. The reverse path has equal old heights, and the output has , so both causal tests pass.
II. Failure of Axiom 1
On with an isolated height-zero loop at , propose at height one. The support is unique, the old reverse path has equal heights, and of the output is . The isolated loop remains, so Axiom 1 fails.
III. Failure of the Causal Tests
Use and propose at height six. The only simple two-path from to is and is absent. The chord is neither a loop nor reciprocal. The reverse witness has , so it fails the bounded test. In the output, and give , violating the closure test.
Q.E.D.
In Plain English:
Section 2.5.4.1 formalizes the properties of the QBD proof regarding raw proposal independence.
2.5.4.2 Calculation: Raw Proposal Predicate Table
Verification of the raw proposal truth table (Raw Proposal Independence §2.5.4.1) (Geometric Constructibility §2.3.1) is based on the following protocols:
- Fixtures: Set the pre-state edge heights and proposed chord for each witness.
- Predicates: Evaluate geometric admission, the bounded reverse test, and the output closure independently.
- Comparison: Check the four truth values in each row.
import networkx as nx
def relations(graph):
relation = nx.DiGraph()
relation.add_nodes_from(graph)
for a in graph:
for b in graph:
if a == b:
continue
if any(len(path) >= 3 and increasing(graph, path)
for path in nx.all_simple_paths(graph, a, b)):
relation.add_edge(a, b)
return relation
def increasing(graph, path):
heights = [graph[a][b]["height"] for a, b in zip(path, path[1:])]
return all(left < right for left, right in zip(heights, heights[1:]))
def evaluate(edges, v, w, u):
graph = nx.DiGraph()
graph.add_weighted_edges_from(edges, weight="height")
height = 1 + max(data["height"] for _, _, data in graph.in_edges(u, data=True))
middle = {z for z in graph[v] if z not in {v, u} and graph.has_edge(z, u)}
geometric = (len({v, w, u}) == 3 and middle == {w}
and not graph.has_edge(v, u) and not graph.has_edge(u, v))
reverse_ok = not any(
len(path) >= 3 and increasing(graph, path)
and graph[path[-2]][u]["height"] < height
for path in nx.all_simple_paths(graph, v, u, cutoff=5)
)
graph.add_edge(u, v, height=height)
directed = all(a != b and not graph.has_edge(b, a) for a, b in graph.edges)
return directed, geometric, reverse_ok, nx.is_directed_acyclic_graph(relations(graph))
fixtures = [
([(0, 1, 0), (1, 2, 0), (2, 3, 0)], 0, 1, 3),
([(0, 1, 0), (1, 2, 0), (3, 3, 0)], 0, 1, 2),
([("A", "Z", 1), ("Z", "D", 2), ("D", "C", 3),
("C", "Z", 4), ("Z", "B", 5)], "A", "Z", "B"),
]
expected = [(True, False, True, True), (False, True, True, True),
(True, True, False, False)]
for index, (fixture, target) in enumerate(zip(fixtures, expected), 1):
actual = evaluate(*fixture)
assert actual == target
print(f"Proposal {index}: {actual}")
Simulation Results:
Proposal 1: (True, False, True, True)
Proposal 2: (False, True, True, True)
Proposal 3: (True, True, False, False)
Conclusion:
The three explicit proposals yield the stated truth table and confirm the predicate evaluations on the raw domain.
In Plain English:
Section 2.5.4.2 formalizes the properties of the QBD calculation regarding raw proposal predicate table.
2.5.4.3 Type-Theoretic Validation via Lean 4 Core
Type-theoretic certification of the raw proposal predicate independence established in Raw Proposal Independence §2.5.4 proceeds via the following verification strategy:
- Model: Raw candidate edge proposals on finite directed graphs, separate irreflexivity, asymmetry, and unique-support admissibility predicates, and three explicit proposal witnesses represent transition-level independence.
- Certified Claims: The module certifies three concrete raw proposal witnesses separating each admissibility condition from the others and proves that geometric admission is equivalent to Axiom 2 Geometric Constructibility §2.3.1 in Raw Proposal Independence §2.5.4.1.
- Scope Boundary: The certificate separates raw proposal predicates on individual candidate transitions. Downstream thermodynamic filtering and global causal admission are evaluated separately.
import QBD.Ch02.L2_5_3_IndependenceCaseB
namespace QBD.Ch02
variable {n : Nat}
-- A raw proposal records a fresh chord at its constructor height and a valid search horizon.
structure RawProposal (n : Nat) where
old : FinTimestampedGraph n
v : Fin n
w : Fin n
u : Fin n
h : Nat
L : Nat
fresh : ¬ old.edges (u, v)
heightCorrect : h = creationHeight old u
horizon : 2 ≤ L
-- The raw output inserts the chord without evaluating any admission predicate.
def RawProposal.output (p : RawProposal n) : FinTimestampedGraph n :=
insertFiniteChord p.old (p.u, p.v) p.h
-- The output directed-link test.
def outputAxiom1 (p : RawProposal n) : Prop := SatisfiesAxiom1 p.output
-- The geometric test uses the specified middle vertex and an absent return edge.
def geometricAdmission (p : RawProposal n) : Prop :=
ThreeDistinct p.v p.w p.u ∧ FinitePUC p.old p.v p.w p.u ∧ ¬ p.old.edges (p.u, p.v)
/-- On a raw proposal the freshness proof is supplied, so the geometric test is Axiom 2. -/
theorem geometric_admission_iff_axiom2 (p : RawProposal n) :
geometricAdmission p ↔ GeometricConstructibility p.old.toDiGraph p.v p.w p.u := by
exact ⟨fun ⟨⟨vw, vu, wu⟩, ⟨first, second, unique⟩, _⟩ => ⟨⟨vw, wu, vu, first, second⟩, unique⟩,
fun ⟨⟨vw, wu, vu, first, second⟩, unique⟩ => ⟨⟨vw, vu, wu⟩, ⟨first, second, unique⟩, p.fresh⟩⟩
-- The bounded guard excludes a simple increasing reverse witness below the chord height.
def boundedReverseOk (p : RawProposal n) : Prop :=
¬ ∃ path, FinMediatedPath p.old p.v p.u path ∧ path.length ≤ p.L ∧
∃ last, path.getLast? = some last ∧ p.old.height last < p.h
-- The output closure test examines the entire merged graph.
def outputClosureOk (p : RawProposal n) : Prop := SatisfiesAxiom3 p.output
-- Butterfly vertex labels in order A, Z, D, C, B.
def butterflyOld : FinTimestampedGraph 5 :=
graphFrom [((0, 1), 1), ((1, 2), 2), ((2, 3), 3), ((3, 1), 4), ((1, 4), 5)]
-- Raw proposal with a missing second support edge.
def proposal1 (L : Nat) (minimum : 2 ≤ L) : RawProposal 4 where
old := initialTree
v := 0
w := 1
u := 3
h := 1
L := L
fresh := by decide
heightCorrect := by decide
horizon := minimum
-- Raw proposal whose output retains the isolated loop.
def proposal2 (L : Nat) (minimum : 2 ≤ L) : RawProposal 4 where
old := G_B_base
v := 0
w := 1
u := 2
h := 1
L := L
fresh := by decide
heightCorrect := by decide
horizon := minimum
-- Raw butterfly proposal closing the support A, Z, B at height six.
def proposal3 (L : Nat) (minimum : 2 ≤ L) : RawProposal 5 where
old := butterflyOld
v := 0
w := 1
u := 4
h := 6
L := L
fresh := by decide
heightCorrect := by decide
horizon := minimum
/-- Adding the height-one return edge to the four-vertex path mediates only vertex 2 to vertex 0. -/
private theorem proposal1_mediated_relation :
∀ a b, FinMediated (insertFiniteChord initialTree (3, 0) 1) a b ↔ a = 2 ∧ b = 0 := by decide
-- Raw proposal truth-table row one.
/-- The malformed support fails geometry. The directed-link test and both causal tests pass. -/
theorem raw_proposal_1 (L : Nat) (minimum : 2 ≤ L) :
outputAxiom1 (proposal1 L minimum) ∧ ¬ geometricAdmission (proposal1 L minimum) ∧
boundedReverseOk (proposal1 L minimum) ∧ outputClosureOk (proposal1 L minimum) := by
refine ⟨?_, ?_, ?_, ?_⟩
· change ∀ a b, (insertFiniteChord initialTree (3, 0) 1).edges (a, b) →
a ≠ b ∧ ¬ (insertFiniteChord initialTree (3, 0) 1).edges (b, a)
decide
· intro admission
exact (by decide : ¬ initialTree.edges (1, 3)) admission.2.1.2.1
· rintro ⟨path, witness, _, _⟩
exact uniform_no_mediated (G := initialTree) (height := 0) (by decide) 0 3 ⟨path, witness⟩
· exact axiom3_of_single_arrow (by decide) (fun a b => (proposal1_mediated_relation a b).mp)
-- Raw proposal truth-table row two.
/-- The isolated loop fails the directed-link test. The supported chord passes geometry and both causal tests. -/
theorem raw_proposal_2 (L : Nat) (minimum : 2 ≤ L) :
¬ outputAxiom1 (proposal2 L minimum) ∧ geometricAdmission (proposal2 L minimum) ∧
boundedReverseOk (proposal2 L minimum) ∧ outputClosureOk (proposal2 L minimum) := by
refine ⟨independence_case_b.1, ?_, ?_, independence_case_b.2.2.2⟩
· change ThreeDistinct (0 : Fin 4) 1 2 ∧ FinitePUC G_B_base 0 1 2 ∧
¬ G_B_base.edges (2, 0)
decide
· rintro ⟨path, witness, _, _⟩
exact uniform_no_mediated (G := G_B_base) (height := 0) (by decide) 0 2 ⟨path, witness⟩
-- Raw proposal truth-table row three.
/-- The butterfly passes the directed-link and geometry tests. Its old two-edge
reverse witness fails the guard at every permitted horizon, and its output has a mediated diagonal. -/
theorem raw_proposal_3 (L : Nat) (minimum : 2 ≤ L) :
outputAxiom1 (proposal3 L minimum) ∧ geometricAdmission (proposal3 L minimum) ∧
¬ boundedReverseOk (proposal3 L minimum) ∧ ¬ outputClosureOk (proposal3 L minimum) := by
refine ⟨?_, ?_, ?_, ?_⟩
· change ∀ a b, (insertFiniteChord butterflyOld (4, 0) 6).edges (a, b) →
a ≠ b ∧ ¬ (insertFiniteChord butterflyOld (4, 0) 6).edges (b, a)
decide
· change ThreeDistinct (0 : Fin 5) 1 4 ∧ FinitePUC butterflyOld 0 1 4 ∧
¬ butterflyOld.edges (4, 0)
decide
· intro guard
apply guard
have witness : FinMediatedPath butterflyOld 0 4 [(0, 1), (1, 4)] := by decide
have below : butterflyOld.height (1, 4) < 6 := by decide
exact ⟨[(0, 1), (1, 4)], witness, minimum, (1, 4), rfl, below⟩
· intro acyclic
let output := insertFiniteChord butterflyOld (4, 0) 6
have forward : FinMediatedPath output 0 2 [(0, 1), (1, 2)] := by decide
have backward : FinMediatedPath output 2 0 [(2, 3), (3, 1), (1, 4), (4, 0)] := by decide
exact acyclic 0 (.prepend ⟨_, forward⟩ (.single ⟨_, backward⟩))
end QBD.Ch02
#print axioms QBD.Ch02.raw_proposal_1
#print axioms QBD.Ch02.raw_proposal_2
#print axioms QBD.Ch02.raw_proposal_3
#print axioms QBD.Ch02.geometric_admission_iff_axiom2
Verification Summary:
The machine-checked proofs verify three finite raw proposal witnesses demonstrating mutual independence of the local transition predicates and establish exact equivalence between geometric admission and the second axiom. Global causal filtering and dynamical selection weights remain outside this transition-level module. The Lean 4 kernel accepts all closed proof terms using only standard axioms, certifying the independence claims of Raw Proposal Independence §2.5.4.
In Plain English:
Machine-checked Lean 4 proofs certify the discrete claims formalized in Section 2.5.4.4.
2.5.5 Proof: Independence of Axioms 1 and 2
I. Failure of Geometric Entailment
satisfies Axioms 1 and 3 and fails both specified geometric predicates (Independence Case A §2.5.2).
II. Failure of Causal Entailment
The triangle and loop meet both geometric tests and have acyclic mediated closure, while the loop violates directed-link irreflexivity (Independence Case B §2.5.3).
III. Scope of the Predicate Tests
The two opposite assignments establish mutual non-entailment for each geometric predicate on the raw graph universe. Separate countermodels give the truth assignments on the raw proposal universe (Raw Proposal Independence §2.5.4).
Q.E.D.
In Plain English:
Section 2.5.5 formalizes the properties of the QBD proof regarding independence of axioms 1 and 2.
2.5.5.1 Type-Theoretic Validation via Lean 4 Core
Type-theoretic certification of the mutual logical independence established in Independence of Axioms 1 and 2 §2.5.1 proceeds via the following verification strategy:
- Model: The assembly module imports the certified Case A, Case B, and raw-proposal independence modules to package both graph-level and transition-level independence.
- Certified Claims: The module certifies mutual independence of the first two axioms at the graph level together with full predicate independence on raw candidate transitions in Independence of Axioms 1 and 2 §2.5.5.
- Scope Boundary: Independence is established via explicit finite model-theoretic and transition-level witnesses. Dynamical selection probabilities and infinite-graph behavior remain outside this logical independence certificate.
import QBD.Ch02.L2_5_2_IndependenceCaseA
import QBD.Ch02.L2_5_3_IndependenceCaseB
import QBD.Ch02.L2_5_4_RawProposalIndependence
namespace QBD.Ch02
-- Assembly of the graph-level independence witnesses.
/-- Both directions of non-entailment hold on the same four-vertex universe with Axiom 3 imposed. -/
theorem axioms_one_two_independent :
(∃ G : FinTimestampedGraph 4, SatisfiesAxiom1 G ∧ SatisfiesAxiom3 G ∧
¬ SatisfiesStaticAxiom2 G ∧ ¬ SatisfiesConstructiveAxiom2 G) ∧
(∃ G : FinTimestampedGraph 4, ¬ SatisfiesAxiom1 G ∧ SatisfiesStaticAxiom2 G ∧
SatisfiesConstructiveAxiom2 G ∧ SatisfiesAxiom3 G) :=
⟨⟨G_A, independence_case_a⟩, ⟨G_B, independence_case_b⟩⟩
/-- At each permitted cutoff, each raw test can fail on a proposal satisfying the other tests. -/
theorem raw_proposal_tests_independent (L : Nat) (minimum : 2 ≤ L) :
(∃ p : RawProposal 4, p.L = L ∧ ¬ outputAxiom1 p ∧ geometricAdmission p ∧
boundedReverseOk p ∧ outputClosureOk p) ∧
(∃ p : RawProposal 4, p.L = L ∧ outputAxiom1 p ∧ ¬ geometricAdmission p ∧
boundedReverseOk p ∧ outputClosureOk p) ∧
(∃ p : RawProposal 5, p.L = L ∧ outputAxiom1 p ∧ geometricAdmission p ∧
¬ boundedReverseOk p ∧ ¬ outputClosureOk p) :=
⟨⟨proposal2 L minimum, rfl, raw_proposal_2 L minimum⟩,
⟨proposal1 L minimum, rfl, raw_proposal_1 L minimum⟩,
⟨proposal3 L minimum, rfl, raw_proposal_3 L minimum⟩⟩
end QBD.Ch02
#print axioms QBD.Ch02.axioms_one_two_independent
#print axioms QBD.Ch02.raw_proposal_tests_independent
Verification Summary:
The machine-checked proofs assemble the finite Case A, Case B, consistent-tree, and raw-proposal witnesses into closed theorems certifying both graph-level and transition-level independence of the first two axioms. Dynamical transition frequencies remain outside this model-theoretic assembly. The Lean 4 kernel accepts all closed proof terms using only standard axioms, certifying the independence claims of Independence of Axioms 1 and 2 §2.5.5.
In Plain English:
Section 2.5.5.1 formalizes the properties of the QBD type-theoretic regarding validation via lean 4 core.
2.6.1 Theorem: Inadequacy of Local Axioms
Let a system be constrained exclusively by Axioms 1 and 2. The transitive causal precedence relation closing Effective Influence §2.6.2 is not guaranteed to constitute a strict partial order. Specifically, the transitive closure of locally valid structures permits violations of strict irreflexivity () and asymmetry (), thereby failing to enforce global causal consistency.
In Plain English:
Section 2.6.1 formalizes the properties of the QBD theorem regarding inadequacy of local axioms.
2.6.2 Lemma: Effective Influence
Let mean that there is a directed path from to of at least two edges, with pairwise distinct vertices and strictly increasing active heights. The relation is irreflexive and every witness admits a split at an interior vertex into two strictly increasing subpaths.
In Plain English:
Section 2.6.2 formalizes the properties of the QBD lemma regarding effective influence.
2.6.2.1 Proof: Effective Influence
I. Witness and Endpoint Conditions
For with , put for (Creation Timestamp §1.4.4). The witness conditions are
A diagonal pair would give a witness with and . At the distinct indices , simplicity requires . Thus
II. Restriction to Two Subpaths
For , set and . Every edge of either path is an edge of . Their height lists are and , respectively. For consecutive heights inside either list the comparisons are inherited from the displayed witness conditions, and at the shared vertex the comparison is .
III. Concatenation under a Strict Join
Conversely, let be simple increasing paths of positive length with intersection of vertex sets exactly and with terminal and initial heights satisfying . The concatenated vertex sequence uses the join once. A repeated vertex would have to repeat within one subpath, or belong to both outside the join, and each possibility contradicts a hypothesis. All height comparisons are
These give one increasing list of length at least two, so the concatenation witnesses (Effective Influence §2.6.2).
Q.E.D.
In Plain English:
Section 2.6.2.1 formalizes the properties of the QBD proof regarding effective influence.
2.6.2.2 Type-Theoretic Validation via Lean 4 Core
Type-theoretic certification of the structural properties of mediated causal paths established in Effective Influence §2.6.2 proceeds via the following verification strategy:
- Model: Timestamped directed graphs, simple directed edge paths of length at least two with strictly increasing heights, interior vertex splits, and strict join operations represent mediated effective influence.
- Certified Claims: The module certifies irreflexivity of mediated paths, interior vertex splitting, indexed path splitting, and strict height-ordered path joins in Effective Influence §2.6.2.1.
- Scope Boundary: The certificate establishes structural properties of mediated paths on arbitrary timestamped graphs. Acyclicity of the transitive closure requires additional global constraints.
import QBD.Ch02.FiniteModels
namespace QBD.Ch02
variable {n : Nat} {V : Type}
theorem directed_split {E : Edge V → Prop} {a b : V} {p q : List (Edge V)}
(path : DirectedEdgePath E a b (p ++ q)) :
∃ mid, DirectedEdgePath E a mid p ∧ DirectedEdgePath E mid b q := by
induction p generalizing a with
| nil => exact ⟨a, rfl, path⟩
| cons e rest ih =>
obtain ⟨mid, left, right⟩ := ih path.2.2
exact ⟨mid, ⟨path.1, path.2.1, left⟩, right⟩
-- Membership and the endpoint of a directed walk.
/-- The final vertex occurs in the vertex list, including in the targets if there is an edge. -/
private theorem finish_mem {E : Edge V → Prop} {a b : V} {p : List (Edge V)}
(path : DirectedEdgePath E a b p) : b ∈ a :: p.map Prod.snd := by
induction p generalizing a with
| nil => exact List.mem_cons.mpr (Or.inl path.symm)
| cons e rest ih => exact List.mem_cons_of_mem _ (ih path.2.2)
-- The endpoint is an edge target in a nonempty directed walk.
/-- The last vertex of a nonempty walk belongs to the list of edge targets. -/
private theorem finish_mem_targets {E : Edge V → Prop} {a b : V} {p : List (Edge V)}
(path : DirectedEdgePath E a b p) (nonempty : p ≠ []) : b ∈ p.map Prod.snd := by
cases p with
| nil => exact False.elim (nonempty rfl)
| cons e rest => exact finish_mem path.2.2
-- Irreflexivity of effective influence.
/-- The targets of a nonempty simple path cannot contain its starting vertex. -/
theorem mediated_irreflexive (G : FinTimestampedGraph n) : ∀ u, ¬ FinMediated G u u := by
rintro u ⟨path, length, directed, _, simple⟩
exact (List.nodup_cons.mp simple).1
(finish_mem_targets directed (List.length_pos_iff.mp (by omega)))
-- Interior splits of mediated witnesses.
/-- Any decomposition into positive-length pieces yields simple increasing subpaths,
with a strictly increasing comparison between the terminal and initial edges at the join. -/
theorem mediated_interior_split {G : FinTimestampedGraph n} {a b : Fin n}
{left right : List (Edge (Fin n))} (leftNonempty : left ≠ []) (rightNonempty : right ≠ [])
(witness : FinMediatedPath G a b (left ++ right)) :
∃ mid last first, DirectedEdgePath G.edges a mid left ∧ DirectedEdgePath G.edges mid b right ∧
IsSimple a left ∧ IsSimple mid right ∧
IsEdgePathMonotone G.height left ∧ IsEdgePathMonotone G.height right ∧
left.getLast? = some last ∧ right.head? = some first ∧ G.height last < G.height first := by
obtain ⟨_, directed, monotone, simple⟩ := witness
obtain ⟨mid, leftPath, rightPath⟩ := directed_split directed
have allDistinct : ((a :: left.map Prod.snd) ++ right.map Prod.snd).Nodup := by
simpa [IsSimple] using simple
obtain ⟨leftSimple, rightTargets, disjoint⟩ := List.nodup_append.mp allDistinct
have rightSimple : IsSimple mid right := List.nodup_cons.mpr
⟨fun overlap => disjoint mid (List.mem_cons_of_mem _ (finish_mem_targets leftPath leftNonempty))
mid overlap rfl, rightTargets⟩
obtain ⟨leftMono, rightMono, across⟩ := List.pairwise_append.mp monotone
let last := left.getLast leftNonempty
let first := right.head rightNonempty
exact ⟨mid, last, first, leftPath, rightPath, leftSimple, rightSimple, leftMono, rightMono,
List.getLast?_eq_some_getLast leftNonempty, List.head?_eq_some_head rightNonempty,
across last (List.getLast_mem _) first (List.head_mem _)⟩
-- Splitting at an arbitrary interior edge count.
/-- Taking and dropping any positive number of edges less than the witness length
gives the two nonempty simple increasing subpaths and the strict join comparison. -/
theorem mediated_split_at {G : FinTimestampedGraph n} {a b : Fin n} {p : List (Edge (Fin n))}
(witness : FinMediatedPath G a b p) {j : Nat} (positive : 0 < j) (inside : j < p.length) :
let left := p.take j
let right := p.drop j
∃ mid last first, left ≠ [] ∧ right ≠ [] ∧
DirectedEdgePath G.edges a mid left ∧ DirectedEdgePath G.edges mid b right ∧
IsSimple a left ∧ IsSimple mid right ∧
IsEdgePathMonotone G.height left ∧ IsEdgePathMonotone G.height right ∧
left.getLast? = some last ∧ right.head? = some first ∧ G.height last < G.height first := by
have left : p.take j ≠ [] := List.length_pos_iff.mp (by
rw [List.length_take]
omega)
have right : p.drop j ≠ [] := List.length_pos_iff.mp (by
rw [List.length_drop]
omega)
have splitWitness : FinMediatedPath G a b (p.take j ++ p.drop j) := by
rw [List.take_append_drop]
exact witness
obtain ⟨mid, last, first, properties⟩ := mediated_interior_split left right splitWitness
exact ⟨mid, last, first, left, right, properties⟩
private theorem height_le_last {H : Edge V → Nat} {path : List (Edge V)} {last : Edge V}
(mono : IsEdgePathMonotone H path) (ending : path.getLast? = some last) :
∀ e ∈ path, H e ≤ H last := by
obtain ⟨pre, rfl⟩ := List.getLast?_eq_some_iff.mp ending
intro e member
rcases List.mem_append.mp member with inside | lastOnly
· exact Nat.le_of_lt ((List.pairwise_append.mp mono).2.2 e inside last (by simp))
· simpa using (show H e ≤ H last from (List.mem_singleton.mp lastOnly).symm ▸ Nat.le_refl _)
-- Monotonicity bounds every edge below by the initial height.
/-- The initial height is a lower bound for every later edge's height. -/
private theorem first_height_le {H : Edge V → Nat} {path : List (Edge V)} {first : Edge V}
(mono : IsEdgePathMonotone H path) (starting : path.head? = some first) :
∀ e ∈ path, H first ≤ H e := by
cases path with
| nil => simp at starting
| cons e rest =>
have eq : e = first := by simpa using starting
subst e
exact List.forall_mem_cons.mpr ⟨Nat.le_refl _, fun next member =>
Nat.le_of_lt ((List.pairwise_cons.mp mono).1 next member)⟩
-- Strict concatenation at a simple join.
/-- Positive-length simple increasing paths join to a mediated witness when their
only common vertex is the join and the heights strictly increase across it. -/
theorem mediated_strict_join {G : FinTimestampedGraph n} {a mid b : Fin n}
{left right : List (Edge (Fin n))} {last first : Edge (Fin n)}
(leftPath : DirectedEdgePath G.edges a mid left) (rightPath : DirectedEdgePath G.edges mid b right)
(leftSimple : IsSimple a left) (rightSimple : IsSimple mid right)
(leftMono : IsEdgePathMonotone G.height left) (rightMono : IsEdgePathMonotone G.height right)
(common : ∀ z, z ∈ a :: left.map Prod.snd → z ∈ mid :: right.map Prod.snd → z = mid)
(ending : left.getLast? = some last) (starting : right.head? = some first)
(increases : G.height last < G.height first) :
FinMediatedPath G a b (left ++ right) := by
have leftLength := List.length_pos_iff.mpr (List.ne_nil_of_mem (List.mem_of_getLast? ending))
have rightLength := List.length_pos_iff.mpr (List.ne_nil_of_mem (List.mem_of_head? starting))
refine ⟨by simp only [List.length_append]; omega, DirectedEdgePath.append leftPath rightPath, ?_, ?_⟩
· exact List.pairwise_append.mpr ⟨leftMono, rightMono, fun e he f hf =>
Nat.lt_of_le_of_lt (height_le_last leftMono ending e he)
(Nat.lt_of_lt_of_le increases (first_height_le rightMono starting f hf))⟩
· have combined : ((a :: left.map Prod.snd) ++ right.map Prod.snd).Nodup :=
List.nodup_append.mpr ⟨leftSimple, (List.nodup_cons.mp rightSimple).2, fun z hz y hy eq => by
subst y
have join := common z hz (List.mem_cons_of_mem _ hy)
exact (List.nodup_cons.mp rightSimple).1 (join ▸ hy)⟩
simpa [IsSimple] using combined
end QBD.Ch02
#print axioms QBD.Ch02.mediated_irreflexive
#print axioms QBD.Ch02.mediated_interior_split
#print axioms QBD.Ch02.mediated_split_at
#print axioms QBD.Ch02.mediated_strict_join
Verification Summary:
The machine-checked proofs establish that mediated effective influence is irreflexive, decomposes cleanly at interior vertices and indices, and supports strict height-monotone joins. Global acyclicity of the transitive closure requires further constraints outside this path-structure module. The Lean 4 kernel accepts all closed proof terms using only standard axioms, certifying the path properties of Effective Influence §2.6.2.
In Plain English:
Machine-checked Lean 4 proofs certify the discrete claims formalized in Section 2.6.2.3.
2.6.3 Lemma: Strict Timestamps
Let use the same simple paths of length at least two as , with nondecreasing heights in place of strictly increasing heights. Then , and the inclusion can be strict even when both relations have acyclic closure.
In Plain English:
Section 2.6.3 formalizes the properties of the QBD lemma regarding strict timestamps.
2.6.3.1 Proof: Strict Timestamps
I. Domain and Objects
Both tests use the same underlying spatial path family (Strict Timestamps §2.6.3) (Effective Influence §2.6.2).
II. Inclusion
For every witness of , each comparison implies , giving .
III. Equal-Height Witness
The graph has outgoing sets in that order. Its only two-edge path is and has no successor. The height pair fails and satisfies . Hence
No pair in starts at , so and . Also . Both closures have empty diagonal. Acyclicity of the weak relation therefore permits equal heights along a mediated path.
Q.E.D.
In Plain English:
Section 2.6.3.1 formalizes the properties of the QBD proof regarding strict timestamps.
2.6.3.2 Type-Theoretic Validation via Lean 4 Core
Type-theoretic certification of the strict-versus-weak timestamp mediation established in Strict Timestamps §2.6.3 proceeds via the following verification strategy:
- Model: Timestamped directed graphs, strictly increasing versus non-decreasing edge-height path predicates, and an explicit equal-height finite counterexample represent the strictness requirement.
- Certified Claims: The module certifies that strict timestamp mediation implies weak timestamp mediation and exhibits an explicit equal-height counterexample showing the converse fails in Strict Timestamps §2.6.3.1.
- Scope Boundary: The separation applies to active snapshot edge-height labels. Chronological creation-occurrence ordering is tracked separately on the historical ledger.
import QBD.Ch02.L2_6_2_EffectiveInfluence
namespace QBD.Ch02
variable {n : Nat} {V : Type}
-- A weak witness keeps the same endpoint, length, and simplicity conditions.
def IsWeakMediatedPath (G : FinTimestampedGraph n) (a b : Fin n) (path : List (Edge (Fin n))) : Prop :=
2 ≤ path.length ∧ DirectedEdgePath G.edges a b path ∧
path.Pairwise (fun e f => G.height e ≤ G.height f) ∧ IsSimple a path
-- Weak mediation uses nondecreasing heights.
def MediatedWeak (G : FinTimestampedGraph n) (a b : Fin n) : Prop :=
∃ path, IsWeakMediatedPath G a b path
instance (G : FinTimestampedGraph n) (a b : Fin n) (p : List (Edge (Fin n))) :
Decidable (IsWeakMediatedPath G a b p) := by
unfold IsWeakMediatedPath
infer_instance
instance (G : FinTimestampedGraph n) (a b : Fin n) : Decidable (MediatedWeak G a b) :=
decideSimplePaths a b (IsWeakMediatedPath G a b) (fun _ witness => witness.2.1)
(fun _ witness => witness.2.2.2)
/-- Every strictly increasing simple witness also witnesses nondecreasing mediation. -/
theorem mediated_implies_weak {G : FinTimestampedGraph n} {a b : Fin n}
(arrow : FinMediated G a b) : MediatedWeak G a b := by
obtain ⟨p, length, directed, mono, simple⟩ := arrow
exact ⟨p, length, directed, List.Pairwise.imp (fun lt => Nat.le_of_lt lt) mono, simple⟩
-- The outward equal-height two-path.
def equalHeightPath : FinTimestampedGraph 3 := graphFrom [((0, 1), 0), ((1, 2), 0)]
-- Weak filtering is strictly weaker even when both closures are acyclic.
/-- The only weak arrow is 0 to 2, while equal heights exclude every strict arrow. -/
theorem strict_weak_timestamp_example :
(∀ a b, ¬ FinMediated equalHeightPath a b) ∧
(∀ a b, MediatedWeak equalHeightPath a b ↔ a = 0 ∧ b = 2) ∧
SatisfiesAxiom3 equalHeightPath ∧ (∀ a, ¬ Reachable (MediatedWeak equalHeightPath) a a) ∧
FinMediated equalHeightPath ≠ MediatedWeak equalHeightPath := by
have weak : ∀ a b, MediatedWeak equalHeightPath a b ↔ a = 0 ∧ b = 2 := by decide
have uniform (a b : Fin 3) : equalHeightPath.height (a, b) = 0 := by
have all : ∀ a b : Fin 3, equalHeightPath.height (a, b) = 0 := by decide
exact all a b
have empty (a b : Fin 3) : ¬ FinMediated equalHeightPath a b := by
rintro ⟨p, length, _, mono, _⟩
rcases p with _ | ⟨first, _ | ⟨second, rest⟩⟩
· simp at length
· simp at length
have comparison := (List.pairwise_cons.mp mono).1 second (by simp)
change equalHeightPath.height (first.1, first.2) <
equalHeightPath.height (second.1, second.2) at comparison
rw [uniform first.1 first.2, uniform second.1 second.2] at comparison
exact Nat.lt_irrefl _ comparison
refine ⟨empty, weak, ?_, ?_, ?_⟩
· exact axiom3_of_empty empty
· have increases {a b} (arrow : MediatedWeak equalHeightPath a b) : a.val < b.val := by
obtain ⟨rfl, rfl⟩ := (weak a b).mp arrow
decide
exact fun a loop => Nat.lt_irrefl _ (StrictCausalMonotonicity.onReachable (h := Fin.val) (fun _ _ step => increases step) loop)
· intro eq
have arrow := (weak 0 2).mpr ⟨rfl, rfl⟩
exact empty 0 2 (eq.symm ▸ arrow)
end QBD.Ch02
#print axioms QBD.Ch02.mediated_implies_weak
#print axioms QBD.Ch02.strict_weak_timestamp_example
Verification Summary:
The machine-checked proofs confirm that strictly increasing edge heights along a mediated path imply weak monotonicity, while an explicit equal-height finite graph witnesses that weak monotonicity does not entail strict causal mediation. Historical ledger ordering remains outside this snapshot-level check. The Lean 4 kernel accepts all closed proof terms using only standard axioms, certifying the separation claims of Strict Timestamps §2.6.3.
In Plain English:
Machine-checked Lean 4 proofs certify the discrete claims formalized in Section 2.6.3.3.
2.6.4 Lemma: Failure of Reflexivity
Let denote mediated simple-path influence on the timestamped directed four-cycle . Then in the nonempty transitive closure, although the simple-path relation is itself irreflexive (Axiom 3 Acyclic Effective Causality §2.7.1).
In Plain English:
Section 2.6.4 formalizes the properties of the QBD lemma regarding failure of reflexivity.
2.6.4.1 Proof: Failure of Reflexivity
I. The Two Simple Witnesses
The vertices are distinct. The sequences and have no repeated vertices, have length two, and satisfy the respective height tests and (Effective Influence §2.6.2). Hence
II. Nonempty Transitive Closure
A witness for is a finite sequence with . The sequence of intermediate vertices has two -steps, so
The composed witness is an -chain. It is not required to be one simple spatial path.
III. Irreflexivity of the Original Filter
If , a simple path of length at least two would have identical first and last vertices, contrary to pairwise vertex distinctness. Therefore for every , even in this countermodel.
IV. Conclusion
The closure violates the required causal irreflexivity (Failure of Reflexivity §2.6.4).
Q.E.D.
In Plain English:
Section 2.6.4.1 formalizes the properties of the QBD proof regarding failure of reflexivity.
2.6.4.2 Type-Theoretic Validation via Lean 4 Core
Type-theoretic certification of the reflexive closure counterexample established in Failure of Reflexivity §2.6.4 proceeds via the following verification strategy:
- Model: A finite four-vertex timestamped square graph, mediated effective-influence witnesses, and the nonempty transitive closure relation represent reflexive causal closure.
- Certified Claims: The module certifies that the mediated transitive closure on the four-vertex square graph contains a reflexive self-reachability pair in Failure of Reflexivity §2.6.4.1.
- Scope Boundary: The counterexample demonstrates that local irreflexivity of mediated paths does not prevent reflexivity of the transitive closure. Global enforcement requires the third axiom.
import QBD.Ch02.L2_6_2_EffectiveInfluence
namespace QBD.Ch02
-- The increasing-height square from §2.6.4.
def reflexivitySquare : FinTimestampedGraph 4 :=
graphFrom [((0, 1), 1), ((1, 2), 2), ((2, 3), 3), ((3, 0), 4)]
/-- The two perimeter halves witness mutual influence although direct mediated self-pairs are impossible. -/
theorem square_closure_reflexive :
(∀ x, ¬ FinMediated reflexivitySquare x x) ∧ FinMediated reflexivitySquare 0 2 ∧
FinMediated reflexivitySquare 2 0 ∧ Reachable (FinMediated reflexivitySquare) 0 0 := by
have forward : FinMediated reflexivitySquare 0 2 := ⟨[(0, 1), (1, 2)], by decide⟩
have back : FinMediated reflexivitySquare 2 0 := ⟨[(2, 3), (3, 0)], by decide⟩
exact ⟨mediated_irreflexive _, forward, back, .prepend forward (.single back)⟩
end QBD.Ch02
#print axioms QBD.Ch02.square_closure_reflexive
Verification Summary:
The machine-checked proof exhibits a four-vertex timestamped square whose mediated effective-influence relation produces a reflexive pair in its nonempty transitive closure, proving that irreflexive mediation alone does not prevent causal loops. Global loop prevention remains outside this counterexample module. The Lean 4 kernel accepts the closed proof term using only standard axioms, certifying the counterexample of Failure of Reflexivity §2.6.4.
In Plain English:
Machine-checked Lean 4 proofs certify the discrete claims formalized in Section 2.6.4.3.
2.6.5 Lemma: Failure of Asymmetry
Let be a directed cycle of length . There is a height assignment under which two vertices satisfy and along simple spatial arcs with disjoint interiors.
In Plain English:
Section 2.6.5 formalizes the properties of the QBD lemma regarding failure of asymmetry.
2.6.5.1 Proof: Failure of Asymmetry
I. Domain and Objects
The arc endpoints define mediated pairs when each arc passes the strict test (Failure of Asymmetry §2.6.5) (Effective Influence §2.6.2).
II. Splitting the Perimeter
Index the perimeter . Put and . The two directed arcs have lengths and , and their interiors are and .
III. Witness Heights
Assign heights on the first arc and on the second. Each arc has at least two edges, pairwise distinct vertices, and strictly increasing heights. Thus
Q.E.D.
In Plain English:
Section 2.6.5.1 formalizes the properties of the QBD proof regarding failure of asymmetry.
2.6.5.2 Type-Theoretic Validation via Lean 4 Core
Type-theoretic certification of the mutual mediation established in Failure of Asymmetry §2.6.5 proceeds via the following verification strategy:
- Model: Finite timestamped bowtie graphs, strictly increasing perimeter arcs, and bidirectional mediated influence witnesses represent failure of asymmetry.
- Certified Claims: The module certifies strictly increasing perimeter arcs in both directions and proves mutual effective mediation between distinct vertices in Failure of Asymmetry §2.6.5.1.
- Scope Boundary: The witness shows that local edge asymmetry does not imply asymmetry of mediated effective influence. Global asymmetry requires the third axiom.
import QBD.Ch02.L2_6_2_EffectiveInfluence
namespace QBD.Ch02
-- Wrap an integer index onto the finite perimeter.
def wrapVertex (L : Nat) (positive : 0 < L) (i : Nat) : Fin L :=
⟨i % L, Nat.mod_lt _ positive⟩
-- The perimeter carries heights 1,2 on its first arc and 1 through L-2 on its second.
def timestampedPerimeter (L : Nat) (positive : 0 < L) : FinTimestampedGraph L :=
TimestampedGraph.ofOptionalHeights fun e =>
if e.2 = wrapVertex L positive (e.1.val + 1) then
some (if e.1.val < 2 then e.1.val + 1 else e.1.val - 1)
else none
-- A contiguous segment of successor edges on the perimeter.
def perimeterArc (L : Nat) (positive : 0 < L) (start length : Nat) : List (Edge (Fin L)) :=
(List.range' start length).map (fun i => (wrapVertex L positive i, wrapVertex L positive (i + 1)))
-- The perimeter edge set is exactly the successor edges.
/-- The height map is present exactly when the target is the source's cyclic successor. -/
theorem perimeter_edge {L : Nat} (positive : 0 < L) (u v : Fin L) :
(timestampedPerimeter L positive).edges (u, v) ↔ v = wrapVertex L positive (u.val + 1) := by
simp [TimestampedGraph.edges, timestampedPerimeter, TimestampedGraph.ofOptionalHeights]
-- Successor commutes with reduction modulo the perimeter length.
/-- A step after wrapping is identical to wrapping after the step. -/
theorem wrap_successor {L : Nat} (positive : 0 < L) (i : Nat) :
wrapVertex L positive (i + 1) = wrapVertex L positive ((wrapVertex L positive i).val + 1) :=
Fin.ext (Nat.mod_add_mod i L 1).symm
-- A contiguous list of perimeter indices forms a directed path.
/-- It starts at the wrapped first index and finishes at the wrapped index after the last edge. -/
theorem perimeter_arc_directed {L : Nat} (positive : 0 < L) (start length : Nat) :
DirectedEdgePath (timestampedPerimeter L positive).edges (wrapVertex L positive start)
(wrapVertex L positive (start + length)) (perimeterArc L positive start length) := by
induction length generalizing start with
| zero => simp [perimeterArc, DirectedEdgePath]
| succ length ih =>
simp only [perimeterArc, List.range'_succ, List.map_cons]
refine ⟨(perimeter_edge positive _ _).mpr (wrap_successor positive start), rfl, ?_⟩
have endpoint : start + (length + 1) = start + 1 + length := by omega
rw [endpoint]
exact ih (start + 1)
-- Perimeter vertices in a contiguous segment.
/-- The initial vertex and all targets are the consecutive indices including both endpoints. -/
theorem perimeter_arc_vertices {L : Nat} (positive : 0 < L) (start length : Nat) :
wrapVertex L positive start :: (perimeterArc L positive start length).map Prod.snd =
(List.range' start (length + 1)).map (wrapVertex L positive) := by
simp only [perimeterArc, List.map_map, List.range'_succ, List.map_cons]
congr 1
rw [List.range'_succ_left, List.map_map]
rfl
-- Simplicity of a segment through at most one wrap.
/-- Two increasing indices in the segment remain distinct after wrapping when
the segment either stops short of the wrap or starts strictly after zero. -/
theorem perimeter_arc_simple {L : Nat} (positive : 0 < L) {start length : Nat}
(bound : start + length ≤ L) (noRepeat : 0 < start ∨ start + length < L) :
IsSimple (wrapVertex L positive start) (perimeterArc L positive start length) := by
unfold IsSimple
rw [perimeter_arc_vertices]
apply List.pairwise_map.mpr
apply (List.pairwise_lt_range' (s := start) (n := length + 1)).imp_of_mem
intro i j hi hj lt eq
have lo := (List.mem_range'_1.mp hi).1
have high := (List.mem_range'_1.mp hj).2
have iLt : i < L := by omega
have vals : i % L = j % L := congrArg Fin.val eq
rw [Nat.mod_eq_of_lt iLt] at vals
by_cases jLt : j < L
· rw [Nat.mod_eq_of_lt jLt] at vals
omega
· have atWrap : j = L := by omega
subst j
simp at vals
omega
-- Perimeter heights in the unwrapped source index range.
/-- Each edge in either arc reads the height assigned to its natural-number source index. -/
private theorem perimeter_arc_edge_height {L : Nat} (positive : 0 < L) {i : Nat} (inside : i < L) :
(timestampedPerimeter L positive).height (wrapVertex L positive i, wrapVertex L positive (i + 1)) =
(if i < 2 then i + 1 else i - 1) := by
change (if wrapVertex L positive (i + 1) = wrapVertex L positive ((wrapVertex L positive i).val + 1)
then some (if (wrapVertex L positive i).val < 2 then (wrapVertex L positive i).val + 1
else (wrapVertex L positive i).val - 1) else none).getD 0 = _
rw [ite_eq_left (wrap_successor positive i)]
simp [wrapVertex, Nat.mod_eq_of_lt inside]
-- Strict increase along either side of the split.
/-- An arc within one height range inherits strict increase from its unwrapped indices. -/
private theorem perimeter_arc_mono {L : Nat} (positive : 0 < L) {start length : Nat}
(bound : start + length ≤ L) (side : start + length ≤ 2 ∨ 2 ≤ start) :
IsEdgePathMonotone (timestampedPerimeter L positive).height
(perimeterArc L positive start length) := by
unfold IsEdgePathMonotone perimeterArc
apply List.pairwise_map.mpr
apply (List.pairwise_lt_range' (s := start) (n := length)).imp_of_mem
intro i j hi hj lt
obtain ⟨iLo, iHi⟩ := List.mem_range'_1.mp hi
obtain ⟨jLo, jHi⟩ := List.mem_range'_1.mp hj
rw [perimeter_arc_edge_height positive (by omega : i < L),
perimeter_arc_edge_height positive (by omega : j < L)]
rcases side with before | after
· simp only [ite_eq_left (by omega : i < 2), ite_eq_left (by omega : j < 2)]
omega
· simp only [ite_eq_right (by omega : ¬ i < 2), ite_eq_right (by omega : ¬ j < 2)]
omega
-- The two simple increasing arcs of every directed perimeter of length at least four.
/-- The arcs have lengths two and L minus two. Vertex 1 is the sole interior
vertex of the first arc and cannot occur in the interior of the return arc. -/
theorem perimeter_increasing_arcs (L : Nat) (size : 4 ≤ L) :
let positive : 0 < L := by omega
let G := timestampedPerimeter L positive
let a := wrapVertex L positive 0
let b := wrapVertex L positive 2
let left := perimeterArc L positive 0 2
let right := perimeterArc L positive 2 (L - 2)
left.length = 2 ∧ right.length = L - 2 ∧
(∀ v, v ∈ (left.map Prod.snd).dropLast → v ∉ (right.map Prod.snd).dropLast) ∧
FinMediatedPath G a b left ∧ FinMediatedPath G b a right := by
dsimp only
have positive : 0 < L := by omega
have wrapEnd : wrapVertex L positive (2 + (L - 2)) = wrapVertex L positive 0 := by
have sum : 2 + (L - 2) = L := by omega
apply Fin.ext
simp [wrapVertex, sum]
refine ⟨by simp [perimeterArc], by simp [perimeterArc], ?_, ?_, ?_⟩
· intro v inside inRight
have eq : v = wrapVertex L positive 1 := by
simpa [perimeterArc, List.range'_succ] using inside
have inTargets := List.dropLast_subset _ inRight
simp only [perimeterArc, List.map_map, List.mem_map, Function.comp_apply] at inTargets
obtain ⟨i, hi, target⟩ := inTargets
obtain ⟨lower, upper⟩ := List.mem_range'_1.mp hi
have vals : (i + 1) % L = 1 % L := congrArg Fin.val (target.trans eq)
rw [Nat.mod_eq_of_lt (by omega : 1 < L)] at vals
by_cases beforeWrap : i + 1 < L
· rw [Nat.mod_eq_of_lt beforeWrap] at vals
omega
· have atWrap : i + 1 = L := by omega
rw [atWrap, Nat.mod_self] at vals
omega
· exact ⟨by simp [perimeterArc], perimeter_arc_directed positive 0 2,
perimeter_arc_mono positive (by omega) (Or.inl (by decide)),
perimeter_arc_simple positive (by omega) (Or.inr (by omega))⟩
· refine ⟨by simp [perimeterArc]; omega, ?_,
perimeter_arc_mono positive (by omega) (Or.inr (by decide)),
perimeter_arc_simple positive (by omega) (Or.inl (by decide))⟩
rw [← wrapEnd]
exact perimeter_arc_directed positive 2 (L - 2)
-- Failure of asymmetry for an arbitrary perimeter.
/-- The two increasing arcs witness both directions of mediated influence and a diagonal in its closure. -/
theorem perimeter_mutual_mediation (L : Nat) (size : 4 ≤ L) :
let positive : 0 < L := by omega
let G := timestampedPerimeter L positive
let a := wrapVertex L positive 0
let b := wrapVertex L positive 2
a.val = 0 ∧ b.val = 2 ∧ FinMediated G a b ∧ FinMediated G b a ∧ Reachable (FinMediated G) a a := by
obtain ⟨_, _, _, left, right⟩ := perimeter_increasing_arcs L size
exact ⟨by simp [wrapVertex], Nat.mod_eq_of_lt (by omega),
⟨_, left⟩, ⟨_, right⟩, .prepend ⟨_, left⟩ (.single ⟨_, right⟩)⟩
end QBD.Ch02
#print axioms QBD.Ch02.perimeter_increasing_arcs
#print axioms QBD.Ch02.perimeter_mutual_mediation
Verification Summary:
The machine-checked proofs construct strictly increasing perimeter arcs yielding mutual mediated influence between distinct vertices, proving that local link asymmetry fails to enforce asymmetry of mediated influence. Global enforcement mechanisms remain outside this counterexample module. The Lean 4 kernel accepts all closed proof terms using only standard axioms, certifying the counterexample of Failure of Asymmetry §2.6.5.
In Plain English:
Machine-checked Lean 4 proofs certify the discrete claims formalized in Section 2.6.5.4.
2.6.6 Lemma: Causal Acyclicity vs. Spatial Triangulation
Let denote the instantaneous Spatial State Graph, and let denote the Causal History Poset. Then the existence of directed 3-cycles representing discrete spatial area elements in does not induce or construct directed causal cycles in , which remains a strict directed acyclic graph.
In Plain English:
Section 2.6.6 formalizes the properties of the QBD lemma regarding causal acyclicity vs. spatial triangulation.
2.6.6.1 Proof: Causal Acyclicity vs. Spatial Triangulation
I. Two Distinct Incidence Relations
Let be the spatial graph, and let be the set of edge-creation events. The event graph has event vertices and causal dependency edges:
where is the stipulated strict history order (Causal Acyclicity vs. Spatial Triangulation §2.6.6). Spatial adjacency is a relation on ; causal precedence is a relation on . They are not identified by sharing an incidence symbol (Causal Graph Substrate §1.4.1).
II. No Cycle in a Strict Event Order
Suppose the event graph contained a positive-length directed cycle
Since , transitivity of gives, inductively,
This contradicts irreflexivity. For , the first edge already gives that contradiction. Therefore has no directed cycles.
III. A Spatial Triangle Does Not Supply the Missing Dependency
The spatial witness is a triangle with distinct supports
(Geometric Quantum §2.3.3). Denote their creation events by . A consistent event order can have
The spatial equality of the final endpoint of and the first endpoint of is an equality in . It does not assert the event dependency . In the concrete order the missing dependency would require , or . In the abstract order,
Both are contradictions. Thus
under the stated separate strict event-order structure.
Q.E.D.
In Plain English:
Section 2.6.6.1 formalizes the properties of the QBD proof regarding causal acyclicity vs. spatial triangulation.
2.6.6.2 Type-Theoretic Validation via Lean 4 Core
Type-theoretic certification of the compatibility between acyclic causal dependencies and spatial triangles established in Causal Acyclicity vs. Spatial Triangulation §2.6.6 proceeds via the following verification strategy:
- Model: Creation-occurrence dependency graphs with strictly increasing causal heights alongside an explicit active spatial three-cycle witness represent the two-tier separation between chronological history and spatial geometry.
- Certified Claims: The module certifies acyclicity of the event dependency order and exhibits a finite spatial triangle witness that satisfies all three axioms simultaneously in Causal Acyclicity vs. Spatial Triangulation §2.6.6.1.
- Scope Boundary: The witness demonstrates coexistence of spatial triangles with acyclic effective causality on a finite graph. Macroscopic triangulated manifolds remain outside this finite witness.
import QBD.Ch02.L2_6_2_EffectiveInfluence
namespace QBD.Ch02
variable {V : Type}
/-- Every nonempty dependency chain remains inside the transitive strict order. -/
theorem event_dependency_acyclic (prec D : V → V → Prop)
(transitive : ∀ {a b c}, prec a b → prec b c → prec a c)
(irreflexive : ∀ a, ¬ prec a a) (included : ∀ {a b}, D a b → prec a b) :
∀ a, ¬ Reachable D a a := by
have order {a b} (chain : Reachable D a b) : prec a b := by
induction chain with
| single step => exact included step
| tail _ step ih => exact transitive ih (included step)
exact fun a chain => irreflexive a (order chain)
-- The three spatial edges and their associated creation occurrences.
def triangleSupport (occurrence : Fin 3) : Edge (Fin 3) :=
(occurrence, ⟨(occurrence.val + 1) % 3, by omega⟩)
-- The creation height belongs to the occurrence, indexed separately from the spatial walk.
def triangleEventHeight (occurrence : Fin 3) : Nat := occurrence.val + 1
-- Event precedence is strict order by creation height.
def triangleEventOrder (first second : Fin 3) : Prop :=
triangleEventHeight first < triangleEventHeight second
-- The event dependencies use the first two successive creation pairs.
def triangleEventDependency (first second : Fin 3) : Prop :=
(first = 0 ∧ second = 1) ∨ (first = 1 ∧ second = 2)
-- The spatial snapshot for the creation-event example.
def spatialTriangle : FinTimestampedGraph 3 := graphFrom [((0, 1), 1), ((1, 2), 2), ((2, 0), 3)]
/-- The spatial triangle coexists with an acyclic order on its creation occurrences. -/
theorem spatial_triangle_event_acyclic :
FinSimpleCycle spatialTriangle [0, 1, 2] ∧
(∀ e, spatialTriangle.height (triangleSupport e) = triangleEventHeight e) ∧
triangleEventOrder 0 1 ∧ triangleEventOrder 1 2 ∧ ¬ triangleEventOrder 2 0 ∧
(∀ a, ¬ Reachable triangleEventDependency a a) := by
refine ⟨by decide, by decide, ?_, ?_, ?_, ?_⟩
· change 1 < 2
decide
· change 2 < 3
decide
· change ¬ 3 < 1
decide
· apply event_dependency_acyclic triangleEventOrder triangleEventDependency
· exact fun h h' => Nat.lt_trans h h'
· exact fun a => Nat.lt_irrefl (triangleEventHeight a)
· rintro a b (⟨rfl, rfl⟩ | ⟨rfl, rfl⟩)
· change 1 < 2
decide
· change 2 < 3
decide
end QBD.Ch02
#print axioms QBD.Ch02.event_dependency_acyclic
#print axioms QBD.Ch02.spatial_triangle_event_acyclic
Verification Summary:
The machine-checked proofs establish that strictly increasing event dependencies remain acyclic while an explicit spatial three-cycle satisfies directed-link rules, geometric constructibility, and acyclic effective causality simultaneously. Continuum manifold assembly remains outside this finite witness module. The Lean 4 kernel accepts all closed proof terms using only standard axioms, certifying the coexistence claims of Causal Acyclicity vs. Spatial Triangulation §2.6.6.
In Plain English:
Machine-checked Lean 4 proofs certify the discrete claims formalized in Section 2.6.6.3.
2.6.7 Lemma: Least Constructive Countermodel
Let denote the class of finite timestamped graphs satisfying Axiom 1 and the constructive geometric predicate. The least vertex count in with for some vertex is four.
In Plain English:
Section 2.6.7 formalizes the properties of the QBD lemma regarding least constructive countermodel.
2.6.7.1 Proof: Least Constructive Countermodel
I. Reduction to a Directed Triangle
Let denote a graph satisfying Axiom 1 Directed Causal Link §2.1.1 on at most three vertices. If , then a finite nonempty chain has the form
For each , let denote a witness of (Effective Influence §2.6.2). Its endpoints satisfy
Let denote , with . Define as the concatenation with for . The endpoint equality makes the two assignments at agree. For ,
Let denote equal-vertex indices in with minimizing . Any equal pair with would give a smaller positive difference . Thus are distinct, so . For the two shorter possibilities,
The first contradicts irreflexivity and the second contradicts the reciprocal-edge exclusion. Hence . Let denote . Since these are all three vertices of ,
All six pairs in the second set are forbidden by Axiom 1. Thus .
II. Mediated Closure on a Triangle
Let denote the triangle, with respective heights . A simple witness in this graph has at most two edges, and membership in requires at least two. Each start vertex has one outgoing edge and its successor also has one, so the complete list of candidates is
The three tests together imply , hence . At least one test fails. In each row below, denotes the relation formed by the other two candidate pairs. The only composition within joins its two arrows at their common vertex:
The terminal vertex of the sole pair in has no outgoing pair in in each row. Thus for . The inclusion yields , whose displayed pairs have distinct endpoints. This contradicts .
III. Construction of a Four-Vertex Accretion
Let denote the graph on with edges , , and . Let and denote the edge set and outgoing neighbors of after insertions. The base satisfies
Define as the rank function with . Every base edge increases by one. A directed cycle in would yield
Let denote the incoming neighbors of in . Pairing each incoming tail with each outgoing head lists the two-paths:
The two endpoint pairs differ, and . Each of the two paths is therefore unique among paths of length at most two with its endpoints, as required of the base (Independence of Axioms 1 and 2 §2.5.1).
For the first candidate , the support from to is obtained from the row of the table:
The first equality establishes candidate-relative PUC and the second excludes an existing edge or its reverse (Principle of Unique Causality (PUC) §2.3.4). The row and the timestamp recurrence yield
(Creation Timestamp §1.4.4).
For the second candidate , the outgoing sets yield the two-path family
Here and . The subfamily ending at consists of alone, and excludes the direct bypass. Hence
These conditions establish PUC and preserve Axiom 1. Since the only incoming edge of is and its height is unchanged, the recurrence yields
The restriction of either or to is . Both heads have no outgoing edge in this restriction, so every directed cycle contains . For a simple cycle with , the sequence is a rotation starting and ending at . Since and for , the two possible two-edge prefixes are and . Their continuations use
The table allows only a return to or termination after the two-edge prefix. Continuation past a return would repeat , contrary to simplicity. Therefore the cycle families, with each cycle written from , are
Both insertions satisfy the cycle condition of the constructive predicate.
IV. Attainment of a Diagonal
The final adjacency and height lists yield the following distinct-vertex witnesses with increasing heights:
These three relations compose in the nonempty closure:
The four-vertex construction and the exclusion for at most three vertices establish the minimum.
Q.E.D.
In Plain English:
Section 2.6.7.1 formalizes the properties of the QBD proof regarding least constructive countermodel.
2.6.7.2 Type-Theoretic Validation via Lean 4 Core
Type-theoretic certification of the minimal vertex count for constructive violation established in Least Constructive Countermodel §2.6.7 proceeds via the following verification strategy:
- Model: Exhaustive finite timestamped graphs on three and four vertices, single-step geometric accretion, and a four-vertex constructive countermodel represent the minimality threshold.
- Certified Claims: The module certifies that all three-vertex Axiom-1 graphs and four-vertex static graphs are acyclic under mediated influence, while an explicit four-vertex constructive countermodel attains the exact minimum in Least Constructive Countermodel §2.6.7.1.
- Scope Boundary: Minimality is established with respect to vertex count for constructive accretion under the local axioms. Static countermodels without constructive accretion are treated in the next module.
import QBD.Ch02.L2_6_2_EffectiveInfluence
namespace QBD.Ch02
variable {n : Nat} {V : Type}
-- The three directed edges of one triangle.
def TriangleEdge (a b c : V) (e : Edge V) : Prop :=
e = (a, b) ∨ e = (b, c) ∨ e = (c, a)
-- A directed triangle has all three cyclic edges active.
def Triangle (G : FinTimestampedGraph n) (a b c : Fin n) : Prop :=
G.edges (a, b) ∧ G.edges (b, c) ∧ G.edges (c, a)
-- Mediation restricted to a specified set of edges keeps the original heights.
def MediatedOn (G : FinTimestampedGraph n) (allowed : Edge (Fin n) → Prop) (a b : Fin n) : Prop :=
∃ p, FinMediatedPath G a b p ∧ ∀ e ∈ p, allowed e
-- A simple suffix beginning at a visited vertex.
/-- Dropping a prefix to a visited vertex leaves a simple path to the original endpoint. -/
private theorem simple_suffix {E : Edge V → Prop} {a b v : V} {p : List (Edge V)}
(directed : DirectedEdgePath E a b p) (simple : IsSimple a p)
(visited : v ∈ a :: p.map Prod.snd) :
∃ suffix, DirectedEdgePath E v b suffix ∧ IsSimple v suffix := by
induction p generalizing a with
| nil =>
have eq : v = a := by simpa using visited
exact ⟨[], eq.trans directed, by simp [IsSimple]⟩
| cons e rest ih =>
rcases List.mem_cons.mp visited with rfl | later
· exact ⟨e :: rest, directed, simple⟩
· exact ih directed.2.2 (List.nodup_cons.mp simple).2 later
-- Loop erasure for the spatial return walk.
/-- Erase the tail first, then either retain the initial edge or erase through
the next visit to the initial vertex. Endpoints stay fixed. -/
private theorem simple_walk {E : Edge V → Prop} {a b : V} {p : List (Edge V)}
(directed : DirectedEdgePath E a b p) :
∃ simple, DirectedEdgePath E a b simple ∧ IsSimple a simple := by
classical
induction p generalizing a with
| nil => exact ⟨[], directed, by simp [IsSimple]⟩
| cons e rest ih =>
obtain ⟨tail, connects, noRepeat⟩ := ih directed.2.2
by_cases repeated : a ∈ e.2 :: tail.map Prod.snd
· exact simple_suffix connects noRepeat repeated
· exact ⟨e :: tail, ⟨directed.1, directed.2.1, connects⟩,
List.nodup_cons.mpr ⟨repeated, noRepeat⟩⟩
-- A closed spatial walk supplies a simple cycle through each of its edges.
/-- Rotate the closed walk around a chosen edge, erase loops in its return walk,
and then prepend that edge to the simple return path. -/
private theorem cycle_through_edge {G : FinTimestampedGraph n} (ax : SatisfiesAxiom1 G)
{a : Fin n} {p : List (Edge (Fin n))} (walk : DirectedEdgePath G.edges a a p)
{e : Edge (Fin n)} (member : e ∈ p) :
∃ c, FinSimpleCycle G c ∧ 2 ≤ c.length ∧ e ∈ cycleEdges c := by
obtain ⟨pre, tail, rfl⟩ := List.append_of_mem member
obtain ⟨mid, before, present, source, after⟩ := directed_split walk
have returnWalk : DirectedEdgePath G.edges e.2 e.1 (tail ++ pre) :=
DirectedEdgePath.append after (source.symm ▸ before)
obtain ⟨path, returns, simple⟩ := simple_walk returnWalk
have nonempty : path ≠ [] := by
intro empty
subst path
exact (ax _ _ present).1 returns.symm
obtain ⟨endEdge, endpoint⟩ : ∃ endEdge, path.getLast? = some endEdge :=
⟨path.getLast nonempty, List.getLast?_eq_some_getLast nonempty⟩
obtain ⟨rest, rfl⟩ := List.getLast?_eq_some_iff.mp endpoint
obtain ⟨_, _, ending⟩ := directed_split returns
have lastTarget : endEdge.2 = e.1 := ending.2.2
let c := e.1 :: e.2 :: rest.map Prod.snd
have cSimple : c.Nodup := by
have rotated : ((e.2 :: rest.map Prod.snd) ++ [e.1]).Nodup := by
simpa [IsSimple, lastTarget] using simple
obtain ⟨front, _, disjoint⟩ := List.nodup_append.mp rotated
exact List.nodup_cons.mpr ⟨fun he => disjoint e.1 he e.1 (by simp) rfl, front⟩
have rebuild := DirectedEdgePath.edgesFrom_rebuild returns
have edgeList : cycleEdges c = e :: (rest ++ [endEdge]) := by
simp only [List.map_append, List.map_cons, List.map_nil, lastTarget] at rebuild
change (e.1, e.2) :: edgesFrom e.2 (rest.map Prod.snd ++ [e.1]) = _
rw [rebuild]
have edgesPresent {start finish : Fin n} {q : List (Edge (Fin n))}
(directed : DirectedEdgePath G.edges start finish q) : ∀ f ∈ q, G.edges f := by
induction q generalizing start with
| nil => simp
| cons f rest ih => exact List.forall_mem_cons.mpr ⟨directed.1, ih directed.2.2⟩
refine ⟨c, ⟨by simp [c], cSimple, ?_⟩, by simp [c], ?_⟩
· rw [edgeList]
exact List.forall_mem_cons.mpr ⟨present, edgesPresent returns⟩
· rw [edgeList]
simp
-- Axiom 1 excludes a two-vertex spatial cycle.
/-- Any simple cycle with at least two vertices therefore has at least three vertices. -/
private theorem cycle_length_ge_three {G : FinTimestampedGraph n} (ax : SatisfiesAxiom1 G)
{c : List (Fin n)} (simple : FinSimpleCycle G c) (length : 2 ≤ c.length) :
3 ≤ c.length := by
rcases c with _ | ⟨a, _ | ⟨b, _ | ⟨d, rest⟩⟩⟩
· simp at length
· simp at length
· have ab : G.edges (a, b) := simple.2.2 _ (by simp [cycleEdges, edgesFrom])
have ba : G.edges (b, a) := simple.2.2 _ (by simp [cycleEdges, edgesFrom])
exact False.elim ((ax _ _ ab).2 ba)
· simp
-- A simple three-cycle presents a directed triangle.
/-- Every edge of a three-vertex simple cycle is one of its three cyclic edges. -/
private theorem triangle_of_cycle {G : FinTimestampedGraph n} {c : List (Fin n)}
(simple : FinSimpleCycle G c) (length : c.length = 3) :
∃ a b d, Triangle G a b d ∧ ∀ e ∈ cycleEdges c, TriangleEdge a b d e := by
rcases c with _ | ⟨a, _ | ⟨b, _ | ⟨d, _ | ⟨z, rest⟩⟩⟩⟩
· simp at length
· simp at length
· simp at length
· refine ⟨a, b, d, ⟨simple.2.2 _ (by simp [cycleEdges, edgesFrom]),
simple.2.2 _ (by simp [cycleEdges, edgesFrom]),
simple.2.2 _ (by simp [cycleEdges, edgesFrom])⟩, ?_⟩
simp [TriangleEdge, cycleEdges, edgesFrom]
· simp at length
-- Expanding a mediated chain retains all the individual witnesses.
/-- A nonempty closure chain expands to a nonempty spatial walk. Any restriction
containing all walk edges retains the same chain of mediated witnesses. -/
private theorem expand_chain {G : FinTimestampedGraph n} {a b : Fin n}
(chain : Reachable (FinMediated G) a b) :
∃ p, p ≠ [] ∧ DirectedEdgePath G.edges a b p ∧
∀ allowed, (∀ e ∈ p, allowed e) → Reachable (MediatedOn G allowed) a b := by
induction chain with
| single step =>
obtain ⟨p, witness⟩ := step
have length := witness.1
exact ⟨p, List.length_pos_iff.mp (by omega), witness.2.1,
fun allowed includeAll => .single ⟨p, witness, includeAll⟩⟩
| tail _ last ih =>
obtain ⟨p, nonempty, directed, remaining⟩ := ih
obtain ⟨q, witness⟩ := last
exact ⟨p ++ q, by simp [nonempty], directed.append witness.2.1,
fun allowed includeAll => .tail
(remaining allowed (fun e he => includeAll e (List.mem_append_left q he)))
⟨q, witness, fun e he => includeAll e (List.mem_append_right p he)⟩⟩
-- Triangle vertices are distinct under Axiom 1.
/-- Distinctness follows from the presence of all three cyclic directed edges. -/
private theorem triangle_distinct {G : FinTimestampedGraph n} {a b c : Fin n}
(ax : SatisfiesAxiom1 G) (triangle : Triangle G a b c) : ThreeDistinct a b c :=
⟨(ax _ _ triangle.1).1, (ax _ _ triangle.2.2).1.symm, (ax _ _ triangle.2.1).1⟩
-- The orientation on any pair of triangle vertices is forced.
/-- Axiom 1 rules out the reverse of every triangle edge as well as each loop. -/
private theorem edge_inside_triangle {G : FinTimestampedGraph n} {a b c x y : Fin n}
(ax : SatisfiesAxiom1 G) (triangle : Triangle G a b c)
(hx : x ∈ [a, b, c]) (hy : y ∈ [a, b, c]) (edge : G.edges (x, y)) :
TriangleEdge a b c (x, y) := by
have noBA := (ax _ _ triangle.1).2
have noCB := (ax _ _ triangle.2.1).2
have noAC := (ax _ _ triangle.2.2).2
have ne := (ax _ _ edge).1
simp only [List.mem_cons, List.not_mem_nil, or_false] at hx hy
rcases hx with rfl | rfl | rfl <;> rcases hy with rfl | rfl | rfl <;>
simp_all [TriangleEdge]
-- Re-index a triangle from any chosen cyclic edge.
/-- A cyclic rotation preserves all three edge memberships and fixes the chosen edge as first. -/
private theorem rotate_triangle {G : FinTimestampedGraph n} {a b c x y : Fin n}
(triangle : Triangle G a b c) (chosen : TriangleEdge a b c (x, y)) :
∃ z, Triangle G x y z ∧ ∀ e, TriangleEdge a b c e ↔ TriangleEdge x y z e := by
rcases chosen with eq | eq | eq <;> obtain ⟨rfl, rfl⟩ := Prod.mk.inj eq
· exact ⟨c, triangle, fun _ => Iff.rfl⟩
· exact ⟨a, ⟨triangle.2.1, triangle.2.2, triangle.1⟩, fun e => by
simp only [TriangleEdge]; exact or_comm.trans or_assoc⟩
· exact ⟨b, ⟨triangle.2.2, triangle.1, triangle.2.1⟩, fun e => by
simp only [TriangleEdge]; exact or_assoc.symm.trans or_comm⟩
-- Two triangles with a common oriented edge have identical third vertices under PUC.
/-- The return two-path across the shared edge must have the same middle vertex. -/
private theorem shared_triangle_identical {G : FinTimestampedGraph n}
{a b c x y z : Fin n} (ax : SatisfiesAxiom1 G) (puc : AllSimple2PathsCompliant G)
(first : Triangle G a b c) (second : Triangle G x y z)
{edge : Edge (Fin n)} (inFirst : TriangleEdge a b c edge) (inSecond : TriangleEdge x y z edge) :
∀ e, TriangleEdge x y z e → TriangleEdge a b c e := by
obtain ⟨u, v⟩ := edge
obtain ⟨m, rotatedFirst, eqFirst⟩ := rotate_triangle first inFirst
obtain ⟨k, rotatedSecond, eqSecond⟩ := rotate_triangle second inSecond
obtain ⟨uv, um, vm⟩ := triangle_distinct ax rotatedFirst
have compliant := puc v m u ⟨vm, uv.symm, um.symm⟩ rotatedFirst.2.1 rotatedFirst.2.2
have same := compliant.2.2.2 k ⟨rotatedSecond.2.1, rotatedSecond.2.2⟩
subst k
exact fun e he => (eqFirst e).mpr ((eqSecond e).mp he)
-- On at most four vertices, two triangle vertex sets share an unordered pair.
/-- There is room for at most one vertex outside a fixed triangle, so another
triangle shares two vertices. Axiom 1 then fixes the same orientation in both. -/
private theorem triangles_share_edge {G : FinTimestampedGraph n} (size : n ≤ 4)
(ax : SatisfiesAxiom1 G) {a b c x y z : Fin n} (first : Triangle G a b c)
(second : Triangle G x y z) :
∃ e, TriangleEdge a b c e ∧ TriangleEdge x y z e := by
obtain ⟨ab, ac, bc⟩ := triangle_distinct ax first
obtain ⟨xy, xz, yz⟩ := triangle_distinct ax second
have oneOutside (s t : Fin n) (hs : s ∉ [a, b, c]) (ht : t ∉ [a, b, c])
(ne : s ≠ t) : False := by
have distinct : ([s, t, a, b, c] : List (Fin n)).Nodup := by
simp [hs, ht, ne, ab, ac, bc]
have bound := nodup_fin_length distinct
simp at bound
omega
by_cases hx : x ∈ [a, b, c]
· by_cases hy : y ∈ [a, b, c]
· exact ⟨(x, y), edge_inside_triangle ax first hx hy second.1, Or.inl rfl⟩
· have hz : z ∈ [a, b, c] := Decidable.byContradiction (fun hz => oneOutside y z hy hz yz)
exact ⟨(z, x), edge_inside_triangle ax first hz hx second.2.2, Or.inr (Or.inr rfl)⟩
· have hy : y ∈ [a, b, c] := Decidable.byContradiction (fun hy => oneOutside x y hx hy xy)
have hz : z ∈ [a, b, c] := Decidable.byContradiction (fun hz => oneOutside x z hx hz xz)
exact ⟨(y, z), edge_inside_triangle ax first hy hz second.2.1, Or.inr (Or.inl rfl)⟩
-- Complete classification of mediated arrows restricted to a triangle.
/-- A simple mediated path inside a triangle has exactly two edges, so each
candidate arrow is determined by its start and the corresponding height comparison. -/
private theorem triangle_mediated_cases {G : FinTimestampedGraph n} {a b c x y : Fin n}
(distinct : ThreeDistinct a b c) (arrow : MediatedOn G (TriangleEdge a b c) x y) :
(x = a ∧ y = c ∧ G.height (a, b) < G.height (b, c)) ∨
(x = b ∧ y = a ∧ G.height (b, c) < G.height (c, a)) ∨
(x = c ∧ y = b ∧ G.height (c, a) < G.height (a, b)) := by
obtain ⟨p, ⟨length, directed, mono, simple⟩, restricted⟩ := arrow
have supported (e : Edge (Fin n)) (member : e ∈ p) :
e.1 ∈ [a, b, c] ∧ e.2 ∈ [a, b, c] := by
rcases restricted e member with rfl | rfl | rfl <;> simp
rcases p with _ | ⟨e, _ | ⟨f, rest⟩⟩
· simp at length
· simp at length
have contained : (x :: (e :: f :: rest).map Prod.snd) ⊆ [a, b, c] := by
intro v member
rcases List.mem_cons.mp member with rfl | target
· exact directed.2.1 ▸ (supported e (by simp)).1
· obtain ⟨edge, he, rfl⟩ := List.mem_map.mp target
exact (supported edge he).2
have bound := simple.length_le_of_subset contained
have empty : rest = [] := List.length_eq_zero_iff.mp (by
change (x :: (e :: f :: rest).map Prod.snd).length ≤ [a, b, c].length at bound
simp only [List.length_cons, List.length_map, List.length_nil] at bound
omega)
subst rest
obtain ⟨_, source, _, join, finish⟩ := directed
change f.2 = y at finish
have compare := (List.pairwise_cons.mp mono).1 f (by simp)
have first := restricted e (by simp)
have second := restricted f (by simp)
obtain ⟨ab, ac, bc⟩ := distinct
rcases first with rfl | rfl | rfl <;> rcases second with rfl | rfl | rfl <;> simp_all
-- Two consecutive arrows on distinct vertices have acyclic closure.
/-- Assign ranks zero, one, and two along the two allowed directed steps. -/
private theorem two_arrows_acyclic {R : Fin n → Fin n → Prop} {s m t : Fin n}
(distinct : ThreeDistinct s m t)
(included : ∀ {a b}, R a b → (a = s ∧ b = m) ∨ (a = m ∧ b = t)) :
∀ x, ¬ Reachable R x x := by
let rank (v : Fin n) : Nat := if v = s then 0 else if v = m then 1 else 2
have up {a b} (edge : R a b) : rank a < rank b := by
obtain ⟨sm, st, mt⟩ := distinct
rcases included edge with ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩
· simp [rank, sm.symm]
· simp [rank, sm.symm, st.symm, mt.symm]
exact fun x loop => Nat.lt_irrefl _ (StrictCausalMonotonicity.onReachable (h := rank) (fun _ _ step => up step) loop)
-- A triangle's mediated closure is acyclic for all heights.
/-- The three possible comparisons cannot all hold around a triangle. The two
remaining arrows form at most a directed chain, which has acyclic closure. -/
theorem triangle_mediated_acyclic (G : FinTimestampedGraph n) (a b c : Fin n)
(distinct : ThreeDistinct a b c) : ∀ x, ¬ Reachable (MediatedOn G (TriangleEdge a b c)) x x := by
obtain ⟨ab, ac, bc⟩ := distinct
by_cases first : G.height (a, b) < G.height (b, c)
· by_cases second : G.height (b, c) < G.height (c, a)
· apply two_arrows_acyclic (s := b) (m := a) (t := c) ⟨ab.symm, bc, ac⟩
intro x y arrow
rcases triangle_mediated_cases ⟨ab, ac, bc⟩ arrow with p | q | r
· exact Or.inr ⟨p.1, p.2.1⟩
· exact Or.inl ⟨q.1, q.2.1⟩
· exact False.elim (Nat.lt_irrefl _ (Nat.lt_trans first (Nat.lt_trans second r.2.2)))
· apply two_arrows_acyclic (s := a) (m := c) (t := b) ⟨ac, ab, bc.symm⟩
intro x y arrow
rcases triangle_mediated_cases ⟨ab, ac, bc⟩ arrow with p | q | r
· exact Or.inl ⟨p.1, p.2.1⟩
· exact False.elim (second q.2.2)
· exact Or.inr ⟨r.1, r.2.1⟩
· apply two_arrows_acyclic (s := c) (m := b) (t := a) ⟨bc.symm, ac.symm, ab.symm⟩
intro x y arrow
rcases triangle_mediated_cases ⟨ab, ac, bc⟩ arrow with p | q | r
· exact False.elim (first p.2.2)
· exact Or.inr ⟨q.1, q.2.1⟩
· exact Or.inl ⟨r.1, r.2.1⟩
-- Localization of a closed mediated chain to the unique directed triangle.
/-- Every edge of the expanded walk is on a simple cycle. If each such cycle is
a triangle and all triangles have the same edges, the whole chain lives there. -/
private theorem acyclic_of_unique_triangle {G : FinTimestampedGraph n} (ax : SatisfiesAxiom1 G)
(onlyTriangles : ∀ c, FinSimpleCycle G c → 2 ≤ c.length → c.length = 3)
(unique : ∀ {a b c x y z}, Triangle G a b c → Triangle G x y z →
∀ e, TriangleEdge x y z e → TriangleEdge a b c e) :
∀ u, ¬ Reachable (FinMediated G) u u := by
intro u loop
obtain ⟨p, nonempty, directed, keep⟩ := expand_chain loop
have onTriangle (e : Edge (Fin n)) (member : e ∈ p) :
∃ a b c, Triangle G a b c ∧ TriangleEdge a b c e := by
obtain ⟨cycle, simple, length, through⟩ := cycle_through_edge ax directed member
obtain ⟨a, b, c, triangle, edges⟩ := triangle_of_cycle simple (onlyTriangles _ simple length)
exact ⟨a, b, c, triangle, edges e through⟩
obtain ⟨e, member⟩ := List.exists_mem_of_ne_nil _ nonempty
obtain ⟨a, b, c, triangle, _⟩ := onTriangle e member
apply triangle_mediated_acyclic G a b c (triangle_distinct ax triangle) u
apply keep
intro f hf
obtain ⟨x, y, z, another, inside⟩ := onTriangle f hf
exact unique triangle another f inside
-- Lower bound for the constructive countermodel.
/-- On at most three vertices every possible spatial cycle is a triangle.
Its vertices exhaust the graph, and Axiom 1 fixes the orientation of all its edges. -/
theorem three_vertex_axiom1_acyclic {G : FinTimestampedGraph n} (size : n ≤ 3)
(ax : SatisfiesAxiom1 G) : SatisfiesAxiom3 G := by
apply acyclic_of_unique_triangle ax
· intro c active length
have lower := cycle_length_ge_three ax active length
have upper := nodup_fin_length active.2.1
omega
· intro a b c x y z triangle other edge inside
obtain ⟨ab, ac, bc⟩ := triangle_distinct ax triangle
have covers (v : Fin n) : v ∈ [a, b, c] := by
by_cases present : v ∈ [a, b, c]
· exact present
· have tooMany : ([v, a, b, c] : List (Fin n)).Nodup := by simp [present, ab, ac, bc]
have bound := nodup_fin_length tooMany
simp at bound
omega
rcases inside with rfl | rfl | rfl
· exact edge_inside_triangle ax triangle (covers x) (covers y) other.1
· exact edge_inside_triangle ax triangle (covers y) (covers z) other.2.1
· exact edge_inside_triangle ax triangle (covers z) (covers x) other.2.2
-- Lower bound for the static countermodel.
/-- On at most four vertices static PUC forces any two directed triangles
sharing an edge to coincide, leaving every closed mediated walk inside one triangle. -/
theorem four_vertex_static_acyclic {G : FinTimestampedGraph n} (size : n ≤ 4)
(ax : SatisfiesAxiom1 G) (static : SatisfiesStaticAxiom2 G) : SatisfiesAxiom3 G := by
apply acyclic_of_unique_triangle ax static.1
intro a b c x y z first second
obtain ⟨e, inFirst, inSecond⟩ := triangles_share_edge size ax first second
exact shared_triangle_identical ax static.2 first second inFirst inSecond
-- The four-vertex base uses labels A, B, C, D in that order.
def constructiveBase : FinTimestampedGraph 4 := graphFrom [((2, 0), 1), ((0, 1), 2), ((1, 3), 4)]
-- Add B to C at the constructor height three.
def constructiveFirst : FinTimestampedGraph 4 := insertFiniteChord constructiveBase (1, 2) 3
-- Add D to A at the constructor height five.
def constructiveCountermodel : FinTimestampedGraph 4 := insertFiniteChord constructiveFirst (3, 0) 5
-- Allow reduction through the finite lists in the cycle certificates.
set_option maxRecDepth 4096
-- Exact two-step constructive history on four vertices.
/-- Both specified support paths pass PUC in their own snapshot, and the two
constructor heights are three and five. No step adds a long simple cycle. -/
theorem constructive_four_accretion : SatisfiesConstructiveAxiom2 constructiveCountermodel := by
have base : SatisfiesConstructiveAxiom2 constructiveBase := by
refine .base (certify_cycles (by decide)) ?_
unfold AllSimple2PathsCompliant
decide
have afterFirst : SatisfiesConstructiveAxiom2 constructiveFirst := by
change SatisfiesConstructiveAxiom2 (insertFiniteChord constructiveBase (1, 2)
(creationHeight constructiveBase 1))
exact .accrete base 2 0 1 (by decide) (by decide) (by decide) (certify_cycles (by decide))
change SatisfiesConstructiveAxiom2 (insertFiniteChord constructiveFirst (3, 0)
(creationHeight constructiveFirst 3))
exact .accrete afterFirst 0 1 3 (by decide) (by decide) (by decide) (certify_cycles (by decide))
-- Four-vertex constructive attainment.
/-- Three increasing two-edge witnesses give A to C, C to B, and B to A. -/
theorem constructive_four_countermodel :
SatisfiesAxiom1 constructiveCountermodel ∧ SatisfiesConstructiveAxiom2 constructiveCountermodel ∧
FinMediated constructiveCountermodel 0 2 ∧ FinMediated constructiveCountermodel 2 1 ∧
FinMediated constructiveCountermodel 1 0 ∧ Reachable (FinMediated constructiveCountermodel) 0 0 := by
have ac : FinMediated constructiveCountermodel 0 2 := ⟨[(0, 1), (1, 2)], by decide⟩
have cb : FinMediated constructiveCountermodel 2 1 := ⟨[(2, 0), (0, 1)], by decide⟩
have ba : FinMediated constructiveCountermodel 1 0 := ⟨[(1, 3), (3, 0)], by decide⟩
refine ⟨?_, constructive_four_accretion, ac, cb, ba, .prepend ac (.prepend cb (.single ba))⟩
unfold SatisfiesAxiom1 DirectedCausalLink TimestampedGraph.toDiGraph
decide
/-- Axiom 1 alone rules out smaller examples, and the four-vertex accretion attains the bound. -/
theorem least_constructive_countermodel :
(∀ {n} (G : FinTimestampedGraph n), n < 4 → SatisfiesAxiom1 G → SatisfiesAxiom3 G) ∧
(∃ G : FinTimestampedGraph 4, SatisfiesAxiom1 G ∧ SatisfiesConstructiveAxiom2 G ∧
¬ SatisfiesAxiom3 G) := by
refine ⟨fun G size ax => three_vertex_axiom1_acyclic (G := G) (by omega) ax, ?_⟩
obtain ⟨ax, constructed, _, _, _, diagonal⟩ := constructive_four_countermodel
exact ⟨constructiveCountermodel, ax, constructed, fun acyclic => acyclic 0 diagonal⟩
end QBD.Ch02
#print axioms QBD.Ch02.triangle_mediated_acyclic
#print axioms QBD.Ch02.three_vertex_axiom1_acyclic
#print axioms QBD.Ch02.four_vertex_static_acyclic
#print axioms QBD.Ch02.constructive_four_countermodel
#print axioms QBD.Ch02.least_constructive_countermodel
Verification Summary:
The machine-checked proofs establish that no three-vertex Axiom-1 graph or four-vertex static graph violates acyclic effective causality, and exhibit a four-vertex constructive accretion sequence attaining the exact minimal countermodel size. Larger multi-step trajectories remain outside this minimality certificate. The Lean 4 kernel accepts all closed proof terms using only standard axioms, certifying the minimality claims of Least Constructive Countermodel §2.6.7.
In Plain English:
Machine-checked Lean 4 proofs certify the discrete claims formalized in Section 2.6.7.3.
2.6.8 Lemma: Least Static Countermodel
Let denote the class of finite timestamped graphs satisfying Axiom 1 and the static geometric diagnostic. The least vertex count in with for some vertex is five.
In Plain English:
Section 2.6.8 formalizes the properties of the QBD lemma regarding least static countermodel.
2.6.8.1 Proof: Least Static Countermodel
I. Exclusion of Two Triangles on Four Vertices
Let denote a graph on at most four vertices satisfying Axiom 1 and the static geometric diagnostic (Independence of Axioms 1 and 2 §2.5.1). Let denote the vertex sets of two directed triangles. Then
If , then . Let and denote the triangle edge sets. For any unordered pair in , both intersections of the triangle edge sets with are singletons. If the singletons differed, their union would include both orientations in , contrary to Axiom 1. Thus
The union over the three unordered pairs yields .
For distinct triangles, . Let denote the intersection, with the shared edge oriented , and let and denote the third vertices in and , respectively. Closure of each triangle determines its other two edges:
Since , the set of simple paths of length at most two from to includes both distinct triples and has cardinality at least two. This contradicts uniqueness under the static diagnostic. Thus contains at most one directed triangle.
II. Localization of a Closed Mediated Chain
Suppose . Then for some , and each link admits a simple witness (Effective Influence §2.6.2). Let denote the closed walk given by substituting those witnesses at the shared endpoints (Least Constructive Countermodel §2.6.7). For , let and denote and , respectively. The return walk from to along the other edges of is
where the first segment is empty if , because . Let denote a shortest walk from to using edges of . If for , deleting that segment yields
In the first case is an edge of . In the second case , so the terminal vertex is preserved. Both walks have edges, contrary to the choice of . Thus the vertices of are distinct. Since , prefixing to yields the simple cycle containing .
The static diagnostic requires each of these cycles to have length three. Since has an edge, there is at least one such triangle, and Part I establishes that there is at most one. Let denote this triangle, let denote its edges, and let denote mediated influence computed using only these edges and their original heights. For the vertices of the original -chain, each witness uses only edges of , and . Consequently,
The closure on the triangle is irreflexive for any assignment of its active heights (Least Constructive Countermodel §2.6.7). Thus , contrary to .
III. Verification of the Five-Vertex Static Diagnostic
Let denote the graph on given by
The edge set and its reverse satisfy
Each pair in has distinct coordinates, establishing Axiom 1 together with the disjointness. The restriction to is , whose heads have no outgoing edges in that restriction. Thus every simple cycle contains . Following each first edge out of yields the following successive choices:
The only outgoing edges from are the two first edges in the table, and each subsequent choice is unique until the return. Continuing past that return would repeat . Hence the listed triangles are the only simple cycles up to rotation.
Every two-path through a middle vertex comes from pairing an incoming edge of with an outgoing edge of . The complete choices and their endpoint pairs are
Each triple in the table has distinct vertices. Let denote the set of destinations of its two-paths starting at , and let denote the destinations of the direct edges from . The row-by-row counts and intersections are
In each row equals the number of two-paths in that row. Thus each destination occurs once among the two-paths from . The empty intersections exclude a direct edge with the same endpoints. Together with the two triangle cycles, this establishes the static diagnostic.
IV. Attainment of a Diagonal
The graph contains the two simple directed witnesses
The first satisfies , and the second satisfies . The two paths yield and , so
The five-vertex example and the exclusion for graphs on at most four vertices establish the minimum.
Q.E.D.
In Plain English:
Section 2.6.8.1 formalizes the properties of the QBD proof regarding least static countermodel.
2.6.8.2 Type-Theoretic Validation via Lean 4 Core
Type-theoretic certification of the five-vertex static countermodel established in Least Static Countermodel §2.6.8 proceeds via the following verification strategy:
- Model: A five-vertex butterfly timestamped graph, its stepwise geometric accretion sequence, and the exhaustive four-vertex acyclicity lower bound represent the least static countermodel.
- Certified Claims: The module certifies that the five-vertex butterfly arises by valid local accretion, satisfies the local axioms while violating Axiom 3 Acyclic Effective Causality §2.7.1, and attains the exact five-vertex minimum for static countermodels in Least Static Countermodel §2.6.8.1.
- Scope Boundary: Minimality applies to static timestamped graphs satisfying the local axioms while admitting a mediated causal loop. Non-constructive arbitrary labelings on larger graphs are not restricted.
import QBD.Ch02.L2_6_7_LeastConstructiveCountermodel
namespace QBD.Ch02
-- The butterfly uses vertex order A, Z, D, C, B.
def butterflyBase : FinTimestampedGraph 5 :=
graphFrom [((0, 1), 1), ((1, 2), 2), ((2, 3), 3), ((1, 4), 5)]
-- Add C to Z at the constructor height four.
def butterflyFirst : FinTimestampedGraph 5 := insertFiniteChord butterflyBase (3, 1) 4
-- Add B to A at the constructor height six to complete the butterfly.
def butterfly : FinTimestampedGraph 5 := insertFiniteChord butterflyFirst (4, 0) 6
-- Allow reduction through the finite lists in the cycle certificates.
set_option maxRecDepth 4096
/-- Two constructor steps produce the butterfly at the source-maximum heights. -/
theorem butterfly_accretion : SatisfiesConstructiveAxiom2 butterfly := by
have base : SatisfiesConstructiveAxiom2 butterflyBase := by
refine .base (certify_cycles (by decide)) ?_
unfold AllSimple2PathsCompliant
decide
have afterFirst : SatisfiesConstructiveAxiom2 butterflyFirst := by
change SatisfiesConstructiveAxiom2 (insertFiniteChord butterflyBase (3, 1)
(creationHeight butterflyBase 3))
exact .accrete base 1 2 3 (by decide) (by decide) (by decide) (certify_cycles (by decide))
change SatisfiesConstructiveAxiom2 (insertFiniteChord butterflyFirst (4, 0)
(creationHeight butterflyFirst 4))
exact .accrete afterFirst 0 1 4 (by decide) (by decide) (by decide) (certify_cycles (by decide))
-- Five-vertex static attainment and independence of Axiom 3.
/-- Both geometric predicates and Axiom 1 hold. The paths from A to D and D to A
are individually simple and strictly increasing, giving a closure diagonal at A. -/
theorem butterfly_countermodel :
SatisfiesAxiom1 butterfly ∧ SatisfiesStaticAxiom2 butterfly ∧
SatisfiesConstructiveAxiom2 butterfly ∧ FinMediated butterfly 0 2 ∧ FinMediated butterfly 2 0 ∧
Reachable (FinMediated butterfly) 0 0 ∧ ¬ SatisfiesAxiom3 butterfly := by
have ad : FinMediated butterfly 0 2 := ⟨[(0, 1), (1, 2)], by decide⟩
have da : FinMediated butterfly 2 0 := ⟨[(2, 3), (3, 1), (1, 4), (4, 0)], by decide⟩
have diagonal : Reachable (FinMediated butterfly) 0 0 := .prepend ad (.single da)
refine ⟨?_, ⟨certify_cycles (by decide), ?_⟩, butterfly_accretion, ad, da,
diagonal, fun acyclic => acyclic 0 diagonal⟩
· unfold SatisfiesAxiom1 DirectedCausalLink TimestampedGraph.toDiGraph
decide
· unfold AllSimple2PathsCompliant
decide
/-- Smaller graphs satisfying both local static predicates are acyclic, while the butterfly is cyclic. -/
theorem least_static_countermodel :
(∀ {n} (G : FinTimestampedGraph n), n < 5 → SatisfiesAxiom1 G →
SatisfiesStaticAxiom2 G → SatisfiesAxiom3 G) ∧
(∃ G : FinTimestampedGraph 5, SatisfiesAxiom1 G ∧ SatisfiesStaticAxiom2 G ∧
SatisfiesConstructiveAxiom2 G ∧ ¬ SatisfiesAxiom3 G) := by
refine ⟨fun G size ax static => four_vertex_static_acyclic (G := G) (by omega) ax static, ?_⟩
obtain ⟨ax, static, constructed, _, _, _, cyclic⟩ := butterfly_countermodel
exact ⟨butterfly, ax, static, constructed, cyclic⟩
end QBD.Ch02
#print axioms QBD.Ch02.butterfly_accretion
#print axioms QBD.Ch02.butterfly_countermodel
#print axioms QBD.Ch02.least_static_countermodel
Verification Summary:
The machine-checked proofs establish that the five-vertex butterfly graph is reachable by local geometric accretion, satisfies the local axioms while exhibiting a mediated causal loop, and attains the exact minimum vertex count of five for a static countermodel. General multi-butterfly dynamics remain outside this finite minimality module. The Lean 4 kernel accepts all closed proof terms using only standard axioms, certifying the minimality claims of Least Static Countermodel §2.6.8.
In Plain English:
Machine-checked Lean 4 proofs certify the discrete claims formalized in Section 2.6.8.3.
2.6.9 Proof: Inadequacy of Local Axioms
I. Spatial Witnesses
Every witness is a simple increasing spatial path (Effective Influence §2.6.2). Weak height filtering allows additional equal-height witnesses (Strict Timestamps §2.6.3).
II. Closure Failure
A composite cycle gives a diagonal pair in (Failure of Reflexivity §2.6.4). In particular, the two increasing arcs of the directed perimeter yield , and hence (Failure of Asymmetry §2.6.5).
The four-vertex accretion satisfies Axiom 1 and the constructive geometric predicate with a diagonal in (Least Constructive Countermodel §2.6.7). The five-vertex butterfly satisfies Axiom 1 and the static geometric diagnostic with a diagonal in (Least Static Countermodel §2.6.8).
III. Spatial Closure
Spatial triangle closure can coexist with acyclic mediated closure (Causal Acyclicity vs. Spatial Triangulation §2.6.6). The two local constraints thus permit both acyclic and cyclic mediated closures.
Q.E.D.
In Plain English:
Section 2.6.9 formalizes the properties of the QBD proof regarding inadequacy of local axioms.
2.6.9.1 Corollary: Global Constraint
A physical theory requires a well-defined causal ordering (a "direction of time"). The proven failure of Axioms 1 and 2 to entail such an order necessitates a third axiom. This axiom must explicitly forbid states containing causal paradoxes, acting as a global topological constraint.
Q.E.D.
In Plain English:
Section 2.6.9.1 formalizes the properties of the QBD corollary regarding global constraint.
2.6.9.2 Type-Theoretic Validation via Lean 4 Core
Type-theoretic certification of the inadequacy of local constraints established in Inadequacy of Local Axioms §2.6.1 proceeds via the following verification strategy:
- Model: The assembly module imports all seven certified Chapter 2 effective-influence, strict-timestamp, reflexivity-failure, asymmetry-failure, spatial-triangulation, and minimal-countermodel modules.
- Certified Claims: The module assembles mediated path structure, strict-versus-weak separation, failure of closure irreflexivity and asymmetry, coexistence of spatial triangles with acyclic dependencies, and the exact four-vertex constructive and five-vertex static countermodel minima in Inadequacy of Local Axioms §2.6.9.
- Scope Boundary: The assembly certifies finite graph-theoretic countermodels and exact small-vertex lower bounds under the local axioms. Global enforcement protocols are certified in the next section.
import QBD.Ch02.L2_6_2_EffectiveInfluence
import QBD.Ch02.L2_6_3_StrictTimestamps
import QBD.Ch02.L2_6_4_FailureOfReflexivity
import QBD.Ch02.L2_6_5_FailureOfAsymmetry
import QBD.Ch02.L2_6_6_CausalAcyclicityVsSpatialTriangulation
import QBD.Ch02.L2_6_7_LeastConstructiveCountermodel
import QBD.Ch02.L2_6_8_LeastStaticCountermodel
namespace QBD.Ch02
/-- The two local axioms permit both mutual effective influence and a closure diagonal. -/
theorem inadequacy_of_local_axioms :
(∃ G : FinTimestampedGraph 4, SatisfiesAxiom1 G ∧ SatisfiesConstructiveAxiom2 G ∧
¬ SatisfiesAxiom3 G) ∧
(∃ G : FinTimestampedGraph 5, SatisfiesAxiom1 G ∧ SatisfiesStaticAxiom2 G ∧
SatisfiesConstructiveAxiom2 G ∧ (∀ a, ¬ FinMediated G a a) ∧
∃ a b, a ≠ b ∧ FinMediated G a b ∧ FinMediated G b a ∧ Reachable (FinMediated G) a a) := by
obtain ⟨links, static, built, forward, backward, loop, _⟩ := butterfly_countermodel
exact ⟨least_constructive_countermodel.2,
⟨butterfly, links, static, built, mediated_irreflexive _, 0, 2, by decide, forward, backward, loop⟩⟩
end QBD.Ch02
#print axioms QBD.Ch02.inadequacy_of_local_axioms
Verification Summary:
The machine-checked proof unifies all seven per-lemma certificates into a single closed theorem confirming that local directed-link and geometric-constructibility constraints cannot prevent mediated causal loops, with exact four-vertex constructive and five-vertex static minima. Global enforcement algorithms remain outside this inadequacy assembly. The Lean 4 kernel accepts the closed proof term using only standard axioms, certifying the logical synthesis of Inadequacy of Local Axioms §2.6.9.
In Plain English:
Section 2.6.9.2 formalizes the properties of the QBD type-theoretic regarding validation via lean 4 core.
2.7.1 Definition: Axiom 3 Acyclic Effective Causality
Let be the Effective Influence relation of mediated simple spatial paths with strictly increasing causal heights (Effective Influence §2.6.2). Acyclic Effective Causality requires its nonempty transitive closure to be irreflexive:
Concatenation of finite -chains makes transitive. If and , concatenation would give , so is asymmetric as well. The strict partial order in this axiom is ; the original time-respecting simple-path relation need not be transitive. The occurrence dependency order is a separate chronological relation on creation records (Monotonicity of History §1.4.5).
Lean 4 (QBD.Ch02.Defs):
/-- A simple directed witness with at least two edges and strictly increasing active heights. -/
def IsMediatedPath {V : Type u} (G : RelTimestampedGraph V) (a b : V)
(path : List (Edge V)) : Prop :=
2 ≤ path.length ∧ DirectedEdgePath G.edges a b path ∧
IsEdgePathMonotone G.height path ∧ IsSimple a path
def Mediated {V : Type u} (G : RelTimestampedGraph V) (a b : V) : Prop :=
∃ path, IsMediatedPath G a b path
/-- §2.7.1 Axiom 3. The nonempty closure of effective influence is irreflexive. -/
def AcyclicEffectiveCausality {V : Type u} (G : RelTimestampedGraph V) : Prop :=
(DiGraph.mk (Mediated G)).DAG
In Plain English:
Causality is strictly acyclic: an event can never be its own cause. This prevents grandfather paradoxes and closed timeline loops.
2.7.2 Theorem: Causal Admission of Chord Batches
Let and denote the mediated relations before and after a chord batch, with irreflexive and each retained chord's height at least every old outgoing height at its target, and let denote the set of retained chord targets. Then is irreflexive if and only if for every , with irreflexivity in particular on a first tick with old edges of uniform height raising a vertex grading by one and elementary return chords of height . Moreover, (i) occurrence-order acyclicity and the local geometric predicates are compatible with cyclic mediated closure, (ii) for every fixed radius there exists a pair of timestamped graphs with identical rooted radius- induced balls and opposite mediated acyclicity, and (iii) for elementary return-chord candidates between distinct vertices with no direct reverse edge on a fixed -vertex support of maximum undirected degree three, the simple-path and walk reverse-witness tests are equivalent at a common cutoff, with the one-tick miss probability at bounded by under a conditional height-comparison success bound given each exposed prefix.
In Plain English:
Section 2.7.2 formalizes the properties of the QBD theorem regarding causal admission of chord batches.
2.7.3 Lemma: Finite-Radius Indistinguishability
For any observation radius , there are timestamped directed graphs whose rooted radius- induced balls coincide, with one graph having acyclic mediated closure and the other having a mediated cycle.
In Plain English:
Section 2.7.3 formalizes the properties of the QBD lemma regarding finite-radius indistinguishability.
2.7.3.1 Proof: Finite-Radius Indistinguishability
I. The Closed and Open Perimeters
Let and . Use the cycle with edges and the open graph (Finite-Radius Indistinguishability §2.7.3) (Failure of Asymmetry §2.6.5). Assign edge heights by
Use the restriction of on .
II. Equality of the Rooted Balls
In the undirected support of , the two routes from to have lengths and . Consequently,
The endpoints of the removed edge satisfy
For , the route remains in and has length . For , the route remains in and has length . Every route in also occurs in . The distance comparisons are therefore
Thus . The deleted edge has neither endpoint in this ball, so the induced edges have the same directions and heights.
III. Opposite Closure Outcomes
The two directed arcs in give
Each arc is a simple path of length and its heights increase strictly. Hence and . In , let denote the index in the order . For every edge of , . A path of length therefore has . Every witness has positive length, so a composition of such witnesses satisfies
This proves for all .
Q.E.D.
In Plain English:
Section 2.7.3.1 formalizes the properties of the QBD proof regarding finite-radius indistinguishability.
2.7.3.2 Type-Theoretic Validation via Lean 4 Core
Type-theoretic certification of the local-horizon blindness established in Finite-Radius Indistinguishability §2.7.3 proceeds via the following verification strategy:
- Model: Pairs of finite timestamped graphs parameterized by an arbitrary inspection radius, radius-bounded neighborhood balls, and global mediated acyclicity predicates represent finite-radius observability.
- Certified Claims: The module certifies that for every finite inspection radius there exist two graphs with identical local neighborhoods around the candidate site that disagree on Axiom 3 Acyclic Effective Causality §2.7.1 in Finite-Radius Indistinguishability §2.7.3.1.
- Scope Boundary: Indistinguishability applies to deterministic checks restricted to a fixed combinatorial ball radius. Global search or probabilistic depth-scaled guards are analyzed in the subsequent modules.
import QBD.Ch02.L2_6_5_FailureOfAsymmetry
namespace QBD.Ch02
universe u
/-- A rooted ball uses distance in the undirected support of the snapshot. -/
def InRootedBall {V : Type u} (G : RelTimestampedGraph V) (root : V) (r : Nat) (x : V) : Prop :=
∃ path, DirectedEdgePath (fun e => G.edges e ∨ G.edges e.swap) root x path ∧ path.length ≤ r
/-- Equality of rooted vertex sets and induced directed edges and active heights. -/
def SameRootedBall {V : Type u} (G H : RelTimestampedGraph V) (root : V) (r : Nat) : Prop :=
(∀ x, InRootedBall G root r x ↔ InRootedBall H root r x) ∧
∀ a b, InRootedBall G root r a → InRootedBall G root r b →
(G.edges (a, b) ↔ H.edges (a, b)) ∧ (G.edges (a, b) → G.height (a, b) = H.height (a, b))
private abbrev Ring (r : Nat) := Fin (2 * (r + 2))
private def ringVertex (r i : Nat) : Ring r := wrapVertex _ (by omega) i
private def closedRing (r : Nat) : RelTimestampedGraph (Ring r) :=
⟨fun e => e.2 = ringVertex r (e.1.val + 1), fun e => e.1.val % (r + 2)⟩
private def openRing (r : Nat) : RelTimestampedGraph (Ring r) :=
⟨fun e => (closedRing r).edges e ∧ e.1.val ≠ r + 1, (closedRing r).height⟩
private def ringDistance {r : Nat} (v : Ring r) : Nat := min v.val (2 * (r + 2) - v.val)
private def openRank {r : Nat} (v : Ring r) : Nat :=
if v.val < r + 2 then v.val + r + 2 else v.val - (r + 2)
private theorem ring_successor {r : Nat} {a b : Ring r} (edge : (closedRing r).edges (a, b)) :
b.val = a.val + 1 ∨ (a.val + 1 = 2 * (r + 2) ∧ b.val = 0) := by
have bValue : b.val = (a.val + 1) % (2 * (r + 2)) := congrArg Fin.val edge
have within := a.isLt
by_cases last : a.val + 1 = 2 * (r + 2)
· exact Or.inr ⟨last, by simpa [last] using bValue⟩
· exact Or.inl (bValue.trans (Nat.mod_eq_of_lt (by omega)))
private theorem ring_distance_step {r : Nat} {a b : Ring r} (edge : (closedRing r).edges (a, b)) :
ringDistance b ≤ ringDistance a + 1 ∧ ringDistance a ≤ ringDistance b + 1 := by
rcases ring_successor edge with next | ⟨last, zero⟩ <;>
simp only [ringDistance, Nat.min_def] <;> split <;> split <;> omega
private theorem ring_distance_walk {r : Nat} {a b : Ring r} {path : List (Edge (Ring r))}
(walk : DirectedEdgePath (fun e => (closedRing r).edges e ∨ (closedRing r).edges e.swap) a b path) :
ringDistance b ≤ ringDistance a + path.length := by
induction path generalizing a with
| nil =>
have equal : a = b := walk
simp [equal]
| cons e rest ih =>
have next : ringDistance e.2 ≤ ringDistance a + 1 := by
rw [← walk.2.1]
exact walk.1.elim (fun edge => (ring_distance_step edge).1) (fun edge => (ring_distance_step edge).2)
have tail := ih walk.2.2
simp only [List.length_cons]
omega
private theorem open_walk {r : Nat} {a b : Ring r} {path : List (Edge (Ring r))}
(walk : DirectedEdgePath (fun e => (closedRing r).edges e ∨ (closedRing r).edges e.swap) a b path)
(budget : ringDistance a + path.length ≤ r) :
DirectedEdgePath (fun e => (openRing r).edges e ∨ (openRing r).edges e.swap) a b path := by
induction path generalizing a with
| nil => exact walk
| cons e rest ih =>
have far (x : Ring r) (value : x.val = r + 1) : ringDistance x = r + 1 := by
simp only [ringDistance, Nat.min_def, value]
split <;> omega
obtain ⟨edge, source, tail⟩ := walk
have step : ringDistance e.2 ≤ ringDistance a + 1 := by
rw [← source]
exact edge.elim (fun edge => (ring_distance_step edge).1) (fun edge => (ring_distance_step edge).2)
have smaller : ringDistance e.2 + rest.length ≤ r := by
simp only [List.length_cons] at budget
omega
refine ⟨?_, source, ih tail smaller⟩
rcases edge with forward | reverse
· exact Or.inl ⟨forward, fun equal => by
have distance := far e.1 equal
rw [source] at distance
omega⟩
· exact Or.inr ⟨reverse, fun equal => by have distance := far e.2 equal; omega⟩
private theorem same_ring_balls (r : Nat) : SameRootedBall (closedRing r) (openRing r) (ringVertex r 0) r := by
have rootDistance : ringDistance (ringVertex r 0) = 0 := by simp [ringDistance, ringVertex, wrapVertex]
constructor
· intro x
constructor
· rintro ⟨p, walk, length⟩
exact ⟨p, open_walk walk (by simpa [rootDistance] using length), length⟩
· rintro ⟨p, walk, length⟩
have liftWalk (a b : Ring r) {edges : List (Edge (Ring r))}
(w : DirectedEdgePath (fun e => (openRing r).edges e ∨ (openRing r).edges e.swap) a b edges) :
DirectedEdgePath (fun e => (closedRing r).edges e ∨ (closedRing r).edges e.swap) a b edges := by
induction edges generalizing a with
| nil => exact w
| cons _ _ ih => exact ⟨w.1.imp And.left And.left, w.2.1, ih _ w.2.2⟩
exact ⟨p, liftWalk _ _ walk, length⟩
· intro a b aBall _
obtain ⟨p, walk, length⟩ := aBall
have close := ring_distance_walk walk
have inside : ringDistance a ≤ r := by omega
have notRemoved : a.val ≠ r + 1 := by
intro equal
simp only [ringDistance, equal, Nat.min_def] at inside
split at inside <;> omega
exact ⟨⟨fun edge => ⟨edge, notRemoved⟩, And.left⟩, fun _ => rfl⟩
private theorem open_rank_step {r : Nat} {a b : Ring r} (edge : (openRing r).edges (a, b)) :
openRank b = openRank a + 1 := by
obtain ⟨present, cut⟩ := edge
change a.val ≠ r + 1 at cut
have aBound := a.isLt
have bBound := b.isLt
rcases ring_successor present with next | ⟨last, zero⟩ <;>
simp only [openRank] <;> split <;> split <;> omega
private theorem open_rank_walk {r : Nat} {a b : Ring r} {path : List (Edge (Ring r))}
(walk : DirectedEdgePath (openRing r).edges a b path) : openRank b = openRank a + path.length := by
induction path generalizing a with
| nil =>
have equal : a = b := walk
simp [equal]
| cons e rest ih =>
have step := open_rank_step walk.1
rw [walk.2.1] at step
have tail := ih walk.2.2
simp only [List.length_cons]
omega
private theorem open_ring_acyclic (r : Nat) : AcyclicEffectiveCausality (openRing r) := by
have rises : StrictCausalMonotonicity (Mediated (openRing r)) openRank := by
rintro a b ⟨p, length, directed, _, _⟩
have distance := open_rank_walk directed
omega
exact rises.dag
private theorem closed_ring_arc (r start : Nat) (half : start = 0 ∨ start = r + 2) :
Mediated (closedRing r) (ringVertex r start) (ringVertex r (start + (r + 2))) := by
let p := perimeterArc (2 * (r + 2)) (by omega) start (r + 2)
refine ⟨p, by simp [p, perimeterArc], ?_, ?_, ?_⟩
· have directed := perimeter_arc_directed (L := 2 * (r + 2)) (by omega) start (r + 2)
have transport {a b : Ring r} {path : List (Edge (Ring r))}
(walk : DirectedEdgePath (timestampedPerimeter (2 * (r + 2)) (by omega)).edges a b path) :
DirectedEdgePath (closedRing r).edges a b path := by
induction path generalizing a with
| nil => exact walk
| cons e rest ih =>
exact ⟨(perimeter_edge (by omega) e.1 e.2).mp walk.1, walk.2.1, ih walk.2.2⟩
exact transport directed
· unfold IsEdgePathMonotone
apply List.pairwise_map.mpr
apply (List.pairwise_lt_range' (s := start) (n := r + 2)).imp_of_mem
intro i j hi hj order
obtain ⟨iLo, _⟩ := List.mem_range'_1.mp hi
obtain ⟨_, jHi⟩ := List.mem_range'_1.mp hj
change (i % (2 * (r + 2))) % (r + 2) < (j % (2 * (r + 2))) % (r + 2)
rw [Nat.mod_eq_of_lt (by omega : i < 2 * (r + 2)), Nat.mod_eq_of_lt (by omega : j < 2 * (r + 2))]
rcases half with zero | midpoint
· rwa [Nat.mod_eq_of_lt (by omega : i < r + 2), Nat.mod_eq_of_lt (by omega : j < r + 2)]
· rw [Nat.mod_eq_sub_mod (by omega : r + 2 ≤ i), Nat.mod_eq_sub_mod (by omega : r + 2 ≤ j)]
rw [Nat.mod_eq_of_lt (by omega : i - (r + 2) < r + 2),
Nat.mod_eq_of_lt (by omega : j - (r + 2) < r + 2)]
omega
· exact perimeter_arc_simple (by omega) (by omega) (by omega)
/-- §2.7.3. Deleting a single perimeter edge outside the observed ball changes Axiom 3. -/
theorem finite_radius_indistinguishability (r : Nat) (_positive : 1 ≤ r) :
∃ (closed opened : RelTimestampedGraph (Fin (2 * r + 4))) (root : Fin (2 * r + 4)),
SameRootedBall closed opened root r ∧ AcyclicEffectiveCausality opened ∧
Reachable (Mediated closed) root root := by
have first := closed_ring_arc r 0 (Or.inl rfl)
rw [Nat.zero_add] at first
have second := closed_ring_arc r (r + 2) (Or.inr rfl)
have closes : ringVertex r (r + 2 + (r + 2)) = ringVertex r 0 := by
apply Fin.ext
have length : r + 2 + (r + 2) = 2 * (r + 2) := by omega
simp [ringVertex, wrapVertex, length]
have loop : Reachable (Mediated (closedRing r)) (ringVertex r 0) (ringVertex r 0) :=
.tail (.single first) (closes ▸ second)
have size : 2 * r + 4 = 2 * (r + 2) := by omega
rw [size]
exact ⟨closedRing r, openRing r, ringVertex r 0, same_ring_balls r, open_ring_acyclic r, loop⟩
end QBD.Ch02
#print axioms QBD.Ch02.finite_radius_indistinguishability
Verification Summary:
The machine-checked proof constructs, for every finite inspection radius, two timestamped graphs sharing identical local neighborhoods around the candidate site while differing in global mediated acyclicity, confirming that no fixed-radius local rule can decide the third axiom. Probabilistic and depth-scaled guards remain outside this deterministic impossibility module. The Lean 4 kernel accepts the closed proof term using only standard axioms, certifying the horizon limitation of Finite-Radius Indistinguishability §2.7.3.
In Plain English:
Machine-checked Lean 4 proofs certify the discrete claims formalized in Section 2.7.3.4.
2.7.4 Lemma: Bounded Reverse-Witness Misses
Let the fixed candidate support have vertices of maximum undirected degree three, with each new height comparison on a fixed simple path having conditional success probability at most given its exposed prefix. At , the probability of any missed reverse witness in one tick is at most , and uniform conditional control across ticks gives the sum of their respective one-tick bounds.
In Plain English:
Section 2.7.4 formalizes the properties of the QBD lemma regarding bounded reverse-witness misses.
2.7.4.1 Proof: Bounded Reverse-Witness Misses
I. Path Probabilities
The reverse-witness guard evaluates paths from a fixed candidate target (Bounded Reverse-Witness Misses §2.7.4) (Acyclic Effective Causality §2.7.1).
For a fixed length- path let be the event that its first comparisons succeed. Since and , . Requiring its final height below the candidate height only restricts this event.
II. Path and Site Counts
The first edge has at most three choices. Subsequent edges have at most two after excluding the predecessor. Thus for a fixed starting vertex at most length- simple paths are possible. With the site bound is
Let be the candidate set and the miss event at site . The candidate count and union bound give
III. Dependence on Horizon
Since and ,
Since , . Let be the event of a miss at tick , let be the history before it, and let be the displayed bound. Under the uniform conditional premise,
Q.E.D.
In Plain English:
Section 2.7.4.1 formalizes the properties of the QBD proof regarding bounded reverse-witness misses.
2.7.4.2 Type-Theoretic Validation via Lean 4 Core
Type-theoretic certification of the finite rational reverse-witness miss bounds established in Bounded Reverse-Witness Misses §2.7.4 proceeds via the following verification strategy:
- Model: Degree-three support catalogs, finite simple-route enumerations, rational prefix weights, finite geometric tails, and multi-tick union bounds represent bounded-depth reverse-path screening.
- Certified Claims: The module certifies degree-three catalog size bounds, prefix probability bounds, finite geometric tail inequalities, one-tick miss bounds from abstract and cataloged counts, and the multi-tick reverse-witness miss bound at logarithmic depth plus three in Bounded Reverse-Witness Misses §2.7.4.1.
- Scope Boundary: The probabilistic interface accepts finite rational event weights and a union-bound premise. Measure-theoretic finite union bounds and real-valued asymptotic convergence at the logarithmic cutoff are certified separately in Type-Theoretic Validation via Lean 4 and Mathlib §2.7.4.3.
import QBD.Ch02.Defs
import Init.Data.Rat
import Init.Grind.Ordered.Rat
namespace QBD.Ch02
/-- The cutoff used in the bounded reverse search. -/
def reverseWitnessCutoff (N : Nat) : Nat := Nat.log2 N + 3
def reverseWitnessMissBound (N : Nat) (p : Rat) : Rat :=
18 * (N : Rat) * (2 * p) ^ reverseWitnessCutoff N / (1 - 2 * p)
/-- A finite sum over indices from zero to `terms - 1`. -/
def rationalPrefixSum (f : Nat → Rat) : Nat → Rat
| 0 => 0
| terms + 1 => rationalPrefixSum f terms + f terms
variable {N : Nat}
/-- Checkable hypotheses on a degree-three undirected support. -/
structure DegreeThreeSupport (neighbors : Fin N → List (Fin N)) : Prop where
distinct : ∀ v, (neighbors v).Nodup
degree : ∀ v, (neighbors v).length ≤ 3
symmetric : ∀ {u v}, v ∈ neighbors u → u ∈ neighbors v
/-- After the first edge, exclude the immediately preceding vertex. -/
def reverseExtensions (neighbors : Fin N → List (Fin N)) (previous current : Fin N) :
Nat → List (List (Fin N))
| 0 => [[]]
| length + 1 => ((neighbors current).erase previous).flatMap fun next =>
(reverseExtensions neighbors current next length).map (next :: ·)
def reverseRouteCatalog (neighbors : Fin N → List (Fin N)) (root : Fin N) :
Nat → List (List (Fin N))
| 0 => [[]]
| length + 1 => (neighbors root).flatMap fun next =>
(reverseExtensions neighbors root next length).map (next :: ·)
/-- A site starts with an ordered pair of distinct neighbors of a middle vertex. -/
def candidateSiteCatalog (neighbors : Fin N → List (Fin N)) : List (Fin N × Fin N × Fin N) :=
(List.finRange N).flatMap fun middle => (neighbors middle).flatMap fun v =>
((neighbors middle).erase v).map fun u => (v, middle, u)
private theorem flatMap_length_bound {α β : Type} (xs : List α) (branch : α → List β) (width : Nat)
(bounded : ∀ x ∈ xs, (branch x).length ≤ width) :
(xs.flatMap branch).length ≤ xs.length * width := by
induction xs with
| nil => simp
| cons x rest ih =>
have current := bounded x (by simp)
have remaining := ih (fun y member => bounded y (List.mem_cons_of_mem _ member))
simp only [List.flatMap_cons, List.length_append, List.length_cons, Nat.succ_mul]
omega
private theorem DegreeThreeSupport.erase_length {neighbors : Fin N → List (Fin N)}
(support : DegreeThreeSupport neighbors) {v previous : Fin N} (present : previous ∈ neighbors v) :
((neighbors v).erase previous).length ≤ 2 := by
rw [List.length_erase_of_mem present]
have degree := support.degree v
omega
private theorem reverse_extension_count {neighbors : Fin N → List (Fin N)}
(support : DegreeThreeSupport neighbors) (length : Nat) {previous current : Fin N}
(edge : previous ∈ neighbors current) : (reverseExtensions neighbors previous current length).length ≤ 2 ^ length := by
induction length generalizing previous current with
| zero => simp [reverseExtensions]
| succ length ih =>
have branches := flatMap_length_bound ((neighbors current).erase previous)
(fun next => (reverseExtensions neighbors current next length).map (next :: ·)) (2 ^ length)
(fun next member => by
rw [List.length_map]
exact ih (support.symmetric (List.mem_of_mem_erase member)))
exact Nat.le_trans branches (by
rw [Nat.pow_succ']
exact Nat.mul_le_mul_right _ (support.erase_length edge))
/-- Degree three bounds the first step by three, each extension by two, and sites by `6N`. -/
theorem degree_three_catalog_bounds {neighbors : Fin N → List (Fin N)}
(support : DegreeThreeSupport neighbors) :
(candidateSiteCatalog neighbors).length ≤ 6 * N ∧
∀ root length, (reverseRouteCatalog neighbors root (length + 1)).length ≤ 3 * 2 ^ length := by
constructor
· have budget := flatMap_length_bound (List.finRange N) (fun middle =>
(neighbors middle).flatMap fun v => ((neighbors middle).erase v).map fun u => (v, middle, u)) 6
(fun middle _ => by
apply Nat.le_trans (flatMap_length_bound (neighbors middle) _ 2 ?_)
· exact Nat.mul_le_mul_right _ (support.degree middle)
· intro v member
simpa using support.erase_length member)
simpa [candidateSiteCatalog, Nat.mul_comm] using budget
· intro root length
apply Nat.le_trans (flatMap_length_bound (neighbors root) _ (2 ^ length) ?_)
· exact Nat.mul_le_mul_right _ (support.degree root)
· intro next member
rw [List.length_map]
exact reverse_extension_count support length (support.symmetric member)
private theorem reverse_extension_complete {neighbors : Fin N → List (Fin N)}
(support : DegreeThreeSupport neighbors) {E : Edge (Fin N) → Prop}
(covered : ∀ a b, E (a, b) → b ∈ neighbors a) {previous current finish : Fin N} {ds : List (Fin N)}
(walk : DirectedEdgePath E current finish (edgesFrom current ds))
(distinct : (previous :: current :: ds).Nodup) :
ds ∈ reverseExtensions neighbors previous current ds.length := by
induction ds generalizing previous current with
| nil => simp [reverseExtensions]
| cons next rest ih =>
have different : next ≠ previous := fun eq => (List.nodup_cons.mp distinct).1 (by simp [← eq])
have choice := (support.distinct current).mem_erase_iff.mpr ⟨different, covered _ _ walk.1⟩
exact List.mem_flatMap.mpr ⟨next, choice,
List.mem_map.mpr ⟨rest, ih walk.2.2 (List.nodup_cons.mp distinct).2, rfl⟩⟩
/-- Every directed simple path on the support is represented in the route catalog. -/
theorem simple_route_in_catalog {neighbors : Fin N → List (Fin N)}
(support : DegreeThreeSupport neighbors) {E : Edge (Fin N) → Prop}
(covered : ∀ a b, E (a, b) → b ∈ neighbors a) {a b : Fin N} {path : List (Edge (Fin N))}
(walk : DirectedEdgePath E a b path) (simple : IsSimple a path) :
path.map Prod.snd ∈ reverseRouteCatalog neighbors a path.length := by
have rebuilt := walk.edgesFrom_rebuild
have directed : DirectedEdgePath E a b (edgesFrom a (path.map Prod.snd)) := rebuilt.symm ▸ walk
have length : (path.map Prod.snd).length = path.length := List.length_map Prod.snd
rw [← length]
unfold IsSimple at simple
generalize path.map Prod.snd = ds at directed simple ⊢
cases ds with
| nil => simp [reverseRouteCatalog]
| cons next rest =>
exact List.mem_flatMap.mpr ⟨next, covered _ _ directed.1,
List.mem_map.mpr ⟨rest, reverse_extension_complete support covered directed.2.2 simple, rfl⟩⟩
/-- The site catalog contains each simple two-path in the directed support. -/
theorem candidate_in_site_catalog {neighbors : Fin N → List (Fin N)}
(support : DegreeThreeSupport neighbors) {G : DiGraph (Fin N)}
(covered : ∀ a b, G.Adj a b → b ∈ neighbors a) {v w u : Fin N} (path : G.TwoPath v w u) :
(v, w, u) ∈ candidateSiteCatalog neighbors := by
obtain ⟨_, _, different, first, second⟩ := path
refine List.mem_flatMap.mpr ⟨w, List.mem_finRange _, List.mem_flatMap.mpr ⟨v, ?_, ?_⟩⟩
· exact support.symmetric (covered _ _ first)
· exact List.mem_map.mpr ⟨u, (support.distinct w).mem_erase_iff.mpr
⟨different.symm, covered _ _ second⟩, rfl⟩
/-- A conditional comparison bound compounds along an exposed prefix. -/
theorem comparison_prefix_probability (mass : Nat → Rat) (p : Rat) (pNonneg : 0 ≤ p)
(initial : mass 0 ≤ 1) (conditional : ∀ j, mass (j + 1) ≤ p * mass j) (k : Nat) :
mass k ≤ p ^ k := by
induction k with
| zero => simpa using initial
| succ k ih =>
rw [Rat.pow_succ, Rat.mul_comm]
exact Rat.le_trans (conditional k) (Rat.mul_le_mul_of_nonneg_left ih pNonneg)
private theorem rational_sum_mono {f g : Nat → Rat} {terms : Nat}
(bound : ∀ j, j < terms → f j ≤ g j) : rationalPrefixSum f terms ≤ rationalPrefixSum g terms := by
induction terms with
| zero => exact Rat.le_refl
| succ terms ih =>
have initial := ih (fun j h => bound j (Nat.lt_trans h (Nat.lt_succ_self _)))
have last := bound terms (Nat.lt_succ_self _)
change rationalPrefixSum f terms + f terms ≤ rationalPrefixSum g terms + g terms
grind
private theorem rational_sum_mul (c : Rat) (f : Nat → Rat) (terms : Nat) :
rationalPrefixSum (fun j => c * f j) terms = c * rationalPrefixSum f terms := by
induction terms with
| zero => simp [rationalPrefixSum]
| succ _ ih => simp only [rationalPrefixSum, ih, Rat.mul_add]
private theorem rational_sum_const (c : Rat) (terms : Nat) :
rationalPrefixSum (fun _ => c) terms = (terms : Rat) * c := by
induction terms with
| zero => simp [rationalPrefixSum]
| succ terms ih =>
change rationalPrefixSum (fun _ => c) terms + c = ((terms + 1 : Nat) : Rat) * c
rw [ih, Rat.natCast_add]
grind
private theorem geometric_sum_identity (q : Rat) (start terms : Nat) :
(1 - q) * rationalPrefixSum (fun j => q ^ (start + j)) terms + q ^ (start + terms) = q ^ start := by
induction terms with
| zero => simp [rationalPrefixSum, Rat.zero_add]
| succ terms ih =>
rw [rationalPrefixSum, ← Nat.add_assoc, Rat.pow_succ, Rat.mul_add]
grind
/-- The finite geometric sum is bounded by the stated tail with no limit argument. -/
theorem finite_geometric_tail (q : Rat) (nonnegative : 0 ≤ q) (belowOne : q < 1) (start terms : Nat) :
rationalPrefixSum (fun j => q ^ (start + j)) terms ≤ q ^ start / (1 - q) := by
have positive : 0 < 1 - q := by grind
have nonzero : 1 - q ≠ 0 := by grind
have tail := geometric_sum_identity q start terms
have residual := Rat.pow_nonneg (n := start + terms) nonnegative
apply Rat.le_of_mul_le_mul_right (c := 1 - q) _ positive
rw [Rat.div_mul_cancel nonzero, Rat.mul_comm _ (1 - q)]
grind
private theorem list_mass_le (weights : List Rat) (bound : Rat)
(each : ∀ w ∈ weights, w ≤ bound) : weights.sum ≤ (weights.length : Rat) * bound := by
induction weights with
| nil => simp
| cons w rest ih =>
have current := each w (by simp)
have remaining := ih (fun x hx => each x (List.mem_cons_of_mem _ hx))
simp only [List.sum_cons, List.length_cons, Rat.natCast_add]
grind
private theorem rat_mul_pow (a b : Rat) (k : Nat) : (a * b) ^ k = a ^ k * b ^ k := by
induction k with
| zero => simp
| succ k ih =>
rw [Rat.pow_succ, Rat.pow_succ a, Rat.pow_succ b, ih]
grind
/-- §2.7.4. A finite union estimate using the site count, path counts, and conditional prefix bounds.
Each list holds the reverse-witness probabilities at one site and one length above the cutoff. -/
theorem bounded_reverse_witness_misses (N sites terms : Nat) (p miss : Rat)
(pPositive : 0 < p) (pSmall : p < 1 / 4)
(weights : Nat → Nat → List Rat) (siteCount : sites ≤ 6 * N)
(pathCount : ∀ s j, s < sites → j < terms →
(weights s j).length ≤ 3 * 2 ^ (reverseWitnessCutoff N + j))
(pathProb : ∀ s j, s < sites → j < terms →
∀ w ∈ weights s j, w ≤ p ^ (reverseWitnessCutoff N + j))
(unionBound : miss ≤ rationalPrefixSum
(fun s => rationalPrefixSum (fun j => (weights s j).sum) terms) sites) :
miss ≤ reverseWitnessMissBound N p := by
let q : Rat := 2 * p
let K := reverseWitnessCutoff N
let tail := q ^ K / (1 - q)
have pNonneg : 0 ≤ p := Rat.le_of_lt pPositive
have qNonneg : 0 ≤ q := by dsimp [q]; grind
have qLt : q < 1 := by dsimp [q]; grind
have tailNonneg : 0 ≤ tail := by
have finite := finite_geometric_tail q qNonneg qLt K 0
exact finite
have perLength (s j : Nat) (hs : s < sites) (hj : j < terms) :
(weights s j).sum ≤ 3 * q ^ (K + j) := by
calc
_ ≤ ((weights s j).length : Rat) * p ^ (K + j) := list_mass_le _ _ (pathProb s j hs hj)
_ ≤ ((3 * 2 ^ (K + j) : Nat) : Rat) * p ^ (K + j) :=
Rat.mul_le_mul_of_nonneg_right (Rat.natCast_le_natCast.mpr (pathCount s j hs hj))
(Rat.pow_nonneg pNonneg)
_ = 3 * q ^ (K + j) := by
rw [Rat.natCast_mul, Rat.natCast_pow, rat_mul_pow]
exact Rat.mul_assoc ..
have perSite (s : Nat) (hs : s < sites) :
rationalPrefixSum (fun j => (weights s j).sum) terms ≤ 3 * tail := by
apply Rat.le_trans (rational_sum_mono (perLength s · hs ·))
rw [rational_sum_mul]
exact Rat.mul_le_mul_of_nonneg_left (finite_geometric_tail q qNonneg qLt K terms) (by decide)
calc
miss ≤ rationalPrefixSum (fun s => rationalPrefixSum (fun j => (weights s j).sum) terms) sites := unionBound
_ ≤ rationalPrefixSum (fun _ => 3 * tail) sites := rational_sum_mono perSite
_ = (sites : Rat) * (3 * tail) := rational_sum_const _ _
_ ≤ ((6 * N : Nat) : Rat) * (3 * tail) :=
Rat.mul_le_mul_of_nonneg_right (Rat.natCast_le_natCast.mpr siteCount)
(Rat.mul_nonneg (by decide) tailNonneg)
_ = reverseWitnessMissBound N p := by
unfold reverseWitnessMissBound tail K q
rw [Rat.natCast_mul, Rat.div_def, Rat.div_def]
grind
/-- The degree-three catalogs and conditional prefix controls supply the one-tick estimate. -/
theorem bounded_reverse_witness_misses_from_catalogs {neighbors : Fin N → List (Fin N)}
(support : DegreeThreeSupport neighbors) (sites terms : Nat) (p miss : Rat)
(pPositive : 0 < p) (pSmall : p < 1 / 4) (rootOf : Nat → Fin N)
(weights : Nat → Nat → List Rat) (siteCover : sites ≤ (candidateSiteCatalog neighbors).length)
(pathCover : ∀ s j, s < sites → j < terms → (weights s j).length ≤
(reverseRouteCatalog neighbors (rootOf s) (reverseWitnessCutoff N + j + 1)).length)
(conditional : ∀ s j, s < sites → j < terms → ∀ w ∈ weights s j,
∃ prefixMass : Nat → Rat, prefixMass 0 ≤ 1 ∧
(∀ k, prefixMass (k + 1) ≤ p * prefixMass k) ∧
w ≤ prefixMass (reverseWitnessCutoff N + j))
(unionBound : miss ≤ rationalPrefixSum
(fun s => rationalPrefixSum (fun j => (weights s j).sum) terms) sites) :
miss ≤ reverseWitnessMissBound N p := by
obtain ⟨siteCount, paths⟩ := degree_three_catalog_bounds support
refine bounded_reverse_witness_misses N sites terms p miss pPositive pSmall weights
(Nat.le_trans siteCover siteCount) (fun s j hs hj => Nat.le_trans (pathCover s j hs hj) (paths _ _))
?_ unionBound
intro s j hs hj w member
obtain ⟨prefixMass, initial, comparison, weightBound⟩ := conditional s j hs hj w member
exact Rat.le_trans weightBound
(comparison_prefix_probability prefixMass p (Rat.le_of_lt pPositive) initial comparison _)
/-- Apply the one-tick bound under uniform conditional control across a finite horizon. -/
theorem reverse_witness_misses_over_ticks (N ticks : Nat) (p miss : Rat) (tickMass : Nat → Rat)
(perTick : ∀ t, t < ticks → tickMass t ≤ reverseWitnessMissBound N p)
(unionBound : miss ≤ rationalPrefixSum tickMass ticks) :
miss ≤ (ticks : Rat) * reverseWitnessMissBound N p := by
apply Rat.le_trans unionBound
rw [← rational_sum_const]
exact rational_sum_mono perTick
end QBD.Ch02
#print axioms QBD.Ch02.comparison_prefix_probability
#print axioms QBD.Ch02.degree_three_catalog_bounds
#print axioms QBD.Ch02.bounded_reverse_witness_misses
#print axioms QBD.Ch02.bounded_reverse_witness_misses_from_catalogs
#print axioms QBD.Ch02.reverse_witness_misses_over_ticks
Verification Summary:
The machine-checked proofs establish the degree-three catalog counts, prefix probability bounds, and finite rational one-tick and multi-tick miss bounds for reverse-witness screening at depth . Measure-theoretic union bounds and real asymptotic convergence are established in the companion Mathlib validation. The Lean 4 kernel accepts all closed proof terms using only standard axioms, certifying the screening bounds of Bounded Reverse-Witness Misses §2.7.4.
In Plain English:
Machine-checked Lean 4 proofs certify the formal claims verified in Section 2.7.4.3.
2.7.4.3 Type-Theoretic Validation via Lean 4 and Mathlib
Type-theoretic certification of the measure-theoretic union bound and asymptotic cutoff convergence established in Bounded Reverse-Witness Misses §2.7.4 proceeds via the following verification strategy:
- Model: Measure-theoretic probability spaces, finite indexed families of miss events, degree-three path catalogs, and real-valued exponential tail bounds represent probabilistic reverse-witness screening and its large-graph limit.
- Certified Claims: The module certifies the finite measure-theoretic union bound, the one-tick reverse-witness miss probability bound derived from catalog coverage and per-path probability hypotheses, and asymptotic convergence of the miss bound to zero at cutoff for in Bounded Reverse-Witness Misses §2.7.4.1.
- Scope Boundary: Catalog coverage of the miss event and per-path conditional probability bounds are supplied as explicit measure-theoretic hypotheses. Multi-tick history-filtration measurability remains outside this one-tick asymptotic certificate.
import QBD.Ch02.L2_7_4_BoundedReverseWitnessMisses
import Mathlib.MeasureTheory.Measure.Real
import Mathlib.MeasureTheory.Measure.Typeclasses.Probability
import Mathlib.Analysis.SpecificLimits.Basic
open MeasureTheory Filter
open scoped ENNReal Topology
namespace QBDMathlib.Ch02
noncomputable def realReverseWitnessMissBound (N : ℕ) (p : ℝ) : ℝ :=
18 * N * (2 * p) ^ QBD.Ch02.reverseWitnessCutoff N / (1 - 2 * p)
theorem finite_measure_union_bound {Ω I : Type*} [MeasurableSpace Ω]
(μ : Measure Ω) [IsFiniteMeasure μ] (sites : Finset I) (events : I → Set Ω)
{miss : Set Ω} (covered : miss ⊆ ⋃ i ∈ sites, events i) :
μ.real miss ≤ ∑ i ∈ sites, μ.real (events i) := by
have bound := (measure_mono (μ := μ) covered).trans
(measure_biUnion_finset_le (μ := μ) sites events)
have finite : (∑ i ∈ sites, μ (events i)) ≠ ∞ :=
ENNReal.sum_ne_top.mpr fun i _ => measure_ne_top μ (events i)
simpa only [measureReal_def, ENNReal.toReal_sum (fun i _ => measure_ne_top μ (events i))]
using ENNReal.toReal_mono finite bound
theorem reverse_witness_measure_bound {Ω : Type*} [MeasurableSpace Ω]
(μ : Measure Ω) [IsProbabilityMeasure μ] (N sites terms : ℕ) {p : ℝ}
(p₀ : 0 ≤ p) (p₁ : p < 1 / 4) (paths : Fin sites → Fin terms → ℕ → Set Ω)
(count : Fin sites → Fin terms → ℕ) (siteBound : sites ≤ 6 * N)
(pathBound : ∀ s j, count s j ≤ 3 * 2 ^ (QBD.Ch02.reverseWitnessCutoff N + j.val))
(pathMass : ∀ s j i, μ.real (paths s j i) ≤ p ^ (QBD.Ch02.reverseWitnessCutoff N + j.val))
{miss : Set Ω}
(cover : miss ⊆ ⋃ s, ⋃ j, ⋃ i ∈ Finset.range (count s j), paths s j i) :
μ.real miss ≤ realReverseWitnessMissBound N p := by
let K := QBD.Ch02.reverseWitnessCutoff N
let q := 2 * p
have q₀ : 0 ≤ q := by dsimp [q]; positivity
have q₁ : q < 1 := by dsimp [q]; linarith
have tail : ∑ j ∈ Finset.range terms, q ^ (K + j) ≤ q ^ K / (1 - q) := by
have series := (hasSum_geometric_of_lt_one q₀ q₁).mul_left (q ^ K)
have leSeries := series.summable.sum_le_tsum (Finset.range terms) (fun j _ => by positivity)
rw [series.tsum_eq] at leSeries
simpa only [pow_add, div_eq_mul_inv] using leSeries
have perSite (s : Fin sites) :
μ.real (⋃ j, ⋃ i ∈ Finset.range (count s j), paths s j i) ≤ 3 * (q ^ K / (1 - q)) := by
calc
_ ≤ ∑ j : Fin terms, μ.real (⋃ i ∈ Finset.range (count s j), paths s j i) :=
measureReal_iUnion_fintype_le _
_ ≤ ∑ j : Fin terms, 3 * q ^ (K + j.val) := by
apply Finset.sum_le_sum
intro j _
calc
_ ≤ ∑ i ∈ Finset.range (count s j), μ.real (paths s j i) :=
finite_measure_union_bound μ _ _ (fun _ h => h)
_ ≤ ∑ _i ∈ Finset.range (count s j), p ^ (K + j.val) :=
Finset.sum_le_sum fun i _ => pathMass s j i
_ = (count s j : ℝ) * p ^ (K + j.val) := by simp
_ ≤ (3 * 2 ^ (K + j.val) : ℝ) * p ^ (K + j.val) :=
mul_le_mul_of_nonneg_right (by exact_mod_cast pathBound s j) (pow_nonneg p₀ _)
_ = _ := by rw [mul_pow]; ring
_ ≤ _ := by
rw [← Finset.mul_sum, Fin.sum_univ_eq_sum_range (fun j => q ^ (K + j)) terms]
exact mul_le_mul_of_nonneg_left tail (by norm_num)
calc
_ ≤ μ.real (⋃ s, ⋃ j, ⋃ i ∈ Finset.range (count s j), paths s j i) := measureReal_mono cover
_ ≤ ∑ s : Fin sites, μ.real (⋃ j, ⋃ i ∈ Finset.range (count s j), paths s j i) :=
measureReal_iUnion_fintype_le _
_ ≤ ∑ _s : Fin sites, 3 * (q ^ K / (1 - q)) := Finset.sum_le_sum fun s _ => perSite s
_ = (sites : ℝ) * (3 * (q ^ K / (1 - q))) := by simp
_ ≤ (6 * N : ℝ) * (3 * (q ^ K / (1 - q))) :=
mul_le_mul_of_nonneg_right (by exact_mod_cast siteBound) (by positivity)
_ = _ := by simp only [realReverseWitnessMissBound, q, K]; ring
theorem reverse_witness_miss_bound_tendsto {p : ℝ} (p₀ : 0 ≤ p) (p₁ : p < 1 / 4) :
Tendsto (fun N : ℕ => realReverseWitnessMissBound N p) atTop (𝓝 0) := by
let q := 2 * p
have q₀ : 0 ≤ q := by dsimp [q]; positivity
have q₁ : 0 < 1 - q := by dsimp [q]; linarith
have logGrows : Tendsto Nat.log2 atTop atTop := tendsto_atTop.2 fun k => by
filter_upwards [eventually_ge_atTop (2 ^ k)] with N hN
exact (Nat.le_log2 (by have := Nat.two_pow_pos k; omega)).2 hN
have small : 2 * q < 1 := by dsimp [q]; linarith
have decay := ((tendsto_pow_atTop_nhds_zero_of_lt_one
(show 0 ≤ 2 * q by positivity) small).comp logGrows).const_mul (36 * q ^ 3 / (1 - q))
refine tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_const_nhds
(by simpa only [Function.comp_def, mul_zero] using decay) (fun N => ?_) (fun N => ?_)
· change 0 ≤ 18 * (N : ℝ) * q ^ QBD.Ch02.reverseWitnessCutoff N / (1 - q)
positivity
· have size : (N : ℝ) ≤ 2 ^ (N.log2 + 1) := by exact_mod_cast Nat.lt_log2_self.le
change 18 * (N : ℝ) * q ^ (N.log2 + 3) / (1 - q) ≤ _
calc
_ ≤ 18 * 2 ^ (N.log2 + 1) * q ^ (N.log2 + 3) / (1 - q) :=
div_le_div_of_nonneg_right (by gcongr) q₁.le
_ = _ := by
rw [pow_add (2 : ℝ) N.log2 1, pow_add q N.log2 3,
show (2 * q) ^ N.log2 = 2 ^ N.log2 * q ^ N.log2 from mul_pow _ _ _]
ring
end QBDMathlib.Ch02
#print axioms QBDMathlib.Ch02.finite_measure_union_bound
#print axioms QBDMathlib.Ch02.reverse_witness_measure_bound
#print axioms QBDMathlib.Ch02.reverse_witness_miss_bound_tendsto
Verification Summary:
The machine-checked proofs establish the finite measure-theoretic union bound, the one-tick reverse-witness miss probability bound from explicit catalog-coverage and per-path probability hypotheses, and asymptotic convergence to zero at cutoff for . Multi-tick history-filtration measurability remains outside this one-tick asymptotic formalization. The Lean 4 and Mathlib kernel accepts all closed proof terms using only standard axioms, certifying the measure-theoretic and asymptotic claims of Bounded Reverse-Witness Misses §2.7.4.
In Plain English:
Machine-checked Lean 4 proofs certify the formal claims verified in Section 2.7.4.4.
2.7.5 Lemma: Exact Poset Invariance
Let be the set of immutable creation occurrences and let mean that is an incoming occurrence present at the source of in its creation snapshot. Under the source-maximum recurrence, the nonempty dependency closure is a strict partial order on , independently of the spatial search horizon (Monotonicity of History §1.4.5).
In Plain English:
Section 2.7.5 formalizes the properties of the QBD lemma regarding exact poset invariance.
2.7.5.1 Proof: Exact Poset Invariance
I. Immediate Dependency Inequality
Let . By the creation-snapshot definition, belongs to the source incoming-height set . The recurrence (Creation Timestamp §1.4.4) gives
This uses membership at creation, without retimestamping an older outgoing edge.
II. Nonempty Dependency Paths
For a chain with , induction gives : the case is equality, and the step follows from
Hence implies . A self-pair would require , which is impossible.
III. Strict Partial Order
Concatenation of positive-length -chains proves transitivity of . If both and , the height inequalities give
a contradiction. Thus is transitive, irreflexive and asymmetric.
IV. Preservation and Scope
When a new occurrence is appended, each of its recorded predecessors satisfies the same strict height inequality, and old labels and dependencies are unchanged. Therefore every finite stage and their cumulative union have no finite dependency cycle: any proposed cycle lies in some finite stage and would yield the contradiction above. This proves the occurrence-order assertion (Exact Poset Invariance §2.7.5). The separate spatial relation still requires its own causal-admission condition; this proof supplies no quantitative bound on missed spatial influence paths.
Q.E.D.
In Plain English:
Section 2.7.5.1 formalizes the properties of the QBD proof regarding exact poset invariance.
2.7.5.2 Type-Theoretic Validation via Lean 4 Core
Type-theoretic certification of the creation-occurrence poset invariance established in Exact Poset Invariance §2.7.5 proceeds via the following verification strategy:
- Model: Creation-occurrence dependency relations, source-maximum height recurrences, finite dependency chains, and the Chapter 1 history-monotonicity structure represent exact chronological order.
- Certified Claims: The module certifies strict height increase across direct dependencies, chain height lower bounds, exact poset invariance under strict height monotonicity, and invariance for the source-maximum recurrence in Exact Poset Invariance §2.7.5.1.
- Scope Boundary: Poset invariance governs the chronological creation-occurrence ledger rather than mediated spatial closure on active snapshots, which requires separate enforcement.
import QBD.Ch02.Defs
import QBD.Ch01.T1_4_5_HistoryMonotonicity
namespace QBD.Ch02
variable {Ω : Type}
-- An occurrence's creation snapshot bounds all recorded predecessor heights.
def UsesSourceMaximum (D : Ω → Ω → Prop) (height : Ω → Nat) : Prop :=
∀ η, ∃ maximum : Nat, height η = maximum + 1 ∧
AttainedHeightMaximum (fun ω => D ω η) height maximum
-- RelationChain lengths are always positive.
/-- Every recorded chain contains at least one relation step. -/
private theorem chain_positive {R : V → V → Prop} {m : Nat} {a b : V}
(chain : RelationChain R m a b) : 0 < m := by
cases chain <;> omega
-- Height increase for one recorded dependency.
/-- A dependency belongs to the creation maximum's incoming set, so its height is smaller. -/
theorem source_maximum_dependency_strict {D : Ω → Ω → Prop} {height : Ω → Nat}
(maximum : UsesSourceMaximum D height) {ω η : Ω} (edge : D ω η) :
height ω < height η := by
obtain ⟨bound, eq, upper, _⟩ := maximum η
have le := upper ω edge
omega
-- Quantitative increase along recorded dependency chains.
/-- A chain of m dependencies increases causal height by at least m. -/
theorem dependency_chain_height {D : Ω → Ω → Prop} {height : Ω → Nat}
(strict : ∀ ω η, D ω η → height ω < height η) {m : Nat} {ω η : Ω}
(chain : RelationChain D m ω η) : height ω + m ≤ height η := by
induction chain with
| one edge => have lt := strict _ _ edge; omega
| cons edge _ ih => have lt := strict _ _ edge; omega
/-- The occurrence-order conclusion is independent of the spatial search horizon. -/
theorem exact_poset_invariance {D : Ω → Ω → Prop} {height : Ω → Nat}
(strict : ∀ ω η, D ω η → height ω < height η) :
(∀ ω η, Reachable D ω η → height ω < height η) ∧
(∀ ω η θ, Reachable D ω η → Reachable D η θ → Reachable D ω θ) ∧
(∀ ω, ¬ Reachable D ω ω) ∧ (∀ ω η, Reachable D ω η → ¬ Reachable D η ω) := by
have rising : StrictCausalMonotonicity D height := fun _ _ step => strict _ _ step
have chainRising := rising.onReachable
exact ⟨fun _ _ step => chainRising step, fun _ _ _ => Reachable.trans, rising.dag,
fun _ _ forward backward => Nat.lt_asymm (chainRising forward) (chainRising backward)⟩
theorem source_maximum_poset_invariance {birth : Ω → Nat} {D : Ω → Ω → Prop} {height : Ω → Nat}
(rules : CausalBirthRules birth D) (source : SourceMaximumHeight birth D height) :
Ch01.HistoryMonotonicity birth D height := Ch01.monotonicity_of_history rules source
end QBD.Ch02
#print axioms QBD.Ch02.source_maximum_dependency_strict
#print axioms QBD.Ch02.dependency_chain_height
#print axioms QBD.Ch02.exact_poset_invariance
#print axioms QBD.Ch02.source_maximum_poset_invariance
Verification Summary:
The machine-checked proofs confirm that direct source-maximum dependencies strictly increase causal height, preserving an exact irreflexive transitive partial order on creation occurrences across all legal transitions. Active-snapshot mediated closure remains a distinct tier governed by the third axiom. The Lean 4 kernel accepts all closed proof terms using only standard axioms, certifying the invariance claims of Exact Poset Invariance §2.7.5.
In Plain English:
Machine-checked Lean 4 proofs certify the discrete claims formalized in Section 2.7.5.3.
2.7.6 Lemma: Independence of Axiom 3
Let have edges in the displayed order with heights . It satisfies Axiom 1 and both specified geometric predicates, while has a diagonal.
In Plain English:
Section 2.7.6 formalizes the properties of the QBD lemma regarding independence of axiom 3.
2.7.6.1 Proof: Independence of Axiom 3
I. The Static Butterfly
The butterfly has edge set , where denotes (Independence of Axiom 3 §2.7.6) (Independence of Axioms 1 and 2 §2.5.1). Each edge has distinct endpoints and the six reversed edges are absent. Deleting leaves only and , which contain no directed cycle. Every simple cycle therefore has a rotation beginning at . After either first edge, the other vertices each have a unique outgoing edge. The first returns are
A longer cycle would repeat before closing. Thus these two triangles exhaust the simple cycles up to rotation.
The complete set of length-two paths is
Thus their endpoint pairs form . These eight pairs are distinct and .
II. The Two Accretions
Start from , with heights respectively. Its two-paths are , and , with distinct endpoints and absent bypasses. Its vertex order advances along every edge, so the base is acyclic. The first return chord is , supported by . The second is , supported by . The two height checks are
By the complete two-path list, the support endpoint pairs and have one witness each even in the final graph. Each update therefore has its displayed unique witness in its pre-addition graph. After each addition the edges are a subset of , so the cycle analysis above excludes any longer simple cycle.
III. The Mediated Cycle
The simple paths
give and . Their composition gives .
Q.E.D.
In Plain English:
Section 2.7.6.1 formalizes the properties of the QBD proof regarding independence of axiom 3.
2.7.6.2 Type-Theoretic Validation via Lean 4 Core
Type-theoretic certification of the logical independence established in Independence of Axiom 3 §2.7.6 proceeds via the following verification strategy:
- Model: The five-vertex butterfly countermodel and its verified local-axiom compliance alongside mediated-acyclicity failure represent independence of the global constraint.
- Certified Claims: The module certifies that global acyclic effective causality is logically independent of the local directed-link and geometric-constructibility constraints via the shared butterfly witness in Independence of Axiom 3 §2.7.6.1.
- Scope Boundary: Independence is established by a finite model-theoretic witness. Dynamical frequency of mediated loops in large stochastic ensembles remains outside this logical separation certificate.
import QBD.Ch02.L2_6_8_LeastStaticCountermodel
namespace QBD.Ch02
/-- The five-vertex butterfly satisfies both local geometry tests and violates Axiom 3. -/
theorem axiom3_independent_of_local_axioms :
∃ G : FinTimestampedGraph 5, SatisfiesAxiom1 G ∧ SatisfiesStaticAxiom2 G ∧
SatisfiesConstructiveAxiom2 G ∧ ¬ SatisfiesAxiom3 G := by
obtain ⟨links, static, constructed, _, _, _, cyclic⟩ := butterfly_countermodel
exact ⟨butterfly, links, static, constructed, cyclic⟩
end QBD.Ch02
#print axioms QBD.Ch02.axiom3_independent_of_local_axioms
Verification Summary:
The machine-checked proof reuses the five-vertex butterfly witness to certify that the local directed-link and geometric-constructibility axioms do not entail acyclic effective causality. Ensemble frequencies of causal loops remain outside this model-theoretic separation. The Lean 4 kernel accepts the closed proof term using only standard axioms, certifying the independence claim of Independence of Axiom 3 §2.7.6.
In Plain English:
Machine-checked Lean 4 proofs certify the discrete claims formalized in Section 2.7.6.3.
2.7.7 Lemma: Loop Erasure of Reverse Witnesses
Let with . A directed walk from to of at least two and at most edges with strictly increasing heights and terminal height below exists if and only if a simple path with those properties exists.
In Plain English:
Section 2.7.7 formalizes the properties of the QBD lemma regarding loop erasure of reverse witnesses.
2.7.7.1 Proof: Loop Erasure of Reverse Witnesses
I. Erasure Preserves an Edge Subsequence
Let be a witness walk from to with and heights . If for , erase the segment from position to . The new walk and its height sequence are
with the suffix empty if . When , the new join edge is the original edge . When , its new endpoint is still . If both height pieces are nonempty then by strict increase in the original list. Thus the new list is increasing and its terminal entry remains below .
II. Finite Reduction
At one erasure the length changes from to . After erasures the lengths satisfy
The endpoints remain distinct, so . The erasures must therefore terminate with no repeated vertex and with length at most .
III. Mediation at the Final Length
The candidate has no direct forward bypass (Geometric Constructibility §2.3.1). A final simple path of length one would be precisely that edge, which is absent. Hence the path has length at least two and obeys the original height cutoff. Conversely, any such simple path is a walk with the required properties. This proves equivalence at the same search horizon (Loop Erasure of Reverse Witnesses §2.7.7).
Q.E.D.
In Plain English:
Section 2.7.7.1 formalizes the properties of the QBD proof regarding loop erasure of reverse witnesses.
2.7.7.2 Type-Theoretic Validation via Lean 4 Core
Type-theoretic certification of the walk-to-simple-path loop erasure established in Loop Erasure of Reverse Witnesses §2.7.7 proceeds via the following verification strategy:
- Model: Directed edge walks with strictly increasing adjacent heights, loop-erasure reduction functions, and reverse-witness miss predicates represent search equivalence between walks and simple paths.
- Certified Claims: The module certifies equivalence between global and adjacent edge-height monotonicity, loop erasure preserving endpoints and strict monotonicity, simple reverse-witness extraction, and exact miss-event equivalence in Loop Erasure of Reverse Witnesses §2.7.7.1.
- Scope Boundary: Loop erasure relies on strict monotonicity of edge heights along the walk. Non-monotone walks or equal-height edges do not preserve strictness under shortcut removal.
import QBD.Ch02.Defs
namespace QBD.Ch02
variable {V : Type}
-- A reverse walk has the same endpoint, length, and terminal-height tests as the guard.
def IsReverseWalk (G : RelTimestampedGraph V) (L h : Nat) (v u : V) (path : List (Edge V)) : Prop :=
2 ≤ path.length ∧ path.length ≤ L ∧ DirectedEdgePath G.edges v u path ∧
IsEdgePathMonotone G.height path ∧ ∃ last, path.getLast? = some last ∧ G.height last < h
-- A simple witness passes the walk tests and visits each vertex only once.
def IsReversePath (G : RelTimestampedGraph V) (L h : Nat) (v u : V) (path : List (Edge V)) : Prop :=
IsReverseWalk G L h v u path ∧ IsSimple v path
-- Equivalence of the pairwise and adjacent height tests.
/-- Natural-number transitivity extends each adjacent comparison to all later edges. -/
theorem edge_monotone_iff_adjacent (height : Edge V → Nat) (path : List (Edge V)) :
IsEdgePathMonotone height path ↔ IsAdjacentHeightIncreasing height path := by
induction path with
| nil => simp [IsEdgePathMonotone, IsAdjacentHeightIncreasing]
| cons e tail ih =>
cases tail with
| nil => simp [IsEdgePathMonotone, IsAdjacentHeightIncreasing]
| cons next rest =>
constructor
· intro increasing
obtain ⟨lower, increasingTail⟩ := List.pairwise_cons.mp increasing
exact ⟨lower next (by simp), ih.mp increasingTail⟩
· rintro ⟨lt, adjacentTail⟩
have increasingTail := ih.mpr adjacentTail
refine List.pairwise_cons.mpr ⟨?_, increasingTail⟩
intro later member
rcases List.mem_cons.mp member with rfl | laterInRest
· exact lt
· exact Nat.lt_trans lt ((List.pairwise_cons.mp increasingTail).1 later laterInRest)
-- A suffix can start at any visited vertex.
/-- Dropping the prefix to a visited vertex preserves the endpoint and simplicity of the suffix. -/
private theorem simple_suffix {E : Edge V → Prop} {a b v : V} {path : List (Edge V)}
(directed : DirectedEdgePath E a b path) (simple : IsSimple a path)
(visited : v ∈ a :: path.map Prod.snd) :
∃ suffix, List.Sublist suffix path ∧ DirectedEdgePath E v b suffix ∧ IsSimple v suffix := by
induction path generalizing a with
| nil =>
have eq : v = a := by simpa using visited
exact ⟨[], .slnil, eq.trans directed, by simp [IsSimple]⟩
| cons e rest ih =>
rcases List.mem_cons.mp visited with eq | later
· subst v
exact ⟨e :: rest, List.Sublist.refl _, directed, simple⟩
· obtain ⟨_, _, tail⟩ := directed
have tailSimple := (List.nodup_cons.mp simple).2
obtain ⟨suffix, sub, connects, suffixSimple⟩ := ih tail tailSimple later
exact ⟨suffix, sub.cons e, connects, suffixSimple⟩
-- Loop erasure as a subsequence of original edges.
/-- Erase loops in the tail first. If the initial vertex occurs in that tail, erase through
its next occurrence. Otherwise prepend the initial edge to the simple tail. -/
theorem erase_loops [DecidableEq V] {E : Edge V → Prop} {a b : V} {path : List (Edge V)}
(directed : DirectedEdgePath E a b path) :
∃ simple, List.Sublist simple path ∧ DirectedEdgePath E a b simple ∧ IsSimple a simple := by
induction path generalizing a with
| nil => exact ⟨[], .slnil, directed, by simp [IsSimple]⟩
| cons e rest ih =>
obtain ⟨present, source, tail⟩ := directed
obtain ⟨simple, sub, connects, noRepeat⟩ := ih tail
by_cases repeated : a ∈ e.2 :: simple.map Prod.snd
· obtain ⟨suffix, suffixSub, suffixPath, suffixSimple⟩ :=
simple_suffix connects noRepeat repeated
exact ⟨suffix, (suffixSub.trans sub).cons e, suffixPath, suffixSimple⟩
· exact ⟨e :: simple, sub.cons_cons e, ⟨present, source, connects⟩,
List.nodup_cons.mpr ⟨repeated, noRepeat⟩⟩
-- The absence of a direct bypass forces mediation.
/-- Distinct endpoints with no direct edge require at least two edges in any directed walk. -/
theorem path_length_at_least_two {E : Edge V → Prop} {v u : V} {path : List (Edge V)}
(distinct : v ≠ u) (noBypass : ¬ E (v, u)) (directed : DirectedEdgePath E v u path) :
2 ≤ path.length := by
cases path with
| nil => exact False.elim (distinct directed)
| cons e rest =>
cases rest with
| nil =>
obtain ⟨present, source, target⟩ := directed
have eq : e = (v, u) := Prod.ext source target
exact False.elim (noBypass (eq ▸ present))
| cons => simp
-- The terminal height bounds every edge of an increasing walk.
/-- All members of an increasing edge list lie below any strict bound on its final height. -/
private theorem increasing_below_last {H : Edge V → Nat} {path : List (Edge V)}
{last : Edge V} {h : Nat} (monotone : IsEdgePathMonotone H path)
(endpoint : path.getLast? = some last) (below : H last < h) :
∀ e ∈ path, H e < h := by
obtain ⟨pre, rfl⟩ := List.getLast?_eq_some_iff.mp endpoint
intro e member
rcases List.mem_append.mp member with inPre | inLast
· have lt := (List.pairwise_append.mp monotone).2.2 e inPre last (by simp)
exact Nat.lt_trans lt below
· simpa using (show H e < h from (List.mem_singleton.mp inLast).symm ▸ below)
-- Exact loop-erasure equivalence at a common horizon.
/-- The simple witness is an edge subsequence, preserves the terminal height bound, and
still has at least two edges because the endpoints are distinct and the bypass is absent. -/
theorem loop_erasure_reverse_witness [DecidableEq V] (G : RelTimestampedGraph V)
(v u : V) (distinct : v ≠ u) (noBypass : ¬ G.edges (v, u)) (L h : Nat) :
(∃ path, IsReverseWalk G L h v u path) ↔ (∃ path, IsReversePath G L h v u path) := by
constructor
· rintro ⟨path, _, upper, directed, monotone, last, endpoint, below⟩
obtain ⟨simple, sub, connects, noRepeat⟩ := erase_loops directed
have lower := path_length_at_least_two distinct noBypass connects
have nonempty : simple ≠ [] := List.length_pos_iff.mp (by omega)
have lastBound := increasing_below_last monotone endpoint below
refine ⟨simple, ⟨lower, Nat.le_trans sub.length_le upper, connects,
List.Pairwise.sublist sub monotone, simple.getLast nonempty,
List.getLast?_eq_some_getLast nonempty, ?_⟩, noRepeat⟩
exact lastBound _ (sub.subset (List.getLast_mem nonempty))
· rintro ⟨path, walk, _⟩
exact ⟨path, walk⟩
-- The comparison of bounded misses used in the assembly proof.
/-- An unbounded qualifying walk missed at cutoff L exists exactly when an unbounded
qualifying simple path is missed at the same cutoff. Each unbounded witness has finite length. -/
theorem reverse_witness_miss_equivalence [DecidableEq V] (G : RelTimestampedGraph V)
(v u : V) (distinct : v ≠ u) (noBypass : ¬ G.edges (v, u)) (L h : Nat) :
((∃ bound path, IsReverseWalk G bound h v u path) ∧ ¬ (∃ path, IsReverseWalk G L h v u path)) ↔
((∃ bound path, IsReversePath G bound h v u path) ∧ ¬ (∃ path, IsReversePath G L h v u path)) := by
have comparison (bound : Nat) := loop_erasure_reverse_witness G v u distinct noBypass bound h
exact and_congr
⟨fun ⟨bound, witness⟩ => ⟨bound, (comparison bound).mp witness⟩,
fun ⟨bound, witness⟩ => ⟨bound, (comparison bound).mpr witness⟩⟩
(not_congr (comparison L))
/-- The strict adjacent comparisons along the list imply a strict first-to-last comparison. -/
theorem edge_path_monotonicity_transitive (H : Edge V → Nat)
(first last : Edge V) (rest : List (Edge V))
(monotone : IsAdjacentHeightIncreasing H (first :: rest ++ [last])) : H first < H last := by
have pairwise := (edge_monotone_iff_adjacent H _).mpr monotone
exact (List.pairwise_cons.mp pairwise).1 last (by simp)
/-- Strict increase over the list and across a closing comparison is impossible. -/
theorem edge_monotone_no_causal_cycle (H : Edge V → Nat) (first last : Edge V)
(rest : List (Edge V)) (monotone : IsAdjacentHeightIncreasing H (first :: rest ++ [last]))
(closes : H last < H first) : False :=
Nat.lt_asymm (edge_path_monotonicity_transitive H first last rest monotone) closes
end QBD.Ch02
#print axioms QBD.Ch02.edge_monotone_iff_adjacent
#print axioms QBD.Ch02.erase_loops
#print axioms QBD.Ch02.loop_erasure_reverse_witness
#print axioms QBD.Ch02.reverse_witness_miss_equivalence
Verification Summary:
The machine-checked proofs confirm that erasing repeated-vertex loops from any strictly height-increasing directed walk yields a simple strictly increasing path with the same endpoints, establishing exact equivalence between walk-based and simple-path reverse-witness misses. Non-monotone walks remain outside this reduction certificate. The Lean 4 kernel accepts all closed proof terms using only standard axioms, certifying the loop-erasure claims of Loop Erasure of Reverse Witnesses §2.7.7.
In Plain English:
Machine-checked Lean 4 proofs certify the discrete claims formalized in Section 2.7.7.3.
2.7.8 Lemma: Batch Causal Preservation under Dominance
Let old be acyclic, with every retained new chord's height dominating the old outgoing heights at its target. The final is acyclic exactly when its full closure has no target diagonal, with the pre-deletion test sufficient and the two-chord sequential diamond also acyclic when both targets are old -sinks.
In Plain English:
Section 2.7.8 formalizes the properties of the QBD lemma regarding batch causal preservation under dominance.
2.7.8.1 Proof: Batch Causal Preservation under Dominance
I. Localization by Height Dominance
Let be the retained chord set, its targets, and . Denote the old and final mediated relations by (Effective Influence §2.6.2). For , choose a simple increasing witness . It uses at least one chord, because a witness made solely of retained old edges would also exist in the old graph. If its -th edge is new and the next edge is old, the two hypotheses give
a contradiction. Starting at its first new edge and applying the same argument at each successive position shows that its final edge is new. Hence
II. Equivalence of Target Diagonals and Acyclicity
If has a diagonal, there is a nonempty closed walk of pairs , with . Since has acyclic closure, some pair is outside . By localization . Rotating the same list of pairs gives a nonempty return walk at , so . Conversely a target diagonal is already a diagonal in the full closure. This proves
Let be the relation just after merge. Every final witness uses edges of the merged graph with identical heights, giving and therefore . The pre-deletion target test implies the final one.
III. The Two Old Sinks
For the sequential diamond the added edges are and with four distinct endpoints (Sequential Constructor Diamond §2.4.6). They cannot occur consecutively, since their sources are disjoint from their targets . By Section I every new witness therefore has exactly one new edge, at its end. If are sinks in , localization and irreflexivity give
A witness of would end with . Its prefix from to uses old edges and has at least two edges, since . It would give , contradicting the sink condition. Thus remains a sink and any arrow from ends at . Neither target admits a nonempty return walk. Section II gives acyclicity of the full relation.
Q.E.D.
In Plain English:
Section 2.7.8.1 formalizes the properties of the QBD proof regarding batch causal preservation under dominance.
2.7.8.2 Type-Theoretic Validation via Lean 4 Core
Type-theoretic certification of the batch causal preservation and target-diagonal screening established in Batch Causal Preservation under Dominance §2.7.8 proceeds via the following verification strategy:
- Model: Synchronous chord batch merges, retained subgraphs under deletion, target-height dominance hypotheses, and mediated reachability closures represent concurrent batch admission.
- Certified Claims: The module certifies that every newly created mediated witness terminates at a batch target, establishes the target-diagonal equivalence and pre-deletion target test, and certifies acyclicity for two old sinks and sequential diamonds in Batch Causal Preservation under Dominance §2.7.8.1.
- Scope Boundary: The target-diagonal equivalence assumes prior acyclicity of the input snapshot and target-height dominance of the admitted batch. Unbounded height inversions across concurrent batches lie outside these hypotheses.
import QBD.Ch02.L2_7_7_LoopErasureOfReverseWitnesses
import QBD.Ch02.L2_4_6_SequentialConstructorDiamond
namespace QBD.Ch02
variable {V : Type}
-- Targets are the endpoints entered by retained chords.
def Target (B : Edge V → Prop) (v : V) : Prop := ∃ u, B (u, v)
-- A frozen merge adds only fresh chords and preserves all active old heights.
structure BatchMerge (old merged : RelTimestampedGraph V) (B : Edge V → Prop) : Prop where
edges : ∀ e, merged.edges e ↔ old.edges e ∨ B e
fresh : ∀ e, B e → ¬ old.edges e
oldHeight : ∀ e, old.edges e → merged.height e = old.height e
-- Deletion leaves a subset of the edges with their heights unchanged.
structure RetainedSubgraph (merged final : RelTimestampedGraph V) : Prop where
edges : ∀ e, final.edges e → merged.edges e
height : ∀ e, final.edges e → final.height e = merged.height e
-- Dominance compares each chord's height with every old edge leaving its target.
def Dominates (old merged : RelTimestampedGraph V) (B : Edge V → Prop) : Prop :=
∀ u v, B (u, v) → ∀ z, old.edges (v, z) → old.height (v, z) ≤ merged.height (u, v)
-- The two retained return chords of the sequential diamond.
def TwoChords (v w u x : V) (e : Edge V) : Prop := e = (u, v) ∨ e = (x, w)
-- Monotonicity of nonempty closure.
/-- Inclusion of relations preserves every original chain in the larger relation. -/
private theorem closure_mono {R S : V → V → Prop} (includeStep : ∀ a b, R a b → S a b)
{a b : V} (walk : Reachable R a b) : Reachable S a b := by
induction walk with
| single edge => exact .single (includeStep _ _ edge)
| tail _ edge ih => exact .tail ih (includeStep _ _ edge)
theorem path_edges {E : Edge V → Prop} {a b : V} {path : List (Edge V)}
(directed : DirectedEdgePath E a b path) : ∀ e ∈ path, E e := by
induction path generalizing a with
| nil => simp
| cons e rest ih =>
exact List.forall_mem_cons.mpr ⟨directed.1, ih directed.2.2⟩
-- Splitting a directed path at a list boundary.
/-- A split shares the same vertex at the end of the prefix and the start of the suffix. -/
private theorem path_split {E : Edge V → Prop} {a b : V} {pre tail : List (Edge V)}
(directed : DirectedEdgePath E a b (pre ++ tail)) :
∃ mid, DirectedEdgePath E a mid pre ∧ DirectedEdgePath E mid b tail := by
induction pre generalizing a with
| nil => exact ⟨a, rfl, directed⟩
| cons e rest ih =>
obtain ⟨present, source, next⟩ := directed
obtain ⟨mid, before, after⟩ := ih next
exact ⟨mid, ⟨present, source, before⟩, after⟩
-- Changing graphs along the same path.
/-- Preserving each path edge and its height preserves directedness and strict increase. -/
private theorem path_transport {G G' : RelTimestampedGraph V} {a b : V} {path : List (Edge V)}
(directed : DirectedEdgePath G.edges a b path) (mono : IsEdgePathMonotone G.height path)
(same : ∀ e ∈ path, G'.edges e ∧ G'.height e = G.height e) :
DirectedEdgePath G'.edges a b path ∧ IsEdgePathMonotone G'.height path := by
constructor
· clear mono
induction path generalizing a with
| nil => exact directed
| cons e rest ih =>
exact ⟨(same e (by simp)).1, directed.2.1, ih directed.2.2
(fun edge member => same edge (List.mem_cons_of_mem e member))⟩
· exact List.Pairwise.imp_of_mem (fun he hf lt => by rw [(same _ he).2, (same _ hf).2]; exact lt) mono
-- Every simple mediated path is nonreflexive.
/-- Its final vertex occurs in the edge-target list and cannot equal its starting vertex. -/
theorem mediated_ne {G : RelTimestampedGraph V} {a b : V} (arrow : Mediated G a b) :
a ≠ b := by
obtain ⟨path, length, directed, _, simple⟩ := arrow
have endpoint_mem {start : V} {edges : List (Edge V)}
(connects : DirectedEdgePath G.edges start b edges) :
b ∈ start :: edges.map Prod.snd := by
induction edges generalizing start with
| nil =>
change start = b at connects
simp [connects]
| cons e rest ih => exact List.mem_cons_of_mem _ (ih connects.2.2)
cases path with
| nil => simp at length
| cons e rest =>
intro eq
exact (List.nodup_cons.mp simple).1 (eq ▸ endpoint_mem directed.2.2)
-- Before the first chord all edges are old, and after it all edges are chords.
/-- An increasing path is entirely old or splits into an old prefix and a nonempty
chord suffix. Dominance rules out the first chord-to-old transition. -/
private theorem batch_path_split {old merged : RelTimestampedGraph V} {B : Edge V → Prop}
(merge : BatchMerge old merged B) (dominance : Dominates old merged B)
{a b : V} {path : List (Edge V)} (directed : DirectedEdgePath merged.edges a b path)
(mono : IsEdgePathMonotone merged.height path) :
(∀ e ∈ path, old.edges e) ∨ ∃ pre first tail, path = pre ++ first :: tail ∧
(∀ e ∈ pre, old.edges e) ∧ (∀ e ∈ first :: tail, B e) := by
have staysNew {start : V} {e : Edge V} {rest : List (Edge V)}
(connects : DirectedEdgePath merged.edges start b (e :: rest))
(rises : IsEdgePathMonotone merged.height (e :: rest)) (newEdge : B e) :
∀ f ∈ e :: rest, B f := by
induction rest generalizing start e with
| nil => exact List.forall_mem_cons.mpr ⟨newEdge, by simp⟩
| cons next rest ih =>
have tail := connects.2.2
have rising := List.pairwise_cons.mp rises
have nextNew : B next := by
apply ((merge.edges next).mp tail.1).resolve_left
intro nextOld
have upper : old.height next ≤ merged.height e := by
obtain ⟨source, target⟩ := next
have joins : source = e.2 := tail.2.1
subst source
exact dominance e.1 e.2 newEdge target nextOld
have comparison := rising.1 next (by simp)
rw [merge.oldHeight next nextOld] at comparison
exact Nat.not_lt_of_ge upper comparison
exact List.forall_mem_cons.mpr ⟨newEdge, ih tail rising.2 nextNew⟩
induction path generalizing a with
| nil => exact Or.inl (by simp)
| cons e rest ih =>
rcases (merge.edges e).mp directed.1 with oldEdge | newEdge
· rcases ih directed.2.2 (List.pairwise_cons.mp mono).2 with onlyOld | usesChord
· exact Or.inl (List.forall_mem_cons.mpr ⟨oldEdge, onlyOld⟩)
· obtain ⟨pre, first, tail, rfl, preOld, chordTail⟩ := usesChord
exact Or.inr ⟨e :: pre, first, tail, rfl, List.forall_mem_cons.mpr ⟨oldEdge, preOld⟩,
chordTail⟩
· exact Or.inr ⟨[], e, rest, rfl, by simp, staysNew directed mono newEdge⟩
-- Read the target of the terminal edge.
/-- In a directed path the terminal edge enters the stated endpoint. -/
private theorem path_last_target {E : Edge V → Prop} {a b : V} {path : List (Edge V)}
{last : Edge V} (directed : DirectedEdgePath E a b path)
(endpoint : path.getLast? = some last) : last.2 = b := by
obtain ⟨pre, rfl⟩ := List.getLast?_eq_some_iff.mp endpoint
obtain ⟨_, _, tail⟩ := path_split directed
exact tail.2.2
-- Localization of every new surviving witness.
/-- Every witness of a newly mediated pair ends with a retained chord, so its endpoint is a target. -/
theorem new_mediated_witness_ends_at_target {old merged final : RelTimestampedGraph V}
{B : Edge V → Prop} (merge : BatchMerge old merged B)
(retained : RetainedSubgraph merged final) (dominance : Dominates old merged B)
{a b : V} {path : List (Edge V)} (newPair : ¬ Mediated old a b)
(length : 2 ≤ path.length) (directed : DirectedEdgePath final.edges a b path)
(mono : IsEdgePathMonotone final.height path) (simple : IsSimple a path) :
∃ last, path.getLast? = some last ∧ B last ∧ last.2 = b := by
obtain ⟨mergedPath, mergedMono⟩ := path_transport directed mono (fun e he =>
⟨retained.edges e (path_edges directed e he), (retained.height e (path_edges directed e he)).symm⟩)
rcases batch_path_split merge dominance mergedPath mergedMono with onlyOld | chordSuffix
· obtain ⟨oldPath, oldMono⟩ := path_transport mergedPath mergedMono (fun e he =>
⟨onlyOld e he, (merge.oldHeight e (onlyOld e he)).symm⟩)
exact False.elim (newPair ⟨path, length, oldPath, oldMono, simple⟩)
· obtain ⟨pre, first, tail, rfl, _, chords⟩ := chordSuffix
let suffix := first :: tail
have someLast : suffix ≠ [] := by simp [suffix]
have lastEq := List.getLast?_eq_some_getLast someLast
have endpoint : (pre ++ suffix).getLast? = some (suffix.getLast someLast) := by
simp [lastEq]
exact ⟨_, endpoint, chords _ (List.getLast_mem someLast), path_last_target directed endpoint⟩
-- Localization of new mediated pairs.
/-- A final influence absent from the old relation necessarily enters the batch target set. -/
theorem new_mediated_pair_target {old merged final : RelTimestampedGraph V} {B : Edge V → Prop}
(merge : BatchMerge old merged B) (retained : RetainedSubgraph merged final)
(dominance : Dominates old merged B) {a b : V}
(arrow : Mediated final a b) (newPair : ¬ Mediated old a b) : Target B b := by
obtain ⟨path, length, directed, mono, simple⟩ := arrow
obtain ⟨last, _, chord, target⟩ :=
new_mediated_witness_ends_at_target merge retained dominance newPair length directed mono simple
exact ⟨last.1, target ▸ chord⟩
-- Locate a marked endpoint along a closure walk.
/-- A walk is entirely old or contains a marked step with a nonempty prefix to its target
and a possibly empty suffix from that target to the original endpoint. -/
private theorem closure_old_or_marked {R S : V → V → Prop} {marked : V → Prop}
(classify : ∀ a b, R a b → S a b ∨ marked b) {a b : V}
(walk : Reachable R a b) :
Reachable S a b ∨ ∃ t, marked t ∧ Reachable R a t ∧ (t = b ∨ Reachable R t b) := by
induction walk with
| @single b edge =>
rcases classify a b edge with old | mark
· exact Or.inl (.single old)
· exact Or.inr ⟨b, mark, .single edge, Or.inl rfl⟩
| @tail b c initial edge ih =>
rcases classify b c edge with old | mark
· rcases ih with oldInitial | ⟨t, ht, enter, leave⟩
· exact Or.inl (.tail oldInitial old)
· rcases leave with rfl | rest
· exact Or.inr ⟨t, ht, enter, Or.inr (.single edge)⟩
· exact Or.inr ⟨t, ht, enter, Or.inr (.tail rest edge)⟩
· exact Or.inr ⟨c, mark, .tail initial edge, Or.inl rfl⟩
-- Exact target-diagonal test.
/-- Rotate a final closed influence walk at the endpoint of a step absent from the old
relation. Acyclicity is therefore equivalent to excluding diagonals at batch targets. -/
theorem target_diagonal_equivalence {old merged final : RelTimestampedGraph V} {B : Edge V → Prop}
(merge : BatchMerge old merged B) (retained : RetainedSubgraph merged final)
(dominance : Dominates old merged B) (oldAcyclic : ∀ x, ¬ Reachable (Mediated old) x x) :
(∀ x, ¬ Reachable (Mediated final) x x) ↔
(∀ t, Target B t → ¬ Reachable (Mediated final) t t) := by
constructor
· exact fun acyclic t _ => acyclic t
· intro targets x loop
have classify (a b : V) (arrow : Mediated final a b) :
Mediated old a b ∨ Target B b := by
by_cases oldPair : Mediated old a b
· exact Or.inl oldPair
· exact Or.inr (new_mediated_pair_target merge retained dominance arrow oldPair)
rcases closure_old_or_marked classify loop with oldLoop | ⟨t, target, initial, finalLeg⟩
· exact oldAcyclic x oldLoop
· rcases finalLeg with rfl | rest
· exact targets t target initial
· exact targets t target (Reachable.trans rest initial)
-- Deletion preserves inclusion in the merged mediated relation and its closure.
/-- Every surviving witness is the same witness in the merged graph, with identical edge heights. -/
theorem deletion_mediated_inclusion {merged final : RelTimestampedGraph V}
(retained : RetainedSubgraph merged final) :
(∀ a b, Mediated final a b → Mediated merged a b) ∧
(∀ a b, Reachable (Mediated final) a b → Reachable (Mediated merged) a b) := by
have inclusion (a b : V) (arrow : Mediated final a b) : Mediated merged a b := by
obtain ⟨path, length, directed, mono, simple⟩ := arrow
obtain ⟨connects, rises⟩ := path_transport directed mono (fun e he =>
⟨retained.edges e (path_edges directed e he), (retained.height e (path_edges directed e he)).symm⟩)
exact ⟨path, length, connects, rises, simple⟩
exact ⟨inclusion, fun _ _ => closure_mono inclusion⟩
-- The pre-deletion target test is sufficient.
/-- If the merged closure has no target diagonal, deletion cannot leave a closure cycle. -/
theorem pre_deletion_target_test {old merged final : RelTimestampedGraph V} {B : Edge V → Prop}
(merge : BatchMerge old merged B) (retained : RetainedSubgraph merged final)
(dominance : Dominates old merged B) (oldAcyclic : ∀ x, ¬ Reachable (Mediated old) x x)
(test : ∀ t, Target B t → ¬ Reachable (Mediated merged) t t) :
∀ x, ¬ Reachable (Mediated final) x x :=
(target_diagonal_equivalence merge retained dominance oldAcyclic).mpr
(fun t target loop => test t target ((deletion_mediated_inclusion retained).2 t t loop))
-- The two return chords cannot be consecutive.
/-- A target of either chord is distinct from the sources of both chords. -/
private theorem two_chords_do_not_join {v w u x : V} (distinct : FourDistinct v w u x)
{e f : Edge V} (first : TwoChords v w u x e) (second : TwoChords v w u x f) :
e.2 ≠ f.1 := by
rcases first with rfl | rfl <;> rcases second with rfl | rfl
· exact distinct.vu
· exact distinct.vx
· exact distinct.wu
· exact distinct.wx
-- The first old sink cannot acquire an arrow to the other target.
/-- A witness from v to w would need an old mediated prefix from v to x, contradicting
the old sink hypothesis because v and x are distinct and have no direct bypass. -/
private theorem two_chord_no_forward {old merged : RelTimestampedGraph V} {v w u x : V}
(distinct : FourDistinct v w u x) (noBypass : ¬ old.edges (v, x))
(merge : BatchMerge old merged (TwoChords v w u x))
(dominance : Dominates old merged (TwoChords v w u x)) (sink : ∀ z, ¬ Mediated old v z) :
¬ Mediated merged v w := by
rintro ⟨path, length, directed, mono, simple⟩
rcases batch_path_split merge dominance directed mono with onlyOld | chordSuffix
· obtain ⟨connects, rises⟩ := path_transport directed mono (fun e he =>
⟨onlyOld e he, (merge.oldHeight e (onlyOld e he)).symm⟩)
exact sink w ⟨path, length, connects, rises, simple⟩
· obtain ⟨pre, first, tail, rfl, preOld, chords⟩ := chordSuffix
have firstChord := chords first (by simp)
obtain ⟨mid, prePath, suffixPath⟩ := path_split directed
cases tail with
| cons next rest =>
exact two_chords_do_not_join distinct firstChord (chords next (by simp)) suffixPath.2.2.2.1.symm
| nil =>
have lastTarget : first.2 = w := suffixPath.2.2
have lastChord : first = (x, w) := firstChord.resolve_left fun eq =>
distinct.vw ((congrArg Prod.snd eq).symm.trans lastTarget)
subst first
have sameMid : x = mid := suffixPath.2.1
subst mid
obtain ⟨oldPath, oldMono⟩ := path_transport prePath (List.pairwise_append.mp mono).1
(fun e he => ⟨preOld e he, (merge.oldHeight e (preOld e he)).symm⟩)
have preSimple : IsSimple v pre := by
have extended : ((v :: pre.map Prod.snd) ++ [w]).Nodup := by
simpa [IsSimple] using simple
exact (List.nodup_append.mp extended).1
exact sink x ⟨pre, path_length_at_least_two distinct.vx noBypass oldPath,
oldPath, oldMono, preSimple⟩
-- The two-old-sinks special case.
/-- The first target stays a sink and arrows from the second can only enter the first.
Neither target can lie on a closure diagonal, even before deletion. -/
theorem two_old_sinks_acyclic {old merged final : RelTimestampedGraph V} {v w u x : V}
(distinct : FourDistinct v w u x) (noBypass : ¬ old.edges (v, x))
(merge : BatchMerge old merged (TwoChords v w u x))
(retained : RetainedSubgraph merged final)
(dominance : Dominates old merged (TwoChords v w u x))
(oldAcyclic : ∀ a, ¬ Reachable (Mediated old) a a)
(sinks : ∀ z, ¬ Mediated old v z ∧ ¬ Mediated old w z) :
∀ a, ¬ Reachable (Mediated final) a a := by
have same : RetainedSubgraph merged merged := ⟨fun _ h => h, fun _ _ => rfl⟩
have targets {t : V} (target : Target (TwoChords v w u x) t) : t = v ∨ t = w := by
obtain ⟨_, chord⟩ := target
exact chord.elim (fun eq => Or.inl (congrArg Prod.snd eq))
(fun eq => Or.inr (congrArg Prod.snd eq))
have sinkV (z : V) (arrow : Mediated merged v z) : False := by
rcases targets (new_mediated_pair_target merge same dominance arrow (sinks z).1) with rfl | rfl
· exact mediated_ne arrow rfl
· exact two_chord_no_forward distinct noBypass merge dominance (fun y => (sinks y).1) arrow
have intoV (z : V) (arrow : Mediated merged w z) : z = v := by
rcases targets (new_mediated_pair_target merge same dominance arrow (sinks z).2) with eq | rfl
· exact eq
· exact False.elim (mediated_ne arrow rfl)
have noFromV (z : V) (walk : Reachable (Mediated merged) v z) : False := by
obtain ⟨_, chain⟩ := walk.toChain
cases chain with
| one edge => exact sinkV _ edge
| cons edge _ => exact sinkV _ edge
apply pre_deletion_target_test merge retained dominance oldAcyclic
intro t target walk
rcases targets target with rfl | rfl
· exact noFromV _ walk
· obtain ⟨_, chain⟩ := walk.toChain
cases chain with
| one edge => exact distinct.vw (intoV _ edge).symm
| cons edge tail =>
have eq := intoV _ edge
have suffix : Reachable (Mediated merged) v _ := (eq ▸ tail : RelationChain _ _ v _).toReachable
exact noFromV _ suffix
/-- The two orders of the sequential diamond preserve Axiom 3 when the targets are old sinks. -/
theorem sequential_diamond_acyclic [DecidableEq V] {G : RelTimestampedGraph V} {v w u x : V}
(distinct : FourDistinct v w u x) (noBypass : ¬ G.edges (v, x)) {cutoff h₁ h₂ : Nat}
(first : AdmissibleChord G cutoff v w u h₁) (second : AdmissibleChord G cutoff w u x h₂)
(dominates₁ : ∀ z, G.edges (v, z) → G.height (v, z) ≤ h₁)
(dominates₂ : ∀ z, G.edges (w, z) → G.height (w, z) ≤ h₂)
(oldAcyclic : AcyclicEffectiveCausality G) (sinks : ∀ z, ¬ Mediated G v z ∧ ¬ Mediated G w z) :
AcyclicEffectiveCausality (insertChord (insertChord G (u, v) h₁) (x, w) h₂) ∧
AcyclicEffectiveCausality (insertChord (insertChord G (x, w) h₂) (u, v) h₁) := by
let forward := insertChord (insertChord G (u, v) h₁) (x, w) h₂
let backward := insertChord (insertChord G (x, w) h₂) (u, v) h₁
obtain ⟨_, _, _, _, _, _, edges, sameEdges, sameHeight⟩ :=
sequential_constructor_diamond G v w u x distinct noBypass cutoff h₁ h₂ first second dominates₁ dominates₂
have chordNe : (u, v) ≠ (x, w) := fun same => distinct.ux (congrArg Prod.fst same)
have merge : BatchMerge G forward (TwoChords v w u x) := by
refine ⟨fun e => Iff.of_eq (congrFun edges e), ?_, ?_⟩
· rintro e (rfl | rfl)
· exact first.fresh
· exact second.fresh
· intro e active
have neFirst : e ≠ (u, v) := fun eq => first.fresh (eq ▸ active)
have neSecond : e ≠ (x, w) := fun eq => second.fresh (eq ▸ active)
simp [forward, insertChord, RelTimestampedGraph.height, neFirst, neSecond]
have dominance : Dominates G forward (TwoChords v w u x) := by
rintro a b (eq | eq) z active
· obtain ⟨rfl, rfl⟩ := Prod.mk.injEq .. |>.mp eq
simpa [forward, insertChord, RelTimestampedGraph.height, chordNe] using dominates₁ z active
· obtain ⟨rfl, rfl⟩ := Prod.mk.injEq .. |>.mp eq
simpa [forward, insertChord, RelTimestampedGraph.height] using dominates₂ z active
have acyclic : AcyclicEffectiveCausality forward :=
two_old_sinks_acyclic distinct noBypass merge ⟨fun _ h => h, fun _ _ => rfl⟩ dominance oldAcyclic sinks
have same : forward = backward := TimestampedGraph.ext sameEdges (funext sameHeight)
change AcyclicEffectiveCausality forward ∧ AcyclicEffectiveCausality backward
exact ⟨acyclic, same ▸ acyclic⟩
end QBD.Ch02
#print axioms QBD.Ch02.new_mediated_witness_ends_at_target
#print axioms QBD.Ch02.target_diagonal_equivalence
#print axioms QBD.Ch02.pre_deletion_target_test
#print axioms QBD.Ch02.two_old_sinks_acyclic
#print axioms QBD.Ch02.sequential_diamond_acyclic
Verification Summary:
The machine-checked proofs establish that under prior acyclicity and target-height dominance, mediated acyclicity of a synchronous chord batch is equivalent to the target-diagonal test on the merged or pre-deletion graph, and holds automatically for two old sinks and sequential diamonds. Batches violating target-height dominance remain outside this certificate. The Lean 4 kernel accepts all closed proof terms using only standard axioms, certifying the batch-admission claims of Batch Causal Preservation under Dominance §2.7.8.
In Plain English:
Machine-checked Lean 4 proofs certify the discrete claims formalized in Section 2.7.8.3.
2.7.9 Lemma: First-Tick Causality on Graded Graphs
Let every old edge have height and raise a vertex grading by one, and let a batch of elementary return chords have height . The mediated closure after the tick is acyclic.
In Plain English:
Section 2.7.9 formalizes the properties of the QBD lemma regarding first-tick causality on graded graphs.
2.7.9.1 Proof: First-Tick Causality on Graded Graphs
I. Height and Grading Changes
An elementary chord closes a directed two-path in the frozen graph (First-Tick Causality on Graded Graphs §2.7.9) (Axiom 2 Geometric Constructibility §2.3.1).
Every candidate chord closes a two-path and has at least one old incoming edge at . Its source maximum is , so its height is . For the grading ,
II. Mediated Witness
Every increasing witness of length at least two uses exactly the two heights . Its first edge raises the grading by one and its second lowers it by two. Thus implies in the merged graph, and the same implication holds after deletions.
III. Exclusion of Closure Diagonals
A chain of mediated pairs from to has . It cannot return to . Hence the final is irreflexive.
Q.E.D.
In Plain English:
Section 2.7.9.1 formalizes the properties of the QBD proof regarding first-tick causality on graded graphs.
2.7.9.2 Type-Theoretic Validation via Lean 4 Core
Type-theoretic certification of the first-tick causal acyclicity on graded graphs established in First-Tick Causality on Graded Graphs §2.7.9 proceeds via the following verification strategy:
- Model: Uniform-height initial snapshots equipped with a strict integer vertex grading, first-tick chord batches, and mediated edge chains represent graded first-tick evolution.
- Certified Claims: The module certifies that every mediated pair in the first-tick merged graph strictly drops the vertex grading by at least one, that mediated chains accumulate this drop, and that the resulting snapshot satisfies Axiom 3 Acyclic Effective Causality §2.7.1 in First-Tick Causality on Graded Graphs §2.7.9.1.
- Scope Boundary: First-tick acyclicity assumes uniform initial edge heights and a strict vertex grading on the input graph. Multi-tick evolution after heterogeneous heights develop requires the general batch-admission test.
import QBD.Ch02.L2_7_8_BatchCausalPreservation
namespace QBD.Ch02
variable {V : Type}
-- The graded first-tick inputs.
structure GradedFirstTick (old merged : RelTimestampedGraph V) (B : Edge V → Prop)
(grade : V → Nat) (h : Nat) : Prop where
oldEdge : ∀ a b, old.edges (a, b) → old.height (a, b) = h ∧ grade b = grade a + 1
chord : ∀ u v, B (u, v) →
merged.height (u, v) = h + 1 ∧ ∃ w, old.edges (v, w) ∧ old.edges (w, u)
-- Exact grading drop for every mediated pair in the merged snapshot.
/-- The only possible increasing witness uses exactly one old edge followed by one
return chord, so the total grading change is one up and two down. -/
theorem first_tick_pair_drops_one {old merged : RelTimestampedGraph V} {B : Edge V → Prop}
{grade : V → Nat} {h : Nat} (merge : BatchMerge old merged B)
(graded : GradedFirstTick old merged B grade h) {a b : V}
(arrow : Mediated merged a b) : grade b + 1 = grade a := by
have edgeProfile (e : Edge V) (present : merged.edges e) :
(merged.height e = h ∧ grade e.2 = grade e.1 + 1) ∨
(merged.height e = h + 1 ∧ grade e.1 = grade e.2 + 2) := by
rcases (merge.edges e).mp present with existing | newChord
· obtain ⟨height, up⟩ := graded.oldEdge e.1 e.2 existing
exact Or.inl ⟨(merge.oldHeight e existing).trans height, up⟩
· obtain ⟨height, w, first, second⟩ := graded.chord e.1 e.2 newChord
have up₁ := (graded.oldEdge e.2 w first).2
have up₂ := (graded.oldEdge w e.1 second).2
exact Or.inr ⟨height, by omega⟩
obtain ⟨path, length, directed, mono, _⟩ := arrow
rcases path with _ | ⟨first, _ | ⟨second, rest⟩⟩
· simp at length
· simp at length
· obtain ⟨firstActive, start, secondActive, join, tailPath⟩ := directed
obtain ⟨firstLt, tailMono⟩ := List.pairwise_cons.mp mono
have increases := firstLt second (by simp)
have steps : (merged.height first = h ∧ grade first.2 = grade first.1 + 1) ∧
(merged.height second = h + 1 ∧ grade second.1 = grade second.2 + 2) := by
rcases edgeProfile first firstActive with before | before <;>
rcases edgeProfile second secondActive with after | after
· omega
· exact ⟨before, after⟩
· omega
· omega
cases rest with
| nil =>
have endpoint : second.2 = b := tailPath
have up := steps.1.2
have down := steps.2.2
rw [start] at up
rw [join, endpoint] at down
omega
| cons third rest =>
have tooHigh := (List.pairwise_cons.mp tailMono).1 third (by simp)
have secondHeight := steps.2.1
rcases edgeProfile third tailPath.1 with profile | profile <;> omega
-- Exact grading loss along counted chains.
/-- Each step drops the grading by one, so a chain of m steps drops it by exactly m. -/
theorem graded_chain_drop {R : V → V → Prop} {grade : V → Nat}
(drops : ∀ a b, R a b → grade b + 1 = grade a) {m : Nat} {a b : V}
(chain : RelationChain R m a b) : grade b + m = grade a := by
induction chain with
| one edge => exact drops _ _ edge
| cons edge _ ih => have drop := drops _ _ edge; omega
-- Graded first-tick acyclicity before and after arbitrary deletion.
/-- Both relations drop the grading by one per witnessed step. A positive-length
chain has a positive grading loss, which excludes both closure diagonals. -/
theorem graded_first_tick_acyclic {old merged final : RelTimestampedGraph V} {B : Edge V → Prop}
{grade : V → Nat} {h : Nat} (merge : BatchMerge old merged B)
(graded : GradedFirstTick old merged B grade h)
(retained : RetainedSubgraph merged final) :
(∀ a b, Mediated final a b → grade b + 1 = grade a) ∧
(∀ m a b, RelationChain (Mediated merged) m a b → grade b + m = grade a) ∧
(∀ m a b, RelationChain (Mediated final) m a b → grade b + m = grade a) ∧
(∀ a, ¬ Reachable (Mediated merged) a a) ∧ (∀ a, ¬ Reachable (Mediated final) a a) := by
have mergedDrop (a b : V) := @first_tick_pair_drops_one V old merged B grade h merge graded a b
have finalDrop (a b : V) (arrow : Mediated final a b) : grade b + 1 = grade a :=
mergedDrop a b ((deletion_mediated_inclusion retained).1 a b arrow)
have acyclic {R : V → V → Prop} (drops : ∀ a b, R a b → grade b + 1 = grade a)
(a : V) (loop : Reachable R a a) : False := by
obtain ⟨m, chain⟩ := loop.toChain
have positive : 0 < m := by cases chain <;> omega
have drop := graded_chain_drop drops chain
omega
exact ⟨finalDrop, fun _ _ _ => graded_chain_drop mergedDrop, fun _ _ _ => graded_chain_drop finalDrop,
acyclic mergedDrop, acyclic finalDrop⟩
end QBD.Ch02
#print axioms QBD.Ch02.first_tick_pair_drops_one
#print axioms QBD.Ch02.graded_chain_drop
#print axioms QBD.Ch02.graded_first_tick_acyclic
Verification Summary:
The machine-checked proofs confirm that on a uniform-height graded graph, every first-tick mediated pair strictly decreases the vertex grading, forcing global acyclicity of mediated effective influence across the entire first-tick chord batch. Subsequent ticks with non-uniform heights remain outside this graded first-tick module. The Lean 4 kernel accepts all closed proof terms using only standard axioms, certifying the graded-causality claims of First-Tick Causality on Graded Graphs §2.7.9.
In Plain English:
Machine-checked Lean 4 proofs certify the discrete claims formalized in Section 2.7.9.3.
2.7.10 Proof: Causal Admission of Chord Batches
I. Occurrence Order and Limits of Observation
Number the butterfly edges in their displayed order (Independence of Axiom 3 §2.7.6). Assign births in that order. The first source has no incoming edge, so its birth height is . For each , enters the source of , and every earlier height is at most . The source-maximum rule yields . Strict increase along each dependency chain yields irreflexivity of (Exact Poset Invariance §2.7.5). The same butterfly satisfies the local geometric predicates and has and , which yield .
For any , the open perimeter and the closed perimeter have identical rooted radius- induced balls, whereas is irreflexive and has a diagonal (Finite-Radius Indistinguishability §2.7.3). A decision determined by the rooted ball would assign the same value to and , which have different acyclicity values.
II. Localization of Batch Diagonals
Height dominance yields (Batch Causal Preservation under Dominance §2.7.8). For any , a nonempty closed chain of pairs contains a pair outside , since otherwise . Its endpoint belongs to , and rotating the chain to begin at yields . Conversely, a target diagonal is a diagonal of .
For the graded first tick, uniform old heights imply , and yields dominance. Each final mediated pair decreases the grading by one (First-Tick Causality on Graded Graphs §2.7.9). A closed chain of pairs at any target would imply , so the target test yields irreflexivity.
III. Equivalence and Miss Probability for Bounded Witness Tests
For a candidate chord with source , target , and height , let denote the event of a qualifying simple reverse path of length at most and let denote the event of a qualifying reverse walk at the same cutoff. Every simple path is a walk, so , and loop erasure with and implies (Loop Erasure of Reverse Witnesses §2.7.7). The inclusions also hold without a cutoff, since each witness has finite length. Thus , and the unions of these miss events over the candidates are equal. Under the elementary candidate, degree, and conditional comparison hypotheses the one-tick simple-path miss bound is , which bounds the same walk-miss event (Bounded Reverse-Witness Misses §2.7.4).
Q.E.D.
In Plain English:
Section 2.7.10 formalizes the properties of the QBD proof regarding causal admission of chord batches.
2.7.10.1 Type-Theoretic Validation via Lean 4 Core
Type-theoretic certification of the global causal enforcement and batch admission established in Causal Admission of Chord Batches §2.7.2 proceeds via the following verification strategy:
- Model: The assembly module imports all seven certified Chapter 2 horizon-indistinguishability, bounded-miss, poset-invariance, Axiom-3-independence, loop-erasure, batch-preservation, and graded-first-tick modules.
- Certified Claims: The module certifies that Axiom 3 Acyclic Effective Causality §2.7.1 defines a strict partial order on mediated closure and assembles horizon blindness, finite rational miss bounds, creation-ledger poset invariance, Axiom-3 independence, walk loop erasure, target-diagonal batch equivalence, and graded first-tick acyclicity in Causal Admission of Chord Batches §2.7.10.
- Scope Boundary: Batch target-diagonal equivalence assumes prior acyclicity and target-height dominance, first-tick acyclicity assumes uniform initial heights and a vertex grading, and the probabilistic miss bound operates over finite rational event weights rather than real-valued asymptotics.
import QBD.Ch02.L2_7_3_FiniteRadiusIndistinguishability
import QBD.Ch02.L2_7_4_BoundedReverseWitnessMisses
import QBD.Ch02.L2_7_5_ExactPosetInvariance
import QBD.Ch02.L2_7_6_IndependenceOfAxiom3
import QBD.Ch02.L2_7_7_LoopErasureOfReverseWitnesses
import QBD.Ch02.L2_7_8_BatchCausalPreservation
import QBD.Ch02.L2_7_9_FirstTickCausalityOnGradedGraphs
namespace QBD.Ch02
/-- Axiom 3 makes the nonempty mediated closure a strict partial order. -/
theorem acyclic_effective_causality_strict_order {V : Type u} {G : RelTimestampedGraph V}
(acyclic : AcyclicEffectiveCausality G) :
(∀ a b c, Reachable (Mediated G) a b → Reachable (Mediated G) b c → Reachable (Mediated G) a c) ∧
(∀ a, ¬ Reachable (Mediated G) a a) ∧
(∀ a b, Reachable (Mediated G) a b → ¬ Reachable (Mediated G) b a) :=
⟨fun _ _ _ => Reachable.trans, acyclic, fun a _ ab ba => acyclic a (ab.trans ba)⟩
/-- The exact tests and the bounded-search conclusions of §2.7.2. -/
structure CausalAdmissionGuarantees : Prop where
targetTest : ∀ {V : Type} {old merged final : RelTimestampedGraph V} {B : Edge V → Prop},
BatchMerge old merged B → RetainedSubgraph merged final → Dominates old merged B →
AcyclicEffectiveCausality old →
(AcyclicEffectiveCausality final ↔ ∀ t, Target B t → ¬ Reachable (Mediated final) t t)
gradedFirstTick : ∀ {V : Type} {old merged final : RelTimestampedGraph V} {B : Edge V → Prop}
{grade : V → Nat} {h : Nat}, BatchMerge old merged B → GradedFirstTick old merged B grade h →
RetainedSubgraph merged final → AcyclicEffectiveCausality merged ∧ AcyclicEffectiveCausality final
occurrenceOrder : ∀ {Ω : Type} {birth : Ω → Nat} {D : Ω → Ω → Prop} {height : Ω → Nat},
CausalBirthRules birth D → SourceMaximumHeight birth D height → Ch01.HistoryMonotonicity birth D height
localIndependence : ∃ G : FinTimestampedGraph 5, SatisfiesAxiom1 G ∧ SatisfiesStaticAxiom2 G ∧
SatisfiesConstructiveAxiom2 G ∧ ¬ SatisfiesAxiom3 G
radiusIndistinguishability : ∀ r, 1 ≤ r →
∃ (closed opened : RelTimestampedGraph (Fin (2 * r + 4))) (root : Fin (2 * r + 4)),
SameRootedBall closed opened root r ∧ AcyclicEffectiveCausality opened ∧
Reachable (Mediated closed) root root
witnessEquivalence : ∀ {V : Type} [DecidableEq V] (G : RelTimestampedGraph V) (v u : V),
v ≠ u → ¬ G.edges (v, u) → ∀ L h,
((∃ bound path, IsReverseWalk G bound h v u path) ∧ ¬ (∃ path, IsReverseWalk G L h v u path)) ↔
((∃ bound path, IsReversePath G bound h v u path) ∧ ¬ (∃ path, IsReversePath G L h v u path))
missBound : ∀ (N sites terms : Nat) (p miss : Rat), 0 < p → p < 1 / 4 →
∀ (weights : Nat → Nat → List Rat), sites ≤ 6 * N →
(∀ s j, s < sites → j < terms → (weights s j).length ≤ 3 * 2 ^ (reverseWitnessCutoff N + j)) →
(∀ s j, s < sites → j < terms → ∀ w ∈ weights s j, w ≤ p ^ (reverseWitnessCutoff N + j)) →
miss ≤ rationalPrefixSum (fun s => rationalPrefixSum (fun j => (weights s j).sum) terms) sites →
miss ≤ reverseWitnessMissBound N p
theorem causal_admission_of_chord_batches : CausalAdmissionGuarantees := by
refine ⟨@target_diagonal_equivalence, ?_, @source_maximum_poset_invariance,
axiom3_independent_of_local_axioms, finite_radius_indistinguishability,
@reverse_witness_miss_equivalence, bounded_reverse_witness_misses⟩
intro V old merged final B grade h merge graded retained
exact (graded_first_tick_acyclic merge graded retained).2.2.2
end QBD.Ch02
#print axioms QBD.Ch02.acyclic_effective_causality_strict_order
#print axioms QBD.Ch02.causal_admission_of_chord_batches
Verification Summary:
The machine-checked proofs certify that acyclic effective causality yields a strict partial order and assemble all seven per-lemma enforcement, screening, invariance, and batch-admission certificates into a single closed theorem. Real-valued asymptotic limits and batches violating target-height dominance remain outside this discrete Core assembly. The Lean 4 kernel accepts all closed proof terms using only standard axioms, certifying the assembled claims of Causal Admission of Chord Batches §2.7.10.
In Plain English:
Section 2.7.10.1 formalizes the properties of the QBD type-theoretic regarding validation via lean 4 core.
2.7.13 Calculation: Verification of the Bounded Reverse-Path Guard
Verification of the frozen-snapshot guard (Acyclic Effective Causality §2.7.1) and its witness conditions (Loop Erasure of Reverse Witnesses §2.7.7) is based on the following protocols:
- Equal Heights: Test the return chord with a two-edge reverse path of equal heights.
- Increasing Heights: Raise the second path height and the candidate height, then repeat the check.
from math import log2
import networkx as nx
def pre_check_aec(graph, source, target, candidate_height):
"""Check a bounded reverse witness for an absent return chord."""
cutoff = int(log2(len(graph))) + 3 if len(graph) > 1 else 1
for path in nx.all_simple_paths(graph, target, source, cutoff=cutoff):
heights = [graph[a][b]["H"] for a, b in zip(path, path[1:])]
if (len(heights) >= 2 and heights[-1] < candidate_height
and all(a < b for a, b in zip(heights, heights[1:]))):
return False
return True
snapshot = nx.DiGraph()
snapshot.add_weighted_edges_from([(0, 1, 0), (1, 2, 0)], weight="H")
assert pre_check_aec(snapshot, 2, 0, 1)
snapshot[1][2]["H"] = 1
assert not pre_check_aec(snapshot, 2, 0, 2)
print("Equal-height path admitted; strictly increasing reverse witness rejected.")
Simulation Results:
Equal-height path admitted; strictly increasing reverse witness rejected.
Conclusion:
The guard admits the equal-height case and rejects the case with an increasing reverse witness below the candidate height.
In Plain English:
Section 2.7.13 formalizes the properties of the QBD calculation regarding verification of the bounded reverse-path guard.
2.7.14 Calculation: Target Closure Verification
Verification of the target-diagonal test on the explicit batch (Batch Causal Preservation under Dominance §2.7.8.1) (Effective Influence §2.6.2) is based on the following protocols:
- Input: Construct the timestamped five-vertex graph and its two dominant chords.
- Closure: Compute simple increasing witnesses and take their full transitive closure.
- Deletion: Remove the specified old edge and recompute the target diagonals.
import networkx as nx
def mediated_relation(graph):
relation = nx.DiGraph()
relation.add_nodes_from(graph)
for start in graph:
for end in graph:
if start == end:
continue
for path in nx.all_simple_paths(graph, start, end):
heights = [graph[a][b]["height"] for a, b in zip(path, path[1:])]
if len(heights) >= 2 and all(a < b for a, b in zip(heights, heights[1:])):
relation.add_edge(start, end)
break
return relation
def timestamped(edges):
graph = nx.DiGraph()
graph.add_weighted_edges_from(edges, weight="height")
return graph
old = timestamped([("v", "w", 0), ("w", "u", 0), ("u", "x", 0),
("v", "z", 0), ("z", "x", 1)])
chords = [("u", "v", 1), ("x", "w", 2)]
assert nx.is_directed_acyclic_graph(mediated_relation(old))
for _, target, height in chords:
assert all(height >= data["height"] for _, _, data in old.out_edges(target, data=True))
merged = old.copy()
merged.add_weighted_edges_from(chords, weight="height")
final = merged.copy()
final.remove_edge("z", "x")
for name, graph, expected in [("merge", merged, ["v", "w"]), ("final", final, [])]:
closure = nx.transitive_closure(mediated_relation(graph))
diagonal = [target for target in ("v", "w") if closure.has_edge(target, target)]
assert diagonal == expected
assert nx.is_directed_acyclic_graph(mediated_relation(graph)) == (not diagonal)
print(f"{name} target diagonals: {diagonal}")
Simulation Results:
merge target diagonals: ['v', 'w']
final target diagonals: []
Conclusion:
The merged example has two target diagonals and the specified deletion removes both. This confirms the pre-deletion and final-state distinction in the fixture.
In Plain English:
Section 2.7.14 formalizes the properties of the QBD calculation regarding target closure verification.
2.7.15 Calculation: First-Tick Grading Verification
Verification of grading decrease and the six-cycle counterexample (First-Tick Causality on Graded Graphs §2.7.9.1) (Effective Influence §2.6.2) is based on the following protocols:
- Graded Input: Construct the outward tree and enumerate every retained subset of its closing chords.
- Mediated Pairs: Check that every mediated pair lowers the fixed grading by one.
- Ungraded Input: Compute the relation after all six closing chords on a uniform-height cycle.
import networkx as nx
def mediated_relation(graph):
relation = nx.DiGraph()
relation.add_nodes_from(graph)
for start in graph:
for end in graph:
if start == end:
continue
for path in nx.all_simple_paths(graph, start, end):
heights = [graph[a][b]["height"] for a, b in zip(path, path[1:])]
if len(heights) >= 2 and all(a < b for a, b in zip(heights, heights[1:])):
relation.add_edge(start, end)
break
return relation
def timestamped(edges):
graph = nx.DiGraph()
graph.add_weighted_edges_from(edges, weight="height")
return graph
from itertools import combinations
old = timestamped([(0, 1, 0), (0, 2, 0), (1, 3, 0), (1, 4, 0),
(2, 5, 0), (2, 6, 0), (3, 7, 0)])
depth = nx.single_source_shortest_path_length(old, 0)
chords = [(u, v, 1) for v in old for w in old[v] for u in old[w]]
count = 0
for size in range(len(chords) + 1):
for batch in combinations(chords, size):
graph = old.copy()
graph.add_weighted_edges_from(batch, weight="height")
relation = mediated_relation(graph)
assert all(depth[b] == depth[a] - 1 for a, b in relation.edges)
assert nx.is_directed_acyclic_graph(relation)
count += 1
print(f"Outward-tree batches checked: {count}")
cycle = timestamped((i, (i + 1) % 6, 0) for i in range(6))
cycle.add_weighted_edges_from((((i + 2) % 6, i, 1) for i in range(6)), weight="height")
relation = mediated_relation(cycle)
assert set(relation.edges) == {(i, (i - 1) % 6) for i in range(6)}
assert not nx.is_directed_acyclic_graph(relation)
print(f"Six-cycle mediated pairs: {sorted(relation.edges)}")
Simulation Results:
Outward-tree batches checked: 32
Six-cycle mediated pairs: [(0, 5), (1, 0), (2, 1), (3, 2), (4, 3), (5, 4)]
Conclusion:
All tested graded batches satisfy the one-step decrease, and the six-cycle gives a cyclic relation. The outputs confirm the grading distinction on these finite inputs.
In Plain English:
Section 2.7.15 formalizes the properties of the QBD calculation regarding first-tick grading verification.