Problem Description Given the following prolog program, answer the following que
ID: 3821246 • Letter: P
Question
Problem Description Given the following prolog program, answer the following queries:
/* Comments in prolog + represents "not equal to" */
%single line comments
day("sunday").
day("monday").
day("tuesay").
day("wednesday").
day("thursday").
day("friday").
no_office("sunday").
no_office("saturday").
take_leave("monday").
visit_mom(X) :- no_office(X) | take_leave(X).
Interpret the queries and guess(!) the answer(s) produced by the program:
1. day("Holiday").
2. day(X).
3. visit_mom(X).
4. visit_mom(X). provided you have changed the rule with this: visit_mom(X) :- no_office(X) , take_leave(X).
5. define a new rule “working_day(X)”to detect the days that are not holidays.
6. Express the following statements in first order logic. You can define the predicates as you wish. Apply appropriate quantifiers for each expression.
a. I can visit my mom every day.
b. I can visit my mom if I have no office.
c. I take leave some day and I can visit my mom.
d. I can take leave if it is a working day.
e. What is the domain for a possible predicate “day(X)”?
Explanation / Answer
From the question :
%single line comments
day("sunday").
day("monday").
day("tuesay").
day("wednesday").
day("thursday").
day("friday").
no_office("sunday").
no_office("saturday").
take_leave("monday").
visit_mom(X) :- no_office(X) | take_leave(X).
Consider the above facts and rules the queries can be solved using the prolog program as follows.
1.
Query : day("Holiday").
Answer : No
2.
Query : day(X).
Answer : No
3.
Query : visit_mom(X).
Answer : No
Reason :
Since X is a variable.
4.
Query : visit_mom(X). provided you have changed the rule with this: visit_mom(X) :- no_office(X) , take_leave(X).
Answer :
Since X is a variable value of X is required.
5.
Query : define a new rule “working_day(X)”to detect the days that are not holidays.
Answer :
working_day(X) :- + no_office(X) | take_leave(X)
6.
Query :
Express the following statements in first order logic. You can define the predicates as you wish. Apply appropriate quantifiers for each expression.
a.
Query : I can visit my mom every day.
Answer : X visit_mom(X) :- day(X)
b.
Query :
I can visit my mom if I have no office.
Answer :
visit_mom(X) :- no_office(X) | take_leave(X)
c.
Query :
I take leave some day and I can visit my mom.
Answer :
X visit_mom(X) :- take_leave(X)
d.
Query :
I can take leave if it is a working day.
Answer :
X take_leave(X) :- + no_office(X)
e.
Query :
What is the domain for a possible predicate “day(X)”?
Answer :
Domain for a possible predicate “day(X)” refers to the possible values values of variable X.
Here ossible values values of variable X is
{"monday","tuesday","wednesday","thrusday","friday","saturday","sunday"}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.