cana.function_properties package

Predicates and quantitative measures on Boolean update functions.

Submodules:

  • unate / rof — semantic and syntactic predicates

  • sampling — shared exact/sampled PI coverage and bootstrap helpers

  • redundancy — input / edge redundancy

  • sensitivity — activities and average sensitivity

  • bias — node bias (ON-fraction)

  • symmetry — LUT permutation symmetry

The package root re-exports the unate / ROF predicate API for convenience. Measure APIs are imported from their submodules.

cana.function_properties.check_syntactic_rof(expr)[source]

Return syntactic-ROF stats for expression expr.

is_rof means syntactic (single occurrence), not semantic read-once after simplification. Constants (no identifiers) are vacuously ROFs.

Parameters:

expr (str)

Return type:

Dict[str, bool | int]

cana.function_properties.check_syntactic_rof_ast(node)[source]

Return syntactic-ROF stats for an AST node (leaf occurrence walk).

Parameters:

node (LogicNode | None)

Return type:

Dict[str, bool | int]

cana.function_properties.require_syntactic_rof_ast(node)[source]

Raise if node is not a syntactic ROF (single occurrence).

Rejects formulas that might only be read-once after simplification; this engine never rewrites.

Parameters:

node (LogicNode | None)

Return type:

None

cana.function_properties.check_syntactic_unate(expr)[source]

Return syntactic-unate stats for expression expr.

Single-pass NNF polarity scan. Stops at the first binate variable (binate has at most one name). n_unique_variables is always a full count (not truncated by early stop). Constants / empty expressions are vacuously unate. Does not parse to an AST.

Parameters:

expr (str)

Return type:

Dict[str, bool | int | List[str]]

cana.function_properties.check_syntactic_unate_ast(node)[source]

Return syntactic-unate stats for an AST node (leaf polarity walk).

Convenience when a tree already exists; enumerates all leaves (no early stop). Prefer check_syntactic_unate() for expression strings.

Parameters:

node (LogicNode | None)

Return type:

Dict[str, bool | int | List[str]]

cana.function_properties.require_syntactic_unate(expr)[source]

Raise if expr is not syntactically unate.

Rejects formulas that might only be unate after simplification; this check never rewrites. Stops at the first binate.

Parameters:

expr (str)

Return type:

None

cana.function_properties.require_syntactic_unate_ast(node)[source]

Raise if node is not syntactically unate.

Parameters:

node (LogicNode | None)

Return type:

None

cana.function_properties.syntactic_input_signs(expr, input_names)[source]

Return per-input signs if expr is syntactically unate; else None.

Uses the NNF string scan. SIGN_POSITIVE / SIGN_NEGATIVE come from the positive / negative sets keyed by input_names; inputs absent from the expression get SIGN_IRRELEVANT. Returns None when not syntactically unate so callers can fall through to a LUT-based check (syntactic binate does not imply semantic binate).

Parameters:
  • expr (str)

  • input_names (Sequence[str])

Return type:

List[frozenset] | None

cana.function_properties.input_sign(lut, idx)[source]

Return the interaction sign of input idx as a frozenset.

  • SIGN_POSITIVE ({1}): positive unate only

  • SIGN_NEGATIVE ({-1}): negative unate only

  • SIGN_BINATE ({1, -1}): neither pure direction (dual-sign)

  • SIGN_IRRELEVANT (frozenset()): both unate (no influence)

Parameters:
Return type:

frozenset

cana.function_properties.input_signs(lut)[source]

Return the sign of each input of lut (length lut.k).

Parameters:

lut (BitLut)

Return type:

List[frozenset]

cana.function_properties.is_function_monotone_increasing(lut)[source]

Return whether the whole function is monotone increasing.

True when every input is positive unate (isotone / monotone up).

Parameters:

lut (BitLut)

Return type:

bool

cana.function_properties.is_function_unate(lut)[source]

Return whether the whole function is unate.

True when every input is purely positive or purely negative (SIGN_POSITIVE or SIGN_NEGATIVE). Irrelevant and binate inputs make the function not unate.

Parameters:

lut (BitLut)

Return type:

bool

cana.function_properties.is_input_negative_unate(lut, idx)[source]

Return whether input idx is negative unate (inhibiting).

Parameters:
Return type:

bool

cana.function_properties.is_input_positive_unate(lut, idx)[source]

Return whether input idx is positive unate (activating).

Parameters:
Return type:

bool

Submodules