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

  • SEARCH
  • Home
  • 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 6606413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:23:35+00:00 2026-05-25T19:23:35+00:00

Peter decides what to do at weekends according to the weather predictions. This is

  • 0

Peter decides what to do at weekends according to the weather predictions.

This is the available information:
Saturday will be sunny, Sunday will be uncertain.
whenever it is sunny, Peter goes to the beach.
Whenever it’s rainy he stays at home.
When the weather is uncertain it depends on the day: Saturdays he goes to the cinema, Sundays he goes for a walk with his family.
Represent in Prolog the previous sentences.
Formulate queries which allow to answer the following questions:
What will Peter do next Saturday?
Will Peter stay at home next Sunday?
Here’s the code I’ve made and that doesn’t work:

out(saturday,suny,_). 
out(sunday,uncertain,_).

out(saturday,sunny,beach).
out(sunday, sunny, beach).
out(saturday,rainny,home).
out(sunday, rainny,home).


out(saturday,uncertain,cinema).
out(sunday,uncertain,family).

Now I don’t know what queries should I make to answer the questions…. I think I might do something like this:

:-out(saturday,_,X).

But it doesn’t work…
If anyone can help me that would be great.

  • 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-25T19:23:36+00:00Added an answer on May 25, 2026 at 7:23 pm

    The main reason it doesn’t work is that you can’t unify your facts. It’s easier to construct prolog programs if you think about them in terms of being a query rather than a program. In your code, you have out matching suny AND sunny. if you fix that spelling error, you get this:

    ?- out(saturday,_,X).
    true ;
    X = beach ;
    X = home ;
    X = cinema ;
    true.
    

    Which is still probably not what you want because it’s still matching too many things. try this instead:

    weather(saturday, sunny).
    weather(sunday, uncertain).
    
    prefers(peter, if_weather(uncertain), onday(sunday), walk_with_family).
    prefers(peter, if_weather(sunny), onday(_), go_to_beach).
    prefers(peter, if_weather(uncertain), onday(saturday), go_to_cinema).
    prefers(peter, if_weather(rainy), onday(_), stay_home).
    
    peter_will_do_next(Day,X) :- prefers(peter, if_weather(Y), onday(Day), X),    weather(Day,Y).
    peter_will_stay_home_on(Day) :- peter_will_do_next(Day,Y), Y == stay_home.
    
    ?- peter_will_do_next(saturday,What).
    What = go_to_beach .
    
    ?- peter_will_stay_home_on(sunday).
    false.
    

    In this code, we specify the facts of the weather as one procedure and the preferences of peter in anther (mostly for clarity). We can then query the facts and get a result that is (more likely) what you had in mind.

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

Sidebar

Related Questions

This is Peter Higgins's pub sub library: https://github.com/phiggins42/bloody-jquery-plugins/blob/master/pubsub.js (function (d) { var cache =
My goal is to have the url routing as following: http://www.abc.com/this-is-peter-page http://www.abc.com/this-is-john-page What is
i have a list like this [peter,1000,michell,2000,kelly,3000] and i would like to convert to
I'm about to start a new project and this time I will work with
In Peter Seibel's Practical Common Lisp , he gives this example: (do ((nums nil)
I just learned from Peter Lawreys post that this is valid expression, and evaluates
I need this Hash {peter => [apple, orange, mango], sandra => [flowers, bike]} convert
I'm using the code below and also seen in this fiddle http://jsfiddle.net/peter/Xt5qu/ to use
I've an access table like this ID | UserName | CarBrand ------------------------- 0 Peter
I saw Michael Sparks's very interesting dissection of Peter Norvig's Spell Checker at the

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.