Skip to content
Alexander V. Chernomyrdin aka chav1961 edited this page May 14, 2017 · 9 revisions

Funny Prolog interpreter

Funny Prolog interpreter can be used an a new scriping language inside the Java VM. It was designed especially to use with the javax.script Java package functionality. To avoid duplication of the JavaDoc, this page contains only Funny Prolog Virtual Machine (FProVM) functionality description.

Content of teh page is:

FProVM components

FProVM consists of:

String and term syntax trees

Both of the trees are based on Pure Library class chav1961.purelib.basic.AndOrTree and used to convert any string and term mnemonics to it's internal form (long ids). Using long ids instead of strings and terms is a common practice to speed up resolution performance.

Fact and rule repository

This repository is in-memory database, that can be serialized to persistent store and deserialized from it. Repository contains chains of facts and rules support usual set of operations with them (seek, prepend/append, remove)

External plugins repository

This repository support list of external plugins for interpreter. External plugin is any class implements chav1961.funnypro.core.interfaces.FProPluginList interface. All the plugins connects to FProVM by standard Java SPI protocol, file name for this protocol is META-INF/services/chav1961.funnypro.core.interfaces.FProPluginList.

Any external plugin needs support chav1961.funnypro.core.interfaces.IResolvable interface asccording to it's life cycle (see JavaDoc). FProVM correctly includes your plugin into resolution machine and allows you extend the standard Funny Prolog interpreter functionality by simple way.

Global stack

GLobal stack is a standard implementation of most of all Prolog machines. It contains a set of methods to manipulate data in it and to use this stack in the unification and backtracking processes.

Parser and Printer

A special class for quick parsing Prolog sentences to it's internal form and convert the internal form of the Prolog entites to it's mnemonic.

Standard resolution plugin

Resolution machine is aslo an external plugin. This plugin implements most of basic functionality of the resolution machine and supports a set of built-in predicates and operatiors in the Prolog database.

Built-in predicates and operators

The complete list of build-in operators at the current release:

  • :-op(1200,xfx,:-).
  • :-op(1200,fx,:-).
  • :-op(1200,fx,?-).
  • :-op(1100,xfy,;).
  • :-op(1100,xfx,|).
  • :-op(1050,xfy,->).
  • :-op(1000,xfy,,).
  • :-op(900,fy,not).
  • :-op(900,fy,+).
  • :-op(700,xfx,=).
  • :-op(700,xfx,=).
  • :-op(700,xfx,==).
  • :-op(700,xfx,==
  • :-op(700,xfx,=..).
  • :-op(700,xfx,is).
  • :-op(700,xfx,=:=).
  • :-op(700,xfx,==).
  • :-op(700,xfx,<).
  • :-op(700,xfx,=<).
  • :-op(700,xfx,>).
  • :-op(700,xfx,>=).
  • :-op(700,xfx,@<).
  • :-op(700,xfx,@<=).
  • :-op(700,xfx,@>).
  • :-op(700,xfx,@>=).
  • :-op(500,yfx,+).
  • :-op(500,yfx,-).
  • :-op(400,yfx,*).
  • :-op(400,yfx,/).
  • :-op(400,yfx,//).
  • :-op(400,yfx,mod).
  • :-op(200,xfx,**).
  • :-op(200,xfy,^).
  • :-op(200,fy,-).

The complete list of build-in predicates at the current release:

  • trace.
  • notrace.
  • spy.
  • !.
  • fail.
  • true.
  • repeat.
  • asserta(?).
  • assertz(?).
  • assert(?).
  • retract(?).
  • call(?).
  • var(?).
  • nonvar(?).
  • atom(?).
  • integer(?).
  • float(?).
  • number(?).
  • atomic(?).
  • compound(?).
  • functor(?,?,?).
  • arg(?,?,?).
  • name(?,?).
  • bagof(?,?,?).
  • setof(?,?,?).
  • findall(?,?,?).
  • memberOf(?,?).
Clone this wiki locally