Converts Prolog algorithms to List Prolog algorithms
- Please download and install SWI-Prolog for your machine at
https://www.swi-prolog.org/build/
.
Download this repository and the List Prolog interpreter.
- Download the LPPM Repository:
mkdir GitHub
cd GitHub/
git clone https://github.com/luciangreen/List-Prolog-Package-Manager.git
cd List-Prolog-Package-Manager
swipl
['lppm'].
lppm_install("luciangreen","Prolog-to-List-Prolog").
../
halt.
- In Shell:
cd Prolog-to-List-Prolog
swipl
['p2lpconverter.pl'].
Run:
Convert Prolog code to List Prolog code by copying Prolog algorithm into test1.pl
and running: p2lpconverter(S1),pp0(S1,S2),writeln(S2).
- Run
p2lp_test(A,B)
orp2lp_test1(N,B)
where N is the test number from Prolog to List Prolog/p2lpverify.pl.
Install:
Load each file into SWI-Prolog using ['la_strings.pl'].
and ['p2slpconverter.pl'].
Run:
Convert Prolog code to List Prolog code by copying Prolog algorithm into test1.pl and running: p2slpconverter.
Input:
a.
b(C,D).
ef(G):-(h(I)->true;true),!.
Note: [a,*,*]
not a
, which is Simple List Prolog. [a,*,*]
is for inputting into CAWPS predicate dictionary.
Output:
[[[a,*,*]],[[b,*,*],[c,d]],[[ef,*,*],[g],:-,[[[[h,*,*],[i]],->,true,or,true],!]]]
Pretty-print List Prolog algorithm by typing e.g.:
pp0([[[a,*,*]],[[b,*,*],[c,d]],[[ef,*,*],[g],(:-),[[[[h,*,*],[i]],->,true,or,true],!]]]).`
Output:
[
[[a,*,*]],
[[b,*,*],[c,d]],
[[ef,*,*],[g],(:-),
[
[[[h,*,*],[i]],->,true,or,true],
!
]]
]
- See also State Machine to List Prolog, which converts from the State Machine generated within SSI (a Prolog compiler written in Prolog) to List Prolog (a version of Prolog with algorithms written as lists). The State Machine may be operated on by, for example, optimisers.