Artificial Intelligence Theory - Final Exam Preparation Notes

Note: This document compiles all concepts, notes, formulas, and examples extracted precisely from the provided material, specifically targeting AI domains.

1. Logical Agents & Wumpus World Problem

Logical Agents

Definition: Logical agents are more intelligent than previous agents. Previous agents only worked on existing knowledge, but logical agents can perform Logical Reasoning on existing knowledge and can also infer new knowledge.

Knowledge Base (KB): Acts as a database or data store based on a proportion/form of sentences. Later on, the agent extracts data, draws conclusions, and creates results.

Agent Architecture & Interaction with KB

The system interacts using specific commands: TELL and ASK.

Commands to Interact with KB

  1. TELL: Provide input / add something to the KB (e.g., "KB me koi cheez add krni hai").
  2. ASK: Query the KB.

Execution Sequence of Logical Agent:

  1. Percept: Read the current environment percept.
  2. Ask: Ask the KB what action to take now against the sequence.
  3. Reasoning: Reason on the provided list of actions.
  4. Tell: Tell the KB that a certain action is to be performed.

The Wumpus World Problem

The Wumpus World is an environment (story description) with rules, primarily formatted as a 4x4 matrix of rooms.

Wumpus World 4x4 Grid Representation

Breeze
(Pit nearby)
Breeze
Breeze
Pit
Breeze
Pit
Breeze
Breeze
Stench, Breeze
Gold (Glitter),
Stench, Breeze
Stench
Agent Start
(1,1)
Stench
Wumpus
Monster

Propositional Logic Checks for Wumpus World:

Rules defined for mapping relations between adjacent blocks based on percepts (e.g., B = Breeze, P = Pit):

R1 : ¬P11 (No pit in starting room 1,1)
R2 : B11 ⇔ (P12 ∨ P21) (Breeze in 1,1 means Pit in 1,2 or 2,1)
R3 : B21 ⇔ (P11 ∨ P22 ∨ P31) (Breeze in 2,1 implies pits in adjacent squares)
R4 : ¬B11 (Example observation)
R5 : B21 (Example observation)

2. Propositional Logic

Limitations of Propositional Logic: It lacks quantification and relationship indication between two objects, which leads to the necessity of Predicate/First-Order Logic.

Core Definitions

Entailment

Represented as: α ⊨ β

Meaning: α, β are sentences. If α is true, then β is true. "Aspects of the real world follows aspect of the real world." Sentences entail sentences.

Sentences & Operator Precedence

A statement is either true or false (uses different symbols). A sentence can be Simple or Complex (uses two or more logical connectives).

Precedence Order: ¬ (Not) , ∧ (Conjunction/AND) , ∨ (Disjunction/OR) , ⇒ (Implication) , ⇔ (Biconditional)

3. Predicate Logic / First Order Logic (FOL)

First-Order logic implements logical agents with broader definitions compared to Propositional logic.

Components of FOL

Quantifiers

Quantifiers define how many values hold the result True/False.

Symbol Name Meaning
Universal Quantifier For all / Everyone
Existential Quantifier Some / Exists / Someone

Rules of Quantifiers

∀x ∀y = ∀y ∀x
∃x ∃y = ∃y ∃x
∃x ∀y ≠ ∀x ∃y

Predicate Logic Examples

Here are several statements translated into First-Order Logic based on the course notes:

English Sentence First-Order Logic (FOL) Representation
Ali is a teacher. Teacher(Ali)
All teachers are human. ∀x (Teacher(x) ⇒ Human(x))
Everyone is a friend of someone. ∀x ∃y isFriend(x, y)
Brothers are siblings. ∀x ∀y (Brother(x, y) ⇒ Siblings(x, y))
One's mother is one female parent. ∀x ∀y (Mother(x, y) ⇒ (Parent(x, y) ∧ Female(x)))
Everyone at UET is hardworking. ∀x (UET(x) ⇒ Hardworking(x))
Someone at UET is hardworking. ∃x (UET(x) ⇒ Hardworking(x))
Everyone likes ice cream. ∀x Likes(x, icecream)
There is someone who doesn't like ice cream. ∃x ¬Likes(x, icecream)
Deans are professors. ∀x (Dean(x) ⇒ Professor(x))

4. Fuzzy Logic

Definition: Fuzzy logic is a form of logic based on probabilistic talk rather than true/false absolutes. While Binary Logic has strict outcomes of either 0 or 1, Fuzzy Logic outcomes lie in a continuous range: [0 - 1].

The Problem with Binary Logic (True Predicate):

Fuzzy Logic Degree Examples

Example 1: Height (Tall)

Example 2: Transition Improvement (Speed)

Fuzzy Logic Operations

Fuzzy operations map to specific mathematical functions based on their input matrices:

Fuzzy Operations Truth / Value Table

A B NOT A (1 - A) A AND B min(A,B) A OR B max(A,B)
0 - 1 - -
0.1 0.3 0.9 0.1 0.3
0.5 0.2 0.5 0.2 0.5
0.4 0.8 0.6 0.4 0.8
0.7 0.3 0.3 0.3 0.7

Fuzzy Logic Membership Functions (Temperature Example)

Membership functions determine the degree (μ) to which an input belongs to a category (e.g., Cold, Warm, Hot).

5. Decision Tree (ID3 Algorithm)

Purpose: Used for Classification purposes. It builds a model to predict the class of an object based on learned decision rules.

Structure:

"Play Tennis" Classic Example Structure

[ROOT NODE: ATTRIBUTE: OUTLOOK]
↙     ↓     ↘
SUNNY     OVERCAST     RAIN

(If Sunny) → [ATTRIBUTE: HUMIDITY] → High (NO) / Normal (YES)
(If Overcast) → [DECISION: YES]
(If Rain) → [ATTRIBUTE: WIND] → Strong (NO) / Weak (YES)

ID3 Step-by-Step Mathematical Process

Step 1: Find the most important feature. Compute the Information Gain (IG) of each feature. The feature with the highest Information Gain is selected as the Root Node.

1. Entropy of Dataset (DS):
Entropy(DS) = - P(yes) * log2(P(yes)) - P(no) * log2(P(no))

2. Information Gain (IG):
IG(Attribute) = Entropy(DS) - Σ [ (Count of Value / Total Count) * Entropy(Value) ]

Sample Dataset Calculation

Temp Humidity Wind Output (Play?)
HNYY
HNYY
MHNY
HNYN
CHNN
CNYY
HHNN
CHNN
MNNY
CHYN
Calculating Base Entropy (DS):

Total Samples = 10. Yes (Y) = 6, No (N) = 4 → [6, 4]

Entropy(DS) = -(6/10) * log2(6/10) - (4/10) * log2(4/10) ≈ 0.97


Calculating Entropy for a Specific Column (e.g., Temp):

Calculate instances of Hot, Mild, and Cold in relation to the target output.


Calculating Information Gain for Temp:

IG(Temp) = Entropy(DS) - [ (4/10)*Ent(Hot) + (4/10)*Ent(Cold) + (2/10)*Ent(Mild) ]

ID3 Tree Building Rules:

  1. If a node's output is pure (straight NO or YES, completely homogeneous), it becomes a leaf node (Decision).
  2. If a column has a mixed outcome, move to the next preference/feature to split the node further.
  3. Higher preference (higher Info Gain) is always calculated and placed first.

6. Machine Learning Fundamentals

Definition: It is a domain of AI. We use it to try to train a model to perform tasks based on data. Applications are vast, spanning across sectors like Health, Finance, and Education.

Three Main Types of Machine Learning:

  1. Supervised Learning
  2. Unsupervised Learning
  3. Reinforcement Learning

7. Supervised Learning

Core Concept: Learning with Labels. Depends on past data. We train the model on data with known outcomes (labeled data) and it maps to the category it belongs to.

Input Data
(Labeled: e.g. Cat, Dog)
Model
(Training)
Predictions
(Actual vs Predicted)

Two Main Tasks in Supervised Learning:

8. Unsupervised Learning

Core Concept: Finding Structure. Input data is unlabeled (don't provide labels). The model groups data based on inherent patterns, likeliness, or shared interests.

Two Main Techniques:

  1. Clustering: Used for grouping data.
    • If "likeliness exists" → add them into their own clusters.
    • Example: Grouping students based on their interests.
  2. Dimensionality Reduction:
    • Data consists of many attributes, but some attributes don't play a significant role.
    • Rule: List them → Remove them.
    • Result: Data is reduced → Performance is improved.

K-Means Clustering (Algorithm & Math)

K = Number of clusters. We compute differences (distances) to group points into centroids.

Distance Formulas:
1 Parameter (1D): d = | x1 - x2 |
2 Parameters (2D Euclidean Distance): d = √[ (x2 - x1)2 + (y2 - y1)2 ]

Mathematical Example (1 Parameter - Marks):

Suppose K=2. We initially specify two random centroids from the data, e.g., C1 = 80, C2 = 60.

Student Marks Distance to C1 (μ=80) Distance to C2 (μ=60) Assigned Cluster
S180|80-80| = 0|80-60| = 20C1
S260|60-80| = 20|60-60| = 0C2
S372|72-80| = 8|72-60| = 12C1 (Min distance is 8)
Centroid (Mean Value) Change:
Because S3 was added to C1, we must compute the new mean for C1.
New μ1 = (80 + 72) / 2 = 76
Now, test the next student (e.g., S4 = 65) against the new centroid μ1=76 and μ2=60:
Distance to C1: |65 - 76| = 11
Distance to C2: |65 - 60| = 5 → Assign to C2 (Min distance).
New C2 Mean: (60 + 65) / 2 = 62.5

Within Cluster Sum of Square (WCSS) & Elbow Method

To find the optimal number of clusters (K), we use the Elbow Method based on WCSS.

9. Reinforcement Learning

Core Concept: Continuous Learning via Reward and Penalty. The agent learns optimal actions to maximize total rewards through an Agent-Environment Loop.

The Agent-Environment Loop:

[ ENVIRONMENT (State) ] → provides current state to → [ ROBOT AGENT ]
[ ROBOT AGENT ] → performs an → [ ACTION (e.g., Move Right) ]
[ ACTION ] → affects the → [ ENVIRONMENT ]
[ ENVIRONMENT ] → returns a → [ REWARD (+10, 0, -1) ] back to the agent.

Training & Deployment Behavior:


End of Artificial Intelligence Theory Preparation Notes. Good luck on your final exam!