Question: DLV Logic Programming; doing math in rules Pravanox Pharmaceuticals has spent decades scouring the world's rainforests for new sources of medical drugs, and this year

DLV Logic Programming; doing math in rules
Pravanox Pharmaceuticals has spent decades scouring the world's rainforests for new sources of medical drugs, and this year a number of these new drugs have been officially approved by the FDA. Using only the clues below, match each drug [Bizolam, Damasol, Favolin, Hamzell, Minitrell, Zednisen] to the condition it treats [arthritis, asthma, diabetes, heart disease, influenza, meningitis], the month it was approved [JanuaryJune, inclusive], and the source [beetle, bromeliad, frog, fig orchid, palm tree, wasp] from which its main ingredient is derived.
a. The pharmaceutical sourced from a specific type of beetle was approved 3 months after Bizolam.
b. The medicine sourced from a specific type of wasp treats influenza.
c. The medicine that treats meningitis was approved sometime before Favolin.
d. Zednisen isn't used to combat heart disease.
e. Hamzell isn't used to combat arthritis.
f. The pharmaceutical approved in January isn't sourced from a bromeliad.
g. The drug that treats meningitis was approved sometime before Bizolam.
h. Hamzell isn't used to combat heart disease.
i. The six drugs are Favolin, the medicine that treats heart disease, the pharmaceutical approved in June, the pharmaceutical approved in May, the drug that treats diabetes and the medicine approved in January.
j. Of Minitrell and the medicine sourced from a specific type of palm tree, one was
approved in June and the other treats asthma.
k. The drug sourced from a specific type of bromeliad was approved sometime before the drug that treats heart disease.
l. The pharmaceutical sourced from a specific type of fig orchid was approved 1 month after the medicine that treats influenza.
Hints: I find these problems easier to debug with a rule like
Solution(D,C,M,S) :- drug(D), condition(D,C), month(D,M), source(D,S).
(Here, name is the base predicate (essentially the relational table key if you know relational databases)) and a dlv invocation like
./dlv -nofacts -filter=Solution taxi.txt
gives the solutions you have so far. The choice of base predicate (primary key): drug, condition, etc. is something you should think about (how easily to encode the facts you have)
You may need to do math in a rule. Math can only occur in the premise/body. You also need to set an upper bound of integers.
#maxint =100.
age(bill,50).
age(gary,51).
% next line says The total of Bill & Garys ages must be over 100
:- age(bill,BA), age(gary,GA), TOTAL=BA+GA, TOTAL<=100.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!