Expanding Workflows

I am adding library support for general term expansion workflows (1). I have currently defined a “predefined” workflow when the term extension set of rules (2) is checked until one of them completes successfully, and the pipeline workflow, where the extension follows from the term extension set of rules, passes the following set in the conveyor. I wonder if there are other reasonable workflows with an extension of terms that, even if they are less common, have practical application and, thus, are still worth supporting the library.

(1) For Logtalk, current versions can be found at:

https://github.com/LogtalkDotOrg/logtalk3/blob/master/library/hook_pipeline.lgt https://github.com/LogtalkDotOrg/logtalk3/blob/master/library/hook_set.lgt

(2) A set of extension rules should be understood in this context as a set of sentences for a term_expansion/2user-defined hook predicate (also possibly a custom hook predicate goal_expansion/2, although this is less likely, given the semantics of the fixed point used for the extension target) defined in the Prolog module or a Logtalk object (except for a pseudo-module / object user).

+4
source share
1 answer

- . expand_term/2 - term_expansion/2. , , - .

(==)/2, Prolog. , , term_expansions/2 . , (==)/2:

expand_term(X, Y) :- term_expansion(X, H), !, expand_term(H, Y).
expand_term(.. ..) :- /* possibly decend into meta predicate */

, , - , . , - , .

, : (nf) . , , , :

 nf(f(t_1,..,t_n)) --> f'(nf(t_1),..nf(t_n))

, f(nf(t_1), .., nf(t_n)), , expand_term, - nf(t_1).. nf(t_n) -, f(nf(t_1), .., nf(t_n)) .

f'(nf(t_1), .., nf(t_n)), , , . . Jekejeke Prolog , .

Jekejeke Prolog . , , :

/* Predefined Simplifications */
sys_goal_simplification((  (  A, B), C), J) :-
   sys_simplify_goal((  B, C), H),
   sys_simplify_goal((  A, H), J).

Example:
     (((a, b), c), d) --> (a, (b, (c, d)))

Jekejeke Prolog , , . .

- . , - .

sys_simplify_goal/2, , , (B,C) , . (B,C) sys_goal_simplification/2, .

, , . , -. .

Jekejeke Prolog . .

Bye

+2

Source: https://habr.com/ru/post/1616078/


All Articles