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

Control Structures in Prolog

The document introduces control structures in Prolog, highlighting their role in guiding execution flow through logical inference and backtracking. It details common types of control structures, including AND, OR, IF-THEN, and IF-THEN-ELSE operators, with examples illustrating their usage. Additionally, it discusses practical applications such as complex decision trees, knowledge representation, and AI systems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Control Structures in Prolog

The document introduces control structures in Prolog, highlighting their role in guiding execution flow through logical inference and backtracking. It details common types of control structures, including AND, OR, IF-THEN, and IF-THEN-ELSE operators, with examples illustrating their usage. Additionally, it discusses practical applications such as complex decision trees, knowledge representation, and AI systems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

BHAGWAN MAHAVIR UNIVERSITY

Bhagwan Arihant Institute & Technology

Artificial Intelligence

Ch: 5 Introduction to
Control Structures
Prolog

Name: Rutvika Ghadiyali Professor Name: Prof. Shivani Patel


[ 2307020703011 ]
What are Control
Structures?
1 Guide Execution 2 Based on Inference
Flow
They rely on logical inference
Control structures direct how and backtracking.
logic is processed.

3 Common Types
• AND (,)
• OR (;)
• IF-THEN (->)
• IF-THEN-ELSE (-> ;)
AND Operator (,)
Purpose Example
Both conditions must be true for likes(john, pizza),
success.
likes(john, pasta).

Behavior
Succeeds only if both goals are true. Executes left to right.
OR Operator (;)
Purpose
At least one condition must be true.

Example
likes(john, pizza); likes(john, pasta).

Behavior
Succeeds if either goal is true. Tries left goal first.
IF-THEN Operator (->)
Condition
Check if condition is true.

Evaluation
Process the logical test.

Execution
Run code only if condition passes.
IF-THEN Example

Condition Operator
is_raining ->

Full Example Action


(is_raining -> take_umbrella) take_umbrella
IF-THEN-ELSE Operator (-> ;)
Condition Check
Evaluate the logical condition.

Path Selection
Choose between two execution paths.

Execution
Run either the "then" or "else" branch.
IF-THEN-ELSE Example
1 Condition
is_raining

2 If True
take_umbrella

3 If False
go_out

4 Full Example
(is_raining -> take_umbrella ; go_out)
Practical Applications
Complex Decision Trees
Build sophisticated logical flows.

Knowledge Representation
Model complex relationships and rules.

AI and Expert Systems


Create intelligent decision-making systems.
Summary of Control
Structures
Logical Foundation
Prolog uses logical rules to guide execution flow.

Basic Operators
AND (,) for multiple conditions. OR (;) for alternatives.

Conditional Logic
IF-THEN (->) adds conditions. IF-THEN-ELSE (-> ;) adds fallbacks.

You might also like