cana.function_properties package
Predicates and quantitative measures on Boolean update functions.
Submodules:
sampling— shared exact/sampled PI coverage and bootstrap helpersredundancy— input / edge redundancysensitivity— activities and average sensitivitybias— 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_rofmeans 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 (
binatehas at most one name).n_unique_variablesis 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_NEGATIVEcome from thepositive/negativesets keyed by input_names; inputs absent from the expression getSIGN_IRRELEVANT. ReturnsNonewhen 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
idxas afrozenset.SIGN_POSITIVE({1}): positive unate onlySIGN_NEGATIVE({-1}): negative unate onlySIGN_BINATE({1, -1}): neither pure direction (dual-sign)SIGN_IRRELEVANT(frozenset()): both unate (no influence)
- Parameters:
lut (BitLut)
idx (int)
- Return type:
frozenset
- cana.function_properties.input_signs(lut)[source]
Return the sign of each input of
lut(lengthlut.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_POSITIVEorSIGN_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
idxis negative unate (inhibiting).- Parameters:
lut (BitLut)
idx (int)
- Return type:
bool
- cana.function_properties.is_input_positive_unate(lut, idx)[source]
Return whether input
idxis positive unate (activating).- Parameters:
lut (BitLut)
idx (int)
- Return type:
bool
Submodules
- cana.function_properties.bias module
- cana.function_properties.redundancy module
- Redundancy
BootstrapResultSampledPiCoveragepi_covers()covering_primes()covering_primes_with_polarity()sample_binstates()sample_pi_coverage()input_redundancy_from_coverage()edge_redundancy_from_coverage()input_redundancy_contributions()edge_redundancy_contributions()input_redundancy()edge_redundancy()bootstrap_input_redundancy()bootstrap_edge_redundancy()
- cana.function_properties.rof module
- cana.function_properties.sampling module
- cana.function_properties.sensitivity module
- cana.function_properties.symmetry module
- cana.function_properties.unate module