Module generic

This module provides symbolic expressions evaluation. The main operation of on a symbolic expression is its reduction. The reduction is driven by the constructors of the symbolic expression itself. Polymorphic dispatch is used to delegate to the methods of the corresponding constructors depending on the class of the first argument of the constructor.

This allows for two main functionalities. If the first argument of the constructor is a constant and if the other arguments are also constants the constructor can perform partial evaluation. If the first argument of the constructor is a symbolic expressions or if some of the other arguments are symbolic expressions the constructor can perform simplification.  The predicate is/2 performs the symbolic expression reduction.

Examples:
?- X is 1/2+1/3.        % partial evaluation
X is 5/6
?- X is 2*A-A.          % simplification
X is A
Not all constructors can be reduced by the default polymorphic dispatch. Some constructors are special forms and need customized handling. For this purpose the default polymorphic dispatch has to be informed, that it doesn’t need to do some handling. This is done by adding a rule to the predicate is_abnormal/1.

The following symbolic expressions evaluation predicates are defined:

X is E:
The predicate succeeds in X in evaluating E by using polymorphism P.
is_abnormal(E):
The predicate succeeds when the expression E has a non-default handling. This predicate is multi file and can be thus extended.

Comments