Show HN: A simple Prolog Interpreter written in a few lines of Python 3

Show HN: A simple Prolog Interpreter written in a few lines of Python 3

In addition to the interpreter, there’s also an interface for testing the functionality which allows a user to enter Prolog rules and perform queries for the solutions:

Prolog stands for ‘Programming in Logic’. As an example, we can represent the statement ‘Something is fun if it’s a blue car or ice cream’ as follows:

As a note, we use capital letters in Prolog to denote variables, which are placeholders for terms we can use to express our rules and query our data. The example below shows how we can perform a very simple query checking if it is sunny:

Of course, Prolog assumes that anything NOT contained within its database of facts and rules is False, so if we queried for any facts that we haven’t defined, it would return ‘No.’

Source: github.com