Prolog Tutorial

Module scientists

:- use_module(library(scientists)).

Knowledge base with very simple facts.

This might be an example suitable for first steps of learning prolog…

Boolean operators

AND (conjunction)

query for computer_pioneers who also are logicians


?-
computer_pioneer(Who), logician(Who).

OR (disjunction)

query for computer_pioneers or logicians


?-
computer_pioneer(Who); logician(Who).

NOT (negation)

query for logicians, who are not (primarily) known as computer_pioneer


?-
logician(Who), \+ computer_pioneer(Who).

Predicate --> RelationSet

Translate the Predicate logician/1 into a Relation represented by a set.


?-
findall(X, logician(X), RelationSet).
//->  X = A, RelationSet = ["Aristoteles","Charles Babbage","Kurt Gödel","David Hilbert","Gottlob Frege","Gottfried Wilhelm Leibniz","Blaise Pascal","Amir Pnueli","Emil Leon Post","Michael Oser Rabin","Bertrand Russell","Alfred Tarski","Alan Turing","Ludwig Wittgenstein"].

logician(Name)

A set of logicians

computer_pioneer(Name)

A set of computer pioneers