Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
49 views10 pages

Control Structures in Prolog

The document provides an introduction to control structures in Prolog, explaining their role in guiding execution flow based on logical inference. It outlines common types of control structures including AND, OR, IF-THEN, and IF-THEN-ELSE operators, along with examples of their usage. The summary emphasizes the logical foundation and basic operators that facilitate conditional logic in programming.
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)
49 views10 pages

Control Structures in Prolog

The document provides an introduction to control structures in Prolog, explaining their role in guiding execution flow based on logical inference. It outlines common types of control structures including AND, OR, IF-THEN, and IF-THEN-ELSE operators, along with examples of their usage. The summary emphasizes the logical foundation and basic operators that facilitate conditional logic in programming.
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 GhadiyaliProfessor Name: Prof. Shivani Patel


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

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

Behavior
Succeeds only if both goals are true. Executes left to right.
2. 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.
3. 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
4. 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)
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.
Thank
You !

You might also like