Question

In: Computer Science

2. Given the following sentences: 1. Jack owns Fiat 2. John owns Opel. 3. Fiat is...

2. Given the following sentences:

1. Jack owns Fiat

2. John owns Opel.

3. Fiat is a car and Opel is a car too.

4. Every car owner can drive

5. Jack exceeds the speed limit

6. John fasten seat belt.

7. Every driver who exceeds the speed limit or does not fasten seat belt breaks traffic rules.

8. Every one who can drive is a driver

9. Everyone who breaks any traffic rules will get a fine

10. Bad drivers get fines.

11. Good drivers do not get fines.

a. Translate these sentences into predicate logic

b. Convert the above sentence represented in predicate logic into Horn Clauses

c. Write the horn clauses into Prolog syntax on any Prolog system available online like SWI Prolog.

d. Prove that Jack is a bad driver and John is a good driver by submitting each of the two previous predicate as goals to your knowledgebase. If the KB failed to infer any of these goals, explain why it failed and what predicate should be there to prove your goals.

Solutions

Expert Solution

a) & b)

predicates:

owns(x, y) => x owns y

car(x) => x is a car

canDrive(x) => x can drive

A(x) => x exceeds the speed limit

B(x) => x fastens seat belt

C(x) => x breaks traffic rules

isDriver(x) => x is a driver

F(x) => x gets fine

bad(x) => x is a bad driver

good(x) => x is a good driver

1.

owns(Jack, Fiat)

2.

owns(John, Opel)

3.

car(Fiat)

car(Opel)

4.

can drive => For all car owners, there exists a car.

canDrive(x) =

5.

A(Jack)

6.

B(John)

7.

8.

9.

10.

11.

c)

% Jack owns Fiat
owns('Jack', 'Fiat').
% John owns Opel.
owns('John', 'Opel').

% Fiat is a car and Opel is a car too
car('Fiat').
car('Opel').

% Every car owner can drive
canDrive(X):-
owns(X, Y), car(Y).

% Jack exceeds the speed limit
exceedsSpeedLimit('Jack').

% John fasten seat belt
fastenSeatBelt('John').

% Every driver who exceeds the speed limit
% or does not fasten seat belt breaks traffic rules
breaksTraffic(X):-
isDriver(X), exceedsSpeedLimit(X), not(fastenSeatBelt(X)).

% Every one who can drive is a driver
isDriver(X):-
canDrive(X).

% Everyone who breaks any traffic rules will get a fine
getFine(X):-
breaksTraffic(X).

% Bad drivers get fines
badDriver(X):-
getFine(X).

% Good drivers do not get fines
goodDriver(X):-
not(getFine(X)).

Code Screenshots:

d)

Outputs:


Related Solutions

What is the output of the following statements? a. cout << ("Jack" <= "John" && "Business"...
What is the output of the following statements? a. cout << ("Jack" <= "John" && "Business" >= "Accounting") << endl; b.cout << boolalpha << ((10 <= 15 - 2) && (15 >= 20) || (15 - 2 != 20)) << endl; c.cout << !(30 > 10) << endl; d.cout << showpos << (6 <= 5 || 3 < 15) << endl; e.cout << boolalpha << ("bill" > "billy") << endl;
Given the names of employees in an office: employees = ["Jack", "Michael", "Tally", "John", "Jane", "Bill"]...
Given the names of employees in an office: employees = ["Jack", "Michael", "Tally", "John", "Jane", "Bill"] 1. Using the Random library in Python, create a codes that: Draws a random sample (with replacement) of 4 employees. Save and Displays the sample. 2. Explain what the difference is between a sample with replacement vs without replacement
Given the following frequency distribution, the distribution is: Value Frequency 1 1 2 2 3 3...
Given the following frequency distribution, the distribution is: Value Frequency 1 1 2 2 3 3 15 10 16 15 17 20 18 40 19 20 20 10 Answer: Which one it is? Normal. Positively skewed. Negatively skewed. Bimodal
Jack owns 1,000 shares of ABC company stock. He expects to receive a total of $3...
Jack owns 1,000 shares of ABC company stock. He expects to receive a total of $3 in dividend/share next year (D1) with a growth rate of 4% a year in dividend. The market discount rate (r) is 10%. (Note: Round up answers in 2 decimal points) (a) If Jack wants to sell the stock at the end of year 5, what is the price he can sell (P5)? (b) What is the intrinsic value of the stock [E(P0)] if Jack...
1. What is the outcome of this case? (Guilty, not guilty, acquitted, etc.) (2-3 sentences) 2....
1. What is the outcome of this case? (Guilty, not guilty, acquitted, etc.) (2-3 sentences) 2. What is the author's basis of dissent OR basis or support for upholding the opinion of the court? (1 full paragraph) 3. How does this judicial opinion (and general case) increase your understanding of what has been learned/discussed during this time period of the class and the events within it? Explain how this case is historically significant to what we have learned. (I full...
John owns a convenience shop called City Conv. The following events occurred for John during 2019-...
John owns a convenience shop called City Conv. The following events occurred for John during 2019- 2020 financial year. (i) John incurred legal expenses as he was sued for false advertising. (ii) John purchased new fridge to the shop - $800. In addition, his builder added more space to the shop front. This cost him $22,000. (iii) John ordered 1000 new T-shirts with printed City Conv’s logos for marketing purposes. These costs him $1,500. (iv) John received a City of...
John owns a convenience shop called City Conv. The following events occurred for John during 2019-...
John owns a convenience shop called City Conv. The following events occurred for John during 2019- 2020 financial year. 1. (i) John incurred legal expenses as he was sued for false advertising. 2. (ii) John purchased new fridge to the shop - $800. In addition, his builder added more space to the shop front. This cost him $22,000. 3. (iii) John ordered 1000 new T-shirts with printed City Conv’s logos for marketing purposes. These costs him $1,500. 4. (iv) John...
(Questions 1–2 are related.) Assume John Marshall owns a $170,000 home, which covers the replacement cost...
(Questions 1–2 are related.) Assume John Marshall owns a $170,000 home, which covers the replacement cost of the structure. (Ignore the deductible clause and consider just the coinsurance requirement.) If John purchased $138,000 of insurance, how much would he collect for a partial loss of $50,000? For a total loss of $170,000? If John purchased $100,000 of insurance, how much would he collect for a $40,000 loss? How much would he collect for a total loss? (Again, ignore the deductible...
Q3. A) I. Put the following sentences into their Clausal Elements: Eg. John / danced /...
Q3. A) I. Put the following sentences into their Clausal Elements: Eg. John / danced / yesterday. S V A i. Seeing is believing. ii. I wish you good luck. iii. What he said at the meeting was completely balderdash. iv. Out of joy, the lecturer appointed Collins the course representative immediately. v. Gyesi scores the third goal for Oasis FC in every competition. II. Construct a Meaningful Sentence for EACH of the Following Patterns i. SAVC ii. ASVOC iii....
For the following exercises, given v, draw v, 3v and 1/2 v. 〈−3, −2〉
For the following exercises, given v, draw v, 3v and 1/2 v.⟨−3, −2⟩
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT