AI FILE
AI FILE
Theory:-
About PROLOG:- PROLOG, which stands for “Programming in logic,” is a high-level
programming language designed for symbolic reasoning and manipulation. It is particularly well-
suited for tasks related to artificial intelligence, logic programming, and rule-based systems.
PROLOG is declarative, meaning that you specify the desired outcome rather than the step-by-
step process to achieve it.
History:- PROLOG was developed in the early 1970s by Alain Colmerauer and a team of
researchers in Marseille,France. The language gained popularity in the field of artificial
intelligence and knowledge representation due to its natural support for formal logic and rule-
based reasoning. Since its inception, PROLOG has been used in a variety of applications,
including expert systems, natural language processing, and database querying.
1- Declarative Syntax:- PROLOG programs describe relationships and rules rather than
specifying a sequence of steps to achieve a goal.
2- Logical Inference:- PROLOG is based on formal logic, enabling users to express and
query relationships using rules of deduction and inference.
3- Pattern Matching:- The language excels at pattern matching,allowing for powerful
and flexible data manipulation.
4- Backtracking:- PROLOG’s unique backtracking mechanism allows the system to
explore alternative solutions when searching for answers to queries.
Basics of Programming in PROLOG:-
Facts and Rules:- Programs consist of facts (statements about relationships) and
rules (logical conditions or implications).
Predicates:- Predicates define relationships between terms. They are the building
blocks of PROLOG programs.
Variables:- Variables are placeholders for unknown values. They allow for more
general and flexible rule definitions.
Queries:- Users interact with the system by posing queries, asking questions, or
seeking solutions to problems.
Recursion:- PROLOG supports recursion, allowing functions or rules to call
themselves, which is a fundamental concept for solving complex problems.
THEORY:-
Where predicate is the name of the relation, and term1,term2,…,termN are the terms involved in the
relation. Each term can be a variable,an atom,,or a compound term.
PROGRAM:-
OUTPUT:-