Introduction to Artificial Intelligence
Introduction to Artificial Intelligence
1. What is AI?
o Artificial Intelligence (AI) is a branch of computer science aimed
at creating systems that can perform tasks that typically require
human intelligence. This includes tasks like learning, reasoning,
problem-solving, understanding language, and recognizing
patterns.
2. Problems of AI:
o Complexity of Human Intelligence: Replicating human thought is
difficult due to its abstract and subjective nature.
o Uncertainty: AI systems must deal with incomplete or unclear
information.
o Ethics: AI raises concerns about job displacement, privacy, and
decision-making authority.
3. AI Techniques:
o Heuristics: These are rules of thumb or shortcuts used to make
problem-solving faster.
o Learning Algorithms: AI systems learn from data and improve
over time.
o Knowledge Representation: This is how AI systems store and use
knowledge to make decisions.
4. Tic-Tac-Toe Problem:
o This is a classic problem in AI. The challenge is to build a system
that can play the game optimally, anticipating the opponent’s
moves and ensuring either a win or a draw.
Intelligent Agents
1. Agents & Environment:
o An agent is an entity that perceives its environment and takes
actions to achieve goals. The environment is everything the agent
interacts with (e.g., a robot interacting with the physical world).
2. Nature of Environment:
o Fully Observable vs. Partially Observable: A fully observable
environment provides all necessary information to the agent, while
a partially observable environment does not.
o Deterministic vs. Stochastic: In a deterministic environment, the
next state is completely determined by the current state and the
agent’s action. In a stochastic environment, there’s some level of
unpredictability.
o Episodic vs. Sequential: In episodic tasks, each action is
independent of the previous ones, while in sequential tasks, current
actions affect future decisions.
3. Structure of Agents:
o Simple Reflex Agents: These agents respond to the environment
based on current conditions without considering the future.
o Model-based Reflex Agents: These agents use internal knowledge
of the environment to make decisions.
o Goal-based Agents: They act to achieve specific goals.
o Utility-based Agents: These agents try to maximize some measure
of happiness or utility.
4. Learning Agents:
o These agents can improve their performance over time by learning
from past experiences. They typically consist of:
▪ Learning Element: Adjusts the agent's actions based on
feedback.
▪ Performance Element: Chooses actions.
▪ Critic: Provides feedback on the agent's actions.
▪ Problem Generator: Suggests exploratory actions for
improvement.
Problem Solving in AI
1. Problems:
o AI involves solving problems by creating systems that simulate
human problem-solving abilities.
2. Problem Space & Search:
o Problem Space: It’s a representation of all possible states the
system can be in during problem-solving.
o Search: AI systems search through this problem space to find a
solution. For example, finding the shortest route in a maze.
3. Defining a Problem as a State Space Search:
o Each state represents a possible configuration of the problem. The
AI navigates between states using actions, trying to reach a goal
state.
4. Production System:
o It consists of:
▪ Rules/Production: Specifies how to move from one state to
another.
▪ Database: Stores the current state.
▪ Control Strategy: Determines how to apply the rules to
solve the problem.
▪ Rule Interpreter: Executes the control strategy.
5. Problem Characteristics:
o Well-defined vs. Ill-defined Problems: A well-defined problem
has a clear goal and rules (like chess), while an ill-defined problem
doesn’t (like understanding emotions).
o Static vs. Dynamic Problems: In static problems, the world
doesn’t change while the AI thinks. In dynamic problems, the
world changes, requiring the AI to act in real-time.
6. Issues in Designing Search Programs:
o Time and Space Complexity: Searching through large problem
spaces can be computationally expensive, requiring careful design.
o Heuristics: Using heuristics can reduce search space and improve
efficiency.
o Uncertainty: Dealing with incomplete or unpredictable
information adds complexity to search algorithms.
Search Techniques in AI
Search techniques are methods used by AI to find solutions to problems by
exploring different possibilities. Let’s break them down step by step:
1. Problem-Solving Agents
• Problem-Solving Agent: This is an AI agent that solves problems by
searching through possible actions to reach a goal.
o It works by:
1. Understanding the Problem: Defines the problem in terms
of the initial state, goal state, and possible actions.
2. Searching for a Solution: Explores the different ways to
reach the goal.
• Example: If a robot wants to move from point A to point B, it must
search for the best path through obstacles.
Breadth-First Finds the shortest path; High memory usage; slow for
Search (BFS) explores all possibilities large problems
Depth-First Uses less memory; faster in Does not always find the
Search (DFS) some cases shortest path; can get stuck
2. A Search*
• How it works: A* search is like a combination of Greedy Best-First
Search and Breadth-First Search. It uses both the cost of reaching the
current state and an estimate (heuristic) of the cost to reach the goal.
o f(n) = g(n) + h(n), where:
▪ g(n) is the actual cost to reach the current state.
▪ h(n) is the estimated cost to the goal (heuristic).
▪ f(n) is the total estimated cost of the solution.
• Advantages: A* is guaranteed to find the shortest path if the heuristic is
good (i.e., it doesn’t overestimate the cost).
• Disadvantages: It can use a lot of memory because it stores many
possible paths.
• Example: If you’re navigating through a maze, A* considers both how far
you’ve traveled and how close you are to the exit.
7. Genetic Algorithms
• How it works: Inspired by biological evolution, genetic algorithms use a
population of solutions and evolve them over time using techniques like:
o Selection: Choosing the best solutions.
o Crossover: Combining two solutions to create a new one.
o Mutation: Randomly altering a solution to explore new
possibilities.
• Advantages: Very effective for large, complex problems where other
search methods fail.
• Disadvantages: Can take a lot of time to find the best solution.
• Example: Breeding plants for better fruit. You select the best plants,
cross-breed them, and sometimes allow random mutations to see if they
produce better offspring.
Adversarial Search
Adversarial search is used in situations where two players compete against
each other, like in games (chess, tic-tac-toe). The goal is to make decisions that
maximize your advantage while minimizing the opponent's advantage.
3. Alpha-Beta Pruning
• How it works: Alpha-beta pruning is an improvement of the minimax
algorithm. It prunes, or cuts off, parts of the game tree that don’t need
to be explored, making the search faster.
o Alpha: The best option for the maximizing player so far.
o Beta: The best option for the minimizing player so far.
• How Pruning Works:
1. While evaluating a game tree, if a branch can’t possibly result in a better
outcome than what has already been found, it is pruned (ignored).
2. This saves time because the algorithm doesn’t evaluate moves that
won’t affect the final decision.
• Example: In a chess game, if you already found a move that gives you a
significant advantage, you stop considering other moves that won’t
improve your position.
4. Additional Refinements
• Heuristics: Sometimes the game tree is too large to search completely,
so AI uses heuristics to estimate the value of positions quickly instead of
fully calculating them.
• Move Ordering: Searching the best moves first can increase the chances
of pruning more branches early, speeding up the process.
5. Iterative Deepening
• How it works: In large game trees, it's often impossible to search deeply
in one go. Iterative deepening searches the game tree in depth-limited
steps.
o It starts by exploring shallow levels and gradually increases the
depth as time allows.
• Advantages:
1. If the search needs to stop early (due to time limits), the AI still has at
least explored part of the game tree.
2. It allows more time to be spent on important parts of the game tree as
the search goes deeper.
4. Resolution
• What is Resolution?: Resolution is a method used in predicate logic to
prove whether a statement is true or false. It is commonly used in
automated reasoning and AI systems.
• How it works:
o You start with a set of known facts (called premises) and a
statement you want to prove.
o Resolution combines and simplifies these facts to either prove the
statement or show that it’s false.
• Example: If you know:
o All humans are mortal: Human(x) → Mortal(x).
o Socrates is a human: Human(Socrates).
Using resolution, you can prove that Socrates is mortal: Mortal(Socrates).
5. Natural Deduction
• What is Natural Deduction?: Natural deduction is a method for
reasoning in predicate logic that involves deriving conclusions step by
step using logical rules.
• How it works:
o You use basic logical rules (like "if-then," "and," and "or") to derive
new facts from known ones.
o It mimics the way humans naturally reason in everyday life.
• Example:
o If you know:
▪ "If it rains, the ground will be wet" (Rain → WetGround).
▪ "It is raining" (Rain).
o You can deduce that "the ground will be wet" (WetGround).
Summary
• Predicate Logic: Allows AI to represent facts about objects and
relationships in a more detailed way than simple propositional logic.
• Instance & ISA: Used to represent hierarchies and relationships between
classes and objects.
• Computable Functions & Predicates: Allow for testing relationships and
calculating values.
• Resolution: A method to prove the truth or falsity of a statement.
• Natural Deduction: A logical reasoning process that derives new facts
step by step from known facts.
Probabilistic Reasoning in AI
Probabilistic reasoning is used in AI to handle uncertainty. In many real-world
situations, AI doesn’t have complete or perfect information, so it uses
probabilities to make the best decisions based on what it knows.
3. Dempster-Shafer Theory
• What is Dempster-Shafer Theory?: Dempster-Shafer theory is another
way to handle uncertainty, but it’s more flexible than standard
probability. Instead of assigning a single probability to an event, it allows
for degrees of belief.
• How It Works:
o You can assign belief to multiple outcomes, including the
possibility of not knowing anything at all.
o It combines different pieces of evidence to give an overall measure
of belief, but allows for situations where the AI is unsure or lacks
information.
• Why It’s Useful:
o This theory is helpful when there’s incomplete information, or
when different sources of information might conflict.
• Example: Imagine you have two weather reports—one says there’s a
60% chance of rain, and the other says 80%. Dempster-Shafer theory
helps you combine these beliefs, while still acknowledging some
uncertainty.
Summary
• Probabilistic Reasoning helps AI make decisions when it doesn’t have
complete certainty.
• Bayesian Networks model relationships between variables and help
calculate probabilities in uncertain environments.
• Dempster-Shafer Theory allows for combining beliefs and handling cases
where information is incomplete.
• Fuzzy Sets & Fuzzy Logic help AI deal with vague or imprecise
information, allowing for reasoning that reflects real-world ambiguity.
Natural Language Processing (NLP)
Natural Language Processing (NLP) is a branch of AI that focuses on enabling
computers to understand, interpret, and respond to human language. It
combines both linguistics and computer science to help machines process and
interact with language.
1. Introduction
• NLP: It allows machines to process and understand language the way
humans do. It helps computers perform tasks like language translation,
speech recognition, and text analysis.
• Goal of NLP: The primary goal is to bridge the gap between human
communication and machine understanding, enabling computers to
understand and respond to text or speech in a meaningful way.
2. Syntactic Processing
• Syntactic Processing: This step involves analyzing the structure of a
sentence (syntax). It checks the grammatical arrangement of words in a
sentence.
• Syntax: It refers to how words are arranged to form sentences.
o For example, in the sentence "The cat sits on the mat," syntactic
processing would identify "the cat" as a noun phrase and "sits on
the mat" as a verb phrase.
• Parsing: Parsing is a key part of syntactic processing. It involves breaking
down a sentence into its parts to understand its grammatical structure.
3. Semantic Analysis
• Semantic Analysis: This step involves understanding the meaning of a
sentence, not just its structure.
• Semantics: Semantics refers to the meaning of words and how they
combine to form meaningful sentences.
o For example, in the sentence "John eats an apple," semantic
analysis understands that "John" is a person and "apple" is an
object that can be eaten.
• Challenges: The meaning of a sentence can often be ambiguous (e.g.,
"The bank was closed" could mean a financial institution or the side of a
river), so semantic analysis tries to resolve these ambiguities.
Learning in AI
Learning is a key aspect of AI, where machines improve their performance
based on data or experience.
1. Forms of Learning
There are different ways machines can learn:
• Supervised Learning: The machine is trained with labeled data (data
where the correct answer is already known). The machine learns from
this data to make predictions about new, unseen data.
o Example: Given labeled images of cats and dogs, the machine
learns to recognize new images as cats or dogs.
• Unsupervised Learning: The machine is given data without labels and
must find patterns or structures on its own.
o Example: Grouping similar customer profiles together based on
purchasing behavior.
• Reinforcement Learning: The machine learns by interacting with its
environment and receiving rewards or penalties for its actions.
o Example: A robot learning to navigate a maze by receiving a
reward when it reaches the exit.
2. Inductive Learning
• Inductive Learning: This type of learning involves making generalizations
from specific examples.
o Example: If a machine sees several examples of birds flying, it
might generalize that all birds can fly (although there are
exceptions like penguins).
3. Knowledge Acquisition
• Knowledge Acquisition: This is the process of gathering and inputting
the knowledge that the expert system will use. It involves working with
human experts to capture their expertise and represent it in a way the
system can use.
o Example: A medical expert’s knowledge is collected and converted
into rules that the system uses to diagnose diseases.
Summary
• NLP: Helps AI understand and interact with human language, handling
syntax, semantics, and real-world context.
• Learning: AI learns from data using methods like decision trees, neural
networks, and genetic algorithms to improve performance and make
decisions.
• Expert Systems: Mimic human experts by using domain knowledge to
solve problems, with knowledge acquired from human experts and used
through a structured shell.