Skip to content

Commit

Permalink
Merge pull request #1462 from bjjwwang/0520
Browse files Browse the repository at this point in the history
refactor some api in intervalValue
  • Loading branch information
yuleisui authored May 20, 2024
2 parents 64dc0bf + 588e958 commit 39b6e83
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 6 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
46 changes: 42 additions & 4 deletions svf/include/AE/Core/IntervalValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,11 @@ class IntervalValue
this->_ub = plus_infinity();
}

/// Check current IntervalValue is smaller than or equal to the other
bool leq(const IntervalValue &other) const
/// Determines if the current IntervalValue is fully contained within another IntervalValue.
/// Example: this: [2, 3], other: [1, 4] -> returns true
/// Note: If the current interval is 'bottom', it is considered contained within any interval.
/// If the other interval is 'bottom', it cannot contain any interval.
bool containedWithin(const IntervalValue &other) const
{
if (this->isBottom())
{
Expand All @@ -316,8 +319,11 @@ class IntervalValue

}

/// Check current IntervalValue is greater than or equal to the other
bool geq(const IntervalValue &other) const
/// Determines if the current IntervalValue fully contains another IntervalValue.
/// Example: this: [1, 4], other: [2, 3] -> returns true
/// Note: If the current interval is 'bottom', it is considered to contain any interval.
/// If the other interval is 'bottom', it cannot be contained by any interval.
bool contain(const IntervalValue &other) const
{
if (this->isBottom())
{
Expand All @@ -333,6 +339,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 39b6e83

Please sign in to comment.