File tree Expand file tree Collapse file tree 1 file changed +5
-8
lines changed
Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -1719,8 +1719,8 @@ def decision(
17191719 """
17201720 return (var & if_true ) | (~ var & if_false )
17211721
1722- def flatten (nnf : NNF ):
1723- """Flattens a formula by removing unnecessary extra nestings.
1722+ def flatten_one_level (nnf : NNF ):
1723+ """Flattens the first "level" of a formula by removing unnecessary extra nestings.
17241724
17251725 param var: The formula to be flattened.
17261726 """
@@ -1730,16 +1730,13 @@ def flatten(nnf: NNF):
17301730 for c in nnf .children :
17311731 if type (c ) == Var :
17321732 new_children .add (c )
1733- # atoms don't need to be nested
1734- elif len (c .children ) == 1 :
1735- new_children .update (c .children )
17361733 # if the operator type is the same as the outer operator, flatten the formula
17371734 # and remove the nested operator by only taking the children (i.e. And(And()) or Or(Or()))
17381735 elif type (c ) == outer_operator :
1739- new_children .update (flatten ( c ) .children )
1736+ new_children .update (c .children )
17401737 else :
1741- # otherwise, continue to flatten the children but keep the operator (i.e. And(Or) or Or(And))
1742- new_children .add (flatten ( c ) )
1738+ # otherwise, keep the operator as is if it is a different type (i.e. And(Or) or Or(And))
1739+ new_children .add (c )
17431740 return outer_operator (new_children )
17441741
17451742#: A node that's always true. Technically an And node without children.
You can’t perform that action at this time.
0 commit comments