A native bit-logic gate library #
The native cost model charges one step per AST unfolding and runs every bounded recursion for its
full iteration count, so arithmetic on a magnitude-v operand costs Θ(v) — linear in the
value, not in the number of bits. Equality of general natural-number labels is therefore out of
reach in polynomial time on this model.
Computing with bits is not. Each gate below recurses on a bit rather than on a value, and each is
bit-closed: its val is 0 or 1 whatever the input. Every gate comes with a val law, an
RfindFree certificate (no unbounded search: the gates are total), and a tc bound linear in the
input value — hence constant on bits, which is what the tc_*_bit bricks at the end state
outright.
cShape0 is the reshaping n ↦ ⟨0, n⟩ that lets a bounded recursion recurse on a bare input.
cIsPos and cNot are the two gates that recurse; cSwap is a pure rewiring; and cOr, cAnd
and cEqBit are composed over those, the last two by De Morgan, so they carry no recursion of
their own. The tc bounds all go through the uniform tc_prec_le.
The public surface is the gates cIsPos, cNot, cSwap, cOr, cAnd and cEqBit with their
val laws (val_cIsPos, val_cNot, val_cOr, val_cAnd, val_cEqBit, val_cEqBit_bit), their
RfindFree certificates and tc bounds (tc_cOr_le, tc_cAnd_le, tc_cEqBit_le), and the
prec cores isPosCore, notCore and orCore with the same three laws each.
The module stays deliberately light over the cost model: these are Boolean primitives, and know nothing of the learners and arithmetic codes assembled from them.
Reshape n ↦ ⟨0, n⟩ so a prec recurses on the value n (seed 0).
Equations
Instances For
cShape0 runs a constant five steps on every input.
[n ≠ 0] as a prec recursing on the value: base 0, step 1.
Equations
Instances For
Positivity indicator n ↦ [n ≠ 0] (bit-closed).
Instances For
isPosCore on a packed ⟨a, n⟩ runs at most 4 * n + 2 steps.
Negation n ↦ [n = 0] (bit-closed).
Equations
Instances For
notCore on a packed ⟨a, n⟩ runs at most 2 * n + 4 steps.
Swap ⟨a,b⟩ ↦ ⟨b,a⟩.
Instances For
Disjunction ⟨a,b⟩ ↦ a ∨ b (bit-closed): recurse on a, seed b.
Equations
Instances For
Conjunction ⟨a,b⟩ ↦ a ∧ b via De Morgan (prec-free, bit-closed).
Equations
Instances For
Bit-equality ⟨a,b⟩ ↦ [a = b] on bits, via (a ∧ b) ∨ (¬a ∧ ¬b) (prec-free, bit-closed).
The general val law is "both zero, or both nonzero"; it coincides with equality exactly on the
binary regime a, b ∈ {0,1} (val_cEqBit_bit).
Equations
Instances For
Every gate is bit-closed: cIsPos outputs a bit.
Gate tc-on-bits bricks #
On bit operands every gate runs a constant number of steps: the prec-based gates unfold ≤ 1
times, the De-Morgan compositions are prec-free.