Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6743405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:57:25+00:00 2026-05-26T11:57:25+00:00

swi-prolog 5.10.2 I have typed this prolog program in. However, when I run option

  • 0

swi-prolog 5.10.2

I have typed this prolog program in. However, when I run option a I get the following error.

go/0 Undefined Procedure save/1

I am sure that save is a proper keyword predicate, and the path to the file does exist as well. Not sure where I am going wrong here.

What does the /0 /1 mean in go and save?

Source code

/* Shopping list */

go:-reconsult('~/projects/prolog/chap7/shopping.pl'),
    write('a: See list'), nl,
    write('b: Add to list'), nl,
    write('c: Delete from list'), nl,
    read(Choice),
    choice(Choice),
    save('~/projects/prolog/chap7/shopping.pl').

/*
  facts for shopping
*/
item(potatoes).
item(bread).
item(coffee).

/*
  Rules for shopping list
*/
choice(a):-listing(item), nl.
choice(b):-write('Enter an item: '),
        read(Item),
        assert(item(Item)).
choice(c):-write('Item to delete: '),
        read(Item),
        retract(item(Item)).
choice(_):-write('Incorrect entry.'), nl.

Many thanks in advance,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:57:26+00:00Added an answer on May 26, 2026 at 11:57 am

    The error message states that the predicate go/0 you defined makes use of a predicate save/1 that the system does not recognize and label as an undefined procedure. Predicates are usually identified by a predicate indicator in the form name/arity, where name is the name of the predicate, represented as an atom, and arity is a number representing how many parameters the predicate has been defined accepting: so, for example, go/0 is the identifier for the predicate go, with no parameters, defined in your program; and save/1 is the identifier for the predicate save, with one parameter, that you are trying to invoke but the system is unable to find. When a predicate has been defined through two or more overloaded versions, e.g. with a different arity for each definition, it may be referred by enclosing each arity between brackets, separated with a comma, e.g. p/[1,2]. Predicates are sometimes called procedures, the two terms being roughly equivalent.

    As it’s possible to see in older SWI-Prolog manuals (the link refers to version 2.9) save/1 indeed used to be defined in the standard library and generally available on those systems. Even in those old systems, it was suggested to use save_program/[1,2] to create a new program instead of save/1, which was said to be exploited for debug purposes only. However, in modern SWI-Prolog systems, nor save/1 neither save_program/[1,2] are available. While it seems that there is no equivalent predicate for save/1, the role of save_program/[1,2] has been taken by qsave_program/[1,2], which you can read about in the latest version of the manual. Be sure to read also about its limitations, just in case you’d want to expand your program way beyond the simple snippet you posted here.

    Having never used that kind of procedures, I must assume you know what you are doing. However, noticing the reconsult/1 call at the beginning of your program that uses the same file saved by save/1 later, I beg you to become aware that there’s a difference between a bunch of Prolog predicates in a text file, i.e. the format that reconsult/1 can read and understand, and the half-text half-binary format that at least qsave_program (but I maintain save and save_program too) uses to write the program on disk. Since, by reading your code, it seems you may be interested in storing the shopping list’s items, as an aside note I would like to add that you may save predicates of interest in a plain text file by using a combination of listing/1 with I/O procedures such as open/3, set_output/1, current_output/1, and the like.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this program in Prolog, it removes elements at each nth element from
I need to do this homework assignment using prolog (SWI-flavor) and cant get my
I have written the following code in SWI-Prolog: :- dynamic state_a/1 . :- dynamic
Assume I have the following rules: unify('test', 'this is a test'). run :- write('Enter
I have set up and installed both interprolog and swi prolog on my linux
I am trying to get my feet wet with some Prolog, as I have
Using SWI-Prolog's listing predicate (or SICStus' predicate in its list library), we have: lists:subtract([],
Why is it that the following code: class swi { public static void main(String[]
sometimes when I run my program it works properly and sometimes when I try
I've thrown a glance at Prolog, and this is my first little try at

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.