This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Styla: a lightweight open source Prolog-in-Scala

2 replies
tarau
Joined: 2012-02-02,
User offline. Last seen 9 weeks 3 days ago.

Styla is a fairly complete Prolog interpreter written in Scala,
derived from Kernel Prolog (see Fluents: A Refactoring of Prolog for
Uniform Reflection and Interoperation with External Objects in
CL'2000).

The open sourced (Apache license) code is hosted at:

http://code.google.com/p/styla/

and it is designed with simplicity and extensibility in mind - hoping
it would be useful to people experimenting with new Prolog extensions
or use it as logic programming component is Scala applications.

Among the features not found in most Prologs, first class Logic
Engines - and a generic view of everything as Fluents (TermSinks and
TermSources) that abstract away iteration over various data types
and computations, including answers produced by Logic Engines.

Styla is not a DSL - it uses a compact combinator parser to cover
a fairly extensive subset of Prolog's original syntax.

Here are some limitations, most things not on this list and expected
from a Prolog system should work.

- toplevel goals that a not conjunctions should be parenthesized
- operators are all fixed and xfx, but they match the default
priorities of
most Prologs' operators - see examples in progs/
- no gui or networking - Scala can do all that better

Take a look at prolog.Main for the start-up sequence - that gives a
glimpse of how to embed it into a Scala or Java program.

To add a new built-in, just clone the closest match in
prolog.builtins
and drop it in the same directory - the runtime system will instantly
recognize it.

Use the script "compile" to recompile the system with scalac "run" to
run it with scala and jrun to run it with java (possibly edit for path
info in this case).

The file prolog/fluents/Lib.scala embeds Prolog code that is present
at start-up. New Prolog code that you want part of the default
libraries can be added there.

Enjoy,

Paul Tarau

Meredith Gregory
Joined: 2008-12-17,
User offline. Last seen 42 years 45 weeks ago.
Re: Styla: a lightweight open source Prolog-in-Scala
Dear Paul,
Sweet! i look forward to trying it out.
Best wishes,
--greg

On Thu, Feb 2, 2012 at 9:56 AM, Paul Tarau <ptarau@gmail.com> wrote:
Styla is a fairly complete Prolog interpreter written in Scala,
derived from Kernel Prolog  (see Fluents: A Refactoring of Prolog for
Uniform Reflection and Interoperation with External Objects in
CL'2000).

The  open sourced (Apache license) code is hosted at:

http://code.google.com/p/styla/

and it is designed with simplicity and extensibility in mind - hoping
it would be useful to people experimenting with new Prolog extensions
or use it as logic programming component is Scala applications.

Among the features not found in most Prologs, first class Logic
Engines -  and a generic view of everything as Fluents (TermSinks and
TermSources) that abstract away iteration over various data types
and computations, including answers produced by Logic Engines.

Styla is not a DSL - it uses a compact combinator parser to cover
a fairly extensive subset of Prolog's original syntax.

Here are some limitations, most things not on this list and expected
from a Prolog system should work.

- toplevel goals that a not conjunctions should be parenthesized
- operators are all fixed and xfx, but they match the default
priorities of
 most Prologs' operators - see examples in progs/
- no gui or networking - Scala can do all that better

Take a look at prolog.Main for the start-up sequence - that gives a
glimpse of how to embed it into a Scala or Java program.

To add a new built-in, just clone the closest match  in
prolog.builtins
and drop it in the same directory - the runtime system will instantly
recognize it.

Use the script "compile" to recompile the system with scalac "run" to
run it with scala and jrun to run it with java (possibly edit for path
info in this case).

The file prolog/fluents/Lib.scala embeds Prolog code that is present
at start-up. New Prolog code that you want part of the default
libraries can be added there.

Enjoy,

Paul Tarau



--
L.G. Meredith
Managing Partner
Biosimilarity LLC
7329 39th Ave SWSeattle, WA 98136

+1 206.650.3740

http://biosimilarity.blogspot.com
Ken McDonald
Joined: 2011-02-13,
User offline. Last seen 42 years 45 weeks ago.
Re: Styla: a lightweight open source Prolog-in-Scala
Very cool...it makes me wish I had a use for Prolog right now.
Ken

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland