Giter VIP home page Giter VIP logo

toy-prolog-interpreter's Introduction

Toy Prolog Interpreter

This is a basic implementation of a Prolog interpreter in OCaml with REPL support. The interpreter follows standard Prolog IO syntax where clauses, facts, rules and terms have their usual definition.

Implementation

The implementation consists of a lexer lexer.mll, a parser parser.mly, an REP loop toyprolog.ml and the core unification and substitution engine tree.ml.

How To

  • The project contains a makefile that generates an executable toyprolog.
  • The executable can be run as ./toyprolog inputfile where inputfile should contain all facts and rules to be loaded before execution.
  • The project also contains a sample prolog script based on the Harry Potter universe family trees. Its called hogwarts.pl and contains lots of interesting facts and rules.
  • NOTE: For obvious reasons the resolution search for queries is depth limited to 100 post which search will terminate.

An Example

make
./toyprolog hogwarts.pl
?-brother(X,ginnyWeasley).
X = ronWeasley;
X = georgeWeasley;
X = fredWeasley;
X = percyWeasley;
X = charlieWeasley;
X = billWeasley;
false.

?-ancestor(X,harryPotter).
X = doreaBlack;
X = charlusPotter;
X = violettaBulstrode;
X = cygnusBlack;
X = ursulaFlint;
X = phineasNigellusBlack;
X = lillyPotter;
X = jamesPotter;
false.

toy-prolog-interpreter's People

Contributors

rachit95arora avatar

Watchers

James Cloos avatar

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.