Module 2
Module 2
Module 2
Knowledge Representation and Reasoning
Topics: Types of knowledge representation, Propositional logic and first-order logic, Semantic networks
and frames, Ontologies and their applications, Deductive and inductive reasoning, Rule-based systems
and non-monotonic reasoning, Probabilistic reasoning and Bayesian networks.
∀x (Bird(x) → CanFly(x))
(b) Procedural Knowledge Representation
Knowledge is represented as procedures or sequences of actions.
Used in expert systems and rule-based AI.
Example: If diagnosing a disease, a system may follow:
o Step 1: Check symptoms.
o Step 2: Match with known diseases.
o Step 3: Suggest treatment.
(c) Semantic Networks
Represents knowledge in a graphical structure with nodes and links.
Example: A semantic network for animals:
Dog → is-a → Mammal
Mammal → is-a → Animal
Dog → has → Fur
(d) Frames
Similar to object-oriented programming.
Represents knowledge in data structures called frames.
Example: A frame for a car:
Car:
- Type: Sedan
- Engine: V6
- Fuel: Petrol
Reasoning in AI
Reasoning is the process of drawing logical conclusions from knowledge.
(a) Types of Reasoning
1. Deductive Reasoning:
o Moves from general to specific.
o Example: "All humans are mortal. Socrates is a human. Therefore, Socrates is
mortal."
2. Inductive Reasoning:
o Moves from specific to general.
o Example: "Every swan I’ve seen is white. Therefore, all swans might be white."
3. Abductive Reasoning:
o Infers the most likely explanation.
o Example: "If the ground is wet, it probably rained."
4. Non-Monotonic Reasoning:
o Beliefs can change when new knowledge is added.
o Example: "Birds can fly, but penguins are birds that cannot fly."
Atomic Propositions: Basic statements that are either True (T) or False (F).
o Example:
P:P:P: "It is raining."
Q:Q:Q: "The road is wet."
Logical Connectives:
o P∧Q=FalseP ∧ Q = FalseP∧Q=False
If P=TrueP = TrueP=True and Q=FalseQ = FalseQ=False, then:
o P∨Q=TrueP ∨ Q = TrueP∨Q=True
o P→Q=FalseP → Q = FalseP→Q=False (since True → False is False)
1. Objects (Entities)
2. Predicates (Properties of objects)
3. Quantifiers (Generalization of statements)
∀x(Human(x)→Mortal(x))\forall x (Human(x) →
o Example: "All humans are mortal."
Mortal(x))∀x(Human(x)→Mortal(x))
Existential Quantifier (∃) → "There exists"
AI))∃x(Student(x)∧Likes(x,AI))
1. Propositional Logic:
o "If it rains, the ground is wet."
Rain→WetGroundRain → WetGroundRain→WetGround
2. First-Order Logic:
∀c(Rains(c)→WetGround(c))\forall c (Rains(c) →
o "If it rains in a city, the ground in that city is wet."
WetGround(c))∀c(Rains(c)→WetGround(c))
2.4 Advantages of First-Order Logic
Connectives (∧, ∨, →) ∃)
Propositions (P, Q, R), Logical Objects, Predicates, Functions, Quantifiers (∀,
Symbols Used
"If it rains, the road is wet." "If it rains in any city, roads in that city are wet."
Example
(Rain → WetRoad) (∀c Rains(c) → WetRoad(c))
2. Frames
Definition:
A Frame is a structured data representation that groups information into a template (similar to a database
record).
Each frame consists of:
Slots (Attributes/Properties)
Fillers (Values assigned to slots)
Example of a Frame for a Car:
Frame: Car
----------------------
Manufacturer: Tesla
Model: Model S
Color: Red
Engine: Electric
Speed: 200 km/h
Owner: John
Here,
"Car" is the frame name.
"Manufacturer", "Model", "Color", "Engine" are slots.
"Tesla", "Model S", "Red" are fillers (values assigned to slots).
Inheritance in Frames:
Frames allow inheritance like semantic networks:
Frame: Vehicle
----------------------
Type: Transport
Fuel: Petrol/Diesel/Electric
Frame: Car (inherits from Vehicle)
----------------------
Type: Transport
Fuel: Petrol/Diesel/Electric
Manufacturer: Tesla
A "Car" is a "Vehicle", so it inherits Type: Transport.
Advantages of Frames:
✔ Modular & Organized representation of knowledge.
✔ Allows default values (if not mentioned, use the parent class value).
✔ Used in expert systems and NLP applications.
Limitations of Frames:
✘ Not well-suited for reasoning (lacks logic).
✘ Does not support complex relationships as well as semantic networks.
Relationships:
- Person OWNS Vehicle
- Car HAS Engine
- Bike HAS Two Wheels
Here, Car and Bike inherit properties from Vehicle.
A Person can own a Vehicle.
A Car has an Engine, while a Bike has Two Wheels.
Types of Ontologies
1. Domain Ontologies:
Focus on a specific field (e.g., Medicine, Finance, Cybersecurity).
Example: SNOMED CT (Medical Ontology) for diseases, symptoms, and treatments.
2. General Ontologies:
Broad knowledge across multiple domains.
Example: WordNet (a lexical database of words and meanings).
3. Upper-Level Ontologies:
Provide high-level categories for structuring knowledge.
Example: SUMO (Suggested Upper Merged Ontology) for AI and reasoning.
Applications of Ontologies in AI
1. Semantic Web & Knowledge Graphs
Ontologies help create a structured web of data.
Example: Google Knowledge Graph links related entities (e.g., searching for “Elon Musk”
shows Tesla, SpaceX, and related entities).
2. Natural Language Processing (NLP)
Used in chatbots, search engines, and text understanding.
Example: IBM Watson uses ontologies to interpret medical texts.
3. Expert Systems & AI Assistants
Ontologies store expert knowledge for AI-driven decision-making.
Example: Medical AI uses ontologies for diagnosing diseases based on symptoms.
4. Robotics & Autonomous Systems
Robots use ontologies to interpret environments and make decisions.
Example: Self-driving cars understand “Road, Traffic Signal, Pedestrian” using ontologies.
5. E-Commerce & Recommendation Systems
Ontologies improve product recommendations by understanding user preferences.
Example: Amazon & Netflix recommendation engines use ontologies to categorize
products/movies.
4. Advantages of Ontologies in AI
Standardized Knowledge Representation → Common vocabulary for AI systems.
Reasoning & Inference → AI can make logical deductions based on ontology rules.
Interoperability → Helps different AI systems communicate & share knowledge.
Improves Machine Learning & NLP → Structured data enhances AI models.
Challenges of Ontologies:
Complex to Design → Requires domain expertise.
Scalability Issues → Large ontologies can be difficult to maintain.
Knowledge Updates → Must be updated as domains evolve.
Ontologies in Action: Real-World Use Cases
Healthcare: Disease diagnosis using medical ontologies (SNOMED, UMLS).
Finance: Risk assessment in banking using financial ontologies.
Cybersecurity: Threat intelligence and attack detection using ontologies.
Education: AI-driven personalized learning paths based on student data.
Autonomous Vehicles: Understanding road environments and traffic rules.
1.5 Deductive and inductive reasoning
Both types of reasoning are used in AI systems, expert systems, and machine learning models.
1. Deductive Reasoning
Definition:
Deductive reasoning is a top-down approach where conclusions are drawn from a set of general
rules or premises. If the premises are true, the conclusion must also be true.
Example:
AI systems use deductive reasoning to apply rules and logic to make decisions.
Definition:
Inductive reasoning is a bottom-up approach where patterns and observations are used to form
general rules or conclusions. The conclusions are probable but not always guaranteed to be true.
Example:
1. Observation 1: The sun has risen in the east every day so far.
2. Observation 2: The sun rose in the east today.
3. Conclusion: The sun will always rise in the east.
The conclusion is likely true, but not 100% certain (e.g., if Earth's rotation changes).
AI uses inductive reasoning to learn patterns from data and make predictions.
Not Always 100% Accurate: Predictions can be wrong if the data is incomplete.
Data Dependency: AI must be trained on a large dataset to make good predictions.
Starting
General rules Specific observations
Point
Certainty 100% certain if premises are true Probable but not always certain
"All birds have feathers → A parrot is a bird "I have seen 100 swans, all are white →
Example
→ A parrot has feathers" All swans are white"
1.5 Rule-based systems and non-monotonic reasoning
1. Rule-Based Systems
A rule-based system (RBS) is an AI system that uses if-then rules to make decisions or
solve problems. It consists of:
1. Rule 1: IF a person has a fever AND cough, THEN they may have the flu.
2. Rule 2: IF a person has a headache AND a stiff neck, THEN they may have
meningitis.
2. Non-Monotonic Reasoning
Unlike classical logic (which is monotonic and does not change), non-monotonic reasoning
allows AI to revise beliefs when new evidence is introduced.
🔹 Example:
A medical AI must diagnose a patient. It doesn't know for sure if the patient has COVID-19,
but it can estimate the probability based on symptoms like fever, cough, and fatigue.
2. Probability Basics
Probabilistic reasoning uses probability theory, which measures the likelihood of an event
occurring.
Where:
3. Bayesian Networks
↘ Cough
Cold → Fever → Test Result
| Fever | Cold | P(Fever | Cold) | |-------|------|---------| | Yes | Yes | 0.8 | | Yes | No | 0.2 | | No |
Yes | 0.2 | | No | No | 0.8 |
This allows AI to compute the probability of having Cold given symptoms like Fever and
Cough.