In: Computer Science
What is the difference between Fact and Query in a logic programming language?
Difference between Fact and Query
FACT | QUERY |
Fact is the logic of the program or is the knowledge of the program on the basis of which we get results from it. | Query is the result that program gives on the basis on facts or we can say calculation or computation is carried out by the use of query. |
Fact starts with a predicate and ends with a full stop.There may be argument inside parathesis between them. | Query starts with predicate and followed by some arguments which can be variables so as to check from the FACT that this is true or not. |
Fact is always true | Query can give a solution or no solution depending upon facts. |
For example consider a fact in Prolog as
father(Ada,Bob). which states the fact that A is
the father of B and consider a query ?-
father(Ada,X).where X is a variable and this query tells
us that what are the possible solutions in which A is a father of
somebody so we get X=Bob
So query is used by user to ask some logic's possible solutions and the facts are the base of the program which are true and on the basis of which query is answered.