0% found this document useful (0 votes)
3 views23 pages

2.0

The document provides an overview of logic, its branches, and applications in artificial intelligence, including deductive, inductive, and abductive logic. It discusses logic programming, knowledge representation, and various logical problems, as well as fuzzy logic and modal logic. Additionally, it covers semantic networks as a method for representing knowledge and outlines practical activities for learners.

Uploaded by

rohan.clinchtech
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)
3 views23 pages

2.0

The document provides an overview of logic, its branches, and applications in artificial intelligence, including deductive, inductive, and abductive logic. It discusses logic programming, knowledge representation, and various logical problems, as well as fuzzy logic and modal logic. Additionally, it covers semantic networks as a method for representing knowledge and outlines practical activities for learners.

Uploaded by

rohan.clinchtech
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/ 23

ARTIFICIAL

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.
pq
qr
-------
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.

Domain Knowledge Representation


◦ Objects: Jug A, Jug B
◦ Actions: Fill, Empty, Pour
◦ Constraints: Limited capacity, can’t measure directly
Logic Problem: Missionaries and
Cannibals
◦ There are 3 missionaries and 3 cannibals on one side of a river.
◦ They have a boat that can carry a maximum of two people at a time.
◦ The goal is to safely transport all of them across the river.
◦ Constraint: At any point, cannibals must never outnumber missionaries on either side.

Domain Knowledge Representation


◦ Objects: Missionaries, Cannibals, Boat
◦ Rules: Cannibals can’t outnumber missionaries
◦ Goal: Safely transport all individuals
Frames and Inheritance
◦ What is a Frame?
A frame is a structure used in AI to represent knowledge in a structured format.
It consists of a name and attributes.
Attributes have values assigned to them.
◦ Example of a Frame (Person Frame):

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)

Example of Logical Inference


◦ Fact: man(Steve) → Steve is a man
◦ Rule: ∀x. man(x) → drinks_coffee(x) → All men drink coffee
◦ Inference: drinks_coffee(Steve) → So, Steve drinks coffee!
Logic and Truth
◦ Example Facts & Assertions
◦ person(Steve)
◦ lecturer(Saran)
◦ tall(Khali)
◦ lecturer(Rohan)
◦ ∀x. person(x) → mortal(x).
◦ → All persons are mortal.
◦ ∃x. animal(x) & has_wings(x).
◦ → There exists an animal that has wings.
Fuzzy Logic
What is Fuzzy Logic?
◦ Unlike traditional crisp logic, where values are either true (1) or false (0), fuzzy logic allows overlapping
sets with degrees of truth.
Example:
◦ Crisp logic: A person is either tall or not tall.
◦ Fuzzy logic: A person can be "somewhat tall" with a degree of membership (e.g., Alex is 0.8 tall, Jo is
0.9 tall).

Fuzzy Sets Example


Membership values assigned:
◦ tall(Alex/0.8, Jo/0.9) → Alex is 80% tall, Jo is 90% tall.
◦ fast(Alex/1, Jo/0.5) → Alex is very fast, Jo is moderately fast.
Fuzzy Logic
Operations on Fuzzy Sets
◦ Negation (~)
Reverse the membership value:
~tall(Alex/0.8, Jo/0.9) → sets (Alex/0.2, Jo/0.1)

◦ 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.

Fuzzy Logic Process


◦ Fuzzification → Convert input values to fuzzy values.
◦ Apply Rules → Use AND/OR operations on fuzzy sets.
◦ Defuzzification → Convert fuzzy results back into a crisp output (e.g., using midpoint or average).
Fuzzy Logic
Example Evaluation
Evaluate: ∀x. tall(x) & fast(x)
Given:
◦ Alex is 150 cm tall, Jo is 180 cm tall.
◦ Alex is a gold medal fast runner, Jo cannot run fast.
◦ tall(Alex/0.8, Jo/0.9), fast(Alex/1, Jo/0.5).
◦ AND Operation (Intersection) → min(tall, fast):
◦ tall & fast (Alex/0.8, Jo/0.5).
◦ Midpoint/Average: (0.8 + 0.5)/2 = 0.65.
◦ Thus, the final fuzzy result is 0.65, meaning Alex and Jo are "moderately" both tall and fast.
Modal Logic
What is Modal Logic?
◦ Modal logic extends classical logic by introducing necessity and possibility operators.
◦ It helps distinguish between:

◦ Necessarily True Statements (L)


◦ Example: "It must be true that I am on Earth." → L (I am on Earth)

◦ Possibly True Statements (M)


◦ Example: "It may be true that I am awake." → M (I am awake)
Modal Logic
Operators in Modal Logic

◦ Necessity (L) → "It must be true."


◦ Example: L. ∀x. boys(x) → male(x)
◦ Interpretation: "For all x, if x is a boy, then x must be male."

◦ Possibility (M) → "It may be true."


◦ Example: M. ∃x. rich(x)
◦ Interpretation: "There may exist some x who is rich."
Semantic Nets
What is a Semantic Net?
A semantic network is a
graph-based
representation of
knowledge.
◦ It consists of:
◦ Nodes → Represent
objects or concepts.
◦ Edges (Links) →
Represent relationships
between nodes.
Semantic Nets in Logic
◦ Nodes: Cat, Animal, Fur, Meow
◦ Edges (Links):
◦ Cat → is a → Animal
◦ Cat → has → Fur
◦ Cat → can → Meow

Representing Semantic Nets using


First-Order Logic (FOL):
◦ is_a(Cat, Animal)
◦ has(Cat, Fur)
◦ can(Cat, Meow)
Semantic Nets in Logic
Practical Work – This Week

◦ Group Activity: Complete the ‘Relationships and Semantics’ tasksheet.


◦ Individual Task: Finish the Logic in AI python coding tutorial.

Note: Upload all activity outputs to your ePortfolio.

Based on material by: © Dr. Basel Barakat ([email protected])

You might also like