Artificial Intelligence Fundamentals: Key Concepts
Minimax Search Algorithm for Two-Player Games
The Minimax algorithm is used in two-player zero-sum games (like chess or tic-tac-toe) to determine the optimal move for a player, assuming the opponent also plays optimally.
Minimax Algorithm Steps
- Input: Current game state (node), depth (how many moves ahead to consider), and whether it’s the maximizing or minimizing player’s turn.
- Check for Terminal State or Depth = 0: If the current state is a terminal state (game over) or the maximum search depth is reached, return the utility value of the current state.
- If Maximizing Player’s Turn:
- Initialize the best value to -∞.
- For each possible move (child of the current state):
- Recursively call Minimax for the minimizing player.
- Update the best value if the returned value is higher.
- Return the best value.
- If Minimizing Player’s Turn:
- Initialize the best value to +∞.
- For each possible move (child of the current state):
- Recursively call Minimax for the maximizing player.
- Update the best value if the returned value is lower.
- Return the best value.
Alpha-Beta Pruning: Performance Optimization
Alpha-Beta Pruning is an optimization technique for Minimax that eliminates branches that cannot possibly affect the final decision, significantly reducing the number of nodes explored.
- Alpha (α): The best value that the maximizing player can guarantee so far.
- Beta (β): The best value that the minimizing player can guarantee so far.
If at any point β ≤ α, the rest of the subtree is pruned (i.e., not explored), as it will not lead to a better outcome for the current player.
Game Theory Defined
Game Theory is a branch of mathematics and economics that studies strategic interactions among rational decision-makers. It provides models and tools to analyze situations where the outcome for each participant (or “player”) depends not only on their own actions but also on the actions of others.
Monte Carlo Tree Search (MCTS)
Monte Carlo Tree Search (MCTS) is a heuristic search algorithm used for decision-making in large and complex search spaces, especially in game-playing AI (like Go, Chess, and other board games). MCTS builds a search tree incrementally and uses random simulations (called playouts) to evaluate the potential of moves. It balances exploration of new moves and exploitation of known good moves using the Upper Confidence Bound for Trees (UCT) formula.
Four Main Steps of MCTS
- Selection: Starting from the root, select child nodes according to a policy (e.g., UCT) until a leaf node is reached.
- Expansion: Expand the leaf node by adding one or more child nodes.
- Simulation (Rollout): Perform a random playout from the new node to a terminal state.
- Backpropagation: Update the values of nodes on the path back to the root based on the simulation result.
Limitations of MCTS
- Computationally Expensive: Requires many simulations to provide reliable estimates, which can be slow in real-time or resource-constrained environments.
- Poor Performance in Deterministic or Simple Domains: Random simulations may be ineffective in some deterministic or simple games where strategic depth is more important.
- Bias in Rollouts: The quality of random simulations affects performance; naive rollouts may produce misleading results.
- Large Branching Factor Issues: In games or problems with extremely large branching factors, the tree can grow too large for practical exploration.
- Difficulty Handling Hidden Information: MCTS struggles with games involving imperfect or hidden information without modifications.
- No Guaranteed Optimality: MCTS is heuristic-based and may not always find the optimal move, especially with limited computation time.
Cutoff Procedure in Search Algorithms
The cutoff procedure is a technique used in search algorithms, especially in game tree search like Minimax, to limit the depth of the search to reduce computation time and resource usage.
Cutoff means stopping the expansion of nodes beyond a certain depth limit or other conditions instead of searching until terminal states. When the cutoff condition is met, the algorithm does not continue expanding the tree. Instead, it evaluates the current node using a heuristic evaluation function to estimate its value.
Cutoff Procedure Example: Tic-Tac-Toe
- Normally, Minimax would explore all moves until the end of the game.
- Suppose we set a cutoff depth of 2 plies (half-moves).
- When Minimax reaches depth 2, it will stop expanding further and use an evaluation function to score the board (e.g., number of possible winning lines).
- Based on these heuristic scores, Minimax will choose the best move without looking further.
Key Problem-Solving Strategies
Strategy | Description |
---|---|
Brute Force | Try all possible solutions; guarantees a result but often inefficient. |
Divide and Conquer | Divide problem into sub-problems, solve them recursively, and combine. |
Greedy Approach | Make the best choice at each step, hoping for a global optimum. |
Dynamic Programming | Store intermediate results to avoid redundant calculations. |
Backtracking | Try possible options, undo when stuck, and try the next. |
Recursion | Solve a problem by calling itself on sub-problems. |
Heuristic Search | Use rules of thumb (heuristics) to guide search (e.g., A*, Hill Climbing). |
Constraint Satisfaction | Solve by assigning values under given constraints (e.g., Sudoku, N-Queens). |
Simulation | Model the behavior and simulate different outcomes. |
Backtracking Algorithm
Backtracking is a general algorithmic technique for solving problems incrementally, by trying partial solutions and then abandoning them (“backtracking”) if they do not lead to a valid complete solution.
Features of Backtracking
- Recursive approach.
- Explores all possible configurations.
- Includes an “undo” step when a dead end is reached.
- Efficient for combinatorial problems, such as puzzles or constraint satisfaction.
Backtracking with the N-Queens Problem
The N-Queens problem involves placing N
queens on an N × N
chessboard so that no two queens attack each other (i.e., no two queens are in the same row, column, or diagonal).
Backtracking Approach for N-Queens
- Start in the first row.
- Try placing a queen in each column of the current row.
- After placing a queen, move to the next row and repeat.
- If a conflict is found (same column or diagonal), backtrack to the previous row and try the next column.
- Continue this until all queens are placed or no solution is possible in the current configuration.
Constraint Satisfaction Problem (CSP)
A Constraint Satisfaction Problem (CSP) is a type of problem in Artificial Intelligence (AI) and computer science where the goal is to find values for variables that satisfy a set of constraints.
CSP Definition Components
- Variables (X): A set of variables X = {X1, X2, …, Xn}.
- Domains (D): Each variable Xi has a domain Di, which is the set of possible values it can take. Example: Di = {1, 2, 3}.
- Constraints (C): A set of constraints C = {C1, C2, …, Cm} that restrict the values the variables can take. Each constraint involves one or more variables and specifies allowable combinations of values.
Example: Map Coloring Problem
- Variables: WA, NT, SA, Q, NSW, V, T (Australian states/territories).
- Domain: Each variable can take values {Red, Green, Blue}.
- Constraints: No two adjacent regions can have the same color. E.g., WA ≠ NT, SA ≠ WA, NT ≠ SA.
What is an AI Agent?
An agent is an entity that perceives its environment through sensors and acts upon that environment through actuators to achieve specific goals. It can be a software program, robot, or human being that performs actions based on observations.
Examples of AI Agents Around Us
- Autonomous Vacuum Cleaner (e.g., Roomba): Perceives room layout and cleans.
- Google Maps: Senses traffic data and suggests optimal routes.
- Thermostat: Senses temperature and adjusts heating or cooling.
- Chatbot: Understands queries and responds appropriately.
- Self-Driving Car: Perceives surroundings and drives accordingly.
Knowledge-Based Agents & Wumpus World
A Knowledge-Based Agent (KBA) uses logical reasoning and a knowledge base (KB) to make decisions.
Wumpus World Example
The Wumpus World is a grid-based environment used to demonstrate KBAs. Hazards include:
- Wumpus (monster)
- Pits
- Gold
The agent must use limited percepts (like breeze or stench) to infer safe paths.
How a KBA Works in Wumpus World
- The agent starts with some initial knowledge (e.g., breeze indicates a pit nearby).
- It adds new percepts as it explores.
- Uses inference rules to deduce which cells are safe.
- Chooses actions based on logical reasoning.
Example Rule: If there is a breeze in (1,1), then at least one adjacent cell has a pit: Breeze(1,1) → Pit(1,2) ∨ Pit(2,1)
Steps of the Knowledge Engineering Process
Knowledge Engineering is the process of building knowledge-based systems.
- Identify the Task: Define the problem the system will solve.
- Acquire Knowledge: Gather information from experts, documents, or databases.
- Represent Knowledge: Use formal languages (like predicate logic) to encode facts and rules.
- Implement Reasoning: Develop inference mechanisms to draw conclusions.
- Test and Refine: Evaluate the system’s performance and adjust knowledge and rules.
Propositional vs. First-Order Logic
Feature | Propositional Logic | Predicate Logic / First-Order Logic (FOL) |
---|---|---|
Basic Unit | Propositions (atomic statements) | Predicates with variables and quantifiers |
Expressiveness | Less expressive | More expressive |
Variables | Not used | Used (e.g., x , y ) |
Quantifiers | Not available | Available (∀ = for all, ∃ = there exists) |
Examples | P , Q , P ∧ Q → R | ∀x Human(x) → Mortal(x) |
Can express relationships? | No | Yes (e.g., Loves(John, Mary) ) |
Suitable for | Simple logical reasoning, Boolean logic | Complex reasoning about objects and their relationships |
Semantic Domain | True/False values of atomic propositions | Objects, properties, and relations |
Knowledge Representation | Limited, no internal structure | Rich structure, detailed modeling of real-world scenarios |
Alternative Names | Propositional calculus | Predicate logic, First-order logic |
Wumpus World Environment with PEAS Description
The Wumpus World is a simple grid-based world (typically 4×4) used in AI to demonstrate knowledge-based agents. The agent must navigate safely, find gold, and avoid dangers like the Wumpus (a monster) and pits.
Agent Percepts in Wumpus World
- Stench: Indicates a Wumpus is nearby.
- Breeze: Indicates a pit is nearby.
- Glitter: Gold is in the current cell.
- Bump: The agent ran into a wall.
- Scream: The Wumpus has been killed.
PEAS Description of Wumpus World Agent
- P (Performance Measure): Grab the gold, exit safely, minimize steps and risk.
- E (Environment): 4×4 grid with Wumpus, pits, walls, and gold.
- A (Actuators): Move forward, turn left/right, grab, shoot, climb.
- S (Sensors): Stench, Breeze, Glitter, Bump, Scream.
Inference Rules in First-Order Logic (FOL)
Rule | Description | Example |
---|---|---|
Modus Ponens | If P → Q and P , then infer Q | Man(Socrates) → Mortal(Socrates) , Man(Socrates) ⟹ Mortal(Socrates) |
Universal Instantiation (UI) | From ∀x P(x) infer P(a) for any constant a | ∀x Animal(x) → Mortal(x) ⟹ Animal(Dog) → Mortal(Dog) |
Existential Instantiation (EI) | From ∃x P(x) infer P(c) for some new constant c | ∃x Loves(x, Juliet) ⟹ Loves(Romeo, Juliet) |
Resolution | Combine two clauses to eliminate a literal | From P ∨ Q and ¬Q ∨ R ⟹ P ∨ R |
Unification | Match variables to apply inference rules | From Loves(x, y) and Loves(John, y) ⟹ match x = John |
Types of Planning in Artificial Intelligence
Planning is a fundamental aspect of AI where an agent decides what actions to take and in what order to achieve specific goals. Planning systems use models of the world, actions, and goals to generate sequences of actions.
Classical Planning
Works in static environments. Example: STRIPS (Stanford Research Institute Problem Solver). Application: Puzzle solving, game logic.
Conditional Planning
Plans include conditions and branches, containing “if-then” rules to handle different outcomes. Example: If door is locked, try key A; else, try key B. Application: Robotics, adaptive systems.
Contingency Planning
Prepares for unexpected situations by including alternatives. Handles incomplete knowledge or uncertainty. Application: Space missions, disaster management.
Hierarchical Planning (HTN – Hierarchical Task Network)
Breaks goals into sub-goals or tasks using a top-down approach. Example: “Plan a wedding” → book venue, invite guests, arrange catering. Application: Project planning, complex systems.
Probabilistic Planning
Deals with uncertain outcomes using probabilities. Actions have multiple possible results, each with a probability. Application: Autonomous vehicles, financial decision-making.
Strategic vs. Tactical Planning
- Strategic Planning: Long-term, high-level goals (e.g., explore Mars).
- Tactical Planning: Short-term, specific steps (e.g., charge battery, move rover 2 meters).
Core Components of Artificial Intelligence
AI systems are built from various components that allow them to perceive, reason, act, and learn. Here’s a breakdown of the core components:
Learning
Definition: The ability of an AI system to learn from data and improve performance over time.
Types:
- Supervised Learning: Learns from labeled data.
- Unsupervised Learning: Learns patterns from unlabeled data.
Reasoning
Definition: Drawing logical conclusions based on available knowledge.
Types:
- Deductive Reasoning: From general rules to specific cases.
- Inductive Reasoning: From specific cases to general rules.
Problem Solving
Definition: Finding a sequence of actions that leads from a start state to a goal state.
Includes: Search algorithms, planning techniques, and heuristics. Example: Solving a maze, pathfinding in games.
Perception
Definition: Gathering data from the environment using sensors. Example: Vision (image recognition), speech recognition, sensor data.
Language Understanding (NLP)
Definition: The ability to understand, interpret, and generate human language.
Subfields:
- Syntax analysis
- Semantic analysis
- Machine translation
Applications: Chatbots, voice assistants, translation systems.
Action (Actuation)
Definition: Acting upon the environment using effectors. Example: A robot moving its arm, a car turning left. Tools: Motors, actuators, display systems.
AI System Architecture
AI architecture defines the framework or structure that integrates the above components to create an intelligent system.
Perception Layer
Gathers input from the environment. Devices: Cameras, microphones, sensors. Converts raw data to structured data.
Knowledge Base
Stores facts, rules, and world models. Used by the reasoning engine to make decisions.
Inference Engine / Reasoning Layer
Applies logic and inference rules to derive conclusions. Example: Rule-based systems, expert systems.
Learning Component
Updates the knowledge base based on new data. Machine learning algorithms are used here.
Planning and Decision-Making Layer
Selects actions based on goals, constraints, and environment. Includes: Planning algorithms, search strategies.
Action/Execution Layer
Converts decisions into real-world actions. Uses effectors like motors, displays, speakers.
User Interface
Communicates with the user via GUI, voice, or text.
Problem Solving vs. Planning in AI
Aspect | Problem Solving | Planning |
---|---|---|
Definition | A general approach to finding a solution path to reach a goal from an initial state. | The process of generating a sequence of actions using domain knowledge to achieve specific goals. |
Goal | Find a path or series of steps to a goal. | Generate a valid action sequence (plan). |
Knowledge Used | Less domain-specific knowledge; often uses search strategies (e.g., DFS, BFS). | Requires detailed domain models: preconditions and effects of actions. |
Focus | Solving specific tasks (e.g., puzzles, games). | Organizing tasks and actions logically. |
Method Used | Search-based (state space search). | Planning-based (e.g., STRIPS, PDDL). |
Example Domains | Mazes, pathfinding, game solving. | Robotics, workflow automation, logistics. |
AI Reasoning Methods: Chaining
Forward Chaining
Forward Chaining is a data-driven reasoning method. It starts from known facts and applies rules to infer new facts until the goal is reached.
How Forward Chaining Works
- Begin with the initial facts.
- Apply rules whose conditions match the current facts.
- Add new facts to the knowledge base.
- Repeat until the goal is derived or no new facts can be added.
Example:
Rules: IF A THEN B. IF B AND C THEN D.
Facts: A, C.
Inference: A → B → (B and C) → D
Property | Description |
---|---|
Direction | Data → Goal |
Trigger | New data/facts |
Control Strategy | Breadth-first or conflict resolution |
Termination | When no new facts are derived or goal is found |
Advantages of Forward Chaining
- Good for exploration and discovering all consequences.
- Useful when all data is known at the start.
- Helpful in real-time systems (e.g., monitoring).
Disadvantages of Forward Chaining
- Can produce irrelevant conclusions.
- May explore many unnecessary paths.
- Less efficient when the goal is specific.
Backward Chaining
Backward Chaining is a goal-driven reasoning method. It starts with the goal and works backward to see if known facts support it.
How Backward Chaining Works
- Begin with a goal to prove.
- Look for rules where the conclusion matches the goal.
- Recursively try to prove the antecedents (conditions).
- If all sub-goals are true, the main goal is proven.
Example:
Goal: Prove D
Rules: IF B AND C THEN D. IF A THEN B
Facts: A, C.
Reasoning: Need B and C → A gives B → C is known → D is proven
Property | Description |
---|---|
Direction | Goal → Data |
Trigger | Query or goal |
Control Strategy | Depth-first (typically) |
Termination | When goal is proved or disproved |
Advantages of Backward Chaining
- Efficient when the goal is known.
- Avoids irrelevant rules and paths.
- Ideal for decision-making systems (e.g., diagnosis).
Disadvantages of Backward Chaining
- Can be inefficient if many sub-goals or deep chains exist.
- May get stuck if not all facts are known.
Ontological Engineering
Ontological Engineering is the study and development of ontologies, which are formal representations of knowledge within a particular domain. It provides a structured framework for defining the concepts, relationships, and rules that exist in that domain.
In AI, ontologies help machines to:
- Understand domain knowledge.
- Enable semantic reasoning.
- Facilitate data sharing and reuse.
What is an Ontology?
An ontology is a specification of:
- Concepts (e.g., Person, Car, Disease)
- Relationships (e.g., hasPart, isA)
- Properties/Attributes (e.g., name, color)
- Rules/Constraints (e.g., “Every car must have wheels”)
Example: In a medical ontology:
- Concept: “Disease”
- Property: “hasSymptom”
- Relationship: “isTreatedBy”
Type | Description | Example |
---|---|---|
Top-level (Upper) Ontology | Describes very general concepts that are common across all domains | Entity, Object, Event |
Domain Ontology | Describes concepts in a specific domain | Medical, Legal, Financial |
Task Ontology | Describes concepts related to specific tasks or processes | Diagnosis, Scheduling |
Application Ontology | Tailored for specific applications | Ontology for a hospital management system |
Planning in Non-Deterministic Domains
In non-deterministic domains, actions may have multiple possible outcomes, and the environment may change unpredictably. Planning must account for uncertainty and partial observability. Plans include contingencies: different branches based on possible outcomes. This often uses conditional or contingency planning, which plans for various eventualities. Example: A robot navigating a slippery floor where movement can fail; it must have backup plans.
Importance of Planning in AI
- Enables autonomous decision-making.
- Helps in efficient resource management.
- Supports complex tasks by breaking them into manageable steps.
- Facilitates anticipation of future events and handling uncertainties.
- Essential for goal-directed behavior in robots, software agents, and logistics.
Algorithm for Classical Planning (STRIPS-like)
- Initialize: Set initial state
S0
. - Goal Test: Check if the current state satisfies the goal; if yes, stop.
- Select Actions: Choose actions whose preconditions are met in the current state.
- Apply Actions: Generate new states by applying chosen actions.
- Search: Use search (e.g., forward search, backward search) through states to find a sequence of actions leading to the goal.
- Return Plan: The sequence of actions from the initial to the goal state.
Limits and Future Opportunities of AI
Limits of AI
- Lack of Common Sense: AI struggles with understanding context like humans.
- Uncertainty and Ambiguity: Difficulty in dealing with incomplete or noisy data.
- Ethical Issues: Bias, privacy concerns, decision accountability.
- Computation Limits: Some problems are too complex (NP-hard).
- Dependency on Data: AI quality depends on the quantity and quality of data.
Future Opportunities with AI
- Explainable AI (XAI): Improving transparency and trust in AI decisions.
- General AI (AGI): Developing AI that can learn across diverse domains.
- Healthcare: Personalized medicine and diagnostics.
- Autonomous Vehicles: Safer and more efficient transport.
- Smart Environments: Integration with IoT and smart cities.
- Collaboration: AI-human teaming to augment human abilities.
Knowledge Representation Structures
Knowledge Representation (KR) is how an AI system organizes and stores knowledge about the world so that it can be used for reasoning, learning, and decision-making.
KR Structure | Description | Example |
---|---|---|
Logical Representation | Uses formal logic (propositional, predicate logic) to represent facts and rules. Enables precise inference. | “All humans are mortal.” |
Semantic Networks | Graph-based structures representing concepts (nodes) and relationships (edges). | “Bird” → “is a” → “Animal” |
Frames (or Schemas) | Data structures representing stereotypical situations with slots (attributes) and values. | Frame for “Car” with slots like color, engine type. |
Production Rules | “If-Then” rules that specify actions based on conditions. Widely used in expert systems. | IF temperature > 100 THEN alarm = ON |
Ontologies | Formal explicit specifications of a shared conceptualization, defining concepts, relations, and constraints. | Medical ontology defining diseases and symptoms. |
Scripts | Represent sequences of events in stereotyped situations, like a story or procedure. | Script for “going to a restaurant.” |
Unification in AI
Unification is a fundamental process in AI, especially in logic programming and automated reasoning. It is the process of finding a substitution that makes two logical expressions identical. The goal is to find a most general unifier (MGU) — the simplest substitution that makes the expressions equal. Unification is used in predicate logic inference, Prolog programming, and theorem proving.
Steps of the Unification Algorithm
- Initialize the set of substitutions θ to empty.
- Compare the two expressions:
- If they are identical constants or variables, no substitution is needed.
- If one is a variable and the other is a term, substitute the variable.
- If both are compound terms (functions), recursively unify their arguments.
- Check for Conflicts: A variable cannot be substituted with a term containing that same variable (occurs check). If a conflict occurs, unification fails.
- Return the set of substitutions (MGU) if successful.
First-Order Logic (FOL)
First-Order Logic (FOL) is a powerful formal language used to represent knowledge with objects, relations, functions, and quantification. It extends propositional logic by adding quantifiers and predicates.
Symbol Type | Description | Examples |
---|---|---|
Constants | Names of specific objects | a , b , John |
Variables | Symbols representing arbitrary objects | x , y , z |
Predicates | Relations or properties applied to objects | Loves(x, y) , Parent(x) |
Functions | Map objects to objects | FatherOf(x) , Plus(x,y) |
Connectives | Logical connectives | ¬ (not), ∧ (and), ∨ (or), → (implies), ↔ (iff) |
Quantifiers | Universal and existential quantification | ∀ (for all), ∃ (there exists) |
Parentheses | Grouping symbols | ( ) |