Friday, December 26, 2025

📘 PAPER 3 – ARTIFICIAL INTELLIGENCE & ROBOTICS UNIT 2: KNOWLEDGE REPRESENTATION & REASONING (university of allahabad)

 

🔴 UNIT 2: KNOWLEDGE REPRESENTATION & REASONING


1️⃣ Knowledge Representation (KR)

✅ Definition

Knowledge Representation is the method used to store knowledge in a machine so that it can:

  • Reason

  • Learn

  • Make decisions


✅ Goals of Knowledge Representation

✔ Represent real-world information
✔ Enable reasoning
✔ Easy to modify
✔ Efficient retrieval


2️⃣ Propositional Logic

✅ Definition

Propositional Logic is a formal system in which:


🔹 Basic Elements

Propositions

Statements that have truth values.

Example:

  • “Ram is tall” → True/False


Logical Connectives

SymbolMeaning
¬NOT
AND
OR
IMPLIES
IFF

Example:

P: It is raining Q: I carry umbrella P → Q

3️⃣ Syntax and Semantics

Syntax

Rules for forming valid expressions.

Semantics

Meaning or truth value of expressions.


4️⃣ Inference in Propositional Logic

🔹 Reasoning Methods

1. Forward Chaining

  • Data-driven

  • Starts from facts

  • Moves forward using rules

2. Backward Chaining

  • Goal-driven

  • Starts from goal

  • Works backward


5️⃣ Resolution Principle

Definition:

Resolution is a rule of inference used for proving statements.

Example:

PQ ¬Q --------- P

✔ Used in theorem proving
✔ Important exam topic


6️⃣ First Order Logic (FOL)

✅ Definition

First Order Logic is more powerful than propositional logic because it:

  • Uses quantifiers

  • Represents objects and relationships


🔹 Quantifiers

SymbolMeaning
For all
There exists

Example:

x (Human(x) → Mortal(x))

7️⃣ Inference in First Order Logic

🔹 Unification

Process of making two expressions identical.

Example:

P(x) and P(Ram) ⇒ x = Ram

🔹 Resolution in FOL

Steps:

  1. Convert to clause form

  2. Skolemization

  3. Apply resolution rule

  4. Derive empty clause


8️⃣ Knowledge Representation Techniques


🔹 1. Semantic Networks

Graph-based representation:

  • Nodes → Objects

  • Arcs → Relationships

Example:

Bird → can fly Sparrow → Bird

✔ Easy to understand
❌ Limited reasoning power


🔹 2. Frames

Structured representation using slots and values.

Example:

SlotValue
NameBird
WingsYes
FlyYes

✔ Used in expert systems


🔹 3. Conceptual Graphs


9️⃣ Uncertain Knowledge

Problem:

Real-world information is often:

  • Incomplete

  • Uncertain

  • Imprecise


🔹 Probabilistic Reasoning

Uses probability to represent uncertainty.

Example:
P(Rain) = 0.7


🔹 Fuzzy Logic

Definition:

Fuzzy logic allows partial truth values between 0 and 1.


Example:

TemperatureTruth Value
Cold0.2
Warm0.7
Hot0.9

Advantages:

✔ Handles uncertainty
✔ Used in washing machines, ACs
✔ Human-like reasoning


🔟 Learning in AI

Types of Learning:

🔹 1. Supervised Learning

🔹 2. Unsupervised Learning

  • No labeled data

  • Clustering

🔹 3. Reinforcement Learning

  • Reward-based learning


1️⃣1️⃣ Concept Learning

Learning general concepts from examples.

Example:
Learning “Bird” from examples like sparrow, pigeon.


1️⃣2️⃣ Inductive Learning

Learning by:

  • Observing examples

  • Generalizing rules


1️⃣3️⃣ Decision Tree Learning

Steps:

  1. Select attribute

  2. Split data

  3. Build tree

  4. Predict output

✔ Simple
✔ Easy to understand


1️⃣4️⃣ Neural Networks (Intro)

Definition:

A Neural Network is inspired by the human brain.


Single Layer Neural Network

Used for:

📘 PAPER 3: ARTIFICIAL INTELLIGENCE & ROBOTICS UNIT 1 – INTRODUCTION TO AI & SEARCH TECHNIQUES (university of allahabad)

 

🔴 UNIT 1 – INTRODUCTION TO AI & SEARCH TECHNIQUES


1️⃣ Introduction to Artificial Intelligence (AI)

✅ Definition of AI

Artificial Intelligence is a branch of computer science that deals with creating intelligent machines capable of performing tasks that normally require human intelligence.

Examples:


2️⃣ Scope of Artificial Intelligence

AI is widely used in the following fields:

🔹 1. Games

🔹 2. Theorem Proving

  • Logical reasoning

  • Mathematical proof verification

🔹 3. Natural Language Processing (NLP)

  • Language translation

  • Chatbots

  • Speech recognition

🔹 4. Vision Systems

  • Face recognition

  • Object detection

  • Medical image analysis

🔹 5. Robotics

  • Industrial robots

  • Medical robots

  • Space robots

🔹 6. Expert Systems

  • Medical diagnosis

  • Fault detection

  • Decision-making systems


3️⃣ AI Techniques

AI techniques are methods used to solve complex problems.

Important AI Techniques:

  • Search techniques

  • Knowledge representation

  • Heuristic methods

  • Machine learning

  • Reasoning techniques


4️⃣ Intelligent Agents

✅ Definition

An Intelligent Agent is an entity that:

  • Perceives environment using sensors

  • Acts using actuators

  • Makes decisions intelligently


Components of Intelligent Agent:

ComponentDescription
SensorsCollect information
ActuatorsPerform actions
EnvironmentWhere agent operates
Agent functionMaps perception to action

Types of Agents

  1. Simple reflex agent

  2. Model-based agent

  3. Goal-based agent

  4. Utility-based agent

  5. Learning agent


5️⃣ Search Techniques in AI

Search is the heart of AI.

Search Problem Components:

  • Initial state

  • Goal state

  • Operators

  • State space

  • Path cost


6️⃣ State Space Search

Definition:

State space is a set of all possible states from initial to goal state.

Example:

8-puzzle problem


7️⃣ Control Strategies

Control strategy decides:

  • Which node to expand next

  • How to traverse state space


8️⃣ Blind Search Techniques

🔹 1. Breadth First Search (BFS)

Characteristics:

  • Explores level by level

  • Uses Queue (FIFO)

  • Finds shortest path

Advantages:

✔ Complete
✔ Optimal

Disadvantages:

❌ High memory usage
❌ Slow for large problems


🔹 2. Depth First Search (DFS)

Characteristics:

  • Goes deep first

  • Uses Stack (LIFO)

Advantages:

✔ Less memory
✔ Easy to implement

Disadvantages:

❌ May go into infinite loop
❌ Not optimal


🔹 BFS vs DFS

BFSDFS
Uses queueUses stack
CompleteNot always
High memoryLow memory
OptimalNot optimal

9️⃣ Heuristic Search Techniques

✅ Heuristic

A heuristic is a rule of thumb used to guide the search.


🔹 1. Hill Climbing

  • Moves toward better state

  • Uses heuristic function

  • Greedy approach

Problems:


🔹 2. Best First Search

  • Uses evaluation function f(n)

  • Chooses best node first


🔹 3. A* Algorithm

Formula:

f(n)=g(n)+h(n)f(n) = g(n) + h(n)

Where:

  • g(n) = cost from start to n

  • h(n) = heuristic estimate

✔ Complete
✔ Optimal
✔ Widely used


🔟 AND–OR Graphs & AO* Algorithm

AND–OR Graph

  • OR node → choose one path

  • AND node → all paths required


AO* Algorithm

  • Used for AND–OR graphs

  • Improves A* algorithm

  • Finds optimal solution graph


1️⃣1️⃣ Constraint Satisfaction Problem (CSP)

Definition:

A problem defined by:

  • Variables

  • Domains

  • Constraints

Example:


1️⃣2️⃣ Game Playing in AI

Minimax Algorithm

  • Two-player game

  • MAX vs MIN

  • Used in chess


Alpha-Beta Pruning

  • Optimization of minimax

  • Reduces nodes explored

  • Faster execution


1️⃣3️⃣ Genetic Algorithms

Inspired by:

  • Natural selection

  • Evolution

  • Steps:

    1. Initialization

    2. Selection

    3. Crossover

    4. Mutation

    5. New generation

📘 PAPER 2: OBJECT ORIENTED PROGRAMMING WITH PYTHON UNIT 5 – NumPy and Pandas (university of allahabad)

 

🔴 UNIT 5 – NumPy and Pandas


🟦 PART A: NUMPY (Numerical Python)


1️⃣ Introduction to NumPy

✅ What is NumPy?

NumPy is a Python library used for:

  • Numerical computation

  • Scientific computing

  • Working with arrays and matrices

✅ Features of NumPy

✔ Faster than Python lists
✔ Supports multi-dimensional arrays
✔ Efficient memory usage
✔ Used in ML, AI, Data Science


2️⃣ ndarray (N-Dimensional Array)

Definition:

The main object of NumPy is ndarray, which represents a multi-dimensional array.

Example:

import numpy as np a = np.array([1,2,3]) print(a)

3️⃣ Data Types in NumPy

a = np.array([1,2,3], dtype=float)

Common Data Types:

  • int

  • float

  • bool

  • complex


4️⃣ Array Attributes

AttributeDescription
ndimNumber of dimensions
shapeSize of array
sizeTotal elements
dtypeData type

Example:

a = np.array([[1,2],[3,4]]) print(a.ndim) print(a.shape)

5️⃣ Array Creation Routines

🔹 From List

np.array([1,2,3])

🔹 Zeros & Ones

np.zeros((2,2)) np.ones((3,3))

🔹 Using arange()

np.arange(1,10,2)

🔹 Using linspace()

np.linspace(1,10,5)

6️⃣ Array from Existing Data

np.asarray([1,2,3]) np.frombuffer(b'hello', dtype='S1')

7️⃣ Array Indexing & Slicing

a = np.array([10,20,30,40]) print(a[1]) print(a[1:3])

8️⃣ Mathematical Operations

a + b a * b np.sqrt(a) np.sum(a) np.mean(a)

🟩 PART B: PANDAS


9️⃣ Introduction to Pandas

✅ What is Pandas?

Pandas is a Python library used for:

  • Data analysis

  • Data manipulation

  • Handling structured data


🔟 Pandas Data Structures

1️⃣ Series

A one-dimensional labeled array.

import pandas as pd s = pd.Series([10,20,30])

2️⃣ DataFrame

A two-dimensional table-like structure.

data = { "Name": ["Amit", "Rahul"], "Marks": [80, 90] } df = pd.DataFrame(data)

1️⃣1️⃣ Creating Series

From List

pd.Series([1,2,3])

From Dictionary

pd.Series({'a':10, 'b':20})

From Scalar

pd.Series(5, index=[1,2,3])

1️⃣2️⃣ Creating DataFrame

From List

pd.DataFrame([[1,2],[3,4]])

From Dictionary

pd.DataFrame({ "Name":["A","B"], "Age":[20,22] })

1️⃣3️⃣ Manipulating DataFrames

Rename Column

df.rename(columns={"Name":"Student_Name"})

Delete Column

df.drop("Age", axis=1)

Delete Row

df.drop(0)

1️⃣4️⃣ Handling Missing Values

Finding Missing Values

df.isnull()

Filling Missing Values

df.fillna(0)

Dropping Missing Values

df.dropna()

1️⃣5️⃣ Advantages of Pandas

✔ Easy data handling
✔ Fast processing
✔ Data cleaning
✔ Used in ML & AI

📘 PAPER 2: OBJECT ORIENTED PROGRAMMING WITH PYTHON UNIT 4 – Dictionaries, Functions, File Handling & Regular Expressions (university of allahabad)

 

🔴 UNIT 4 – Dictionaries, Functions, File Handling & Regular Expressions


1️⃣ Dictionaries in Python

✅ Definition

A dictionary is an unordered collection of data stored as key–value pairs.

Example:

student = { "name": "Amit", "age": 20, "course": "MCA" }

🔹 Characteristics

✔ Key-value based
Mutable
Keys must be unique
Fast access


🔹 Accessing Dictionary Elements

print(student["name"])

🔹 Adding & Updating Values

student["age"] = 21 student["city"] = "Delhi"

🔹 Deleting Elements

del student["age"]

2️⃣ Counting Frequency Using Dictionary

Example:

text = "banana" freq = {} for ch in text: if ch in freq: freq[ch] += 1 else: freq[ch] = 1 print(freq)

Output:

{'b':1, 'a':3, 'n':2}

3️⃣ Python Functions

✅ Definition

A function is a block of reusable code.


🔹 Function Syntax

def function_name(parameters): statements return value

🔹 Types of Arguments

  1. Positional

  2. Keyword

  3. Default

  4. Variable-length


Example:

def add(a, b=5): return a + b

4️⃣ Passing Function as Argument

def square(x): return x*x def fun(f, value): return f(value) print(fun(square, 5))

5️⃣ Lambda Function

Definition:

Anonymous function written in one line.

square = lambda x: x*x print(square(5))

6️⃣ Map Function

nums = [1,2,3] result = list(map(lambda x: x*2, nums))

7️⃣ List Comprehension

squares = [x*x for x in range(5)]

8️⃣ File Handling in Python


🔹 Opening a File

f = open("data.txt", "r")

File Modes:

ModeMeaning
rRead
wWrite
aAppend
r+Read + Write

🔹 Reading File

f.read()

🔹 Writing File

f.write("Hello Python")

🔹 Closing File

f.close()

9️⃣ String Processing

Common String Functions:

s.upper() s.lower() s.replace() s.split() s.strip()

🔟 Regular Expressions (RegEx)

Definition:

Regular expressions are used for pattern matching.


Common Symbols

SymbolMeaning
.Any character
^Start of string
$End of string
*Zero or more
+One or more
[a-z]Range

Example:

import re pattern = re.search("python", "I love python")

📘 PAPER 2: OBJECT ORIENTED PROGRAMMING WITH PYTHON UNIT 3 – Classes, Objects & OOP Concepts (university of allahabad)

 

🔴 UNIT 3 – Classes, Objects & OOP Concepts


1️⃣ Class and Object


✅ Class

A class is a blueprint or template used to create objects.

📌 It defines:

  • Data members (variables)

  • Member functions (methods)

Example:

class Student: def show(self): print("This is a student")

✅ Object

An object is an instance of a class.

s1 = Student() s1.show()

🔹 Key Difference

ClassObject
BlueprintReal-world entity
LogicalPhysical
No memoryUses memory

2️⃣ Abstract Data Type (ADT)

✅ Definition

An ADT defines:

  • What operations are to be performed

  • Not how they are implemented

It focuses on behavior, not implementation.

Example:


3️⃣ Classes and Objects in Python

Example Program:

class Person: def __init__(self, name): self.name = name def display(self): print("Name:", self.name) p = Person("Rahul") p.display()

4️⃣ Constructor (__init__)

Definition:

A constructor is a special method used to initialize objects.

Example:

class Student: def __init__(self, roll): self.roll = roll

5️⃣ Features of OOP in Python


🔹 1. Encapsulation

Binding data and methods together.

class Bank: def __init__(self): self.__balance = 5000

Data hiding
✔ Security


🔹 2. Abstraction

Showing essential features and hiding internal details.

Achieved using:


🔹 3. Inheritance

Child class inherits properties of parent class.

class Parent: def show(self): print("Parent") class Child(Parent): pass

Types of Inheritance:

  1. Single

  2. Multiple

  3. Multilevel

  4. Hierarchical

  5. Hybrid


🔹 4. Polymorphism

Same function behaves differently.

Example:

print(len("Python")) print(len([1,2,3]))

6️⃣ Abstract Class

Definition:

An abstract class contains abstract methods (methods without body).

Using abc module:

from abc import ABC, abstractmethod class Shape(ABC): @abstractmethod def area(self): pass

7️⃣ Scope in Python

Types of Scope:

  1. Local

  2. Global

  3. Non-local

  4. Built-in


Example:

x = 10 # global def fun(): x = 5 # local print(x)

8️⃣ Multithreading in Python


✅ Definition

Multithreading means executing multiple threads simultaneously.


Is Multithreading Supported in Python?

✔ Yes
❌ But limited due to GIL (Global Interpreter Lock)


Example:

import threading def display(): print("Hello") t = threading.Thread(target=display) t.start()

Advantages:


Disadvantages:

  • Complex debugging

  • GIL limits performance

🌐 What is a Chrome Extension?

   🌐 What is a Chrome Extension? A  Chrome Extension  is a small software program that adds extra features to your browser. 👉 Think like: ...