Simple Prolog Example for Work

I am trying to run a simple gprologlauncher on my Linux machine, GNU Prolog was installed from the Ubuntu Software Center.

From GNU Prolog Intro I got the following example saved in HelloWorld.pl.

parent(hank,ben).
parent(hank,denise).
parent(irene,ben).
parent(irene,denise).
parent(alice,carl).
parent(ben,carl).
parent(denise,frank).
parent(denise,gary).
parent(earl,frank).
parent(earl,gary).
grandparent(X,Z):-parent(X,Y),parent(Y,Z).
ancestor(X,Y):-parent(X,Y).
ancestor(X,Y):-parent(Z,Y),ancestor(X,Z).

Run gprolog, enter [HelloProlog].and get the following error:

| ?- [HelloProlog].
uncaught exception: error(instantiation_error,consult/1)

Even if I don’t download the code from the file, but run it interactively, I get an error message:

uwe@z11:~/desktop$ gprolog
GNU Prolog 1.3.0
By Daniel Diaz
Copyright (C) 1999-2007 Daniel Diaz
| ?- parent(Luke,Anakin).
uncaught exception: error(existence_error(procedure,parent/2),top_level/0)
| ?- 

Is my installation working or what am I doing wrong?

+4
source share
1 answer

Prolog ( ), , [HelloProlog]. ['HelloProlog']. Prolog, , .

, , , . HelloWorld.pl.

+6

Source: https://habr.com/ru/post/1531899/


All Articles