Module integer

This module provides integer constants. The module is responsible for the reduction rules that perform partial evaluation. In case that some extra arguments is not integer or the reduction demands it, the rules delegate to the rational, polynom and fraction methods since an integer can be easily also viewed as a rational, polynom or fraction:

Examples:
?- X is 1+2.
X = 3
?- X is 1+1/2.
X is 3/2

The reduction rules are just predicates inside the integer module with a Python first argument for the method receiver. We provide reduction rules for basic arithmetic. The only special function supported so far is the sqrt/1 constructor. Other bitwise operations or special functions are currently not supported. Error handling is rudimentary.

The following integer constant predicates are defined:

-(P, Q):
The predicate succeeds in Q with the P negated.
+(P, Q, R):
The predicate succeeds in R with the sum of P and Q.
-(P, Q, R):
The predicate succeeds in R with P subtracted by Q.
*(P, Q, R):
The predicate succeeds in R with the product of P and Q.
/(P, Q, R):
The predicate succeeds in R with P divided by Q.
^(P, Q, R):
The predicate succeeds in R with P raised by Q.
sqrt(P, Q):
The predicate succeeds in Q with the square root of P.

Kommentare