Skip to content

Commit 5f60c39

Browse files
committed
Further simplify intersections
1 parent 9d8df88 commit 5f60c39

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

lib/elixir/lib/module/types/descr.ex

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4991,6 +4991,25 @@ defmodule Module.Types.Descr do
49914991
bdd_leaf_intersection(leaf, bdd, leaf_intersection)
49924992
end
49934993

4994+
# Take two BDDs, B1 = {a1, C1, U2, D2} and B2.
4995+
# We can treat a1 as a leaf if C1 = :bdd_top.
4996+
# Then we have:
4997+
#
4998+
# ((a1 and C1) or U2 or (not a1 and D2)) and B2
4999+
#
5000+
# Which is equivalent to:
5001+
#
5002+
# (a1 and B2) or (B2 and (U2 or not a1 and D2))
5003+
defp bdd_intersection({leaf, :bdd_top, u, d}, bdd, leaf_intersection) do
5004+
bdd_leaf_intersection(leaf, bdd, leaf_intersection)
5005+
|> bdd_union(bdd_intersection(bdd, {leaf, :bdd_bot, u, d}))
5006+
end
5007+
5008+
defp bdd_intersection(bdd, {leaf, :bdd_top, u, d}, leaf_intersection) do
5009+
bdd_leaf_intersection(leaf, bdd, leaf_intersection)
5010+
|> bdd_union(bdd_intersection(bdd, {leaf, :bdd_bot, u, d}))
5011+
end
5012+
49945013
defp bdd_intersection(bdd1, bdd2, _leaf_intersection) do
49955014
bdd_intersection(bdd1, bdd2)
49965015
end

0 commit comments

Comments
 (0)