Breadth-first search by rounds #
A round of breadth-first search (Cslib.Reachability.expand) appends to the list of the elements
found so far every successor of one of them that has not been found yet. The found elements stay
distinct, a round only appends, and a round adds nothing exactly when the found elements are
closed under successors. So if at most N distinct elements are reachable from start, after
N rounds from [start] (Cslib.Reachability.search) the found elements are exactly the
reachable ones (Cslib.Reachability.mem_search_iff): each round before closure finds a new
element. The number of rounds, not a search for a fixed point, keeps the algorithm a plain
iteration, as polynomial-time certificates need. When no bound on the number of reachable
elements is known in advance, the search runs until a round adds nothing: the closing round
(Cslib.Reachability.closingRound) is the least number of rounds after which the found elements
are closed, and they are then exactly the reachable ones
(Cslib.Reachability.mem_search_iff_of_closed).
Main definitions #
Cslib.Reachability.insertNew: append an element to a list if not already present.Cslib.Reachability.expand: one round of breadth-first search.Cslib.Reachability.search: a number of rounds from a start element.Cslib.Reachability.closingRound: the least number of rounds after which the search is closed.
Main results #
Cslib.Reachability.nodup_search: the found elements are distinct.Cslib.Reachability.reflTransGen_of_mem_search: the found elements are reachable.Cslib.Reachability.mem_search_iff_of_closed: once a round adds nothing, the found elements are the reachable ones.Cslib.Reachability.expand_search_eq_of_bound,Cslib.Reachability.mem_search_iff: after as many rounds as there are reachable elements, the search is closed and the found elements are the reachable ones.Cslib.Reachability.closingRound_le,Cslib.Reachability.expand_search_ne_of_lt_closingRound: the closing round is the least round after which the search is closed.
References #
Append an element unless it is already in the list.
Instances For
One round of breadth-first search: append, in order, every successor of a found element that has not been found yet.
Instances For
rounds rounds of breadth-first search from start.
Instances For
Zero rounds of breadth-first search return the singleton list [start].
A round only appends.
A round keeps the found elements distinct.
A round adds nothing exactly when the found elements are closed under successors.
The rounds only append.
The found elements are distinct.
The found elements are reachable.
A closed round finds every reachable element: once a round adds nothing, the found elements
are exactly those reachable from start.
Breadth-first search closes within as many rounds as there are reachable elements: if every
list of distinct elements reachable from start has at most bound entries, a round after at least
bound rounds adds nothing.
After as many rounds as there are reachable elements, the found elements are the reachable
ones. If every list of distinct elements reachable from start has at most bound entries, then
after at least bound rounds the found elements are closed under successors, so they include
every reachable element.
Searching until closed #
The closing round: the least number of rounds after which a round from start adds nothing,
or 0 if the search never closes. Searching until closed takes this many rounds, a number that
need not be known in advance.
Instances For
The search is closed after the closing round, if it ever closes.
The closing round is at most any round after which the search is closed.
Before the closing round, every round finds a new element.