Lucianpedia Wiki


List Prolog Interpreter (LPI) is a version of Prolog that can be used to write algorithms with CAWMP  because the List Prolog algorithms are in list format. See all examples.

For example:

        [       [[n,head],[[v,l],[v,h]]],
],[[[v,l], [3, 2, 1]]]).


Definite Clause Grammars in List Prolog are like base cases, e.g. test 15:


and a "bottom case" in case it is not at the end of the string, e.g.:


given the clause:


Functional List Prolog (FLP)[]

Predicate names and variables may be substituted for variable names, e.g. in [[n,function],[[[n,function2],[2]],1,1,[v,c]]] function2 is passed as a variable.

Strong Type Statements[]

FLP may optionally use strong type statements, e.g.

,[[[[v,a], 1],[[v,b], "a"],[[v,c], [n,a]]]]).


LPI includes a system command call equals4, which pattern matches lists and lists of lists, etc. to other lists, e.g.


        [       [[n,equals4],[[v,a],[[v,b],"|",[v,c]]]]

LPI can enter an equals4 mode, in which arguments may be processed as lists (including atoms and predicate names), and may enter a non-equals4 mode, which doesn't replace all variable names, only [a,b] not [[c,d],[e,f]].


LPI's findall command finds non-deterministic results of its body and returns them in a list, e.g.


        [       [[n,findall],[[v,a1],[[n,member2],[[v,a],[v,a1]]],


LPI's maplist command recursively runs a command on the given input, e.g.


        [       [[n,maplist],[[n,+],[v,a],0,[v,b]]]


International LPI API Integration[]

List Prolog Interpreter may run algorithms in languages other than English, through integration with a dictionary generator for other languages, documentation generator and algorithm translator.

Notable Verification Tests[]

  • Test 15 - String (like atom) to list (like term) grammar interpreter
  • Test 17 - Split strings after ".", "!" and "?" + space, with a grammar interpreter.
  • Test 116 - Split after given characters, producing "" if one of these characters is at the start, e.g. ".aaa.bbb.", [".", "?"] produces ["", "aaa", "bbb"]
  • Test 117 - Split on given characters, returning them as well, e.g. "a   a. a ", [" ", "."] produces ["a", " ", " ", " ", "a", ".", " ", "a", " "]

Planned Features[]

SSI (State Saving Interpreter) with the redo feature in trace.

Further Reading[]

See also Text to Breasoning (formerly part of the List Prolog Interpreter Repository).