@@ -31,6 +31,73 @@ parsePresburgerRelationFromPresburgerSet(ArrayRef<StringRef> strs,
31
31
return result;
32
32
}
33
33
34
+ TEST (PresburgerRelationTest, intersectDomainAndRange) {
35
+ PresburgerRelation rel = parsePresburgerRelationFromPresburgerSet (
36
+ {// (x, y) -> (x + N, y - N)
37
+ " (x, y, a, b)[N] : (x - a + N == 0, y - b - N == 0)" ,
38
+ // (x, y) -> (x + y, x - y)
39
+ " (x, y, a, b)[N] : (a - x - y == 0, b - x + y == 0)" ,
40
+ // (x, y) -> (x - y, y - x)}
41
+ " (x, y, a, b)[N] : (a - x + y == 0, b - y + x == 0)" },
42
+ 2 );
43
+
44
+ {
45
+ PresburgerSet set =
46
+ parsePresburgerSet ({// (2x, x)
47
+ " (a, b)[N] : (a - 2 * b == 0)" ,
48
+ // (x, -x)
49
+ " (a, b)[N] : (a + b == 0)" ,
50
+ // (N, N)
51
+ " (a, b)[N] : (a - N == 0, b - N == 0)" });
52
+
53
+ PresburgerRelation expectedRel = parsePresburgerRelationFromPresburgerSet (
54
+ {" (x, y, a, b)[N] : (x - a + N == 0, y - b - N == 0, x - 2 * y == 0)" ,
55
+ " (x, y, a, b)[N] : (x - a + N == 0, y - b - N == 0, x + y == 0)" ,
56
+ " (x, y, a, b)[N] : (x - a + N == 0, y - b - N == 0, x - N == 0, y - N "
57
+ " == 0)" ,
58
+ " (x, y, a, b)[N] : (a - x - y == 0, b - x + y == 0, x - 2 * y == 0)" ,
59
+ " (x, y, a, b)[N] : (a - x - y == 0, b - x + y == 0, x + y == 0)" ,
60
+ " (x, y, a, b)[N] : (a - x - y == 0, b - x + y == 0, x - N == 0, y - N "
61
+ " == 0)" ,
62
+ " (x, y, a, b)[N] : (a - x + y == 0, b - y + x == 0, x - 2 * y == 0)" ,
63
+ " (x, y, a, b)[N] : (a - x + y == 0, b - y + x == 0, x + y == 0)" ,
64
+ " (x, y, a, b)[N] : (a - x + y == 0, b - y + x == 0, x - N == 0, y - N "
65
+ " == 0)" },
66
+ 2 );
67
+
68
+ PresburgerRelation computedRel = rel.intersectDomain (set);
69
+ EXPECT_TRUE (computedRel.isEqual (expectedRel));
70
+ }
71
+
72
+ {
73
+ PresburgerSet set =
74
+ parsePresburgerSet ({// (2x, x)
75
+ " (a, b)[N] : (a - 2 * b == 0)" ,
76
+ // (x, -x)
77
+ " (a, b)[N] : (a + b == 0)" ,
78
+ // (N, N)
79
+ " (a, b)[N] : (a - N == 0, b - N == 0)" });
80
+
81
+ PresburgerRelation expectedRel = parsePresburgerRelationFromPresburgerSet (
82
+ {" (x, y, a, b)[N] : (x - a + N == 0, y - b - N == 0, a - 2 * b == 0)" ,
83
+ " (x, y, a, b)[N] : (x - a + N == 0, y - b - N == 0, a + b == 0)" ,
84
+ " (x, y, a, b)[N] : (x - a + N == 0, y - b - N == 0, a - N == 0, b - N "
85
+ " == 0)" ,
86
+ " (x, y, a, b)[N] : (a - x - y == 0, b - x + y == 0, a - 2 * b == 0)" ,
87
+ " (x, y, a, b)[N] : (a - x - y == 0, b - x + y == 0, a + b == 0)" ,
88
+ " (x, y, a, b)[N] : (a - x - y == 0, b - x + y == 0, a - N == 0, b - N "
89
+ " == 0)" ,
90
+ " (x, y, a, b)[N] : (a - x + y == 0, b - y + x == 0, a - 2 * b == 0)" ,
91
+ " (x, y, a, b)[N] : (a - x + y == 0, b - y + x == 0, a + b == 0)" ,
92
+ " (x, y, a, b)[N] : (a - x + y == 0, b - y + x == 0, a - N == 0, b - N "
93
+ " == 0)" },
94
+ 2 );
95
+
96
+ PresburgerRelation computedRel = rel.intersectRange (set);
97
+ EXPECT_TRUE (computedRel.isEqual (expectedRel));
98
+ }
99
+ }
100
+
34
101
TEST (PresburgerRelationTest, applyDomainAndRange) {
35
102
{
36
103
PresburgerRelation map1 = parsePresburgerRelationFromPresburgerSet (
0 commit comments