Thinking Humanly
•“The exciting new effort to make computers think ...
machines with minds, in the full and literal sense.”
(Haugeland, 1985).
• “[The automation of] activities that we associate with
human thinking, activities such as decision-making,
problem-solving, learning ...” (Bellman, 1978).
Thinking Rationally
• “The study of mental faculties through the use of
computational models.” (Charniak and McDermott,
1985).
• “The study of the computations that make it possible
to perceive, reason, and act.” (Winston, 1992).
6.
Acting Humanly
•“The art of creating machines that perform functions
that require intelligence when performed by people.”
(Kurzweil, 1990).
• “The study of how to make computers do things at
which, at the moment, people are better.” (Rich and
Knight, 1991).
Acting Rationally
• “Computational Intelligence is the study of the
design of intelligent agents.” (Poole et al., 1998)
• “AI . . . is concerned with intelligent behavior in
artifacts.” (Nilsson, 1998)
Production Systems:
Aproduction system in AI refers to a model of computation that represents problem-solving using rules. It consists of:
Set of Rules (Productions): These condition-action pairs guide the system on what to do in each state. For example, in
a chess engine, a rule might state: "If a bishop is threatened, move it to a safe position.“
Working Memory (Global Database): The memory stores the current state of the problem or knowledge base. The
system continuously updates this memory as it moves from one state to another.
Control System: It determines which rules to apply, in what order, and when to stop the process. Control strategies
(discussed below) play a critical role in this component.
9.
Types ofProduction Systems:
1. Monotonic Systems: Once a rule is applied, the condition it addresses is permanently satisfied.
Example of a Monotonic System:
Temperature Control System in a Heating Device:
In a heating device (like a thermostat), the temperature increases monotonically when the heating element is powered. As more
energy is supplied, the temperature rises steadily without decreasing, illustrating a monotonic increase in output temperature
relative to the input energy.
2. Non-Monotonic Systems: Conditions can be revisited, and rules may be applied multiple times when needed.
Example of a Non-Monotonic System:
Thermostat-Controlled Heating and Cooling System:
In a home heating and cooling system controlled by a thermostat, the temperature may not change consistently as you adjust
the settings. For example:
As you increase the temperature setting, the system may turn on the heater and raise the temperature.
However, after a certain point, the system may switch off or switch to cooling mode, causing the temperature to drop.
In this case, the output (temperature) can both increase and decrease as you adjust the input (thermostat setting), resulting in a
non-monotonic relationship.
10.
3. Commutative Systems:Different sequences of rule applications lead to the same result.
Example of a Commutative System:
Addition in Arithmetic:
In basic arithmetic, the addition operation is commutative:
• 3+5=5+3
•The order in which you add the numbers does not change the result; both give 8.
4. Non-Commutative Systems: Different sequences can lead to different results.
Example of a Non-Commutative System:
String Concatenation:
In programming, concatenating strings is non-commutative. For example:
• "Hello" + "World" = "HelloWorld".
• "World" + "Hello" = "WorldHello". The order changes the final string.
11.
Breadth-First Search(BFS)
Breadth First Search (BFS) is a fundamental graph traversal algorithm. It begins with a node, then
first traverses all its adjacent. Once all adjacent are visited, then their adjacent are traversed. This differs
from DFS in that the closest vertices are visited before others. We mainly traverse vertices level by
level.
It follows Queue based approach.
Output: 1 2 5 3 4
12.
How Does theBFS Algorithm Work?
Let us understand how the algorithm works with the help of the following example where the source vertex is
0.
17.
Step 6: Removenode 3 from the front of the queue visit the unvisited neighbors and push them into the queue.
18.
Steps 7: Removenode 4 from the front of the queue visit the unvisited neighbors and push them into the queue.
Now, the Queue becomes empty, So, terminate this process of iteration.
19.
Complexity Analysis ofBreadth-First
Search (BFS) Algorithm:
Time Complexity of BFS Algorithm: O(V +
E)
•BFS explores all the vertices and edges in
the graph. In the worst case, it visits every
vertex and edge once. Therefore, the time
complexity of BFS is O(V + E), where V and
E are the number of vertices and edges in
the given graph.
20.
Applications of BFSin Graphs:
BFS has various applications in graph theory and computer science, including:
• Shortest Path Finding: BFS can be used to find the shortest path between two nodes in an unweighted graph. By keeping
track of the parent of each node during the traversal, the shortest path can be reconstructed.
• Cycle Detection: BFS can be used to detect cycles in a graph. If a node is visited twice during the traversal, it indicates the
presence of a cycle.
• Connected Components: BFS can be used to identify connected components in a graph. Each connected component is a set
of nodes that can be reached from each other.
• Topological Sorting: BFS can be used to perform topological sorting on a directed acyclic graph (DAG). Topological
sorting arranges the nodes in a linear order such that for any edge (u, v), u appears before v in the order.
• Level Order Traversal of Binary Trees: BFS can be used to perform a level order traversal of a binary tree. This traversal
visits all nodes at the same level before moving to the next level.
• Network Routing: BFS can be used to find the shortest path between two nodes in a network, making it useful for routing
data packets in network protocols.
21.
Depth-First Search(DFS)
Depth First Search (DFS) is a fundamental graph traversal algorithm used to explore all nodes and edges in a
graph. It starts from a given node (called the root in a tree or any arbitrary node in a graph) and explores as far
as possible along each branch before backtracking. It follows stack-based approach.
Output: A D F C E B
22.
How Does theDFS Algorithm Work?
Let us understand how the algorithm works with the help of the following example
28.
•Complexity Analysis ofDepth-
First Search (BFS) Algorithm:
•Time Complexity of DFS
Algorithm: O(V + E)
•Time complexity: O(V + E). Note
that the time complexity is the
same here because we visit every
vertex at most once and every edge
is traversed at most once (in
directed) and twice in undirected.
29.
1. Pathfinding:
• Maze/GraphTraversal: DFS can be used to find a path from a source to a destination, especially when you're looking for
any possible solution rather than the shortest path.
• Solving puzzles: DFS can be applied to solve puzzles such as mazes, where exploring one potential solution to its depth is
necessary before backtracking and trying alternative paths.
2. Cycle Detection:
• In both directed and undirected graphs, DFS can be used to detect cycles. If DFS revisits a node that has already been
visited and is not its parent, a cycle exists.
3. Topological Sorting:
• DFS is commonly used for topological sorting in Directed Acyclic Graphs (DAGs). This is crucial for resolving
dependencies, such as in task scheduling or determining the build order in software projects.
4. Finding Connected Components:
• DFS can be used to identify all connected components in a graph. For example, in a social network, it can help identify
distinct clusters of users who are all connected to each other.
5. Solving Problems on Trees:
• DFS is often used for exploring trees to solve problems like:
• Finding the height or depth of a tree.
• Finding the longest path in a tree (diameter).
• Finding ancestors or descendants of a node.