2.0
2.0
INTELLIGENCE
Rohan Raj Poudel
Logic
◦ Definition:
Logic is the study of correct reasoning and the principles that govern valid inference.
◦ Origin:
The word "logic" comes from the Greek word "logos", meaning reason, discourse, or language.
◦ Development in Antiquity:
Developed independently across various ancient civilizations.
◦ Aristotle (384–322 BCE): Introduced syllogistic logic, forming the foundation of classical logic.
pq
qr
-------
if p is True, then r is also true (law of syllogism)
◦ Ibn Sina (Avicenna) (980–1037): Developed Avicennian logic, which later replaced Aristotelian logic
as the dominant system in the medieval Islamic and European worlds.
Branches of Logic
◦ Deductive Logic (Formal Logic): Derives conclusions based on established premises.
Example:
All humans are mortal.
Socrates is a human.
Therefore, Socrates is mortal.
◦ Inductive Logic: Draws general conclusions based on specific observations.
Example:
Every swan I have seen is white.
Therefore, all swans are white (until proven otherwise).
◦ Abductive Logic: Forms best-guess conclusions based on incomplete information.
Often used in scientific hypotheses and AI-based reasoning.
Logic Programming
◦ Definition:
Logic programming is a paradigm where computation is seen as automatic reasoning over a
knowledge base consisting of facts, rules, and relationships.
◦ Key Concept:
A logic program defines what should be computed rather than specifying how it should be computed.
How It Works:
◦ Facts: Known truths in a domain.
◦ Rules: Logical conditions that infer new facts.
◦ Queries: Questions asked about the knowledge base.
Logic Problem: Water Jug Problem
You have two jugs:
◦ Jug A with a capacity of 3 liters
◦ Jug B with a capacity of 4 liters
Your goal is to measure exactly 2 liters in Jug A using only these two jugs.
Person-1A1
Name Rubin
Age 24
Height 180cm
Weight 160lbs
Frames and Inheritance
Frames: Inheritance
◦ One frame can serve as a
template for others.
◦ A base frame (parent)
provides common
attributes that other
frames (children) inherit.
◦ Example: Car Frame
Inheritance
F1 (Base Frame): General
attributes for all cars.
F2 and F3 (Child Frames):
Inherit attributes from F1
and add their own specific
values.
Logical Representation in AI
Language Structure
◦ Names: john, elizabeth, apple, table
◦ Predicates: Facts describing names, e.g., red(apple), tall(elizabeth), brown(table)
◦ Relations: Represent how things interact, e.g., on(table, apple)
◦ Connectives: & (and), ∨ (or), ~ (not), → (if-then)
◦ Quantifiers: Ǝ (there exists), ∀ (for all)
◦ Variables: Stand for any object, e.g., x, y, z, P, Q, R
◦ Example:
◦ ∀x (apple(x) → red(x)) → All apples are red.
◦ Ǝy (table(y) & brown(y)) → There exists a brown table.
Logic and Truth
◦ Logic relies on formal, unambiguous mathematical sentences that are either true or false based on
given facts.
Examples of Truth Statements:
◦ ✅ Mr. Oli is Prime Minister → TRUE
◦ ❌ Mr. Poudel is Prime Minister → FALSE
◦ ❌ The sky is green → FALSE
Logical Representation: Logical sentences are true or false depending on facts.
Example 1: Prime Minister Representation
◦ ∃x. person(x) & prime_minister(x)
◦ person(Mr. Oli) → prime_minister(Mr. Oli) ✅
Logic and Truth
Example 2: Sky and Colors Representation
◦ ∃x. ∃y. sky(x) & has_color(x, y), color(y)
◦ ∃x. ∃(blue). sky(x) & has_color(x, blue), color(blue)
Given facts:
◦ color(blue) ✅
◦ color(red) ✅
◦ has_color(sky, blue) ✅
◦ This means the sky is blue.
Logic and Reasoning
Three key aspects of using logic in AI:
◦ Representing Information: (Facts & Rules)
◦ Inferring New Information: (Drawing conclusions)
◦ Controlling Inference: (Choosing what and when to infer)
◦ AND (Intersection)
Take the minimum value:
tall (Alex/0.8, Jo/0.9) & fast (Alex/1.0, Jo/0.5) → tall & fast sets (Alex/0.8, Jo/0.5).
◦ OR (Union)
Take the maximum value:
tall (Alex/0.8, Jo/0.9) OR fast (Alex/1.0, Jo/0.5) → tall & fast sets (Alex/1.0, Jo/0.9).
Fuzzy Logic
Fuzzy Rule Example
◦ IF bank balance is full (A1) OR salary is high (B1) THEN holiday is high (C1).
◦ IF bank balance is empty (A2) OR salary is low (B2) THEN holiday is low (C2).
◦ Assign values to A1, B1, A2, and B2, then use AND/OR rules to determine C1 or C2.