Question: Solve in DLV ASCII format Using DLV for First Order Logic: Predicate Logic programming The most important thing to remember is that in a DLV
Solve in DLV ASCII format
Using DLV for First Order Logic: Predicate Logic programming
The most important thing to remember is that in a DLV program CAPITAL LETTERS are variable terms, and lowercase are constant ground terms. Furthermore, all variables are universally quantified by default. We will discuss what to do with existential statements later.
Due to the semidecidability of First Order Logic, DLV limits the kinds of statements that you can make. In particular, you cannot reference variables on the left hand side of an implication that did not exist on the right hand side DLV reports rule not safe
So x y px qx y is illegal unsafe in DLV qXY : pX
but x y px r y qx y is OK qxy : px ry
Using negation has another set of issues with decidability safety Usually, rather than true negation, you want to use constraints if these things hold, then the model is inconsistent encoded in DLV as : likespuppiesX hatespuppiesX Meaning that nobody can both like and hate puppies simultaneously, that is an inconsistent model.
Complete the following program. There is only one correct model.
After seeing the latest Hollywood blockbuster, several friends went to the local cafe for a latenight drink. Using the clues below, match each person Ivan Linda, Patricia, Virgil to their drink cafe mocha, flat white, chai tea, earl grey tea and determine the final bill for each $ $ $ $ Remember that in these kinds of problems each value is only used once in the solution.
The one who had the flat white paid dollars less than Virgil.
The person who paid $ had the earl grey tea.
Ivan paid dollars more than the one who had the earl grey tea.
The one who had the cafe mocha paid dollar more than Patricia.
Encoding in DLV requires some anchor facts compare: Relational Database Tables; these act as a
Primary KeyID Here we use the person name as the Primary ID Then the other facts are relations eg relational tables indexed by the primary key. Here, the other relations are the drink every person has a drink and price paid every person pays some amount
The following is a partial solution in standard FOL notation to get you started. Remember that DLV variables are capitalized and constants are lowercase exactly the opposite of the FOL notation
NOTE: written in FOL syntax, not DLV syntax!!!!!
There exist four different people
these are the anchoring facts, like a database primary key
person IVAN
person LINDA
person PATRICIA
person VIRGIL
Every person drinks some drink.
p person p drinks p MOCHA drinks p FLAT drinks p CHAI drinks p EARL
Every person pays some bill Ive rounded up
p person p pays p pays p pays p pays p
Two different people cannot have the same drink a constraint
ppd drinks p d drinks p d p p False
Two different people cannot have the same bill another constraint
ppb pays p b pays p b p p False
CLUE : The one who had the flat white paid dollars less than Virgil.
DLV CAN do arithmetic, but let's keep it simple this week...
If Virgil paid then flat white paid
If Virgil paid then flat white paid
It is inconsistent with the problem for Virgil to pay or
p pays VIRGIL drinks p FLAT pays p
p pays VIRGIL drinks p FLAT pays p
pays VIRGIL False
pays VIRGIL False
CLUE : The person who paid $ had the earl grey tea.
p pays p drinks p EARL
p b drinks p EARL pays p bb False
CLUE : Ivan paid dollars more than the one who had the earl grey tea.
again, we'll do the math ourselves here
p drinks p EARL pays p pays IVAN
p drinks p EARL pays p pays IVAN
pays IVAN False
pays IVAN False
CLUE : The one who had the cafe mocha paid dollar more than Patricia
You finish the program.
to make the solution easier to see,
If we have a person, their drink, and their bill, then we have a solution
run the command: dlv pfiltersolution file.txt
solutionPDB : personP drinksPD paysPB
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
