cana.function_outputs.ast module
Boolean expression AST: parse, invert, and leaf walks.
Structural & / | / ! trees only — no read-once assumption.
Callers that need syntactic ROF (single occurrence) should use
cana.function_properties.rof.
- class cana.function_outputs.ast.LogicNode(op, children)[source]
Bases:
objectNode in a boolean expression AST.
opis one ofAND,OR,LITERAL,NEGATED_LITERAL. For leaves,childrenis the variable name (str); for gates it is a list of childLogicNodeinstances.- Parameters:
op (str)
children (Union[str, List['LogicNode']])
- op
- children
- cana.function_outputs.ast.expression_to_ast(expr_str)[source]
Parse a boolean expression into a
LogicNodeAST.Accepts python (
and/or/not) or symbolic (&/|/!) operators. Splits on top-level|then&, unwraps outer parentheses, and treats!as a prefix pushed viainvert_ast()(NNF; stacked!!acancels).- Parameters:
expr_str (str)
- Return type:
LogicNode | None
- cana.function_outputs.ast.invert_ast(node)[source]
Apply De Morgan dualization (swap AND/OR, flip literals).