elif(n.name=='ᑌ'and((n.left.name=='σ'andn.left.child==n.right)or(n.right.name=='σ'andn.right.child==n.left))):#Union of two equal things, but one has a selection
#selection and union of the same thing
elif(n.name=='ᑌ'):
ifn.left.name=='σ'andn.left.child==n.right:
changes=1
changes=1
ifn.left=='σ':#Selection on left. replacing self with right.
replace_node(n,n.right)
replace_node(n,n.right)
else:#Selection on left. replacing self with right.
elifn.right.name=='σ'andn.right.child==n.left:
replace_node(n,n.left)
elif(n.name=='ᑎ'and((n.left.name=='σ'andn.left.child==n.right)or(n.right.name=='σ'andn.right.child==n.left))):#Intersection of two equal things, but one has a selection
changes=1
changes=1
ifn.left=='σ':#Swapping with the selection
replace_node(n,n.left)
replace_node(n,n.left)
else:
#selection and intersection of the same thing
elifn.name=='ᑎ':
ifn.left.name=='σ'andn.left.child==n.right:
changes=1
replace_node(n,n.left)
elifn.right.name=='σ'andn.right.child==n.left:
changes=1
replace_node(n,n.right)
replace_node(n,n.right)
#TODO make work the following line...
#Subtraction and selection of the same thing
elif(n.name=='-'and(n.right.name=='σ'andn.right.child==n.left)):#Subtraction of two equal things, but one has a selection
elif(n.name=='-'and(n.right.name=='σ'andn.right.child==n.left)):#Subtraction of two equal things, but one has a selection
n.name=n.right.name
n.name=n.right.name
n.kind=n.right.kind
n.kind=n.right.kind
n.child=n.right.child
n.child=n.right.child
n.prop='(not (%s))'%n.right.prop
n.prop='(not (%s))'%n.right.prop
n.left=n.right=None
n.left=n.right=None
#Subtraction of the same thing or with selection on the left child