Error 22 Instantiation Error Prolog
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Prolog giving instantiation error up vote 0 down vote favorite I am stuck up for a very long time with the prolog error in my homework. I try to make a addition using is/2 and it always results in: ++Error[XSB/Runtime/P]: [Instantiation] ++Error[XSB]: [Runtime/C] Uninstantiated argument of evaluable function +/2 Goal: _Var + 2, probably as 2nd arg of is/2 Any pointer will greatly help me in completing my homework. prolog share|improve this question edited Apr 9 '12 at 10:24 asked Apr 9 '12 at 2:54 stackuser 7133712 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote The problem is that when Prolog tries to calculate the value of Cost2, the value of F is still unknown and therefore an addition attempt leads to an instantiation error. You should ensure that F is a ground value when addition is reached. share|improve this answer answered Apr 9 '12 at 10:12 Alexander Serebrenik 2,9221727 But, When I try to assign F value directly to the function call instead of Cost2 is F+Cost1 , it picks up the F value correctly –stackuser Apr 9 '12 at 11:03 As I've explained if the value of F is known, the addition works fine. It reports an error only if the value of F is unknown. –Alexander Serebrenik Apr 9 '12 at 11:09 add a comment| Your Answer draft saved dr
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up prolog instantiation error with =:= operator up vote 1 down vote favorite I'm writing a http://stackoverflow.com/questions/10068412/prolog-giving-instantiation-error function called subseq which checks if one list is a subsequence of another. subseq([],[]). subseq([],[Y|Ys]). subseq([X|Xs],[Y|Ys]) :- X=:=Y, subseq(Xs,Ys). subseq([X|Xs],[Y|Ys]) :- X=\=Y, subseq([X|Xs],Ys). When I try subseq(X,[1,2]) I get: X = [] ? ; uncaught exception: error(instantiation_error,(=:=)/2) Why is this happening? My guess is that [] is being operated on by =:=, but how do I check for/prevent this error? prolog share|improve this question edited Feb 2 '14 at 23:43 false http://stackoverflow.com/questions/6194815/prolog-instantiation-error-with-operator 10k651107 asked May 31 '11 at 23:50 Michael L 83 add a comment| 1 Answer 1 active oldest votes up vote 3 down vote accepted You use =:= and =\= in the wrong context here. Those two operators should be used when you have two expressions at hand and want to evaluate and compare them. In your test, because X is not known beforehand, Prolog couldn't evaluate X and compare with Y. More information about =:= and =\= could be found here: Prolog Operator =:=. In your code you only need unification for atoms so one possible fix could be: subseq([],[]). subseq([],[_|_]). subseq([X|Xs],[Y|Ys]) :- X=Y, subseq(Xs,Ys). subseq([X|Xs],[Y|Ys]) :- X\=Y, subseq([X|Xs],Ys). share|improve this answer answered Jun 1 '11 at 0:14 pad 34.1k754116 1 Many Prolog systems provide dif/2 which you could use in place of (\=)/2. I would not call this predicate subseq/2, though. –false Jun 1 '11 at 22:48 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a guest Name Email discard By posting your answer, you agree to the privacy policy and terms of service. Not the answer y
John Gallagher (Denmark). Ulrich Geske (Germany). Neng-Fa Zhou (United States). Christoph Beierle (Germany). Dietmar Seipel (Germany). Mike Elston (New Zealand). Mats Carlson (Sweden). Feliks Kluzniak (United https://www.complang.tuwien.ac.at/ulrich/iso-prolog/error_k States). Samer Abdallah (United Kingdom). Michael Hanus (Germany). Joachim Schimpf (Australia). https://books.google.com/books?id=v6wMBwAAQBAJ&pg=PA71&lpg=PA71&dq=error+22+instantiation+error+prolog&source=bl&ots=QLFdAmBQnA&sig=VCnLqFSKWL6FRuYp4gTdThS9Hwc&hl=en&sa=X&ved=0ahUKEwiv_fCz0cTPAhVQwGMKHerdBSgQ6AEITzAH Daniel Diaz (France). Vítor Santos Costa (Portugal). Klaus Däßler (Germany). Manuel Hermenegildo (Spain). Jonathan Hodgson (United States). Katsuhiko Nakamura (Japan). Roger Scowen (United Kingdom). David S. Warren (United States). History 2008-02-24: First e-mail report to WG17. 2009-07-17: Action item in Pasadena, 2009. 2009-10-29: Delivered error 22 to WG17 as N213. 2010-07-21: Resolution in Edinburgh: uninstantiation_error. 2010-07-26: N226. 2010-12-13: Superseded by DTC2. 2012-02-14: Published within ISO/IEC 13211-1:1995/Cor.2:2012. Changes under version control. Motivation In ISO/IEC 13211-1:1995 subclause 8.11.5.3 f, a goal open(File, Mode, Stream) has the following error defined: f) Stream is not a variable— type_error(variable, Stream) The argument Stream should be unified with error 22 instantiation a stream-term (7.10.2), more specifically (7.10.2.1): A standard-conforming program shall make no assumptions about the form of the stream-term, except that: a) It is a ground term. b) It is not an atom. c) It uniquely identifies a particular stream during the time that the stream is open. It is implementation dependent whether or not the pro- cessor uses the same stream-term to represent different source/sinks at different times. It is therefore possible for a standard conforming processor to reuse stream-terms for different mutually exclusive file operations. This can be observed in many processors such as SICStus 3, SWI, YAP. YAP version Yap-6.0.0 ?- open(t, write, S), close(S), open(t, write, S). ERROR!! TYPE ERROR- open(t,write,$stream(3)): expected unbound variable, got $stream(3) ?- open(t, write, S), close(S), open(t, write, S2), S == S2. S = S2 = '$stream'(3) ? ; no Whereas the first query produces the required type_error(variable,S), the second clearly shows that success could have been possible. In all other situations, type errors mean semantically failure.
frÃ¥n GoogleLogga inDolda fältBöckerbooks.google.se - From the viewpoint of an "industrial" this book is most welcome, as one of the most significant demonstrations of the maturity of Prolog. Logic programming is a fascinating area in computer science, which held for years - and still does - the promise of freeing ourselves from programming based on the...https://books.google.se/books/about/Prolog_The_Standard.html?hl=sv&id=v6wMBwAAQBAJ&utm_source=gb-gplus-shareProlog: The StandardMitt bibliotekHjälpAvancerad boksökningKöp e-bok – 674,23 krSkaffa ett tryckt exemplar av den här bokenSpringer ShopAmazon.co.ukAdlibrisAkademibokandelnBokus.seHitta boken i ett bibliotekAlla försäljare»Prolog: The Standard: Reference ManualPierre Deransart, AbdelAli Ed-Dbali, Laurent CervoniSpringer Science & Business Media, 6 dec. 2012 - 272 sidor 0 Recensionerhttps://books.google.se/books/about/Prolog_The_Standard.html?hl=sv&id=v6wMBwAAQBAJFrom the viewpoint of an "industrial" this book is most welcome, as one of the most significant demonstrations of the maturity of Prolog. Logic programming is a fascinating area in computer science, which held for years - and still does - the promise of freeing ourselves from programming based on the "Von Neumann" machine. In addition computer programming has long been for solid theoretical foundations. While conventional engineering, dealing mainly with "analogical complexity", developed over some hundred years a complete body of mathematical tools, no such toolset was available for "digital complexity". The only mathematical discipline which deals with digital complexity is logic and Prolog is certainly the operational tool which comes closest to the logical programming ideal. So, why does Prolog, despite nearly twenty years of development, still appear to many today to be more of a research or academic tool, rather than an industrial programming language? A few reasons may explain this: First, I think Prolog suffers from having been largely assimilated into - and thus followed the fate of - Artificial Intelligence. Much hype in the late 1980 created overexpectations and failed to deliver, and the counterreaction threw both AI and Prolog into relative obscurity. In a way, maybe this is a new chance for the Prolog co