@@ -5130,45 +5130,24 @@ defmodule Module.Types.Descr do
51305130 { lit2 , bdd_difference ( bdd1_minus_u2 , c2 ) , :bdd_bot , bdd_difference ( bdd1_minus_u2 , d2 ) }
51315131
51325132 { :eq , { lit , c1 , u1 , d1 } , { _ , c2 , u2 , d2 } } ->
5133+ # The formula is:
5134+ # {a1, (C1 or U1) and not (C2 or U2), :bottom, (D1 or U1) and not (D2 or U2)} when a1 == a2
5135+ #
5136+ # Constrained: (C1 and not C2 and not U2) or (U1 and not C2 and not U2)
5137+ # Dual: (D1 and not D2 and not U2) or (U1 and not D2 and not U2)
5138+ #
5139+ # We can optimize the cases below.
51335140 cond do
51345141 c2 == :bdd_bot and d2 == :bdd_bot ->
5142+ # Constrained = (C1 and not U2) or (U1 and not U2)
5143+ # Dual = (D1 and not U2) or (U1 and not U2)
5144+ # Hence:
51355145 { lit , bdd_difference ( c1 , u2 ) , bdd_difference ( u1 , u2 ) , bdd_difference ( d1 , u2 ) }
51365146
5137- u2 == :bdd_bot ->
5138- cond do
5139- d2 == :bdd_bot ->
5140- { lit , bdd_difference ( c1 , c2 ) , bdd_difference ( u1 , c2 ) , bdd_union ( u1 , d1 ) }
5141-
5142- c2 == :bdd_bot ->
5143- { lit , bdd_union ( u1 , c1 ) , bdd_difference ( u1 , d2 ) , bdd_difference ( c1 , c2 ) }
5144-
5145- true ->
5146- # If d2 or c2 are bottom, we can remove one union.
5147- #
5148- # For example, if d2 is bottom, we have this BDD:
5149- #
5150- # {l, (C1 or U1) and not C2, U1 and not C2, D1 or U1}
5151- #
5152- # Where the constrained part is:
5153- #
5154- # (l and (C1 or U1) and not C2)
5155- #
5156- # Which expands to:
5157- #
5158- # (l and C1 and not C2) or (l and U1 and not C2)
5159- #
5160- # Given (U1 and not C2) is already part of the uncertain/union,
5161- # we can skip (l and U1 and not C2), and we end up with:
5162- #
5163- # {l, C1 and not C2, U1 and not C2, D1 or U1}
5164- #
5165- # Which are the formulas used above.
5166- { lit , bdd_difference ( bdd_union ( u1 , c1 ) , c2 ) ,
5167- bdd_difference ( bdd_difference ( u1 , c2 ) , d2 ) ,
5168- bdd_difference ( bdd_union ( u1 , d1 ) , d2 ) }
5169- end
5170-
51715147 u1 == :bdd_bot or u1 == u2 ->
5148+ # Constrained = (C1 and not C2 and not U2)
5149+ # Dual = (D1 and not D2 and not U2)
5150+ # Hence:
51725151 { lit , bdd_difference_union ( c1 , c2 , u2 ) , :bdd_bot ,
51735152 bdd_difference_union ( d1 , d2 , u2 ) }
51745153
0 commit comments