0% found this document useful (0 votes)
4 views

Prolong programming

Prolog is a declarative programming language focused on logic and rules, primarily used in artificial intelligence and computational linguistics. It features a rule-based system, automatic backtracking, and recursive processing, making it suitable for applications like expert systems and natural language processing. Despite its advantages, Prolog has limitations such as performance issues and a steep learning curve, but remains valuable for logical reasoning and automation.

Uploaded by

padhyeadwita
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Prolong programming

Prolog is a declarative programming language focused on logic and rules, primarily used in artificial intelligence and computational linguistics. It features a rule-based system, automatic backtracking, and recursive processing, making it suitable for applications like expert systems and natural language processing. Despite its advantages, Prolog has limitations such as performance issues and a steep learning curve, but remains valuable for logical reasoning and automation.

Uploaded by

padhyeadwita
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

PROLOG

PROGRAMMING
INTRODUCTION
TO PROLOG
• Prolog (Programming in Logic) is a declarative programming
language primarily used for artificial intelligence and
computational linguistics.
• Unlike procedural programming languages like C or Python,
Prolog is based on logic and rules.
• Instead of giving step-by-step instructions, the programmer
defines facts and rules, and Prolog figures out the solution
through logical inference.
• Used in AI applications, natural language processing, expert
systems, and symbolic reasoning.
CHARACTERISTICS OF
PROLOG
1.Declarative Language: Focuses on what needs to be solved rather than
how to solve it.
2. Rule-Based System: Programs are written using facts, rules, and queries.
3.Pattern Matching: Uses a process called unification to match variables with
data.
4.Backtracking Mechanism: If one solution path fails, Prolog automatically
goes back and tries another.
5.Recursive Processing: Prolog heavily relies on recursion instead of loops
for iteration.
6.Symbolic Computation: Best suited for handling symbols, strings, and
logic-based operations, rather than numerical computations.
SYNTAX AND
A Prolog program consists of three key components:
STRUCTURE
1.Facts: We can define fact as an explicit relationship between
objects, and properties these objects might have. So facts are
unconditionally true in nature.
Following are some guidelines to write facts −
• Names of properties/relationships begin with lower case letters.
• The relationship name appears as the first term.
• Objects appear as comma-separated arguments within
parentheses.
• A period "." must end a fact.
The syntax for facts is as follows −
relation(object1,object2...).
Example
parent(john, mary).
parent(mary, alice).
2. Rules:
We can define rule as an implicit relationship between objects. So facts are
conditionally true. So when one associated condition is true, then the predicate is also
true.
Suppose we have some rules as given below −
• Lili is happy if she dances.
• Tom is hungry if he is searching for food.
So these are some rules that are conditionally true, so when the right hand side is true,
then the left hand side is also true.
Syntax:
rule_name(object1, object2, ...) :- fact/rule(object1, object2, ...)
Example:
grandparent(X, Y) :- parent(X, Z), parent(Z, Y).
3. Queries:
Queries are some questions on the relationships between objects and object properties. So
question can be anything, as given below −
• Is tom a cat?
• Does Kunal love to eat pasta?
• Is Lili happy?
• Will Ryan go to play?
So according to these queries, Logic programming language can find the answer and return
them.

Example:
?- grandparent(john, Who).

• Variables: Begin with an uppercase letter (e.g., X, Who).


• Atoms: Lowercase words or strings (e.g., john, mary).
• Predicates: Describe relationships (e.g., parent(john, mary)).
EXECUTION MECHANISM
• Unification: Prolog matches variables with values to satisfy a
query.
• Backtracking: If a query fails, Prolog retraces steps to find an
alternative solution.
• Resolution: The process of deriving conclusions from known
facts and rules.
• Example Execution:
1.Query: ?- grandparent(john, alice).
2.Prolog checks rules and facts:
parent(john, mary).
parent(mary, alice).
3. Since both match the grandparent rule, Prolog returns:
Prolog: alice
APPLICATIONS OF PROLOG
• Artificial Intelligence (AI): Used in expert systems,
chatbots, and decision-making systems.
• Natural Language Processing (NLP): Helps in
parsing and understanding human language.
• Knowledge-Based Systems: Used in medical
diagnosis and legal document analysis.
• Automated Reasoning: Used in theorem proving and
logical inference engines.
• Robotics: Helps robots make decisions based on
predefined logic.
• Database Systems: Efficient for querying relational
data due to its logical structure.
ADVANTAGES OF PROLOG
• Expressive and Concise: Complex problems
can be represented in a few logical rules.
• Automatic Backtracking: Searches multiple
solutions without extra coding.
• Built-in Pattern Matching: Helps with tasks
like searching, classification, and planning.
• High-Level Abstraction: No need to worry
about low-level implementation details.
• Great for AI and Symbolic Processing:
Efficient in handling logical and symbolic
computation.
LIMITATIONS OF PROLOG
• Performance Issues: Prolog is slower than procedural
languages for numerical computations.
• Difficult Debugging: Errors can be hard to trace due to
automatic backtracking.
• Steep Learning Curve: The logic-based approach is
challenging for beginners.
• Limited Use Cases: Best suited for logic-based problems
rather than general-purpose programming.
• Lack of Industry Adoption: Not as popular as Python,
Java, or C++ in mainstream software development.
CONCLUSION
Prolog is a powerful logic-based programming
language ideal for AI, expert systems, and rule-based
reasoning. Its declarative nature simplifies complex
problem-solving, making it valuable for applications in
AI and computational intelligence. While it has a
learning curve, mastering Prolog enables efficient
logical reasoning and automation, keeping it relevant
in modern tech fields.
THANK YOU

You might also like