lps v1.0.16
lps.js
LPS is a logic-based programming language and production system developed by Robert Kowalski and Fariba Sadri at Imperial College London. lps.js is the LPS runtime implemented in JavaScript.
Usage
As CLI tools
lps.js provides several CLI tools to run and interact with LPS programs. For instructions on installation and how to use these CLI tools, see the lps-cli repository.
As npm Library
To use lps.js as a npm library, you need to have a package.json
ready for your application (see npm documentation), then run the following command:
$ npm install --save lps
Once installed, you may access lps.js in your JS code by require()
or import
.
const LPS = require('lps');
LPS.loadFile('program.lps')
.then((engine) => {
engine.run();
});
As Library in Browser Context
If you are using Webpack for bundling your client-side application, you can use lps.js as a normal Node.js library via require()
or import
. Webpack will automatically bundle lps.js into your client-side application.
Alternatively if you are not using Webpack, you may download a pre-bundled lps.js from Releases and use a <script>
tag to include lps.js as a library in your web pages. If you wish, you may choose to create the bundled for browser lps.js yourself by following instructions below.
Once added to your web pages, the LPS
object becomes globally accessible for use.
Bundling for Browser
To bundle lps.js for the browser, you need to have npm
installed on your system, and also to install all development dependencies described in package.json
by running npm install
. Once all development dependencies are installed, you can create a bundled version of lps.js for the browser by running:
$ npm run build:browser
The output bundle JS file will then be found at dist/lps.bundle.js
.
In LPS Studio
In addition to the other methods of running LPS programs, it is possible to write visualisation for LPS programs in LPS Studio. See the other repository for more information on how to download, run and write LPS visualisation in LPS Studio.
Tests
To run all tests on lps.js, you you need to have npm
installed on your system, and also to install all development dependencies described in package.json
by running npm install
. Once all development dependencies are installed, start full tests by running:
$ npm test
To only test the source code using the unit test suite, you may use the command:
$ npm run test:source
Alternatively if you only wish to run tests on lps.js using LPS programs, you may use the command:
$ npm run test:programs
License
The lps.js implementation is open source and licensed under the BSD 3-Clause. The implementation is based on research and Prolog implementation authored by Robert Kowalski, Fariba Sadri, Miguel Calejo and Jacinto Dávila. The implementation of lps.js has also referenced David Wei's LPS implementation for his MSc Computer Science Individual Project and thesis at Imperial College London, supervised by Fariba Sadri and Krysia Broda, in 2015.
lps.js was implemented as part of Sam Yong's MSc Computer Science Individual Project and thesis at Imperial College London in 2018.
Resources
- LPS Imperial College London DoC Website
- LPS Prolog Interpreter
- Notes on how Parsers and Compilers work
- Computational Logic for Use in Teaching (CLOUT) with LPS
- Robert Kowalski and Fariba Sadri. Reactive Computing as Model Generation. New Generation Computing, 33(1):33–67, 2015 link
- Robert Kowalski and Fariba Sadri. Programming in logic without logic programming. Theory and Practice of Logic Programming, 16:269–295, 2016. link
- Robert Kowalski and Marek Sergot. A logic-based calculus of events. New Generation Computing, 4:67–94, 1986. link
- Robert Kowalski and Fariba Sadri. Towards a Logic-based Production System Language. Technical Report, Imperial College London, 2010. link
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago