CausalGraph: Acyclicity, Ancestor Relation (V2) #
IsDAG is a Prop mixin class on CausalGraph V (mirroring
IsMarkovKernel from Mathlib/Probability/Kernel/Defs.lean): required
only by operations that genuinely need acyclicity (topological sort,
well-founded fixpoint induction).
The ancestor relation uses Relation.ReflTransGen directly (no
intermediate adapter); consumers can use mathlib's existing API for
reflexive-transitive closures.
IsAncestor G u v iff there is a chain v ← w₁ ← ... ← u via parents.
Defined via mathlib's Relation.ReflTransGen over the inlined
"is-parent-of" relation.
Equations
- G.IsAncestor = Relation.ReflTransGen fun (u v : V) => u ∈ G.parents v
Instances For
IsStrictAncestor G u v iff there is a nonempty chain via parents.
Defined via mathlib's Relation.TransGen.
Equations
- G.IsStrictAncestor = Relation.TransGen fun (u v : V) => u ∈ G.parents v
Instances For
Decidable (G.IsAncestor u v) via the Core.Relation.ReflTransGen
substrate's Fintype headline. The relation fun u v => u ∈ G.parents v
has decidable successors G.children u (already defined as
Finset.univ.filter (v ∈ G.parents ·) in Defs.lean).
Equations
Decidable (G.IsStrictAncestor u v) via the substrate's TransGen
Fintype headline.
Acyclicity mixin: the strict-ancestor relation is well-founded —
no infinite chain of parents. Required by topologicalOrder,
develop fixpoint, and well-founded recursion over the parent
relation.
Mathlib analogue: IsMarkovKernel from
Mathlib.Probability.Kernel.Defs — a Prop class on a value of a
structure, marking a property consumers may require.
A Std.Irrefl instance for IsStrictAncestor follows from
well-foundedness; deferred until a consumer needs it.
- wf : WellFounded G.IsStrictAncestor
The strict-ancestor relation has no infinite descending chain.
Instances
Depth-based IsDAG construction: a graph is acyclic if every edge
strictly decreases some ℕ-valued depth function (parent depth <
child depth). Reuses Subrelation.wf over InvImage Nat.lt depth,
which is well-founded by Nat's standard wellfoundedness.
The standard mathlib pattern for proving wellfoundedness of finite
inductive relations: define a measure into ℕ, show the relation
decreases it, conclude.