0% found this document useful (0 votes)
36 views11 pages

Prolog Lab Guide

The document discusses the key concepts of facts, rules, and queries in Prolog. Facts are statements that are considered true, rules define relationships between facts, and queries are questions posed to retrieve information based on the facts and rules.

Uploaded by

2022661286
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views11 pages

Prolog Lab Guide

The document discusses the key concepts of facts, rules, and queries in Prolog. Facts are statements that are considered true, rules define relationships between facts, and queries are questions posed to retrieve information based on the facts and rules.

Uploaded by

2022661286
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

LAB GUIDE

PROLOG
Facts, Rules and Queries in Prolog
• Facts
• Facts are statements about the world that we consider to be true.
• In Prolog, facts are used to represent basic information or assertions.
• They consist of a predicate (a term representing a relationship or property)
followed by a list of arguments.
• Facts are usually defined at the beginning of a Prolog program and remain
constant throughout execution.
• Example: student(john, 20, male). Here, student is a predicate, and john, 20,
and male are arguments representing a student's name, age, and gender,
respectively.
Facts, Rules and Queries in Prolog
• Rules
• Rules define relationships or properties based on other facts or rules.
• They consist of a head (the thing being defined) and a body (the conditions
that must be true for the rule to be true).
• Rules are used to infer new information from existing facts or rules.
• They can involve logical operators like conjunction (,) and disjunction (;) to
express complex conditions.
• Example: parent(X, Y) :- father(X, Y); mother(X, Y). Here, parent(X, Y) is the
head, and father(X, Y); mother(X, Y) is the body. This rule defines parent
based on either father or mother relationships.
Facts, Rules and Queries in Prolog
• Queries
• Queries are questions posed to the Prolog system to retrieve information or
check if a certain statement is true.
• They consist of a predicate followed by variables or specific values to be
queried.
• Prolog attempts to find values for the variables that make the query true,
based on the facts and rules defined in the program.
• Queries are typically entered interactively at the Prolog interpreter prompt.
• Example: ?- student(john, Age, male). Here, student(john, Age, male) is the
query, asking for the age of the student named John who is male.
THE END

You might also like