Coder Social home page Coder Social logo

luciangreen / ssi Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 845 KB

A Prolog Compiler written in Prolog.

License: BSD 3-Clause "New" or "Revised" License

Prolog 99.94% Raku 0.01% C 0.06%
state saving interpreter prolog swipl recursive web apps compiler ssi

ssi's Introduction

State Saving Interpreter (SSI)

D7123F59-111C-4A88-A9BD-5006F7D36E7A

  • White hexagons on a black background.

  • With the State Saving Interpreter, users can save states of the interpreter between times and deprecate List Prolog Interpreter.

Getting Started

Please read the following instructions on installing 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, List Prolog Interpreter (LPI) and the repositories which LPI is dependent on. The Languages repository enables SSI to be run in different languages.

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

Running

  • In Shell: cd SSI swipl ['ssi'].

  • You may need to replace swipl with swipl --stack-limit=1G above to run tests 15 and 25.

Learn Prolog with SSI

You can learn List Prolog, SSI's programming language at List Prolog Documentation.

Explanation of what it does

  • State Saving Interpreter (SSI), like List Prolog Interpreter, runs algorithms in the List Prolog language. List Prolog algorithms are lists, which can be more easily generated and analysed. SSI is different because it manually creates and follows choice points (allowing multiple possible solutions like Prolog) unlike List Prolog Interpreter, which relies on Prolog to manage choice points.
  • SSI was written to save the states of the Prolog interpreter.
  • It solves the problem of backtracking by saving states.
  • It works by manually storing and referring to choice points, records of the variable binding table and recursive states. These include "virtual" commands (commands such as member2 which compute all results when they are first run). The interpreter loads these choice points as the algorithm encounters flow through predicates, commands and recursion.
  • It supports the Higher-Order call Command.
  • SSI supports member2, stringconcat, nested findall, cut and the commands of List Prolog Interpreter.
  • SSI will enable running segments of a complex algorithm on a supercomputer and prevent data loss in low-power areas.

Tests

To run SSI-specific tests, run: only_ssi_test(off,NTotal,Score).

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

ssi_test_all00("en",off,NTotal,Score).
ssi_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).

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

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

where the user should replace 1 with the test number from

respectively.

  • 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 all tests (main, types, open and open types) back-translating to and from any language:

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

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

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

where the user replaces 1 with the test number from

respectively.

  • See note 1 above.

SSI Web Service

  • A low-code backend web Prolog service.

  • After loading swipl and [ssi]., load State Saving Interpreter to run web apps with ssi_server(8000). and go to http://127.0.0.1:8000 in your browser.

  • Modify the application to run, the window's title and background colour in ssi-api.pl.

  • Before running on your server, change the API key in api-key(1234567890). in ssi-api-key.pl to a different API key.

  • To delete old session files every month, run swipl ssi-ws.pl using a scheduler in Linux, i.e. crontab -e.

  • Setting_up_a_VPS_with_TextToBr describes how to set up a Virtual Private Server, which can run Prolog over the web.

  • SSI Web Service contains few, but central commands for mainly AI-purposes in Prolog. For more tutorials, see my Lucian Academy YouTube Channel.

  • To comply with browsers' security requirements, only run SSIWS apps with a password screen, as follows:

read_password("password")

Documentation

See List Prolog Documentation.

SSI with Prolog queries

Authors

Lucian Green - Initial programmer - Lucian Academy

License

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

ssi's People

Contributors

luciangreen avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

ssi's Issues

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.