|
43 | 43 | call(G__2, H1, H2, L0-L1),
|
44 | 44 | maplistdif(G__2, T1, T2, L1-LX).
|
45 | 45 |
|
46 |
| -%% arithmetic_expansion(+Type, Term, -ExpandedTerm, ?ListDifference). |
| 46 | +%% arithmetic_expansion(+Type, Term, -ExpandedTerm, -Unifier-Rest). |
47 | 47 | %
|
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 | +% ``` |
51 | 59 | %
|
52 | 60 | % NOTE: Order of clauses is important for correctness.
|
53 | 61 | arithmetic_expansion(func, T, T, L-L) :-
|
|
0 commit comments