Giter Club home page Giter Club logo

listprologinterpreter's Introduction

List Prolog Interpreter

List Prolog Interpreter (LPI) makes it easier to generate List Prolog programs. It works by interpreting different versions of Prolog that are in a list format. Using an algorithm that was written in SWI-Prolog, it easily parses and runs List Prolog code.

Getting Started

Please read the following instructions on how to install the project on your computer for writing code.

Prerequisites

  • Please download and install SWI-Prolog for your machine at https://www.swi-prolog.org/build/.

  • You may need to install gawk using Homebrew.

  • Install Translation Shell on Mac, etc. Change line in

culturaltranslationtool/ctt2.pl
trans_location("../../../gawk/trans").

to correct location of trans.

1. Install manually

Download this repository, the Languages repository (which enables List Prolog Interpreter to be run in different languages), SSI and Cultural Translation Tool.

2. Or Install from List Prolog Package Manager (LPPM)

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","listprologinterpreter").
halt

Running

  • In Shell: cd listprologinterpreter swipl ['listprolog'].

  • Running the tests To run all tests, enter: test(off,NTotal,Score).

To run a specific test: test1(off,TestNumber,Passed). where TestNumber is the test number from lpiverify4.pl.

Example of an end to end test The query test1(Debug,1,Passed). where Debug (trace)=off tests the following predicate:

test(1,[[n,function],[1,1,[v,c]]],
[
        [[n,function],[[v,a],[v,b],[v,c]],":-",
        [
                [[n,+],[[v,a],[v,b],[v,c]]]
        ]
        ]
]
,[[[[v,c], 2]]]).

This query contains the query tested, the predicate and the required result.

Also, the query test1(off,7,Passed).

test(7,[[n,reverse],[[1,2,3],[],[v,l]]],
[
        [[n,reverse],[[],[v,l],[v,l]]],
        [[n,reverse],[[v,l],[v,m],[v,n]],":-",
        [       [[n,head],[[v,l],[v,h]]],
                [[n,tail],[[v,l],[v,t]]],
                [[n,wrap],[[v,h],[v,h1]]],
                [[n,append],[[v,h1],[v,m],[v,o]]],
                [[n,reverse],[[v,t],[v,o],[v,n]]]
        ]
        ]
],[[[[v,l], [3, 2, 1]]]]).

tests the reverse predicate.

To run all tests (main, types, open and open types) in any language:

test_all00("en",off,NTotal,Score).
test_all00("en2",off,NTotal,Score).

where "en2" is an English language with e.g. "concatenate strings" instead of stringconcat ("en", or see available language codes - see the Languages repository for instructions about how to install different languages).

  • Note 1: drag and drop contents of test_open_and_types_open_data/ into an empty file in BBEdit (Mac) to copy and paste into Terminal for tests with input.

To run a test from one of main, types, open or open types, run one of:

test_all01(test,            4,"en2",off,1,Passed).
test_all01(test_types_cases,6,"en2",off,1,Passed).
test_all01(testopen_cases,  3,"en2",off,1,Passed).
test_all01(test_open_types, 5,"en2",off,1,Passed).

where 1 is replaced with the test number from

respectively.

  • Run Prolog tests:
['lpiverify_pl.pl].
test_pl1(off,A,B).
  • See note 1 above.

To run all tests (main, types, open and open types) back-translating to and from any language:

test_all_bt00("en2",off,NTotal,Score).

To run a test from one of main, types, open or open types, run one of:

test_all_bt01(test,            4,"en2",off,1,Passed).
test_all_bt01(test_types_cases,6,"en2",off,1,Passed).
test_all_bt01(testopen_cases,  3,"en2",off,1,Passed).
test_all_bt01(test_open_types, 5,"en2",off,1,Passed).

where 1 is replaced with the test number from

respectively.

  • See note 1 above.

Documentation

See List Prolog Documentation and List Prolog Caveats.

Text to Breasonings

Text to Breasonings now has its own repository.

Data to Types Documentation

See Data to Types Documentation.

LPI API

  • To run LPI on a Prolog server:
  • Move lpi-api.pl to the root (/username/ or ~ on a server) of your machine.
  • Re-enter the paths to your Prolog files in it.
  • Enter [lpi-api.pl] in SWI-Prolog and server(8000)..
  • On a local host access the algorithm at http://127.0.0.1:8000 and replace 127.0.0.1 with your server address.

Diagram of List Prolog Converters

Diagram of List Prolog Converters

* Above: Cycle of Normal Prolog e.g. a(B,C):-d(E),f. to Simple List Prolog e.g. 
[[f1, [a, b, c, d, e], (:-),
[[+, [a, b, f]],
[+, [c, f, g]],
[+, [d, g, h]],
[=, [e, h]]]]]
(Prolog-to-List-Prolog Converter), to List Prolog e.g.
[
[[n,function],[[v,a],[v,b],[v,c]],":-",
[
  [[n,+],[[v,a],[v,b],[v,c]]]
  ]
]
]
(Simple-List-Prolog-to-List-Prolog) back to Normal Prolog (List-Prolog-to-Prolog-Converter).

See Simple-List-Prolog-to-List-Prolog, Prolog-to-List-Prolog (includes Prolog to Simple List Prolog) and List-Prolog-to-Prolog-Converter.

Occurs Check

  • To return false if an equals4 variable is in terms of itself, for example:
occurs_check([v,a],[[v,a]]).
false.
  • then enter turn_occurs_check(on).. To return true. above, indicating any occurrences have been ignored, enter turn_occurs_check(off). (the default).

List Prolog Interpreter with Prolog queries

Versioning

We will use SemVer for versioning.

Authors

Lucian Green - Initial programmer - Lucian Academy

License

I licensed this project under the BSD3 License - see the LICENSE.md file for details

listprologinterpreter's People

Contributors

luciangreen avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

hardy1334

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.