/-- The assignment a satisfies the formula ψ (a literal (v, b) holds if a v = b). -/
defHolds (a : ℕ→Bool) (ψ : Fml) : Prop:=∀C∈ ψ, ∃ t ∈C, a t.1 = t.2
/-! ### Corollary 6 -/
/-- **«no two of which share a satisfying assignment, so that their numbers of satisfying
assignments add up»** (to the number of the given formula), for EVERY formula ψ and EVERY list L of
formulas, counted on n variables: if no assignment (of all the variables x₀, x₁, …) satisfies two
formulas at different places of L, and an assignment satisfies ψ exactly if it satisfies some
formula of L, then the number of satisfying assignments of ψ is the sum of those of the formulas of
L. -/
defStAddUp : Prop:=∀ (n : ℕ) (ψ : Fml) (L : ListFml), (L.Pairwisefun y z =>∀a : ℕ→Bool, ¬(Holds a y ∧Holds a z)) → (∀a : ℕ→Bool, Holds a ψ ↔∃ y ∈L, Holds a y) →
cntN n ψ = (L.map fun y => cntN n y).sum
/-- An assignment satisfies a node of the counting tree exactly if it satisfies some leaf below it,
at every depth of the cut. -/
defStCovered : Prop:=∀ (θ : ℕ→ℕ) (k d : ℕ) (x : CNode) (a : ℕ→Bool), Holds a (leafF x) ↔∃ y ∈ leaves (stepC θ k) d x, Holds a (leafF y)
/-- The formula at the root (with the empty side list) has the satisfying assignments of the given
formula. -/
defStRootSame : Prop:=∀ (u : ListUnit) (ψ : Fml) (a : ℕ→Bool), Holds a (leafF (rootPlain (u, ψ)).2) ↔Holds a ψ
/-- **The numbers of the leaves add up to that of the given formula**, for all thresholds, every
width and every depth of the cut. It is proved in this development from
`SplitCount.StDisjointLeaves`, `StCovered`, `StRootSame` and `StAddUp`. -/
defStTreeAddsUp : Prop:=∀ (θ : ℕ→ℕ) (k d n : ℕ) (ψ : Fml),
cntN n ψ = ((leaves (stepPlain (stepC θ k)) d (rootPlain (List.replicate n (), ψ))).map fun x => cntN n (leafF x.2)).sum
/-- The same for one step of the tree: it is the statement `CountKSat.StStepCount` of
proof/consequences/CountKSat/. It is proved in this development from `SplitCount.StDisjoint` and
`StAddUp` (the list of the two children), and handed to `CountKSat.stProgC`, which has it as a
hypothesis, in the place of proof/consequences/CountKSat/'s own proof. -/
abbrevStStepAdds : Prop:=CountKSat.StStepCount
/-- `SplitCount.SparsifiesPlain` WITHOUT the sum: the bounds on the tree alone. ψ has variables
below n and nonempty clauses of at most k literals. The tree of depth Dd·n has at most 2^{εn}
leaves. The formula of a leaf has at most Bl·n clauses of at most max k 2 literals, on the same
variables. The stack of the walk never holds more than Dd·n + 1 nodes, each with at most (|ψ| +