Documentation

CslibFrontier.Computability.Circuit.Encoding.Check

Checking circuit gate codes #

The existing Program.IsCodeFrom predicate has one Boolean checker for arbitrary signatures. Its native certificate charges the operator's supplied encoding and a certified binary arity function. Only actual argument lists are traversed; neither arity nor wire numbers drive an allocation. The input count is unary and wire numbers are binary. Output-wire validity and output-count agreement are separate checks.

Main definitions #

Main results #

Checking codes #

def Cslib.Circuits.codeCheck (σ : Signature) (n : ℕ) (gates : List (σ.Op × List ℕ)) :

Whether a list of gates is the code of a program on n inputs (Program.IsCodeFrom), as a Boolean test: every entry has the arity of its operation and reads only inputs and earlier gates.

theorem Cslib.Circuits.codeCheck_eq_true_iff {σ : Signature} {n : ℕ} {gates : List (σ.Op × List ℕ)} :
codeCheck σ n gates = true ↔ Program.IsCodeFrom σ n 0 gates

codeCheck σ n gates returns true iff gates is a valid program code on n inputs.

Gate validation is polynomial-time in the full encoded input, for unary input count and binary wire indices, when computing an operation's binary arity is polynomial-time. No bound on the numeric arity is required: comparison uses the actual argument-list length.