Module simp [preloaded]

The body conversion only caters for wrapping variables into call/1. It is possible to implement further heuristics be explicitly calling expand_term/2 respectively expand_goal/2 during asserts or calls. By this module it is arranged that simplify_term/2 respectively simplify_goal/2 are called after the expansion. The predicates are customizable by the end-user via term_simplification/2 respectively goal_simplification/2.

Example:
?- [user].
goal_expansion((X is E), true) :- ground(E), X is E.
test(Y) :- X is 1+2, Y is 4*X.
^D
?- listing(test/1).
test(12).

There are situations where the compile-time heuristics have to be undone to make them trans-parent. For example when listing clauses or debugging goals. The predicates rebuild_term/2 respectively rebuild_goal/2 are responsible for undoing expansions and simplifications. The rebuilding uses the same flags as the expansion and as well customizable via term_rebuilding/2 respectively goal_rebuilding/2.

The following term simplification predicates are provided:

sys_term_simplification(C, D):
This predicate can be used to define custom term simplification rules.
sys_simplify_term(C, D):
The system predicate succeeds if the simplification of the term C unifies with D.
sys_goal_simplification(C, D):
This predicate can be used to define custom goal simplification rules.
sys_simplify_goal(C, D):
The system predicate succeeds if the simplification of the goal C unifies with D.
rest_simplification(C, D):
This predicate can be used to define custom rest simplification rules.
simplify_rest(C, D):
The system predicate succeeds if the simplification of the rest C unifies with D.
sys_term_rebuilding(C, D):
This predicate can be used to define custom term rebuilding rules.
sys_rebuild_term(C, D):
The system predicate succeeds if the rebuild of the term C unifies with D.
sys_goal_rebuilding(C, D):
This predicate can be used to define custom goal rebuilding rules.
sys_rebuild_goal(C, D):
The system predicate succeeds if the rebuild of the goal C unifies with D.
rest_rebuilding(C, D):
This predicate can be used to define custom rest rebuilding rules.
rebuild_rest(C, D):
The system predicate succeeds if the rebuild of the rest C unifies with D.

Kommentare