The current definition of Expression.depth is a bit weird. In particular:
The Not gate does not add a level of depth
The Xor, Xnor, Equal, Unequal, ITE, gates add two levels of depth
Also, the calculation is a bit wasteful. It calculates max(arg.depth + 1 for arg in self.args). It would be cheaper to calculate max(arg.depth for arg in self.args) + 1.
The current definition of
Expression.depth
is a bit weird. In particular:Not
gate does not add a level of depthXor
,Xnor
,Equal
,Unequal
,ITE
, gates add two levels of depthAlso, the calculation is a bit wasteful. It calculates
max(arg.depth + 1 for arg in self.args)
. It would be cheaper to calculatemax(arg.depth for arg in self.args) + 1
.