unit 2 lecture 2
unit 2 lecture 2
Why is it important?
It bridges the gap between how humans think and how machines
compute. It must:
• Express a variety of knowledge: AI systems need to handle different
types of information, such as facts, rules, relationships, and
probabilities, to solve diverse problems.
Example:
Consider a virtual assistant like Siri or Alexa. To answer the question,
"What's the weather like today?", it uses factual knowledge
(temperature and forecast). When asked, "How long will it take to
reach the airport?", it integrates spatial knowledge (distance, traffic
data) with reasoning.
2. Syntax
Propositional logic uses symbols (like P, Q) to represent statements and
connectors (like AND, OR) to combine them.
Here are the key connectors with examples:
a) AND ( ∧ )
• Meaning: Both propositions must be true for the combined
statement to be true.
AND (P ∧ Q)
P Q P∧ Q
T T T
T F F
F T F
F F F
Example:
Let P = "It is raining."
Let Q = "It is cloudy."
P ∧ Q = "It is raining AND it is cloudy."
o If both P and Q are true (it's raining and cloudy), then P ∧ Q =
true.
o If either or both are false, P ∧ Q = false.
b) OR ( ∨ )
• Meaning: At least one proposition must be true for the combined
statement to be true.
• OR (P ∨ Q)
P Q P∨ Q
T T T
T F T
F T T
F F F
• Example:
Let P = "I will study."
Let Q = "I will play."
P ∨ Q = "I will study OR I will play."
o If either P or Q (or both) are true, then P ∨ Q = true.
o If both P and Q are false, then P ∨ Q = false.
c) NOT ( ¬ )
• Meaning: This reverses the truth value of a proposition.
• Negation (¬P)
P ¬P
T F
F T
• Example:
Let P = "I am hungry."
¬P = "I am NOT hungry."
o If P = true (you are hungry), then ¬P = false.
o If P = false (you are not hungry), then ¬P = true.
d) IMPLIES ( → )
• Meaning: If one statement is true, it leads to another being true.
• Implication (P → Q)
P Q P→ Q
TT T
TF F
FT T
FF T
• Example:
Let P = "I study."
Let Q = "I will pass the exam."
P → Q = "If I study, then I will pass the exam."
o If P is true (you study) and Q is true (you pass), then P → Q =
true.
o If P is true (you study) but Q is false (you fail), P → Q = false.
o If P is false (you don’t study), P → Q = true regardless of Q.
Examples :
Propositions:
• P = "I wake up early."
• Q = "I go for a jog."
Expressions:
• AND: "I wake up early AND I go for a jog" → P∧Q
o True if you do both.
• OR: "I wake up early OR I go for a jog" → P∨Q
o True if you do at least one of these activities.
• NOT: "I do NOT wake up early" → ¬P.
o True if you sleep in.
• IMPLIES: "If I wake up early, I go for a jog" → P→Q
o True unless you wake up early and don’t jog.
Online Shopping
Propositions:
• P = "The product is in stock."
• Q = "I will buy it."
Expressions:
• AND: "The product is in stock AND I will buy it" → P∧Q
o True if both conditions are true.
• OR: "The product is in stock OR I will buy it" → P∨Q
o True if either or both conditions are true.
• NOT: "The product is NOT in stock" → ¬P
o True if the product is unavailable.
• IMPLIES: "If the product is in stock, I will buy it" → P→Q
o True unless the product is in stock and you don’t buy it.
2. Syntax Components
a) Objects
Objects are the entities we are talking about.
Examples:
• People: John, Alice, David.
• Things: Ball, Pizza, Book.
b) Predicates
Predicates describe properties of objects or relationships between
objects.
Examples:
• Likes(John, Pizza): John likes pizza (relationship).
• Taller(John, Alice): John is taller than Alice (relationship).
• Red(Ball): The ball is red (property).
c) Quantifiers
Quantifiers allow us to generalize or specify statements.
1. Universal Quantifier ( ∀ )
Indicates that a statement applies to all objects.
Syntax: ∀x [Predicate(x)].
Example:
• ∀x Likes(x, Pizza): "Everyone likes pizza."
o Meaning: For every object x likes pizza.
• ∀x Animal(x) → HasHeart(x): "All animals have hearts."
2. Existential Quantifier ( ∃ )
Indicates that a statement applies to at least one object.
Syntax: ∃x [Predicate(x)].
Example:
• ∃x Likes(x, Pizza): "At least one person likes pizza."
o Meaning: There exists an object x such that x likes pizza.
• ∃x Red(x) ∧ Ball(x): "There is a red ball."
b) Traffic Example
• ∀x Car(x) → NeedsFuel(x): "Every car needs fuel."
• ∃x Car(x) ∧ Electric(x): "There exists a car that is electric."
c) Family Relationships
• Parent(John, Alice): "John is a parent of Alice."
• ∀x Parent(x, Alice) → Loves(x, Alice): "Everyone who is a parent of
Alice loves her."
• ∃x Parent(x, Alice) ∧ Doctor(x): "There exists a parent of Alice who is
a doctor."
Exercise:
1. Every student studies.
2. At least one student plays football.
3. All teachers give homework.
4. Some students like mathematics.
5. Every book has an author.
6. There is at least one red car.
7. All cats have tails.
8. Some birds can’t fly.
9. Every parent loves their child.
10. At least one person in the class wears glasses.
Solution:
Every student studies.
∀x (Student(x) → Studies(x))
At least one student plays football.
∃x (Student(x) ∧ PlaysFootball(x))
All teachers give homework.
∀x (Teacher(x) → GivesHomework(x))
Some students like mathematics.
∃x (Student(x) ∧ LikesMath(x))
Every book has an author.
∀x (Book(x) → ∃y (Author(y) ∧ Wrote(y, x)))
There is at least one red car.
∃x (Car(x) ∧ Red(x))
All cats have tails.
∀x (Cat(x) → HasTail(x))
Some birds can’t fly.
∃x (Bird(x) ∧ ¬CanFly(x))
Every parent loves their child.
∀x ∀y (Parent(x, y) → Loves(x, y))
At least one person in the class wears glasses.
∃x (Person(x) ∧ InClass(x) ∧ WearsGlasses(x))
4. Combining Quantifiers
We can also combine universal and existential quantifiers to create more
complex statements.
Example:
• ∀x Student(x) → ∃y Teacher(y) ∧ Teaches(y, x):
"For every student, there exists a teacher who teaches them."
c. Semantic Networks
A semantic network is a way to represent knowledge in a graphical form,
similar to a mind map. It consists of nodes (representing objects or
concepts) and edges (representing relationships).
1. Nodes
Nodes represent concepts, objects, or ideas.
Example:
• "Dog" (a concept)
• "Mammal" (a category)
• "Barks" (a property of dogs)
2. Edges
Edges define relationships between nodes, such as categories,
properties, or actions.
Example Relationships:
• IsA: Specifies that an object belongs to a category.
o "Dog → IsA → Mammal"
• HasProperty: Indicates an attribute of the object.
o "Dog → HasProperty → Barks"
• Can: Denotes an action the object can perform.
o "Dog → Can → Run"
• PartOf: Indicates that an object is a part of something larger.
o "Wheel → PartOf → Car"
d. Frames
Frames are a data structure used to represent knowledge about objects
in a more structured and detailed manner. They can be thought of as a
template or form where specific details about an object or concept are
stored. Frames capture attributes and relationships in an organized way,
often used in AI for representing objects and reasoning.
1. Structure of Frames
A frame is like a container or structure for storing information about an
object. It consists of:
• Slots: These are like fields or attributes that define properties of the
object.
• Filler: This is the actual value or information stored in a slot.
This frame contains various slots (like Make, Model, Engine) and the
corresponding fillers (like Toyota, Corolla, Petrol). Each slot describes a
specific attribute of the car.
e. Rule-Based Systems
Knowledge is stored as “if-then” rules, which are great for decision-
making.
• Example:
o Rule: If temperature < 0, then state = Solid.
o Input: Temperature = -5.
o Output: State = Solid.
• Analogy: It’s like following a recipe: If the step is to mix ingredients,
you do so.
Objects &
Complexity Simple facts
relationships
Highly
Expressiveness Limited
expressive
Expert
Example Use
Logic circuits systems,
Case
language