Custom data structure syntax in Prolog -


in prolog, [h|t] list begins h , remaining elements in list t (internally represented '.'(h, '.'(…))).

is possible define new syntax in similar fashion? example, possible define [t~h] list ends h , remaining elements in list t, , use freely [h|t] in heads , bodies of predicates? possible define e.g. <h|t> different structure lists?

one can interpret question literally. list-like data structure, accessing tail can expressed without auxiliary predicate. well, these minus-lists used in first prolog system — 1 called prolog 0 , written in algol-w. example the original report, p.32 transliterated iso prolog:

t(x-a-l, x-a-u-x).   ?- t(nil-m-e-t-a-l, pluriel). pluriel = nil-m-e-t-a-u-x. 

so take left-associative operator.

but, suspect, that's not wanted. want extension lists.

there have been several attempts this, 1 more recent prolog iii/prolog iv. however, quite similar constraints, have face how define equality on these operators. in other words, need go beyond syntactic unification e-unification. problem sounds easy in beginning frightening complex. simple example in prolog iv:

>> l = [a] o m, l = m o [z]. m ~ list, l ~ list. 

clearly inconsistency. is, system should respond false. there no such m, prolog iv not able deduce this. have solve @ least such problems or along them somehow.

in case want dig this, consider research started j. makanin's pioneering work:

problem of solvability of equations in free semi-group, akad. nauk sssr, vol.233, no.2, 1977.

that said, might case there simpler way want. maybe associative list operator not needed.

nevertheless, not expect expressiveness such extension compared have in prolog, dcgs. in particular, general left-recursion still problem termination in grammars.


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -