cana.function_properties.rof module

Syntactic read-once (ROF) checks on expressions and ASTs.

Syntactic ROF means every identifier occurs exactly once in the written expression / AST (n_variables == n_unique_variables; also called trivial / single-occurrence). That is distinct from semantic read-once-ness: a formula may become read-once only after algebraic rewriting (e.g. a & a ≡ a), which this module does not attempt.

is_rof in return dicts means syntactic ROF.

Prime count / generation for syntactic ROFs lives in cana.primes.rof_primes.

cana.function_properties.rof.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.rof.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.rof.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