Counting the clauses of an encoded formula #
A formula's encoding is a stream of two-bit tokens, one of which marks the end of a clause. Counting those tokens counts the clauses, and an algorithm that has to loop over the clauses needs that count in unary.
The scan consumes two bits per step, so it is an iteration rather than a fold: the state is the count so far paired with the unread suffix.
Main definitions #
Complexity.sepCount— how many clause markers a bit string carriesComplexity.ccStep— one two-bit step
Main results #
Complexity.ccStep_iterate— the scan countsComplexity.clauseCountFn_mem_FP,Complexity.clauseCountFn_eq— counting is polynomial time
How many clause markers — the token 10 — a bit string carries.
Equations
- Complexity.sepCount (true :: false :: r) = Complexity.sepCount r + 1
- Complexity.sepCount (head :: head_1 :: r) = Complexity.sepCount r
- Complexity.sepCount x✝ = 0
Instances For
The scan as one function #
The clause count, in unary.