|
View:
New views
12 Messages
—
Rating Filter:
Alert me
|
|
|
Undefined Procedure HelpHey,
Im trying for days to figure out why i get this error: ERROR: ask/2: Undefined procedure: known/3 Exception: (11) ask(nostrils, external_tubular) ? Unknown option (h for help) Exception: (11) ask(nostrils, external_tubular) ? creep Exception: (7) bird(_G229) ? creep Thanks for the assistance in advance. bird(whistling_swan) :- family(swan), voice(muffled_musical_whistle). bird(canada_goose):- family(goose), season(winter), country(united_states), head(black), cheek(white). bird(canada_goose):- family(goose), season(summer), country(canada),head(black), cheek(white). bird(trumpeter_swan) :- family(swan), voice(loud_trumpeting). bird(laysan_albatross):- family(albatross), color(white). bird(black_footed_albatross):- family(albatross), color(dark). order(tubenose) :- nostrils(external_tubular) ,live(at_sea), bill(hooked). order(waterfowl) :- feet(webbed), bill(flat). family(albatross) :- order(tubenose), size(large), wings(long_narrow). family(swan) :- order(waterfowl), neck(long), color(white), flight(ponderous). nostrils(X):- ask(nostrils, X). live(X):- ask(live, X). bill(X) :- ask(bill, X). wings(X):- ask(wings, X). neck(X):- ask(neck, X). size(X) :- ask(size,X). color(X):- ask(color, X). feet(X):- ask(feet, X). flight(X):- ask(flight,X). voice(X):- ask(voice,X). ask(A, V):- known(yes, A, V), !. ask(A, V):- known(_, A, V),!,fail. ask(A, V):- write(A:V), write('? : '),read(Y),asserta(known(Y, A, V)), Y == yes. |
|
|
Re: Undefined Procedure HelpOn 2009/10/19, at 00:14, Sigismo wrote: > Hey, > Im trying for days to figure out why i get this error: > > ERROR: ask/2: Undefined procedure: known/3 > Exception: (11) ask(nostrils, external_tubular) ? Unknown option > (h for > help) > Exception: (11) ask(nostrils, external_tubular) ? creep > Exception: (7) bird(_G229) ? creep > > Thanks for the assistance in advance. > > bird(whistling_swan) :- family(swan), voice(muffled_musical_whistle). > bird(canada_goose):- family(goose), season(winter), > country(united_states), > head(black), cheek(white). > bird(canada_goose):- family(goose), season(summer), > country(canada),head(black), cheek(white). > bird(trumpeter_swan) :- family(swan), voice(loud_trumpeting). > bird(laysan_albatross):- family(albatross), color(white). > bird(black_footed_albatross):- family(albatross), color(dark). > > order(tubenose) :- nostrils(external_tubular) ,live(at_sea), > bill(hooked). > order(waterfowl) :- feet(webbed), bill(flat). > > family(albatross) :- order(tubenose), size(large), wings(long_narrow). > family(swan) :- order(waterfowl), neck(long), color(white), > flight(ponderous). > > > nostrils(X):- ask(nostrils, X). > live(X):- ask(live, X). > bill(X) :- ask(bill, X). > wings(X):- ask(wings, X). > neck(X):- ask(neck, X). > size(X) :- ask(size,X). > color(X):- ask(color, X). > feet(X):- ask(feet, X). > flight(X):- ask(flight,X). > voice(X):- ask(voice,X). > > > ask(A, V):- known(yes, A, V), !. > ask(A, V):- known(_, A, V),!,fail. > ask(A, V):- write(A:V), write('? : '),read(Y),asserta(known(Y, A, > V)), Y == > yes. Add to your program the directive: :- dynamic(known/3). Cheers, Paulo ----------------------------------------------------------------- Paulo Jorge Lopes de Moura, PhD Assistant Professor Dep. of Computer Science, University of Beira Interior 6201-001 Covilhã, Portugal Office 3.18 Ext. 3276 Phone: +351 275319891 Fax: +351 275319899 Email: <mailto:pmoura@...> Home page: <http://www.di.ubi.pt/~pmoura> Research: <http://logtalk.org/> Blog: <http://blog.logtalk.org/> ----------------------------------------------------------------- _______________________________________________ SWI-Prolog mailing list SWI-Prolog@... https://mailbox.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog |
|
|
Re: Undefined Procedure HelpThanks it works but as ":-dynamic known/3". Im wondering why it would behave like that without the directive?
|
|
|
Re: Undefined Procedure HelpOn 2009/10/19, at 17:30, Sigismo wrote: > Thanks it works but as ":-dynamic known/3". It should work both ways, otherwise you would have found a bug. Some Prolog compilers, such as SWI-Prolog, declare "dynamic" as an operator but that is not required by the ISO Prolog standard. > Im wondering why it would behave > like that without the directive? You're probably calling the known/3 predicate before asserting the first clause for it. Calling an unknown predicate is usually an error (it depends on the current value of the "unknown" Prolog flag; consult the SWI-Prolog documentation). Cheers, Paulo ----------------------------------------------------------------- Paulo Jorge Lopes de Moura, PhD Assistant Professor Dep. of Computer Science, University of Beira Interior 6201-001 Covilhã, Portugal Office 3.18 Ext. 3276 Phone: +351 275319891 Fax: +351 275319899 Email: <mailto:pmoura@...> Home page: <http://www.di.ubi.pt/~pmoura> Research: <http://logtalk.org/> Blog: <http://blog.logtalk.org/> ----------------------------------------------------------------- _______________________________________________ SWI-Prolog mailing list SWI-Prolog@... https://mailbox.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog |
|
|
Re: Undefined Procedure HelpO ok, Thanks again.
|
|
|
Re: Undefined Procedure Helpok. now im lost again. I tried compiling native in the appendix.http://www.amzi.com/ExpertSystemsInProlog/xsipfrtop.htm . I inserted the dynamic directive similar to the other one right below the op directive hoping that it would fix the problem and I get the following error using the same compiler as before:
5 ?- consult('native.pl'). ERROR: c:/users/sigi/documents/prolog/native.pl:48:0: Syntax error: Operator expected Warning: c:/users/sigi/documents/prolog/native.pl:107: Singleton variables: [X] Warning: c:/users/sigi/documents/prolog/native.pl:149: Singleton variables: [N] % native.pl compiled 0.02 sec, 0 bytes true. 6 ?- main. This is the native Prolog shell. Type help. load. solve. how(Goal). whynot(Goal). or quit. at the prompt. > load. Enter file name in single quotes (ex. 'birds.nkb'.): 'birds.pl'. % birds.pl compiled 0.00 sec, 0 bytes > solve. ERROR: ask/3: Undefined procedure: known/3 Exception: (22) ask(nostrils, external_tubular, [ask(nostrils, external_tubular), nostrils(external_tubular), order(tubenose), family(albatross), bird(laysan_albatross), top_goal(laysan_albatross)]) ? ERROR: ask/3: Undefined procedure: known/3 creep Exception: (21) prov(ask(nostrils, external_tubular), [ask(nostrils, external_tubular), nostrils(external_tubular), order(tubenose), family(albatross), bird(laysan_albatross), top_goal(laysan_albatross)]) ? creep Exception: (18) prove((nostrils(external_tubular), live(at_sea), bill(hooked)), [order(tubenose), family(albatross), bird(laysan_albatross), top_goal(laysan_albatross)]) ? creep Exception: (16) prove((order(tubenose), size(large), wings(long_narrow)), [family(albatross), bird(laysan_albatross), top_goal(laysan_albatross)]) ? creep Exception: (14) prove((family(albatross), color(white)), [bird(laysan_albatross), top_goal(laysan_albatross)]) ? creep Exception: (9) solve ? creep Exception: (8) do(solve) ? creep |
|
|
|
|
|
Re: Undefined Procedure HelpHey, here are the two files. I renamed the extension just incase it gets blocked or something like what hotmail does. Thanks in advance.
sigismo birds.txt native.txt
|
|
|
Re: Undefined Procedure HelpHello,
On Tue, Oct 20, 2009 at 10:00 PM, Sigismo <ziggydotcom@...> wrote: > > http://www.nabble.com/file/p25974653/birds.txt birds.txt > http://www.nabble.com/file/p25974653/native.txt native.txt Your problem comes from your use of abolish/2 to retract all clauses for known/3. In SWI, abolish/2 is meant for static predicates. Modify your solve/1 predicate to read: > solve :- > retractall(known(_, _, _)), > prove(top_goal(X),[]), > write('The answer is '),write(X),nl. > solve :- > write('No answer found.'),nl. You should also pay attention to the errors and warnings you get. When loading this code under SWI, I get the following error: > ERROR: /home/nicolas/Desktop/native.pl:48:0: Syntax error: Operator expected The offending line is: > ask(Attribute,_,_) :- not multivalued(Attribute),known(yes,Attribute,_),!, fail. This should be written as: > ask(Attribute, _, _) :- > \+ multivalued(Attribute), > known(yes, Attribute, _), !, > fail. I also removed the warnings about singleton variables by prefixing their names with an underscore. Now, I can solve for the laysan_albatross, but I did not try any other combination. HTH, -- Nicolas _______________________________________________ SWI-Prolog mailing list SWI-Prolog@... https://mailbox.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog |
|
|
|
|
|
Re: Undefined Procedure HelpThanks for all the help. The program compiles without errors and warnings but there is another problem :(.
nostrils:external_tubular? (yes or no) > no. ERROR: Out of global stack Exception: (18) prove((nostrils(external_tubular), live(at_sea), bill(hooked)), [order(tubenose), family(albatross), bird(laysan_albatross), top_goal(laysan_albatross)]) ? creep Exception: (16) prove((order(tubenose), size(large), wings(long_narrow)), [family(albatross), bird(laysan_albatross), top_goal(laysan_albatross)]) ? creep Exception: (14) prove((family(albatross), color(white)), [bird(laysan_albatross), top_goal(laysan_albatross)]) ? creep Exception: (9) solve ? creep Exception: (8) do(solve) ? creep After i got this i did some reasearch and found out that u can use the manpce/0 predicate to adjust stack sizes. I unchecked the limit and ran manpce again it had a value of 1024mb in the text box i currently have for 4gigs or ddr2 ram. I ran it again this time it took a minute after responding negatively to the 1st question or any other question it later gave me the same error. I noticed that the process (plwin.exe) topped out about 1.5gigs of ram. I rewrote the knowlege base to support only two birds and i still recieve the global out of stack error. The updated files are here: native.pl birds.pl Any assistance will be very much appreciated. Thanks in advance Sigismo.
|
|
|
Re: Undefined Procedure HelpHello,
On Fri, Oct 23, 2009 at 13:21, Sigismo <ziggydotcom@...> wrote: > > Thanks for all the help. The program compiles without errors and warnings but > there is another problem :(. > nostrils:external_tubular? (yes or no) > no. > ERROR: Out of global stack Since your knowledge base is small, such an error should prompt you to look for an infinite loop somewhere in your code. Tracing through it will show you exactly where things get bad. In short: ?- consult('native.pl'). % native.pl compiled 0.01 sec, 19,648 bytes true. ?- consult('birds.pl'). % birds.pl compiled 0.00 sec, 24,008 bytes true. ?- trace, solve. Call: (8) solve ? creep [... skip over lines...] Exit: (22) get_user(no, [ask(nostrils, external_tubular), nostrils(external_tubular), order(tubenose), family(albatross), bird(laysan_albatross), top_goal(laysan_albatross)]) ? creep ^ Call: (22) asserta(known(no, nostrils, external_tubular)) ? creep ^ Exit: (22) asserta(known(no, nostrils, external_tubular)) ? creep Call: (22) no=yes ? creep Fail: (22) no=yes ? creep Fail: (21) ask(nostrils, external_tubular, [ask(nostrils, external_tubular), nostrils(external_tubular), order(tubenose), family(albatross), bird(laysan_albatross), top_goal(laysan_albatross)]) ? creep Redo: (20) prov(ask(nostrils, external_tubular), [ask(nostrils, external_tubular), nostrils(external_tubular), order(tubenose), family(albatross), bird(laysan_albatross), top_goal(laysan_albatross)]) ? creep ^ Call: (21) clause(ask(nostrils, external_tubular), _L396) ? creep ^ Exit: (21) clause(ask(nostrils, external_tubular), (known(yes, nostrils, external_tubular), !)) ? creep Call: (21) prove((known(yes, nostrils, external_tubular), !), [ask(nostrils, external_tubular), nostrils(external_tubular), order(tubenose), family(albatross), bird(laysan_albatross), top_goal(laysan_albatross)]) ? creep When you hit the Redo, you enter an infinite loop. When the user answers no, it does not constitute a wrong answer, but a failure to prove the current goal... So ask/2 should not fail on a 'no' (whatever the user tells is *true*, even if he/she says 'no'), and prove should not retry in this case. Hope this helps, -- Nicolas _______________________________________________ SWI-Prolog mailing list SWI-Prolog@... https://mailbox.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog |
| Free embeddable forum powered by Nabble | Forum Help |