Did you know ... Search Documentation:
Pack interval -- prolog/interval.pl
PublicShow source

An interval is represented as L...U, where L stands for the lower bound and U for the upper bound. If the upper bound is a negative number, it has to be written with an additional space, e.g., -3... -2, or in the infix notation, ...(-3, -2). The choice of using consult and not the module system is motivated by need for more flexibility.

 interval(+A, ?Res) is nondet
True if A evalutes to Res. Atoms, numbers, and strings are not evaluated. Supported operations:
  • Comparison: '>', '<', '>=', '=<', '=\=', '=:='
  • Basic arithemtic: addition '+', subtraction '-', division '/', multiplication '*'
  • Square root for positive interval: 'interval(sqrt(A), Res)'
  • Square root for negative or mixed interval: 'interval(sqrt1(A), Res)'
  • Power: 'interval(A^atomic(N), Res)' or 'interval(A**atomic(N), Res)' with N being a natural number
  • Exponential: 'interval(exp(A)), Res)'
  • Absolute value: 'interval(abs(A), Res)'
  • Sine: 'interval(sin(A), Res)'
  • Unary plus: 'interval(+(A), Res)'
  • Unary minus: 'interval(-(A), Res)'
  • Max: 'interval(max(A, B), Res)'
  • Min: 'interval(min(A, B), Res)'
  • Rounding: 'interval(round(1.356...1.634, atomic(2)), Res)'
Arguments:
A- is the expression to be evaluted.
Res- is the result. This should always be unbound. For checking results, use 'interval(1...2 + 1, Res), Res = 2...3' instead of 'interval(1...2 + 1, 2...3)'

Undocumented predicates

The following predicates are exported, but not or incorrectly documented.

 interval(Arg1, Arg2, Arg3)