Question
by using prolog program : - Below is a list of the most recent American presidents: Donald Trump 2017- Barack Obama 2009-2017 George W.Bush 2001-2009
by using prolog program :
- Below is a list of the most recent American presidents:
Donald Trump 2017-
Barack Obama 2009-2017
George W.Bush 2001-2009
Bill Clinton 1993-2001
George H.W.Bush 1989-1993
Ronald Reagan 1981-1989
Jimmy Carter 1977-1981
Gerald Ford 1974-1977
Richard Nixon 1969-1974
Lyndon B.Johnson 1963-1969
John F. Kennedy 1961-1963
a) Build a knowledge base using the predicate directlyAfter/2 which encodes one president is directly after another president.
b) Formulate and add a RULE called directlyBefore/2 tells which president is directly before which other president.
c) Define another rule called after/2 that tells us which president is (directly or indirectly) after which other president. For example, the query after(Barak Obama, John F. Kennedy). should evaluate to be true, while after(George H. Bush,Barak Obama). should fail.
d) Test your implementation by asking queries. Write down your query and also the result.
Is Obama directly before Trump?
Is Carter after Johnson?
Who are after Ford?
Who are the presidents in the knowledge base?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started