Decidability of Relation.ReflTransGen on a finite carrier #
Reachability along a relation whose successors lie in a finite set is decidable: close {a} under
the successor function until it stops growing, and test membership. Mathlib has the analogue for
finite simple graphs (SimpleGraph.Reachable), not for an arbitrary relation.
Main declarations #
Finset.isFixedPt_iterate_card: an inflationary operation on the subsets of a finite setureaches a fixed point withinu.carditerations.Function.exists_lt_card_iterate_eq: on a finite type, every point of a forward orbit is reached withincard αiterations.Relation.ReflTransGen.reach,mem_reach_iff: the set reached from a node, and its characterization.decidable_of_finset_stepand its wrappers for a list-valued successor function, a decidable relation with a bounding list, and aFintypecarrier; theTransGensiblings; and the twoDecidableRelinstances over aFintype.total_of_left_unique,of_forall_exists,exists_boundary: order-theoretic facts about the closure.partialOrderOfCovers,linearOrderOfCovers,decidableLEOfCovers: the order generated by a relation of immediate subsumption whose edges decrease a rank, and its decidability.Relation.reflTransGen_iff_reachIn,decidableLEOfRank: along edges that decrease a natural-number rank, reachability is a search to the depth of the rank.Relation.transGen_iff_mem_iterate,decidable_TransGen_of_option: reachability along a partial function is decided by iterating it, with no closure computation.
Implementation notes #
reach iterates one round of closure (insert a u).card times without testing for the fixed
point, so that by decide evaluates a plain Nat.iterate. The bound comes from cardinality alone:
a strictly growing chain of subsets of a finite set is no longer than the set.
An inflationary operation on the subsets of a finite set reaches a fixed point after as many iterations as the set has elements.
On a finite type, a point of the forward orbit of a is reached within card α iterations,
since a longer path repeats a point and can be shortened.
One round of closing a set under a successor function.
Equations
- Relation.ReflTransGen.closeStep step S = S ∪ S.biUnion step
Instances For
The nodes reached from a along step, when every successor lies in the finite set s.
Equations
- Relation.ReflTransGen.reach step s a = (Relation.ReflTransGen.closeStep step)^[(insert a s).card] {a}
Instances For
Decidability #
Relation.ReflTransGen r is decidable when r has a finset-valued successor function whose
values lie in a finite set.
Equations
- Relation.ReflTransGen.decidable_of_finset_step step s step_eq step_in_s a b = decidable_of_iff (b ∈ Relation.ReflTransGen.reach step s a) ⋯
Instances For
Relation.TransGen r is decidable under the hypotheses of decidable_of_finset_step, as a
first step followed by reachability.
Equations
- Relation.ReflTransGen.decidable_TransGen_of_finset_step step s step_eq step_in_s a b = decidable_of_iff (∃ c ∈ step a, b ∈ Relation.ReflTransGen.reach step s c) ⋯
Instances For
The list-valued form of decidable_of_finset_step.
Equations
- Relation.ReflTransGen.decidable_of_finite_step step s step_eq step_in_s a b = Relation.ReflTransGen.decidable_of_finset_step (fun (a : α) => (step a).toFinset) s.toFinset ⋯ ⋯ a b
Instances For
Relation.ReflTransGen r is decidable when r is decidable and its successors lie in a
list.
Equations
- Relation.ReflTransGen.decidable_of_finite s succ_in_s a b = Relation.ReflTransGen.decidable_of_finite_step (fun (a : α) => List.filter (fun (x : α) => decide (r a x)) s) s ⋯ ⋯ a b
Instances For
Relation.ReflTransGen r is decidable on a Fintype given a finset-valued successor
function.
Equations
- Relation.ReflTransGen.decidable_of_fintype_step step step_eq a b = Relation.ReflTransGen.decidable_of_finset_step step Finset.univ step_eq ⋯ a b
Instances For
Relation.TransGen r is decidable on a Fintype given a finset-valued successor function.
Equations
- Relation.ReflTransGen.decidable_TransGen_of_fintype_step step step_eq a b = Relation.ReflTransGen.decidable_TransGen_of_finset_step step Finset.univ step_eq ⋯ a b
Instances For
Relation.ReflTransGen r is decidable on a Fintype when r is.
Equations
- Relation.ReflTransGen.decidable_of_fintype a b = Relation.ReflTransGen.decidable_of_fintype_step (fun (a : α) => {x : α | r a x}) ⋯ a b
Instances For
Relation.TransGen r is decidable on a Fintype when r is.
Equations
- Relation.ReflTransGen.decidable_TransGen_of_fintype a b = Relation.ReflTransGen.decidable_TransGen_of_fintype_step (fun (a : α) => {x : α | r a x}) ⋯ a b
Instances For
Reachability on a Fintype is decidable, the analogue for a relation of mathlib's
DecidableRel G.Reachable for finite simple graphs. Concrete decides over this instance may
need +kernel.
The closure of an acyclic relation as an order #
Over a left-unique relation, positions reaching a common target are comparable, dually to
Relation.ReflTransGen.total_of_right_unique.
On a finite carrier, if the relation is acyclic and every element other
than a has a predecessor, then a reaches everything.
Crossing a boundary #
A reflexive-transitive path from inside S to outside it crosses the
boundary at a single step, the source reaching the exit and the entry
reaching the target — the Relation.ReflTransGen analogue of
SimpleGraph.Walk.exists_boundary_dart.
Reachability along a partial function #
Reachability along a partial function is reachability by its iterates on Option α.
On a finite carrier, reachability along a partial function is reachability within
card (Option α) iterations.
Reachability along a partial function on a Fintype is decidable by iterating the function,
in time linear in the carrier, where decidable_TransGen_of_fintype closes a set.
Equations
- Relation.ReflTransGen.decidable_TransGen_of_option f a b = decidable_of_iff (some b ∈ List.iterate (fun (x : Option α) => x.bind f) (f a) (Fintype.card (Option α))) ⋯
Instances For
On a finite carrier, a relation whose transitive closure is irreflexive is well founded.
The order generated by immediate subsumption #
A path along edges that decrease a rank does not increase it.
A path along edges that decrease a rank, ending no lower than it starts, is trivial.
The partial order whose ≤ is the reflexive transitive closure of covers, given a rank
that every covers edge strictly decreases.
Equations
- partialOrderOfCovers covers rank hrank = { le := Relation.ReflTransGen covers, le_refl := ⋯, le_trans := ⋯, lt_iff_le_not_ge := ⋯, le_antisymm := ⋯ }
Instances For
The order of partialOrderOfCovers is decidable when allSorts lists every target of a
covers edge.
Equations
- decidableLEOfCovers allSorts complete a b = Relation.ReflTransGen.decidable_of_finite allSorts complete a b
Instances For
Whether b is reachable from a in at most n steps along the successor lists step.
Equations
- Relation.reachIn step 0 x✝¹ x✝ = (x✝¹ == x✝)
- Relation.reachIn step n.succ x✝¹ x✝ = (x✝¹ == x✝ || (step x✝¹).any fun (c : α) => Relation.reachIn step n c x✝)
Instances For
Along edges that decrease a natural-number rank, b is reachable from a exactly when it is
reachable within rank a steps.
The order of partialOrderOfCovers is decidable, for edges listed by step and a
natural-number rank, by searching from a to the depth of its rank.
Equations
- decidableLEOfRank step rank hstep hrank a b = decidable_of_iff (Relation.reachIn step (rank a) a b = true) ⋯
Instances For
The linear order whose ≤ is the reflexive transitive closure of covers, for a relation
whose closure is total and which a rank strictly decreases along.
Equations
- One or more equations did not get rendered due to their size.