customer(chuchi, goyal, 800.00).
customer(rishu, jain, 900.00).
get_cust_bal(X, Y, Z):-
customer(chuchi, Y, 800.00),
customer(X, Y, Z),
format('owes me Bal ~w', [X, Y, Z]).
the error is
Format error: too many arguments
ERROR: In:
ERROR: [11] format('owes me Bal ~w',[_4304,goyal|...])
ERROR: [9] toplevel_call(user:user: ...) at c:/program files/swipl/boot/toplevel.pl:1162
ERROR:
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.
Related
I’m trying to import Aleph with SWI-Prolog. When I run my program I get the error below. What do I have to do to import library(aleph)? By the way, I have already downloaded aleph.pl for my program.
Here is my test program, I know there must be something wrong with the library aleph.
:- use_module(library(aleph)).
:- aleph.
I got the error:
ERROR: c:/users/mac/desktop/swi-prolog/aleph draft/1.pl:1:
source_sink `library(aleph)' does not exist
Warning: c:/users/mac/desktop/swi-prolog/aleph draft/1.pl:1:
Goal (directive) failed: user:use_module(library(aleph))
ERROR: c:/users/mac/desktop/swi-prolog/aleph draft/1.pl:2:
catch/3: Undefined procedure: aleph/0
Warning: c:/users/mac/desktop/swi-prolog/aleph draft/1.pl:2:
Goal (directive) failed: user:aleph
Welcome to SWI-Prolog (threaded, 32 bits, version 7.6.4)
You should use the installer:
?- pack_install(aleph).
% Contacting server at http://www.swi-prolog.org/pack/query ... ok
Install aleph#5 from GIT at https://github.com/friguzzi/aleph.git Y/n?
% Cloning into '/home/carlo/lib/swipl/pack/aleph'...
% Contacting server at http://www.swi-prolog.org/pack/query ... ok
% "aleph.git" was downloaded 6 times
Package: aleph
Title: Aleph Inductive Logic Prorgramming system
Installed version: 5
Author: Fabrizio Riguzzi <fabrizio.riguzzi#unife.it>
Activate pack "aleph" Y/n?
true.
?- use_module(library(aleph)).
true.
Here is the example I tried, and I didn't get the inductive theory.
% Aleph initialization
:- aleph.
% Mode declarations
% mode(RecallNumber,PredicateMode).
% - output
:- modeh(*,grandparent(+person,+person)).
:- modeb(*,father(-person,-person)).
:-begin_bg.
person(john).
person(johnJunior).
person(johnJuniorJunior).
person(jack).
person(jackJunior).
person(jackJuniorJunior).
father(johnJunior, john).
father(johnJuniorJunior, johnJunior).
father(jackJunior, jack).
father(jackJuniorJunior, jackJunior).
:-determination(grandparent/2,father/2).
:-end_bg.
:-begin_in_pos.
grandparent(john, johnJuniorJunior).
grandparent(jack, jackJuniorJunior).
:-end_in_pos.
:-begin_in_neg.
grandparent(jack, john).
:-end_in_neg.
:-aleph_read_all.
Here is my output:
[theory]
[Rule 1] [Pos cover = 1 Neg cover = 0]
grandparent(john,johnJuniorJunior).
[Rule 2] [Pos cover = 1 Neg cover = 0]
grandparent(jack,jackJuniorJunior).
[time taken] [0.015625]
[total clauses constructed] [2]
true.
I guess aleph systeme didn't work.
I’m trying to import Aleph with SWI-Prolog. When I run my program I get the error below. What do I have to do to import library(aleph)? By the way, I have already downloaded aleph.pl for my program.
Here is my test program, I know there must be something wrong with the library aleph.
:- use_module(library(aleph)).
:- aleph.
I got the error:
ERROR: c:/users/mac/desktop/swi-prolog/aleph draft/1.pl:1:
source_sink `library(aleph)' does not exist
Warning: c:/users/mac/desktop/swi-prolog/aleph draft/1.pl:1:
Goal (directive) failed: user:use_module(library(aleph))
ERROR: c:/users/mac/desktop/swi-prolog/aleph draft/1.pl:2:
catch/3: Undefined procedure: aleph/0
Warning: c:/users/mac/desktop/swi-prolog/aleph draft/1.pl:2:
Goal (directive) failed: user:aleph
Welcome to SWI-Prolog (threaded, 32 bits, version 7.6.4)
You should use the installer:
?- pack_install(aleph).
% Contacting server at http://www.swi-prolog.org/pack/query ... ok
Install aleph#5 from GIT at https://github.com/friguzzi/aleph.git Y/n?
% Cloning into '/home/carlo/lib/swipl/pack/aleph'...
% Contacting server at http://www.swi-prolog.org/pack/query ... ok
% "aleph.git" was downloaded 6 times
Package: aleph
Title: Aleph Inductive Logic Prorgramming system
Installed version: 5
Author: Fabrizio Riguzzi <fabrizio.riguzzi#unife.it>
Activate pack "aleph" Y/n?
true.
?- use_module(library(aleph)).
true.
Here is the example I tried, and I didn't get the inductive theory.
% Aleph initialization
:- aleph.
% Mode declarations
% mode(RecallNumber,PredicateMode).
% - output
:- modeh(*,grandparent(+person,+person)).
:- modeb(*,father(-person,-person)).
:-begin_bg.
person(john).
person(johnJunior).
person(johnJuniorJunior).
person(jack).
person(jackJunior).
person(jackJuniorJunior).
father(johnJunior, john).
father(johnJuniorJunior, johnJunior).
father(jackJunior, jack).
father(jackJuniorJunior, jackJunior).
:-determination(grandparent/2,father/2).
:-end_bg.
:-begin_in_pos.
grandparent(john, johnJuniorJunior).
grandparent(jack, jackJuniorJunior).
:-end_in_pos.
:-begin_in_neg.
grandparent(jack, john).
:-end_in_neg.
:-aleph_read_all.
Here is my output:
[theory]
[Rule 1] [Pos cover = 1 Neg cover = 0]
grandparent(john,johnJuniorJunior).
[Rule 2] [Pos cover = 1 Neg cover = 0]
grandparent(jack,jackJuniorJunior).
[time taken] [0.015625]
[total clauses constructed] [2]
true.
I guess aleph systeme didn't work.
I wanted to create a "function" that "returns" the even elements of a list :
elements_pairs([], []).
elements_pairs([H|T], R) :- H mod 2 =:= 0, elements_pairs(T,Rn), R is [H|Rn].
elements_pairs([H|T], R) :- not(H mod 2 =:= 0), elements_pairs(T,Rn), R is Rn.
This elements_pairs([1,3,4,6], R) produces this error:
ERROR: Type error: [] expected, found [4|6] (a compound) ("x" must hold one character)
ERROR: In: ERROR: [11] _3884 is [4|6] ERROR: [10]
elements_pairs([4,6],_3918) at path/tp.pl:21 ERROR: [9]
elements_pairs([3,4|...],_3956) at path/tp.pl:21 ERROR: [8]
elements_pairs([1,3|...],_3994) at path/tp.pl:21 ERROR: [7]
What's wrong ?
Thank you
I am very new to Prolog. I need to find all the paths from Source to Destination in a maze.
I wrote the following clause so that I do not have to write all the edge relations explicitly:
neighbour(X,Y) :-
( X =:= Y+1
; Y =:= X+1
; X =:= Y+6
; Y =:= X+6
).
Next, for finding path I do the following:
path(Source,Source,_).
path(Source,Destination,PathList) :-
neighbour(Source,Z), % find a neighbour of Source
not(member(Z,PathList)), % that is not already in the list
% and see if there is a path from Z to Destination
path(Z,Destination,[Source|PathList]).
While running it I queried the following:
?- path(1,2,[]). % "Is there a path from 1 to 2?"
This gives me the following error:
ERROR: Arguments are not sufficiently instantiated
ERROR: In:
ERROR: [10] 1=:=_26424+1
ERROR: [9] neighbour(1,_26452) at /Users/sujitkumar/Desktop/this sem/PL/2.pl:3
ERROR: [8] path(1,2,[]) at /Users/sujitkumar/Desktop/this sem/PL/2.pl:30
ERROR: [7] <user>
I do not understand why the expression is not getting evaluated.
I am trying to write the following formula into swi prolog but get an error,
Here is the code/query I am typing
[X, Y, Z] ins 0 .. 4, X #= Y + 1.
and here is the error I am getting
ERROR: Syntax error: Operator expected
ERROR: [X, Y, Z]
ERROR: ** here **
ERROR: ins 0..4, X #= Y + 1 .
Could someone let me know what I did wrong.
The problem was that I forgot to import the library [library(clpfd)] so basically had to use the following statement use_module(library(clpfd)). This was spotted by #CapelliC