A Proplog Interpreter in Scala

Proplog

Proplog is a subset of Prolog.

Proplog predicates are strings representing propositions. There are no terms.

For example, here's a simple Proplog knowledge base

homerIsParentOfBart.
homerIsMale.
homerIsFatherOfBart :- homerIsParentOfBart, homerIsMale.

Demo

Here's a session with the Proplog Interpreter:

-> help
commands: quit, clear, load, show, help, or some query
-> show
done
-> load
Enter kbase name: kbase1
done
-> show
a :- c, e.
b :- c, d.
a :- b.
e.
c.
done
-> e
true
-> b
false
-> a
true
-> clear
done
-> show
done
-> quit
bye

Proplog Grammar

clause ::= proposition ~ opt(":-" ~ propositions) ~ "."
propositions ::= proposition ~ rep(","~proposition)
proposition ::= [a-zA-Z][a-zA-Z0-9]*

Proplog Design

Note that clauses can represent rules or facts.

Implementation

Complete:

Proplog Implementation