Skip to content

Commit

Permalink
refactor some api in intervalValue
Browse files Browse the repository at this point in the history
  • Loading branch information
bjjwwang committed May 20, 2024
1 parent 64dc0bf commit 3b0674a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
5 changes: 3 additions & 2 deletions svf/include/AE/Core/AbstractState.h
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ class AbstractState
auto it = rhs.find(item.first);
if (it == rhs.end()) return false;
// judge from expr id
if (item.second.getInterval().geq(it->second.getInterval())) return false;
if (item.second.getInterval().contain(it->second.getInterval())) return false;
}
return true;
}
Expand All @@ -409,7 +409,8 @@ class AbstractState
// judge from expr id
if (it->second.isInterval() && item.second.isInterval())
{
if (!it->second.getInterval().geq(item.second.getInterval()))
if (!it->second.getInterval().contain(
item.second.getInterval()))
return false;
}

Expand Down
38 changes: 36 additions & 2 deletions svf/include/AE/Core/IntervalValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ class IntervalValue
}

/// Check current IntervalValue is smaller than or equal to the other
bool leq(const IntervalValue &other) const
/// this: [2,3], other: [1, 4], return true
bool containedWithin(const IntervalValue &other) const
{
if (this->isBottom())
{
Expand All @@ -317,7 +318,8 @@ class IntervalValue
}

/// Check current IntervalValue is greater than or equal to the other
bool geq(const IntervalValue &other) const
/// this: [1,4], other: [2,3], return true
bool contain(const IntervalValue &other) const
{
if (this->isBottom())
{
Expand All @@ -333,6 +335,38 @@ class IntervalValue
}
}

/// Check the upper bound of this Interval is less than or equal to the lower bound
/// e.g. [1, 3] < [3, 5] return true, lhs.ub <= rhs.lb
bool leq(const IntervalValue &other) const {
if (this->isBottom()) {
return true;
}
else if (other.isBottom())
{
return false;
}
else
{
return this->_ub.leq(other._lb);
}
}

/// Check the lower bound of this Interval is greater than or equal to the upper bound
/// e.g. [3, 5] > [1, 3] return true, lhs.lb >= rhs.ub
bool geq(const IntervalValue &other) const {
if (this->isBottom()) {
return true;
}
else if (other.isBottom())
{
return false;
}
else
{
return this->_lb.geq(other._ub);
}
}


/// Equality comparison
bool equals(const IntervalValue &other) const
Expand Down

0 comments on commit 3b0674a

Please sign in to comment.