Skip to content

Commit 30a2978

Browse files
committed
Update comment
1 parent 9b0a631 commit 30a2978

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/loader.pl

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,19 @@
4343
call(G__2, H1, H2, L0-L1),
4444
maplistdif(G__2, T1, T2, L1-LX).
4545

46-
%% arithmetic_expansion(+Type, Term, -ExpandedTerm, ?ListDifference).
46+
%% arithmetic_expansion(+Type, Term, -ExpandedTerm, -Unifier-Rest).
4747
%
48-
% Recursively traverse `Term` and assemble a list of replacements that makes
49-
% `ExpandedTerm` a valid arithmetic relation (`Type = rela`) or functional
50-
% expression (`Type = func`).
48+
% `ExpandedTerm` is the minimal generalization of `Term` which makes a valid
49+
% arithmetic relation (`Type = rela`) or functional expression (`Type = func`).
50+
% That means if all unifications from `Unifier` hold then `ExpandedTerm == Term`.
51+
% `Unifier-Rest` form together a list difference. `Term` is traversed from left
52+
% to right, depth-first. As seen in example bellow: `X` is invalid arithmetic
53+
% term, `E` is valid arithmetic term, `L` - unifier:
54+
%
55+
% ```
56+
% ?- arithmetic_expansion(rela, X is sqrt([]+Y*foo(e/2)), E, L-[]).
57+
% E = (X is sqrt(_A+Y*_B)), L = [[]=_A,foo(e/2)=_B].
58+
% ```
5159
%
5260
% NOTE: Order of clauses is important for correctness.
5361
arithmetic_expansion(func, T, T, L-L) :-

0 commit comments

Comments
 (0)