Binary branching #
A binary branching T : BinaryBranching σ marks some states as leaves (T.IsLeaf) and gives
every state a false child and a true child (T.next). A word w : List Bool names the state
reached by following its branches (walk). It is a node word when its proper prefixes reach
inner states (IsNodeWord), and a leaf word when moreover it reaches a leaf (IsLeafWord).
Leaf words are determined by the positions of their true branches
(IsLeafWord.eq_of_getD_eq), so leaf words of length at most Λ with at most ρ true
branches number at most ∑_{j ≤ ρ} (Λ choose j) (card_le_sum_choose_of_isLeafWord).
When no branch is infinite (Terminating, for instance when a measure decreases from every inner
state to its children, Terminating.of_lt), every node word extends to a leaf word. A depth-first
search (searchStep) keeps a stack of states and an accumulator, updated by an arbitrary function
at each leaf. Started from a state, it takes fewer than twice as many steps as the state has
leaves, and its accumulator becomes the fold of the update over a duplicate-free list of all leaf
words; meanwhile its stack holds at most h + 1 states of the tree when the leaf words have length
at most h (exists_iterate_searchStep). A function that is additive at inner states sums over
the leaves to its value at the root (sum_leafWords_eq).
The sparsification procedures of Impagliazzo, Paturi and Zane and of counting sparsification are binary branchings whose leaves are the sparse clause sets.
Main definitions #
Cslib.BinaryBranching: leaves and children on a type of states.Cslib.BinaryBranching.walk,.IsNodeWord,.IsLeafWord: the tree of a state.Cslib.BinaryBranching.walkSeq: follow a branch sequence until a leaf.Cslib.BinaryBranching.searchStep: one step of depth-first search.Cslib.BinaryBranching.Terminating: every branch ends at a leaf.
Main results #
Cslib.BinaryBranching.IsLeafWord.eq_of_getD_eq: leaf words are determined by theirtruebranches.Cslib.BinaryBranching.card_le_sum_choose_of_isLeafWord: few short leaf words with fewtruebranches.Cslib.BinaryBranching.exists_iterate_searchStep: depth-first search folds over the leaves.Cslib.BinaryBranching.sum_leafWords_eq: additive functions sum over the leaves.
A binary branching on states σ: some states are leaves, and every state has a false
child and a true child, of which only those of inner states matter.
The state reached along a word of branches.
A node word: its proper prefixes reach inner states.
A leaf word: its proper prefixes reach inner states and it reaches a leaf.
Follow the branch sequence f for at most n steps, stopping at a leaf.
One step of the depth-first search, on a stack of states and an accumulator: a leaf on top is
popped and the accumulator is updated with it by f; an inner state on top is replaced by its
false and true children.
Every branch ends at a leaf: the relation between the children of an inner state and the state is well-founded.
Termination #
A branching terminates when a natural-number measure decreases from every inner state to its children.
Induction on a terminating branching. A property of the leaves that passes from the two children of every inner state to the state holds for every state.
Words #
Every leaf word is a node word.
Walking along a leaf word reaches a leaf.
The only leaf word of a leaf is the empty word.
A leaf word is a node word reaching a leaf.
The proper prefixes of a node word reach inner states.
Leaf words are determined by their true branches. Two leaf words with true branches
at the same positions are equal.
Following a branch sequence ends at the state of some node word.
Following a branch sequence that agrees with a leaf word, for at least as many steps, ends at that leaf.
Few leaf words. Leaf words of length at most Λ with at most ρ true branches number
at most ∑_{j ≤ ρ} (Λ choose j).
Terminating branchings #
Every state has a leaf word.
Every node word extends to a leaf word.
Depth-first search. Started from a state s above a stack rest, the search takes N
steps, fewer than twice the number of leaves of s, to return to rest. Meanwhile it folds the
update f over the leaves of s, in the order of a duplicate-free list L of the leaf words of
s: after each step the accumulator is the fold over a prefix of L. If the leaf words of s
have length at most h, the stack above rest consists of at most h + 1 states of the tree of
s, reached along node words of length at most h.
Additive functions sum over the leaves. If g is the sum of its values at the two
children of every inner state, then its sum over the leaf words of s is its value at s.