LLZK 0.1.0
Veridise's ZK Language IR
Loading...
Searching...
No Matches
llzk::UnreducedInterval Class Reference

An inclusive interval [a, b] where a and b are arbitrary integers not necessarily bound to a given field. More...

#include <Intervals.h>

Public Member Functions

 UnreducedInterval (const llvm::DynamicAPInt &x, const llvm::DynamicAPInt &y)
 UnreducedInterval (int64_t x, int64_t y)
 This constructor is primarily for convenience for unit tests.
Interval reduce (const Field &field) const
 Reduce the interval to an interval in the given field.
UnreducedInterval intersect (const UnreducedInterval &rhs) const
 Compute and return the intersection of this interval and the given RHS.
UnreducedInterval doUnion (const UnreducedInterval &rhs) const
 Compute and return the union of this interval and the given RHS.
UnreducedInterval computeLTPart (const UnreducedInterval &rhs) const
 Return the part of the interval that is guaranteed to be less than the rhs's max value.
UnreducedInterval computeLEPart (const UnreducedInterval &rhs) const
 Return the part of the interval that is less than or equal to the rhs's upper bound.
UnreducedInterval computeGTPart (const UnreducedInterval &rhs) const
 Return the part of the interval that is greater than the rhs's lower bound.
UnreducedInterval computeGEPart (const UnreducedInterval &rhs) const
 Return the part of the interval that is greater than or equal to the rhs's lower bound.
UnreducedInterval operator- () const
bool overlaps (const UnreducedInterval &rhs) const
llvm::DynamicAPInt getLHS () const
llvm::DynamicAPInt getRHS () const
llvm::DynamicAPInt width () const
 Compute the width of this interval within a given field f.
bool isEmpty () const
 Returns true iff width() is zero.
bool isNotEmpty () const
void print (llvm::raw_ostream &os) const

Friends

UnreducedInterval operator+ (const UnreducedInterval &lhs, const UnreducedInterval &rhs)
UnreducedInterval operator- (const UnreducedInterval &lhs, const UnreducedInterval &rhs)
UnreducedInterval operator* (const UnreducedInterval &lhs, const UnreducedInterval &rhs)
std::strong_ordering operator<=> (const UnreducedInterval &lhs, const UnreducedInterval &rhs)
bool operator== (const UnreducedInterval &lhs, const UnreducedInterval &rhs)
llvm::raw_ostream & operator<< (llvm::raw_ostream &os, const UnreducedInterval &ui)

Detailed Description

An inclusive interval [a, b] where a and b are arbitrary integers not necessarily bound to a given field.

Definition at line 26 of file Intervals.h.

Constructor & Destructor Documentation

◆ UnreducedInterval() [1/2]

llzk::UnreducedInterval::UnreducedInterval ( const llvm::DynamicAPInt & x,
const llvm::DynamicAPInt & y )
inline

Definition at line 28 of file Intervals.h.

◆ UnreducedInterval() [2/2]

llzk::UnreducedInterval::UnreducedInterval ( int64_t x,
int64_t y )
inline

This constructor is primarily for convenience for unit tests.

Definition at line 30 of file Intervals.h.

Member Function Documentation

◆ computeGEPart()

UnreducedInterval llzk::UnreducedInterval::computeGEPart ( const UnreducedInterval & rhs) const

Return the part of the interval that is greater than or equal to the rhs's lower bound.

For example, given *this = [0, 7] and rhs = [3, 5], this function would return [3, 7], since rhs has a minimum value of 3. If this interval's upper bound is less than the rhs's lower bound, the returned interval will be "empty" (an interval where a > b). For example, if *this = [0, 6] and rhs = [7, 10], then no part of *this is greater than or equal to rhs.

Definition at line 83 of file Intervals.cpp.

◆ computeGTPart()

UnreducedInterval llzk::UnreducedInterval::computeGTPart ( const UnreducedInterval & rhs) const

Return the part of the interval that is greater than the rhs's lower bound.

For example, given *this = [0, 7] and rhs = [3, 5], this function would return [4, 7], since rhs has a minimum value of 3. If this interval's upper bound is less than or equal to the rhs's lower bound, the returned interval will be "empty" (an interval where a > b). For example, if *this = [0, 7] and rhs = [7, 10], then no part of *this is greater than rhs.

Definition at line 75 of file Intervals.cpp.

◆ computeLEPart()

UnreducedInterval llzk::UnreducedInterval::computeLEPart ( const UnreducedInterval & rhs) const

Return the part of the interval that is less than or equal to the rhs's upper bound.

For example, given *this = [0, 7] and rhs = [3, 5], this function would return [0, 5], since rhs has a max value of 5. If this interval's lower bound is greater than to the rhs's upper bound, the returned interval will be "empty" (an interval where a > b). For example, if *this = [8, 10] and rhs = [0, 7], then no part of *this is less than or equal to rhs.

Definition at line 68 of file Intervals.cpp.

◆ computeLTPart()

UnreducedInterval llzk::UnreducedInterval::computeLTPart ( const UnreducedInterval & rhs) const

Return the part of the interval that is guaranteed to be less than the rhs's max value.

For example, given *this = [0, 7] and rhs = [3, 5], this function would return [0, 4], since rhs has a max value of 5. If this interval's lower bound is greater than or equal to the rhs's upper bound, the returned interval will be "empty" (an interval where a > b). For example, if *this = [7, 10] and rhs = [0, 7], then no part of *this is less than rhs.

Definition at line 60 of file Intervals.cpp.

◆ doUnion()

UnreducedInterval llzk::UnreducedInterval::doUnion ( const UnreducedInterval & rhs) const

Compute and return the union of this interval and the given RHS.

Parameters
rhs
Returns

Definition at line 55 of file Intervals.cpp.

◆ getLHS()

llvm::DynamicAPInt llzk::UnreducedInterval::getLHS ( ) const
inline

Definition at line 106 of file Intervals.h.

◆ getRHS()

llvm::DynamicAPInt llzk::UnreducedInterval::getRHS ( ) const
inline

Definition at line 107 of file Intervals.h.

◆ intersect()

UnreducedInterval llzk::UnreducedInterval::intersect ( const UnreducedInterval & rhs) const

Compute and return the intersection of this interval and the given RHS.

Parameters
rhs
Returns

Definition at line 50 of file Intervals.cpp.

◆ isEmpty()

bool llzk::UnreducedInterval::isEmpty ( ) const
inline

Returns true iff width() is zero.

Definition at line 114 of file Intervals.h.

◆ isNotEmpty()

bool llzk::UnreducedInterval::isNotEmpty ( ) const
inline

Definition at line 116 of file Intervals.h.

◆ operator-()

UnreducedInterval llzk::UnreducedInterval::operator- ( ) const

Definition at line 90 of file Intervals.cpp.

◆ overlaps()

bool llzk::UnreducedInterval::overlaps ( const UnreducedInterval & rhs) const

Definition at line 118 of file Intervals.cpp.

◆ print()

void llzk::UnreducedInterval::print ( llvm::raw_ostream & os) const
inline

Definition at line 118 of file Intervals.h.

◆ reduce()

Interval llzk::UnreducedInterval::reduce ( const Field & field) const

Reduce the interval to an interval in the given field.

Parameters
field
Returns

Definition at line 20 of file Intervals.cpp.

◆ width()

DynamicAPInt llzk::UnreducedInterval::width ( ) const

Compute the width of this interval within a given field f.

If a > b, returns 0. Otherwise, returns b - a + 1.

Definition at line 132 of file Intervals.cpp.

◆ operator*

UnreducedInterval operator* ( const UnreducedInterval & lhs,
const UnreducedInterval & rhs )
friend

Definition at line 106 of file Intervals.cpp.

◆ operator+

UnreducedInterval operator+ ( const UnreducedInterval & lhs,
const UnreducedInterval & rhs )
friend

Definition at line 97 of file Intervals.cpp.

◆ operator-

UnreducedInterval operator- ( const UnreducedInterval & lhs,
const UnreducedInterval & rhs )
friend

Definition at line 102 of file Intervals.cpp.

◆ operator<<

llvm::raw_ostream & operator<< ( llvm::raw_ostream & os,
const UnreducedInterval & ui )
friend

Definition at line 120 of file Intervals.h.

◆ operator<=>

std::strong_ordering operator<=> ( const UnreducedInterval & lhs,
const UnreducedInterval & rhs )
friend

Definition at line 122 of file Intervals.cpp.

◆ operator==

bool operator== ( const UnreducedInterval & lhs,
const UnreducedInterval & rhs )
friend

Definition at line 101 of file Intervals.h.


The documentation for this class was generated from the following files: