Skip to main content
Artificial Computational Intelligence

Knowledge Representation Using Logics

Published: 2026-08-13
Level: postgraduate
Audience: Postgraduate students in Artificial Computational Intelligence

Prerequisite Knowledge

This lecture builds on the following concepts from earlier lectures. If any feel unfamiliar, review the linked notes before proceeding.

Previously Covered in This Subject

  • Acting rationally: rational agents — covered in Lecture 1 (agent types and the rational-agent view, which knowledge-based agents extend)
  • What is intelligence? — covered in Lecture 1 (the debate this lecture returns to when asking whether logical deduction is really intelligence)

Knowledge Representation Using Logics

The first half of the course dealt with problem solving — search techniques, informed and uninformed search, evolution and genetic algorithms, game playing and adversarial search. This module shifts gears into the computational side: how an agent stores knowledge, how it derives new knowledge from what it already has, how multiple agents work together, and how probability fits in. The plan for the remaining classes: logic for today and the next class, then multi-agent systems, then probability and reasoning over time, and the course closes with AI ethics in the final class. Today and next class form one combined agenda: we look at a sample agent and why logic is needed, then inference using truth tables, inference using resolution by contradiction, and predicate logic in the next class.

9.1 Knowledge-Based Agents

9.1.1 What an Agent Knows and How It Knows It

Hook — a search agent cannot answer this question. A route-finding agent can hand you the shortest path between two cities. But ask it "can a road be a negative number of kilometers long?" and it has no idea — nothing in its search tree tells it that fact. Knowledge representation is the missing piece: giving an agent a body of facts and general rules it can reason over, not just a tree of states to explore.

So far in the course, nothing was said about what knowledge an agent has, how that knowledge is stored, or how it is inferred. The search algorithms assumed a tree or a game state exists in memory, and that was the end of it. A knowledge-based agent works differently: it solves problems by representing knowledge in a state space, reasoning about the solution, and revising what it knows as it goes.

The central component of such an agent is its knowledge base (KB for short). The central question of this module is knowledge representation: how an agent stores what it knows in a form it can later reason over.

The three building blocks of a knowledge base.

  • A sentence is the technical unit of knowledge: a statement in a knowledge representation language that asserts something about the world. These are not English sentences — they are written in a formal language the agent can process mechanically.
  • A knowledge representation language is the formal language the sentences are written in. It has fixed syntax (which strings count as sentences) and fixed semantics (what each sentence means).
  • An axiom is a sentence that is taken as given, without being derived from other sentences. It is the starting point — a fact the agent was told, or a general rule of the environment, rather than a conclusion the agent reached.

Think of the KB as an agent's filing cabinet. Each drawer is a sentence written in the representation language. The agent's whole job is: file new sheets (what it perceives), pull sheets out (what it wants to know), and draw new sheets from old ones (inference). Everything that follows in this lecture — Wumpus World, propositional logic, truth tables, equivalences — builds this cabinet and the rules for working with it.

How does this differ from the search agents of the earlier classes? A problem-solving agent knows what actions are available and what each action does, but it knows no general facts: an 8-puzzle agent does not know that two tiles cannot occupy the same square. That knowledge lives in the designer, not in the agent. A knowledge-based agent, by contrast, stores general rules and facts as sentences, and can combine and recombine them to serve purposes it was never explicitly programmed for — exactly what a human does when they reason from what they know.

Assumptions & scope.

  • The KB is a set of sentences, but the set only helps if the inference rules used on it are sound — an answer drawn from the KB should follow from what was told to it. The KB must not "make things up" as it goes along.
  • A sentence is a representation of the world, not the world itself. The knowledge is only as good as the language it is written in: propositional logic (this lecture's language) cannot express "for all cells…" — that needs first-order logic, a later topic.
  • Sentences are static once added. This is monotonic reasoning: adding a new sentence can only add new conclusions, never withdraw old ones. This holds throughout the logic module.

Pitfalls.

  • Treating English sentences and logic sentences as the same thing. English is ambiguous ("bank", "and then"); a representation language is designed to have exactly one meaning per sentence.
  • Confusing axiom with derived sentence. An axiom is given; a derived sentence is the result of inference. The distinction matters because only axioms can be wrong when the world disagrees.
  • Thinking the KB needs to mirror every detail of the world. It holds only what the agent was told or perceived — partial knowledge is the normal case, and reasoning with partial knowledge is the whole point.

Real-world: today's modern agent loops — the kind that carry a context, update a memory, and reason over it — still rest on this same rudimentary core: storing knowledge and inferring from stored knowledge. What we study here is the very basic foundation of how knowledge systems work. The names change (context windows, memory banks), the loop does not: keep a body of knowledge, add to it, ask it questions, act on the answers.

Recap. A knowledge-based agent is built around a knowledge base: a set of sentences in a formal representation language, some of them given (axioms), others derived by inference. The rest of this lecture makes that abstract idea concrete — first with a game, then with a logic.

9.1.2 The Knowledge Base: Tell, Ask, and Update

Every time a knowledge-based agent is invoked, it does one of three things: it can tell, it can ask, or it can update.

The tell / ask / update cycle.

  • Purpose. The agent needs a fixed interface between its sensors and actuators on one side and its reasoning core on the other. Tell, ask, and update are that interface — three operations that work on the same knowledge base.
  • Inputs. A percept (a sensor reading, e.g., "breeze in this cell"), an action query (a question about what to do next), or new knowledge (a recently learned fact or rule).
  • Outputs. An updated KB (after tell or update) or an action recommendation (after ask).

The steps:

  1. Tell — the agent reports what it just perceived to the knowledge base. Its percepts get added as new sentences. For example, standing in cell (1,1) and feeling nothing, the agent TELLs the KB: "there is no stench, no breeze, no glitter here."
  2. Ask — the agent asks the knowledge base which action it should perform. The KB is queried, the question is answered from the sentences it holds, and the answer determines what the agent does.
  3. Update — the agent adds something it has recently come across to its knowledge base — a deduction it made, or a fact it learned — so the KB grows richer with every step.

In the standard loop, the agent performs these in order every cycle: TELL what it perceives, ASK what to do, then TELL which action it took, and repeat.

Trace — one cycle of the loop, with real content.

Take a Wumpus-World agent standing in cell (1,1) that has just perceived nothing at all.

  1. TELL — the agent adds a percept sentence to the KB: "In (1,1) there is no stench, no breeze, no glitter."
  2. ASK — the agent asks the KB: "Which action should I perform next?" The KB answers from its sentences: the no-breeze fact, combined with the general rule "breeze means an adjacent pit", lets the agent conclude that cells (2,1) and (1,2) have no pit and no wumpus — they are safe. The answer that comes back: "Move to (2,1), or move to (1,2) — both are safe."
  3. Tell (action) — the agent moves to (2,1) and TELLs the KB that it performed that action, then the cycle starts again with the new percept at (2,1).

Every cycle adds at least one sentence, so the KB gets richer, and the answers it gives get sharper. That is the entire engine of a knowledge-based agent.

The same interface, from a database point of view: if you have worked with databases, this is similar to CRUD operations — create, read, update, delete. The tell/ask/update cycle is the logical cousin of that pattern. In your databases course the operations are about records; here they are about sentences of knowledge.

Knowledge-based agent Database equivalent What it does
Tell Create / Insert Adds a new sentence (a percept or fact)
Ask Read / Query Retrieves an answer from what is stored
Update Update Adds newly learned knowledge
— (built into the others) Delete The KB never deletes — reasoning is monotonic

When the loop breaks.

  • Ask before Tell: if the agent asks before reporting its percepts, the answer misses the latest evidence — the agent reasons on stale knowledge.
  • Garbage in, garbage out: if a tell adds a sentence that contradicts existing ones, the KB becomes inconsistent and every subsequent answer is suspect. Good knowledge-based systems check new sentences against the old ones.
  • The frame problem of scale: a KB that grows without bound slows every ask. Real systems (and the truth-table method later in this lecture) hit this wall — which is why inference design, not storage, is the hard part.

9.1.3 Knowledge-Based Agents vs Learning Agents

How is this different from a learning agent? At the end of the day, every learning agent — whatever loop or architecture it uses — fundamentally has to store some data, and from that stored data it has to infer something. If you agree with that, then this is exactly what we are looking at: how knowledge is stored and how it is inferred. Today's loop-based agents and knowledge systems are way, way ahead of this, but viewed from the right angle, all of them rely on these fundamentals.

Dimension Knowledge-based agent Learning agent
Source of knowledge Told by a designer, or perceived (TELL / ASK / UPDATE) Extracted from data by a training process
Core mechanism Explicit sentences + inference rules Stored parameters + a learned function
Can it explain itself? Yes — it can show the sentences that led to a conclusion Usually no — the reasoning is buried in weights
What updates Sentences added to the KB Parameters adjusted by training
Shared foundation Both store something and infer from the stored thing Both store something and infer from the stored thing

The lesson: the learning-versus-knowledge divide is smaller than it looks. A learning agent is, at its core, a knowledge-based agent whose sentences (or parameters) were learned from data instead of being written by a designer. The lecture's point is that the storage-and-inference fundamentals are common to both.

Exam note: this links back to the second class, where the different types of agents were introduced — reflexive agents, simple agents, and knowledge-based agents, which solve problems by representing knowledge in state space and reasoning about the solution. When you revise agent types, place this lecture's KB machinery under the knowledge-based type.

9.1.4 Prolog: A Language for Logic

You can build knowledge-based systems in higher-level languages like Python or Java, but it is not comfortable: you would spend most of your time writing the inference machinery yourself. There is a separate language built exactly for this: Prolog.

What Prolog gives you.

  • Purpose. A language where you write the knowledge base directly and let the language's built-in inference engine do the asking.
  • Inputs. Sentences of the knowledge base written as Prolog facts and rules — statements connected with and, or, and implies, exactly the connectives of this lecture. A query, phrased as a question to the program.
  • Outputs. Whether the query follows from the sentences — yes or no, plus the variable bindings that make it true, if any.
  • Why it exists. Inference is hard to build correctly. Prolog packages it, so a knowledge engineer writes only the knowledge.

It is a very simple language, almost like a Boolean language — you write some sentences using and, or, and so on, and you get output. The program's job is to chain through the sentences you wrote and answer whether your question is entailed by them.

Real-world: Prolog is a logic programming language, and in one of the upcoming webinars you will learn it, and in some assignments you will also do that. You can download it and run it in a command line. After this lecture's logic topics, the Webinar and the Prolog exercises will feel familiar: the entailment checks you will watch the program perform are exactly the entailment checks defined later in this lecture — modus ponens, modus tollens, and-elimination — running inside a machine.

Recap. The tell/ask/update loop is the skeleton of every knowledge-based agent, and Prolog is the ready-made skeleton for building them. The rest of the lecture fills in the muscle: what the sentences look like (logic), what "asking" means (entailment), and how answers are computed (inference).

9.2 The Wumpus World

9.2.1 The Setup: Grid, Pit, Wumpus, and Gold

Hook — can an agent know what it has not seen? A 4×4 cave, one monster, a few pits, a heap of gold — and an agent that must reach the gold without ever seeing the whole board. The question this module answers: how much can the agent deduce about the hidden cells before stepping into them?

The problem used to understand logic in this class is a small game: a 4 × 4 grid with a few elements in it. There is a start cell — this is where the agent is. There is a pit — actually there can be several pits, placed anywhere. There is a wumpus — the wumpus is like a devil — sitting somewhere. And there is gold. The aim: the agent must reach the gold and pick it up. The agent starts at cell (1,1), facing right. The grid is the setup for every example that follows, and the setup varies from game to game: in one configuration the pits are in these locations, the wumpus there, the gold here; in another configuration everything is somewhere else.

Three rules define the danger:

  • If the agent enters a pit cell, it falls and dies.
  • If it enters the wumpus cell, the wumpus eats it — the agent dies.
  • The gold: the agent wants to grab it, and grabbing it (then climbing out) is the win condition.

The pit, the wumpus, and the gold are static — they do not move while the agent moves. This is not Pacman; the enemies do not play back. Only the agent navigates, from the start, and it must find its way without getting killed.

The goal is not grabbing the gold. The goal statement is very important: discover the location of the wumpus, the pits, and the gold, so that the agent can navigate to the gold without falling prey to the wumpus or the pits. The goal is not just to grab the gold — it is first to figure out, using perception and knowledge, where the wumpus is and where the pits are. That is what this whole module is about. We are not really interested in reaching the goal or in rewards — that is the search problem from before. Here, in every cell, the question is: are you able to reason and deduce some things? The agent's knowledge for transition requires a configuration of the environment in order to do logical reasoning.

The performance measure, using the PEAS ideas from the earlier classes:

  • +1000 if the agent gets the gold.
  • −1000 if it dies — meaning it falls in a pit or is eaten by the wumpus.
  • −1 (or +1, your choice) for each action taken, because walking each cell costs energy.
  • −10 for using the arrow — but the arrow variant is not covered in this discussion.

The arrow concept exists in the game: the agent has only one arrow, and it can shoot it; if the wumpus is in the next room the wumpus gets killed, but if the wumpus is not there the arrow just hits the wall or falls into a pit and is wasted. That arrow part is a variant we do not discuss further.

9.2.2 Percepts and Sensors

Wherever there is a pit, the four cells around it — above, below, left, and right — have breeze. There is a hole dug out of the ground, so in the adjacent cells you feel the breeze. Wherever the wumpus is, the four cells around it — above, below, left, and right — have stench, a bad smell. Gold glitters, but only in its own cell — the shine does not radiate to other rooms. Two more percepts: bump, when the agent walks onto a wall and cannot go further; and scream, when the wumpus is killed — the scream is perceived everywhere in the cave.

The five sensors and what they report.

  • Stench — there is a wumpus in a directly adjacent cell (not diagonal).
  • Breeze — there is a pit in a directly adjacent cell.
  • Glitter — the gold is in the same cell the agent is standing in.
  • Bump — the agent walked into a wall.
  • Scream — the wumpus died; audible from anywhere in the cave.

A percept sequence can be written as a tuple with a question mark for each sensation — the agent answers each sensor in turn:

For example, standing in cell (1,1) the agent answers each: am I getting stench? no. Am I getting breeze? no. Glitter? I see none here. Bump? no. Scream? no. That "none, none, none, none, none" percept — the OK percept — is the single piece of evidence the whole first example is built on.

There is exactly one wumpus and exactly one gold, but there can be many pits. There are no false alerts in this environment — it is a standard problem, the sensors and percepts are always correct. A smell always means a real wumpus nearby, and a breeze always means a real pit nearby; the agent never has to second-guess its sensors.

9.2.3 Actuators, Rewards, and the Arrow

The actuators — the actions available to the agent.

  • Go forward — move one cell in the direction the agent faces.
  • Turn left — rotate 90 degrees counterclockwise, without moving.
  • Turn right — rotate 90 degrees clockwise, without moving.
  • Grab — pick up the gold if it is present in the current cell.
  • Shoot — fire the arrow in the direction the agent faces (only if it still has the arrow).
  • Climb — leave the cave, possible when the agent is at the start cell.

In terms of a body, the actuators are the hand and the legs — forward, backward, turning left and right are all done with hands and legs.

Since the agent starts at (1,1) facing right, it cannot go left at the start; from (1,1) it can only move right or up. That one constraint matters for the first deductions: the two cells the agent can reach are (2,1) to the right and (1,2) above — and those are exactly the two cells the OK percept will first rule out as dangerous.

9.2.4 Environment Characteristics

Classifying the Wumpus World with the properties from the early classes:

Property Value Why
Fully observable? No — partially observable. The agent knows only the cell it is in. In that cell it can perceive stench, breeze, and so on, but it does not know the full board configuration. Percepts are only local.
Deterministic? Yes. Outcomes are exactly specified: enter a pit — you fall; enter the wumpus cell — you get eaten; enter the gold cell — you pick it up.
Episodic or sequential? Sequential. The actions affect the next actions — where you are determines what you can perceive and where you can go next. Rewards may also come only after many actions.
Static or dynamic? Static. The pits do not move, the wumpus does not move, the gold does not move. Only the agent moves.
Discrete? Yes. It is a grid-based problem with a finite number of states and steps.
Single agent? Yes. The wumpus is not considered an agent here — it is more like a natural phenomenon, a bad thing waiting in its cell to kill you. You could also model it as another agent if you want, but in this problem it is treated as part of the environment.

The sequential and partially observable entries are the two that make this problem interesting: because the world is sequential, today's moves decide tomorrow's percepts, and because it is partially observable, the agent must infer the hidden board from the local percepts it collects along the way.

9.2.5 The Symbol Legend

All the diagrams in the rest of the module use a fixed set of symbols — the legend that lets you read a board diagram at a glance:

Symbol Meaning
A The agent
B Breeze
G Glitter (the gold)
OK Safe state — no danger near you: no stench and no breeze, which means none of the adjacent cells (top, bottom, left, right) has a wumpus or a pit
P Pit
S Stench
V Visited
W Wumpus

Pictures that also appear on the diagrams: P? means "a pit is possible here" (one of the suspect cells) and W! means "the wumpus is definitely here" (deduced, not perceived).

To read such a diagram: picture the board as a grid of squares, rows numbered 1 to 4 from bottom to top and columns numbered 1 to 4 from left to right, with the start square (1,1) in the bottom-left corner. In each square the diagram marks what the agent knows — a visited square carries its symbol (A, OK, V, B, S, G), an inferred square carries P? or W! — and the unmarked squares are simply unknown. The story of every diagram is the same: a spread of known symbols in the visited region, question marks where inference is still undecided, and a clear safe corridor toward the gold.

9.2.6 General Rules for Pits and Wumpus

Starting from the given knowledge of the game, we write generic statements that hold for any cell . The first statement: if there is a pit in cell , then you will feel breeze in the cell to its right, the cell to its left, the cell above it, and the cell below it. Written as logic:

Rule set 1 — pit and wumpus spread their warning to the four neighbors.

Read this as: "if there is a pit in some cell , then there is breeze in the cell at " — one column to the right — "and in " — one column to the left — "and in " — one row up — "and in " — one row down. The same shape holds for the wumpus: if the wumpus is in cell , stench will be in the four cells around it:

Each symbol names one fact about the world: is true when cell contains a pit; is true when the agent perceives breeze there; and mean the same for the monster and its smell.

Now comes the interesting direction. If I see breeze at , where could the pit be? It could be to the right, to the left, above, or below — any one of the four adjacent cells. I cannot put an "and" here, because I do not know which one it is; I must put an "or":

And the same for stench: if I see stench at , the wumpus is in at least one of the four adjacent cells:

The "and" versus "or" distinction is the heart of these rules. "And" means certainty: if there is a pit here, then definitely, in all four cells, there is breeze. "Or" means uncertainty: if there is breeze, I am not sure where the pit is — definitely among those four cells someone is a pit, and there could be more pits too. The "or" is why the diagrams carry question marks: I know a pit is adjacent, but I do not know which cell.

All of these facts can be negated as well. If I do not find a pit, there is no breeze in its adjacent cells; if I do not find a wumpus, the four sides do not have stench. So:

No stench at means there is no wumpus in any adjacent cell, and no breeze at means there is no pit in any adjacent cell. This absence direction is what makes an OK percept so valuable: one cell with no percept clears all of its neighbors.

Assumptions & scope of the rules.

  • Adjacency is side-to-side, not diagonal. The rules cover exactly four cells — right, left, up, down. A pit at a diagonal never produces breeze.
  • Cells outside the grid do not exist. If is a wall, that cell simply does not exist — you are bumping onto the wall, there is nothing there, and there is no breeze or stench from a nonexistent cell. The or-forms over four cells quietly shrink to two or three real candidates at the edges.
  • Dead wumpus, no stench. If the wumpus is killed, the stench is gone: bury him in the pit and there is no smell. The rules describe the live game.
  • The rules are biconditional in spirit but directional in use. The forward form (pit ⇒ breeze in all four) and the reverse or-form (breeze ⇒ pit in at least one of four) together capture "breeze if and only if a pit is adjacent" — the exact equivalence that the knowledge base in section 9.5 will write as .

9.2.7 Worked Reasoning Example 1: The Numbered Grid

The first configuration has numbered cells, so every deduction can be followed precisely.

Worked Example — the OK start, the breeze detour, and the cornered wumpus.

Step 1 — the initial percept at (1,1). The agent starts at (1,1) and its percept is OK: none, none, none, none, none — no stench, no breeze, no glitter, no bump, no scream. From the OK state we can immediately write down what the cell itself is not:

That was done with zero actions — just standing in (1,1) and perceiving OK. Now the more valuable step: use the general rules backwards. If there is no stench in (1,1), then none of the adjacent cells has a wumpus. If there is no breeze in (1,1), then none of the adjacent cells has a pit. The adjacent cells of (1,1) are (2,1) and (1,2). So:

From this alone, (2,1) and (1,2) become OK states: standing in (1,1), the agent already knows those two cells are safe — no wumpus, no pit. That is the game beginning: the agent can go either to (1,2) or to (2,1). Both are equally possible; this example goes to (2,1) first.

Step 2 — (2,1): breeze. The agent moves forward to (2,1) and perceives breeze. If there is breeze, there is a pit adjacent: at (3,1), at (2,2), or at (1,1). But (1,1) is where the agent came from — it was OK, so there cannot be a pit there. That leaves two suspects: the pit is either at (3,1) or at (2,2). The agent does not know which — so the question mark sits over each in the diagram. At this point two options exist: risk, and walk into one of the suspect cells (if the pit is not there, the agent survives — it is risking), or backtrack. We do not want to risk, so the agent backtracks to (1,1) and moves to (1,2) instead. This is why the earlier choice of (2,1) over (1,2) did not matter in the end — the breeze at (2,1) changed the plan, and the agent retraced its steps.

Step 3 — (1,2): stench, but no breeze. In (1,2) the agent perceives stench and nothing else. Stench means the wumpus is adjacent: at (1,1), at (2,2), or at (1,3). The agent came from (1,1), so no wumpus there. Now the beautiful argument: if the wumpus were at (2,2), there would have been stench in all four cells around (2,2) — (2,1), (2,3), (1,2), and (3,2). But when the agent visited (2,1) moments earlier, it perceived only breeze — no stench. So the wumpus is not at (2,2), and so it is at (1,3).

The same elimination corners the pit. Earlier the pit was at (3,1) or (2,2). If the pit were at (2,2), there would be breeze in the cells around it — including (1,2), where the agent is standing now. But there is no breeze at (1,2). So there is no pit at (2,2), and so the pit is at (3,1). Both are now cornered: (3,1) is a pit, (1,3) is the wumpus.

The verdict. Two moves, two percepts, and the agent has located both the pit and the wumpus — that is logic. And (2,2) is safe: it is not the wumpus cell (eliminated by the missing stench at (2,1)) and it is not a pit (eliminated by the missing breeze at (1,2)). So the next move is: go to (2,2), and continue the problem from there.

Sense-check. Every step was forced: no percept at (1,1) cleared two neighbors; the breeze at (2,1) narrowed the pit to two cells; the stench plus the remembered no-stench at (2,1) pinned the wumpus; the remembered no-breeze at (1,2) pinned the pit. Nothing was guessed — every conclusion follows from percepts the agent actually recorded.

The agent keeps all of this in memory as a percept vector — one entry per visited cell: at (1,1) it was OK, at (2,1) it felt breeze, at (1,2) it felt stench. That vector is its knowledge base, and it can consult it on every move. Notice what made the (2,2) deduction possible: the agent remembered what it did not perceive in earlier cells — the absence of stench at (2,1) and the absence of breeze at (1,2). A knowledge base that stored only positive percepts could never have done this.

9.2.8 Worked Reasoning Example 2: The Lean Grid

The second problem is the same Wumpus World but with no cell numbers — a leaner diagram, the kind you should be able to read directly from the symbols. The reasoning is identical, so we track it in relative terms: up, right, below, above.

Worked Example — the lean grid: OK start, breeze above, stench on the right, gold with both.

The agent is told it is in an OK state at the start cell. From that single fact it knows: no pit and no wumpus in any adjacent cell. It can go up or right; this example goes up. The moment it lands in the upper cell, it perceives breeze. Where are the pits? The pit could be in the cell below — but that is where the agent came from, so not there. The pit can be here (above) or here (to the right). Two options, question marks over both. But a new inference falls out: if there were a pit in the start cell's right neighbor, the agent would have felt breeze in the start cell too — and the start cell was OK. That eliminates one more cell. The key eliminations are: no pit below (came from there), and the third adjacent cell is cleared by the OK start.

The agent backtracks to the start and goes right instead. In this cell it perceives stench — and, importantly, no breeze. No breeze eliminates the pit: if the pit had been in the upper-right cell, the agent would have felt breeze both in the upper cell (where it first felt breeze) and here. It felt no breeze here, so there is no pit in the upper-right cell. The pit that caused the breeze must be in the upper-upper cell. But now there is a newer problem: stench here means a wumpus is adjacent — one of the neighboring cells — but not the start cell, since that is where the agent came from. So the wumpus is in one of the two remaining neighbors. If the wumpus had been in the upper-right cell, the agent would have seen stench in the upper cell too — but when it visited the upper cell it saw no stench. So the wumpus is not there either, and it is pinned to the remaining cell. The agent has now concluded: this is where the pit is, and this is where the wumpus is — that is why this cell smells.

The agent moves to the cell below the wumpus — the safe cell next to the stench — and perceives OK there. No stench, no breeze. What does that indicate? The adjacent cells are safe: if a pit or wumpus were adjacent, the agent would have got the smell or the breeze. Up: no pit or wumpus. Right: no pit or wumpus. Left: already explored. Bottom: already explored. Two options remain — up or right. This example goes right, and luckily the agent gets G — the gold — though it perceives stench and breeze there too. Why the stench? The wumpus is below this cell. The breeze? The pit could be in either of the two remaining suspect cells, but the agent is not worried — as long as it has the gold, the problem is over.

Sense-check. Every claim on this board was forced by the same two moves as the numbered grid: "when I was in this cell I did not perceive smell, so the wumpus is not there; when I was in that cell I did not feel breeze, so the pit is not there; so the pit is here, the wumpus is there." The lean board carries no cell numbers, yet the reasoning never needed them.

Every step of this walkthrough is the same pattern: "when I was in this cell I did not perceive smell, so the wumpus is not there; when I was in that cell I did not feel breeze, so the pit is not there; so the pit is here, the wumpus is there." That is what the agent does at a very low level, and that is the whole heart of logic.

Recap. Two boards, one pattern: a single OK percept starts a chain of deductions, and every later percept — or missing percept — narrows the suspects until the hidden objects are cornered. The agent never saw the pit or the wumpus; it deduced them. That is the skill the rest of this lecture formalizes.

9.2.9 Student Questions and Answers

A first cluster of questions is about the game itself — where things can be placed and what the agent senses.

Q: Can gold be on the same cell as the wumpus? A: No, it cannot. If it were, there would be no point — you would always go take the gold and get eaten.

Q: What are the sensors here? A: Smell — you can smell the stench from adjacent cells. Feel — you can feel the breeze in adjacent squares of a pit. Glitter — in the square where the gold is, not in adjacent ones. Bump — if the agent walks onto a wall it cannot go further. Scream — when the wumpus is killed it can be perceived everywhere. The actuators are the hand and legs; the actions are forward, backward, turn left, turn right, grab, shoot, climb.

Q: Are these symbols like intersection and union? A: Yes, they are like and and or. We come to those formally right after this example.

Q: Can gold be near the wumpus or pit state? A: Yes, it can be near — but it cannot be in the same cell.

The next cluster is about the key deduction of the first walkthrough — why cell (2,2) is safe, and how far the reasoning reaches.

Q: Why is (2,2) safe? How do we know it is not the wumpus? A: Because the wumpus has already been cornered. The stench here in (1,2) comes from the wumpus, and we proved it is at (1,3): if the wumpus were at (2,2), we would have got stench at (2,1) as well when we visited it — but at (2,1) we saw no stench. Similarly, if there were a pit at (2,2), standing here in (1,2) we should have seen breeze — but there is no breeze here. So that cell has nothing; it is a safe state.

Q: What if (1,2) also had a breeze? A: Then you cannot deduce much — you would have to risk only. In this case there was no breeze, so we could corner both. The deduction worked precisely because of the percept that was absent.

Q: Why did we go to (2,1) first? We could have gone to (1,2). A: Both were equally possible. Once we reached (2,1) and felt breeze, we saw the value of having the option: we came back and went to (1,2) instead. The order of the first move did not lock us into anything.

Then the questions about the agent's memory and knowledge between moves.

Q: How is the agent keeping things in memory? A: As a percept vector — one entry per cell: location one was OK, location (2,1) felt breeze, and so on. It notes that and keeps it in its memory, like a vector.

Q: Will the agent have knowledge between attempts? A: Yes. Every move it can go back to its knowledge base, whatever it has, and reason from it. Nothing learned is thrown away between steps.

Q: Does the agent need visibility of next states to decide OK or not OK? A: No — you do not need to go there. That is the whole heart of the problem. In the current cell you can smell or feel the breeze, so you can decide: if I am getting a stench, somewhere around me there is a wumpus, top or bottom or left or right; if I see a breeze, there is a pit somewhere around me. That itself is good enough to tell me I am not in an OK state. You never need to enter the dangerous cell to know it is dangerous.

The questions below are about the edges of the rules — walls, dead wumpus, sensor trust, and the overall intent of the problem.

Q: What if the neighbor cell is a wall, like outside the grid? A: Then that cell does not exist — you bump onto the wall and there is nothing there. No breeze or stench comes from a nonexistent cell.

Q: Will the stench still be there once the wumpus is gone? A: No. If the wumpus is killed, we just bury him in the pit — no smell.

Q: Is there a false alert in the environment, like a smell without a wumpus? A: No, there is no false alert. It is a standard problem: the sensors and percepts are all correct.

Q: Is this equivalent to "think and act rationally"? A: Yes — this is exactly what rationality is. The agent thinks (deduces) and then acts accordingly.

Q: Do we always need to keep in mind that the problem is solvable with positive intent? A: Not really. This problem is about whether we can deduce new information. There might be problems where you cannot get the gold — you will always die. For example, put a pit here and a wumpus there in the grid and nothing can be done. The point is: can you reason about it without even going to the next cells? If I am in a cell with both stench and breeze, all sides are attacked — there is either a wumpus or a pit, so I cannot move anywhere. Being able to do that reasoning is what is important, not taking the gold.

Q: So accumulation of information is needed as the agent goes forward? A: Yes, that is very good — correct. Could reinforcement learning be used for this? Yes, RL could be used, but it is not what this problem is about. This problem is about logic: the agent's knowledge grows by deduction, not by reward signals.

9.2.10 Why This Is Logic, Not Probability

Q: All these decisions are being predicted through probability — how is that calculated based on movement? A: No — this is not probability, it is pure logic. It is seen evidence. When the agent stood in one cell and did not find breeze, and stood in another and found breeze, the conclusion that this particular cell has no pit is 100 percent guaranteed. If the pit were there, the agent would definitely have seen breeze in the adjacent cell. This is definitive, not probabilistic.

Q: What if we start from a breeze state? Then the agent cannot reason and any choice is a risk? A: That is correct. If you start in a breeze state and there is no other evidence, you cannot reason further in that scenario — any move is a risk. Deduction needs at least one grounded fact to push from.

That question came up twice and the answer matters. The agent does not need to visit a cell to confirm it has no pit, because the problem is built so that breeze or stench in an adjacent cell lets you conclude it. Probability-based reasoning is a different type of system that comes later in the course — this module is pure logic and seen evidence. The word "guaranteed" is doing real work here: in logic, a correct deduction from true premises is certain, not likely. A probabilistic system would say "there is an 80 percent chance of a pit here"; the logical agent says "there is definitely no pit here, because I perceived no breeze in a cell that would have shown one."

Recap + bridge. The Wumpus World showed reasoning in action: percepts plus general rules, deductions in every cell, and conclusions that are certain, not probable. The next step is to make "logic" precise — a formal language with syntax, meaning, and a definition of what it means for one sentence to follow from another.

9.3 What Is Logic?

9.3.1 The Definition of Logic

Hook — what did the Wumpus agent just do? The agent never saw the pit or the wumpus, yet it said with certainty where they are. How is a guarantee like that possible? The answer is logic: a formal language in which conclusions follow from facts with certainty, not luck.

Logic, in this course, means: combine the current percept with the existing knowledge base, and do logical reasoning to identify state information. Reasoning is conducted or assessed according to the available knowledge about the domain. The Wumpus World showed exactly this: the only information given was "you are in cell (1,1) and you are OK" — that was all. But from that alone the agent inferred: if I am OK here, I am safe, so there is no wumpus and no pit here, and no gold here; and near me — on top and to the right — there is no pit or wumpus either. All of that is inferencing. Reasoning is assessed according to available knowledge, and from that knowledge you can create more knowledge and new percepts.

Logics are formal languages for representing information such that conclusions can be drawn from it. The phrase "formal languages" is the key: like programming languages, they are precise — every symbol, every combination rule, every meaning is fixed in advance. That precision is what makes certain inference possible. Human language is too messy for this job; a formal logic is not.

9.3.2 Syntax and Semantics

Every sentence or premise is expressed according to the syntax of the representation language — the set of rules that decides which strings count as sentences at all.

Syntax — what counts as a sentence of the language.

In arithmetic, for example, " plus equals 4" is a well-formed sentence, while a scrambled string like (the spoken example "xy 4 = 2" is the same idea) is not — it violates the syntax. Any arithmetic book would say it is not a sentence; it is just a jumble of symbols. The same idea applies to logic: there is a syntax that decides which strings are sentences of the language. Before you can ask whether a statement is true, you must first ask whether it is well-formed — whether the grammar of the language even accepts it.

Semantics — what a sentence means.

Semantics is the meaning of a sentence — it defines the truth of the sentence in a world. In a world where and , the sentence is true; in a world where and , that same sentence is false. Same sentence, two worlds, two truth values. In standard logics, every sentence or premise has to be either true or false in each world — never in between. (Degrees of truth belong to fuzzy logic, a later and different topic.)

Syntax and semantics work together: syntax tells you which strings are sentences, semantics tells you which worlds make each sentence true. A string that fails syntax never gets a truth value at all; a sentence that passes syntax is true in some worlds and false in others.

9.3.3 Models

Models — the possible worlds of a logic.

A model is an assignment of truth values to the symbols of the language — a possible world, not necessarily reality. Any combination of truth values counts as a model. With two variables and , both can be true, one can be true and the other false, the first false and the second true, or both false — four models in total:

For symbols there are models — two choices (true or false) for each of the symbols. With 3 symbols that is models; with 7 symbols, . A model satisfies a sentence — written — when is true in that model. The set of all models of is written . Models are pure mathematics: the symbol might mean "there is a pit in (1,2)" in the Wumpus World, but as a symbol it could just as well mean "I am in Paris today and tomorrow." The logic does not care what the symbols mean to us — only that each model assigns each one true or false.

9.3.4 Entailment

Entailment is written with the symbol . " entails " — — means: in every model where is true, is also true. In set terms:

Every model of is also a model of — the set of worlds where holds is a subset of the worlds where holds. Note the direction: if , then is the stronger statement — it rules out more possible worlds.

Entailment in the Wumpus World.

The agent is at (2,1) and has detected breeze. The agent is interested in the adjacent squares — (1,1), (2,2), and (3,1). Each of these squares might or might not contain a pit — it has a pit or it does not, true or false — and all combinations are possible, giving models. The knowledge base tells us that at (1,1) no breeze was perceived, and so (2,1) has no pit — . That kind of cross-questioning — "I saw no breeze at (1,1), so (2,1) has no pit" — is entailment. The deduction is guaranteed: in every model where the KB is true, is also true.

The haystack picture of entailment and inference. Think of the set of all consequences of the KB as a haystack and the sentence as a needle. Entailment is the needle being in the haystack — a fact about the logic, whether anyone looks for it or not. Inference is the act of finding it — an algorithm working through the sentences. The distinction is written formally: means "the inference procedure derives from ." A good inference procedure is sound (it only finds needles that are truly in the haystack) and complete (it finds every needle that is there).

And note the vocabulary bridge: what discrete mathematics calls inference, AI calls entailment — it is the same thing, just the AI term for it.

Q: Is this not just inference from the knowledge base? A: Yes — inference is the word used in discrete mathematics; in AI the same thing is called entailment. Both are the same idea: a sentence follows from what we already know. Entailment is the semantic fact ("it follows"), inference is the procedure that discovers the fact.

9.3.5 Propositions: What Counts and What Does Not

Propositional logic is Boolean logic. A sentence qualifies as a proposition if at the end you can say whether it is true or false — it may not always be true; a false statement is perfectly acceptable as a proposition. Assessability is everything.

  • "The sun rises in the east and sets in the west" — a proposition; at the end it is true or false.
  • "1 + 1 = 2" — a proposition.
  • "1 + 2 = 5" — a proposition! Its validity is false, but we can assess it — that is all that matters.
  • "B is a vowel" — also a proposition; its truth value is false, and that is okay.

But these are not propositions: "Will you go to office today?" — there is no true or false value, you cannot correctly answer; "You are beautiful!" — exclamatory; and instructions and warnings, like "Read this carefully" — you cannot validate an instruction. Question marks, exclamation marks, instructions — those are not logic statements.

A mixed case: "" is not a proposition when and are unknown — there is no way to assess it. But if the values of and are given, then it becomes assessable, and then it is a proposition. The same statement becomes a proposition once its variables are fixed.

Q: Can we say that factual plus Boolean equals propositional? A: That is correct. Every statement you see is a fact — it can either be true or false. If you can assess the validity of the statement, then it is propositional logic. Fact (it claims something about the world) plus Boolean (it has exactly two possible truth values) equals propositional.

Q: Is "B is a vowel" really a proposition? A: Yes. It is a propositional statement. The truth value is not true — but that is fine. Assessability is all that matters. The statement has an answer; the answer just happens to be false.

Q: "" — is that not a proposition? A: Correct, as long as and are not given. If and values are given, and the equation is given, then yes — it becomes a proposition, because you can now evaluate true or false. You do not need the equation to be satisfied; you only need to be able to assess it.

From the standard discrete mathematics book come a couple of negation exercises: "Michael's PC runs Linux" is a proposition, and its negation is "Michael's PC does not run Linux." "Vandana's smartphone has 32 GB" — express it in simple English and then negate it, same pattern: "Vandana's smartphone does not have 32 GB." The negation of a proposition is always another proposition: whatever the original claims, the negation claims the opposite, and exactly one of the two is true.

9.3.6 Is This Really Intelligence?

Q: Is it really intelligence, since it is programmatically deployed? A: This goes straight back to the first class. Fifty years back, when doors started opening automatically, people said doors are intelligent. Then people started saying: that is not intelligent, it is just a bunch of sensors — when you are near, it senses you and opens. That is not intelligence, that is just programmed. The same debate happens with all these algorithms: there is a group of people who say "I understand this, this is exactly how it is coded, it is programmatically done — so how is this intelligence?" This system exhibits intelligence, but if you go into it, it is just programmatic. It all comes back to the first class's question: what is intelligence?

Q: Are humans intelligent? What if we are also programmed by a superior being — programmed to learn as we grow, by the environment, like our agents? A: That is again in the line of thought of the first class. Are humans always intelligent? No. Are non-humans intelligent? Dogs are. If you want that answer, you should move away from AI towards spiritual intelligence — and you are in the right direction. There is a lot of work where people talk about humans being programmed: we all know our goal state, we all know some navigation paths, there are hurdles in between, and from your past experiences you make rationality — that is what you believe. And later from that, you build your knowledge base.

Q: Isn't it the other way around — that machines are trying to mimic humans? A: That all goes back to the first class: is it mimicking humans, or is it beginning rationality? We do not want machines to mimic humans. We want them to do the right thing — to act rationally. The Wumpus agent does not imitate a human player; it deduces, then acts on the deduction. That acting rationally is the course's definition of intelligence.

Recap + bridge. Logic gives us the tools: sentences with syntax and semantics, worlds called models, and entailment — — meaning holds in every model of . What counts as a sentence (a proposition) is now settled. The next step is the machinery of propositions: the connectives that build complex sentences and the truth tables that say exactly when each one is true.

9.4 Propositional Logic: Connectives and Truth Tables

9.4.1 The Five Connectives

Hook — how do you say "if" in a machine? The Wumpus rules are full of ifs: "if there is a pit here, then there is breeze next door." English "if" is sloppy. Propositional logic gives exactly five building blocks — not, and, or, implies, double implies — and with them every statement of the Wumpus World can be written down unambiguously.

Propositional logic defines the language of allowable sentences. A sentence is a single propositional statement or a symbol, and complex sentences are constructed by joining them with logic connectives. For the Wumpus World, a proposition such as "the wumpus is in (1,3)" is written as a symbol, usually upper case, such as — the full line is a proposition, and the symbol indicates that proposition. You can use , , , , and so on. The names are arbitrary but chosen to be mnemonic: stands for "the wumpus is in (1,3)", for "there is a pit in (3,1)". Note that is a single atomic symbol — the , , and are not meaningful parts you can separate.

The five connectives, in the order the course uses them.

  1. Not (negation, ). means "the wumpus is not in (1,3)". It is the negative of a sentence: if the sentence is given, the negation is the opposite. One symbol, one flip.
  2. And (conjunction, ). "" means the wumpus is in (1,3) and the pit is in (3,1) — both must be true. It is called a conjunction, and each part is called a conjunct. (The symbol looks like an "A" for "And".)
  3. Or (disjunction, ). "" means the wumpus is in (1,3) or the pit is in (3,1) — at least one is true, and possibly both. It is called a disjunction, and its parts are called disjuncts.
  4. Implies (implication or conditional, ). A sentence such as reads in plain English: "if the wumpus is in (1,3) and the pit is in (3,1), then the wumpus is not in (2,2)." The part before the arrow is the premise (also called the antecedent); the part after is the conclusion or consequent. Implications are also known as rules or if–then statements.
  5. Double implies (biconditional, ). "" means the wumpus is in (1,3) if and only if the wumpus is not in (2,2). It can be broken into both directions: and .

The grammar of the language is fixed: a sentence is an atomic symbol, a parenthesized sentence, or one sentence joined to another by a connective. That tiny grammar generates every propositional sentence there is — including every rule of the Wumpus World.

Q: Which part of the implication is which? A: The part before the arrow is the premise, also called the antecedent. The part on the right is the conclusion or consequent. The implication says: when the premise holds, the conclusion follows. In , is the premise and is the conclusion.

9.4.2 Truth Tables for Each Connective

A truth table is a tabular compilation of the possible truth values of a sentence over its symbols. Truth tables are used most of the time to verify entailment and similar claims — you may have seen them in earlier courses.

Negation: if the premise is true, the negation is false; if the premise is false, the negation is true.

T F
F T

Conjunction: is true only when both and are true; every other combination is false.

T T T
T F F
F T F
F F F

Disjunction: is true as long as at least one of them is true; the only false case is when both are false.

T T T
T F T
F T T
F F F

Q: Can we throw the implies truth table once more? A: Implies is false in exactly one case: premise true and conclusion false. All other cases are true — that is the whole table. Everything surprising about implication lives in that single shape.

Implication: is false only in the single case where the premise is true and the conclusion is false; all other cases are true.

T T T
T F F
F T T
F F T

Double implication: is the same as writing and together — both directions. It is true when both are true and when both are false; in the other two cases it is false.

T T T
T F F
F T F
F F T

For symbols there are combinations, and there are tricks for filling the columns: for the rightmost column alternate T F T F T F…; the next column TT FF TT FF…; the next TTTT FFFF… and so on, and the table is done. The trick works because the columns are independent: the last column is the fastest-changing bit, and each column to its left changes half as often.

A note on "or": the used here is the inclusive or — true when one or both parts are true. A different connective, XOR (exclusive or), yields false when both disjuncts are true. XOR also exists and is part of the same family; it is exactly the gate used when two switches must differ to pass current.

Real-world: all of these truth tables are implemented in computers using gates — AND, OR, XOR, NOR, NOT. The gates are the hardware versions of the connectives. You may have met the same material in discrete mathematics, or in computer organization courses; these days it even shows up in school curricula.

9.4.3 The Tricky Row: Why Implication with a False Premise Is True

The one row of the implication table that students find strange is "false premise → anything". Example: "If I am elected, then I will lower taxes." If I am not elected, what can you say about lowering the taxes? You are not expecting anything — and the statement as a whole is still true. Voters would expect the politician to lower taxes if elected; also, if the politician is not elected, voters will not have any expectation — although the person may still have enough influence to cause those in power to lower taxes, you are not worried about that. It is only when the politician is elected and still does not reduce the tax — premise true, consequent false — that the implication becomes false. If the premise itself did not happen, there is no way to verify the implication, so it stays true.

The cleanest way to hold this row in your head: "" says "If is true, then I am claiming that is true; otherwise I am making no claim." An implication makes a promise only about the case where its premise holds. Where the premise does not hold, there is nothing to check — so the sentence cannot be called false.

Q: If is false and is true, then is true? A: Yes. If your premise itself is false, then you do not need to worry about anything — is true when is false. The implication guarantees that when and are true, the implication is true, but the implication does not guarantee anything when the premise is false. There is no way of knowing whether or not the implication is false, since did not happen.

9.4.4 Precedence and Ambiguous Sentences

Some sentences are ambiguous if the parentheses are missing. Consider a line with negation and conjunction: should you first do the negation of , and then AND that result with ? Or should you first do the AND and then negate the whole line? Without precedence rules or parentheses, you do not know what to do first — such a line is ambiguous:

These two are different sentences. The first negates , then ANDs with ; the second performs the AND first, then negates the whole answer. The resolution is done using precedence — knowing which connective binds first resolves the ambiguity.

The standard order, from highest to lowest precedence:

The negation binds most tightly: in the sentence , the attaches to first, giving , not . The analogy with arithmetic is exact: means , not . When in doubt, parentheses remove all doubt — use them freely, and the sentence becomes unambiguous.

9.4.5 Connectives as Hardware Gates

The truth tables of the connectives are constant — you cannot change them; , and, or, and the biconditional tables are always the same. In a computer these are the logic gates: AND gates, OR gates, XOR gates, NOR gates, NOT gates.

The gate view of the connectives.

  • An AND gate outputs 1 only when both inputs are 1 — exactly the truth table of .
  • An OR gate outputs 1 when at least one input is 1 — exactly .
  • A NOT gate flips its input — exactly .
  • XOR outputs 1 when the inputs differ — the exclusive variant of .
  • NOR is "not OR": it outputs 1 only when both inputs are 0.

When you write a conjunction in propositional logic, you are describing exactly the behavior of an AND gate: feed it two truth values, read the output. A full Wumpus World rule such as is, at the silicon level, a small circuit of such gates. This hardware connection is the same material you would have studied in discrete mathematics and computer organization.

Recap + bridge. Five connectives, five truth tables, one surprising row (implication with a false premise), and a precedence order that makes every sentence unambiguous. With these tools the Wumpus World rules can be written as a formal knowledge base — which is exactly the next step.

9.5 Wumpus World as a Propositional Knowledge Base

9.5.1 Symbols for Pits, Wumpus, Breeze, and Stench

Hook — from pictures to sentences. The diagrams of section 9.2 (A, B, G, P, S, W) are informal: human-readable but not machine-processable. To make an agent actually reason, the same knowledge must be written as sentences in propositional logic — the formal language of the last section.

Now the Wumpus World knowledge is translated into propositional logic. For each location :

  • is true if there is a pit in .
  • is true if there is a wumpus in .
  • is true if the agent perceives a breeze in .
  • is true if the agent perceives stench in .

That is all — the plain English of the problem is now a set of symbolic statements. Every percept the agent can record and every hidden fact it cares about has one symbol. From here on, "the agent feels breeze at (2,1)" and "the formula is in the knowledge base" mean the same thing.

9.5.2 The Knowledge Base Sentences

Given a particular configuration, the knowledge base contains these sentences, labeled R1 through R5 — R stands for rule:

In plain English: R1 says there is no pit in (1,1). R2 says the agent perceives breeze at (1,1) if and only if there is a pit at (1,2) or a pit at (2,1) — those are the only cells adjacent to (1,1). R3 says breeze at (2,1) if and only if a pit is at (1,1), (2,2), or (3,1) — the cells adjacent to (2,1). R4 says no breeze was perceived at (1,1). R5 says breeze was perceived at (2,1).

Notice the two kinds of sentences. R2 and R3 are general rules — they hold in every Wumpus World, because they are just the adjacency fact of section 9.2 written with a biconditional: a square is breezy if a neighbor has a pit, and a square is breezy only if a neighbor has a pit. R1, R4, and R5 are percepts — facts about this particular world, gathered by the agent's sensors.

Knowledge base entries are insights and facts, not heuristics. Each entry — R1 through R5 — is knowledge, a hint or an insight about the world. They are not heuristics: the information is already in the knowledge base because either the domain expert told us (the rules of the game), or the agent itself saw it and updated its knowledge base (the percepts). A knowledge base is a collection of such knowledge, where each piece is a small, independent insight, fact, or rule. Some entries are simple literal facts like these; others are complex sentences with multiple literals — more like a rule engine that can be substituted and evaluated.

9.5.3 Literals, Facts, and Rules

Each atom inside these sentences — for example , , , — is called a literal. The negation symbol is an operator, not a literal: a literal is either an atomic sentence (a positive literal, like ) or a negated atomic sentence (a negative literal, like ). The symbol itself is one literal whether it appears bare or with a in front of it.

Q: How many unique literals are there — five or seven? A: Seven: , , , , , , . Negation is an operator, so is not a separate literal — is already counted. Do not count the connectives (, , ), and do not double-count the negated .

In the knowledge base above, that makes exactly seven unique literals. This count is not a trivia detail — it decides the size of the truth table in the next section: seven literals means models.

9.5.4 The Query: Is There a Pit in (1,2)?

The agent now has to decide: should I move to cell (1,2)? Before moving, it should make sure there is no pit there and no wumpus there. So the query asked of the knowledge base is: is — "there is no pit in (1,2)" — entailed by the knowledge base? In other words, can this be inferred from the knowledge base; can the agent tell that this is true from what it already knows?

If turns out to be true, the agent can go to (1,2). If it turns out false — there is a pit — the agent will not go there. And after the query is resolved, the answer becomes knowledge: when the query is solved, it is added as a new sentence in the knowledge base. The agent works exactly like this internally: it is given a body of knowledge, it answers queries, and each resolved query extends the KB.

Q: Is the we are finding considered a literal? A: Yes, it is a literal — there is only one thing in it. For this literal, we have to find out whether it holds: is there a pit or not in (1,2), based on the knowledge base?

How do you resolve such a query? There are several techniques: a truth table, theorem proving, resolution, contradiction — and there is an algorithm for it. The next section looks at the truth table approach in full.

Recap + bridge. The Wumpus World is now a formal object: seven literals, five rules, one knowledge base , and one pressing question — does ? Answering that question is the entire business of the next section.

9.6 Inference by Truth Table

9.6.1 The Five Steps

The question is: is entailed from the knowledge base? The truth table approach has five steps.

Hook — the brute-force definition of "follows". Entailment was defined as "true in every model where the KB is true." The most direct way to check that is to stop theorizing and just look at all the models. That literal look-at-everything approach is the truth table method: exhaustive, simple, and guaranteed — at a price.

  1. Extract all the literals from the knowledge base. In this KB there are seven: , , , , , , . Do not count the operators.
  2. Enumerate all models — all combinations of true/false assignments to the propositional symbols. With two variables, and , there are four combinations: both true, both false, one true and one false, the other true and the other false. With symbols there are combinations — for seven literals, rows. Use the filling tricks: T F T F…, TT FF TT FF…, TTTT FFFF…, and the table is done.
  3. In all the models, find those where the KB is true — that is, where every sentence R1 through R5 is true.
  4. In those models, check the query sentence.
  5. If the query is true in all the models where the KB is true, it entails; otherwise it does not.

That is the whole approach — it takes many pages in a logic textbook to explain, but the essence is these five steps. The algorithm is sound (it directly implements the definition of entailment, so it can never announce a false conclusion) and complete (it always terminates and always finds the answer, because there are only finitely many models to inspect).

9.6.2 Step by Step on the Real Knowledge Base

Worked Example — building the 128-row table and finding the three KB-true rows.

The full truth table has 128 rows; the class only showed the start and end of it, with dots in between. The first seven columns are the seven literals — , , , , , , — starting with all of them false and ending with all of them true, covering every combination.

Then compute the truth value of each rule column:

  • R1 = . The column is already there; negate that column, and write the result. Where is false, R1 is true; where is true, R1 is false.
  • R2 = . Use precedence: first compute the or of and , then combine that with the column using the biconditional.
  • R3 = . Same pattern: or the three pit literals first, then the biconditional with .
  • R4 = . Negate the column.
  • R5 = . The column itself.

The knowledge base is the conjunction of all the rules — . An "and" across the rule columns is true only in the rows where every single rule is true. In this table there are exactly three such rows, and those are the highlighted ones:

KB
F F F F F T T T
F F F F T F T T
F F F F T T T T

Why these three and no more? R1 forces false, R4 forces false, R5 forces true; R2 then forces false, so and are both false; and R3 is left demanding true — which leaves exactly the three combinations shown. Those three rows are the only models of the KB.

9.6.3 The Verdict on the Query

Worked Example — checking in the three KB-true rows.

Take only those three rows — forget the other 125. In those rows, check the query . Where is the column? Its value in the three rows: false, false, false. Negate it: false negates to true, false to true, false to true. In all three rows the query is true. So the conclusion: is entailed from the knowledge base — there is no pit in (1,2). The agent can safely move there, and it adds this as its sixth sentence of knowledge:

The entailment becomes a new rule in the KB. This is the working cycle of the agent: ask, answer, add the answer to the knowledge base, ask again.

Sense-check. Each of the three KB-true rows has false — no row contradicts "no pit at (1,2)". A single KB-true row with true would have destroyed the entailment; none exists. You do not need to evaluate the query over the entire table — only in the rows where the KB is true.

9.6.4 Other Queries on the Same Table

The same table answers further queries.

Worked Example — why fails and succeeds.

Is entailed? In the three KB-true rows, look at the column: false, then true, then true. Negating: true, false, false. The query is not true in all KB-true rows — only in two of the three. So the agent cannot entail that there is no pit at (2,2); it cannot conclude it. The knowledge base simply does not decide this question — in one of its three models there is a pit at (2,2), in the other two there is not. (Nor can the agent conclude the opposite: is also false in one of the three rows.)

Contrast with : in the three rows is false, false, false, so its negation is true, true, true — is entailed. No pit at (2,1), with certainty.

The rule: the query must be satisfied in every row where the knowledge base is true — if even one KB-true row fails the query, the entailment fails. That single counterexample is enough, and that is what happened to .

The same table also illustrates how the whole method generalizes: the algorithm walks the models one by one, keeps only the rows where the KB is true, and checks the query in those rows only. That recursive enumeration — assigning symbols one at a time and pruning branches where the KB is already false — is exactly how a program such as the classic TT-ENTAILS procedure implements these five steps.

9.6.5 Complexity and Practicality

For this one entailment, an entire table of 128 rows had to be built, every rule column computed, the KB column ANDed, and then the query checked. Is it even practical? For a computer, 128 rows is nothing — it scales fine. In an exam, it is not scalable. But what about a million records? The time complexity is — big O of — and that is bad, that is worse than fine. Every time you add one more literal to the knowledge base, the table doubles in size. (In fact, propositional entailment is co-NP-complete, so every known inference algorithm has worst-case exponential time — the truth table is not uniquely slow, just honestly slow.)

Space complexity is still okay: you hold the table in memory — one row at a time, if you enumerate carefully, the memory used stays linear in the number of symbols, even though the time does not.

Why the truth table does not scale. The table has rows for literals. Adding the seventh literal doubled a 64-row table to 128 rows; a fiftieth literal would demand rows — beyond any machine. You may be able to optimize and skip parts of the computation (checking only rows where the KB is not already false), but at the end the approach is not effective for large knowledge bases — which is exactly why the next technique, theorem proving, exists: clever rules that reach the same answer in a few lines instead of 128 rows.

Q: How are we inferring the first seven literals to be false or true from the knowledge base? A: We are not inferring them at all. Those seven columns are the random assignments — like the - table with true, true / true, false / false, true / false, false. For seven columns we have put all combinations. The inferencing starts only at the rule columns — R1, R2, R3, R4, R5 — and the KB column that ANDs them.

Q: Is this scalable? Just for this one entailment, so much work. A: Not really. You created a complete table with 128 rows, calculated all the statement values, ANDed them, queried, and so on. There are optimizations — we may not need to compute everything — but in an effective way it is still heavy. That is where the next approach comes in: theorem proving.

Q: The last step — do we need the whole table, or only some rows? A: Only the rows where the knowledge base is true. Forget everything else, take those three rows, and in them check whether the query is true. You do not need to do the entire table — the other 125 rows cannot change the answer.

Exam note: the truth table with 128 rows is the definition of entailment made concrete, but in the exam it is not scalable — know the five steps of the truth table approach and the reasoning, not brute-force enumeration. The next lecture picks up the smarter path: theorem proving with logical equivalences.

9.7 Logical Equivalences: Theorems for Faster Inference

9.7.1 Logical Equivalence and the Laws

Hook — 128 rows of brute force, or four lines of thinking? The truth table answered "no pit at (1,2)" by grinding through 128 rows. But an expert human can prove the same fact in about five steps. The difference is a toolbox of logical equivalences — sentences that are guaranteed to mean the same thing, so they can be swapped freely in any argument.

The truth table approach is complete but exponential. Theorem proving is the alternative: apply clever rules, and deduce the same answer in four lines instead of 128 rows. The first concept needed is logical equivalence: alpha logically implies beta — written — when the two sentences have the same truth value in every model. Equivalences play the same role in logic that arithmetic identities () play in ordinary math: they let you rewrite a sentence into a friendlier shape without changing its meaning. There are many equivalence laws, all from discrete mathematics:

  • Commutativity: is the same as ; is the same as — the order of the two sentences does not matter.
  • Associativity: the same regrouping for conjunctions and disjunctions — , and the same shape for . When everything is an and, the grouping is irrelevant.

  • Double negation: the negation of the negation of alpha gives alpha — the two negations cut each other and only alpha remains. "It is not the case that the wumpus is not in (1,3)" is just "the wumpus is in (1,3)".
  • Contrapositive: is equivalent to . If being a wumpus cell implies being smelly, then not smelling implies not being the wumpus cell.

  • Biconditional: is equivalent to — both directions together. This is the elimination rule that will start the five-step proof below.
  • Implication elimination: — "if the premise holds, the conclusion follows" is the same as "either the premise fails or the conclusion holds". This is exactly the single-false-row reading of the implication table from section 9.4.
  • De Morgan's laws: and — negation distributes over and/or by flipping the connective: "not (A and B)" means "not A or not B".
  • Idempotence law and — repeating a sentence adds nothing.
  • Distributivity and more distributes over and distributes over , exactly like multiplication distributes over addition; the textbook table includes domination laws and others besides.

Using these laws, you can quickly arrive at the same entailment conclusion. The practical skill is recognizing which law applies where — the same way you decide which arithmetic identity makes an expression simpler.

Q: As part of the open book exam, will we have this table of logical equivalences? A: Yes, all of this will be covered in the syllabus. These laws are prerequisite knowledge — you should have learned them in your undergraduate math course. If at all there is a question on them, the question itself will give you what is needed.

9.7.2 Proving the Laws with Truth Tables

Every equivalence law can itself be proved with a truth table — the very method that was just declared too slow is the perfect tool for proving the shortcuts. Take alpha and beta; write the possible truth values; compute the column for and the column for — the two columns are identical, and that is why the commutativity law exists.

The homework tradition when logic is taught: take the left-hand side of each law in one column of a truth table and the right-hand side in another column; if the two columns are exactly the same, the law is proved.

Worked Example — proving commutativity of with a truth table.

Write both sides of as their own columns:

T T T T
T F F F
F T F F
F F F F

The two right-hand columns read T, F, F, F in both tables — identical. The law is proved: swapping the order of a conjunction never changes its truth value. The same two-column trick verifies every other law in the list, including the surprising ones: contraposition, De Morgan, implication elimination.

Go practice these laws the same way: solve an entailment with a truth table first, then verify the same conclusion by applying the laws. Kenneth Rosen's Discrete Mathematics and Its Applications, shown in class, is the reference for the full list of laws, with many exercises.

9.7.3 Inference Rules for the Next Class

Before the next class, read up on the basic inference rules — especially modus ponens, modus tollens, and and-elimination.

The three inference rules.

  • Modus ponens (Latin: "mode that affirms"): from and , conclude .

If a rule says "breeze in (1,1) implies a pit in (1,2) or (2,1)" and the agent perceives breeze in (1,1), then the agent may conclude "a pit is in (1,2) or (2,1)".

  • Modus tollens (Latin: "mode that denies"): from and , conclude .

If the implication holds and the conclusion is false, the premise must have been false — the contrapositive in action.

  • And-elimination: from a conjunction , conclude either conjunct.

If the KB contains "no pit at (1,2) and no pit at (2,1)", each half is individually available.

With those, the same entailment that took a full truth table can be deduced in about five statements, applying one rule after another:

Worked Example — proving in five steps instead of 128 rows.

Start from the same KB (R1–R5) as the truth table method:

  1. Biconditional elimination on R2 gives

  1. And-elimination on R6 gives the second half:

  1. Contrapositive turns R7 around:

  1. Modus ponens with R8 and the percept R4 :

  1. De Morgan distributes the negation:

The last line contains the answer: no pit at (1,2) (and no pit at (2,1) either). Five steps, no table, no 128 rows — and the proof never even mentioned , , , or : irrelevant sentences can be ignored entirely, which no truth table can do.

Sense-check. Each step is a sound rule applied to a true sentence, so the conclusion is guaranteed true wherever the KB is true — the same guarantee the truth table delivered, with a fraction of the work.

There is no fixed order of application: one person may reach the result in ten steps by starting with biconditional elimination then contraposition; someone else who starts with De Morgan may take a bigger route. The difficulty is proficiency — knowing which law to apply where, so that you are quicker and do not go in circles. For that reason, even further techniques exist — conjunctive normal form (CNF) and resolution — which are also covered next class.

Q: Will these theorems be applied in some fixed order — first biconditional elimination, then contraposition, then modus ponens? A: No, it need not always be ordered. You are in the right direction, but different routes exist: some people achieve the result in ten steps, others start directly with De Morgan and take a bigger route. The order is not fixed, and that is part of the problem — you should be proficient and know which law to apply where. That is where CNF and resolution, which we learn next class, come in as systematic techniques: they remove the guesswork about which law to apply.

9.7.4 Prolog in Practice

The first webinar (coming Tuesday) teaches some of these laws along with Prolog. In Prolog you put these statements directly — the sentences of the knowledge base — then ask the query, and the program answers whether it entails or not. That is a very powerful language: it is a language for logic programming.

Real-world: Prolog is used in assignments and the webinar; it is pretty simple, you can download it and run it in a command line. What the program does when you press enter is theorem proving: it applies the same inference rules this lecture introduced — modus ponens, modus tollens, and-elimination — to chain from your facts to your query. After the webinar you will also understand the labels: entailment checks, modus ponens, modus tollens, and-elimination — the same ideas in a running system.

Recap + bridge. Logical equivalences give the rewriting laws; modus ponens, modus tollens, and and-elimination give the step rules; together they replace exponential enumeration with short proofs — and next class turns that into a complete, mechanical procedure (CNF + resolution) that even a program can run without human judgment.

Exam Guidance Summary

The exam guidance for the final exam was given at the end of this class. The items below are the ones that matter for how you prepare.

  • Syllabus: the open book final exam covers all classes 1 through 16 — not just the post-mid-semester ones. Everything taught in the course is examinable, including this lecture's logic topics.
  • Open book logistics: a single PDF combining all sixteen class decks will be uploaded before the final class (around the 15th class), with this year's watermark — that alone is allowed into the exam. Do not print the individual weekly decks, and do not print books — book printouts are outright illegal (copyright); buy the book instead.
  • Solved problems: per clear guidelines, no solved problems or past exam questions will be in the final PDF. They are taught in class but not carried into the exam.
  • Depth expectation: the slides are the bare minimum — they get you to about 50% of the marks. Going to the textbook gets you to 75%; one more step beyond that gets you to 90%. The slide decks have been intentionally toned down to fit the class modality, so slide-only preparation leaves half the paper on the table.
  • Genetic algorithm question (from the mid-semester): implementation was not asked — you only had to list the steps: where selection happens, roulette wheel, next generation, and so on. The same pattern applies to the key: sample keys are not the only correct answer; if you solved it better, you get the credit.
  • Truth table inference: the 128-row table is not scalable — in the exam, know the five steps of the truth table approach and the reasoning, not brute-force enumeration.
  • Must know before the next class: logical equivalence laws (commutativity, associativity, double negation, contrapositive, biconditional, De Morgan, idempotence) and the inference rules modus ponens, modus tollens, and and-elimination.
  • Background reading: Kenneth Rosen's discrete mathematics textbook — chapter 1, sections 1.1 (propositional logic) and 1.2 (applications of propositional logic) are required; sections up to 1.4 are also part of the course from the AI angle. The book has dozens of exercises (about 54 on truth values) — practice converse, inverse, and truth table conversions.
  • Revaluation requests: be specific — point out where you deserve more marks and why, challenge the evaluators with arguments. Vague requests like "please give me more marks" are not useful.
  • Remaining weightage: after the mid-semester, more than 60% of the weightage is still ahead — quiz 2, assignment 2, and the final exam. The logic topics of this module will carry real marks in that remaining weight.
  • Question paper philosophy: the paper will be different from what was discussed in class — that is the interest.

Exam note: the mid-semester paper was balanced and within the syllabus; topics like pattern databases were covered (the Rubik's-cube-specific application was not, but the topic itself was). Expect the same philosophy: anything in classes 1–16 is fair game, and the paper will ask the ideas in a fresh shape, not the exact class examples.

Key Industry Applications

The ideas of this lecture are the foundation of several systems you will meet in industry and in later coursework.

  • Prolog — a logic programming language: write sentences with and, or, and implications; ask a query; get the entailment answer. Used in the webinar and assignments; downloadable and runs in a command line. In industry, Prolog and its descendants power rule-based systems in legal reasoning, scheduling, and natural-language parsing, where explicit sentences and queries are more useful than opaque models.
  • Modern agent loops — today's knowledge-based systems and loop-based agents with context and memory updates still rest on the tell / ask / update fundamentals of a knowledge base. Large-language-model agents, chatbot memory, and retrieval pipelines are the modern names for the same pattern: store what happened, ask the store for guidance, act.
  • CRUD in databases — the tell, ask, update cycle of a knowledge-based agent is the logical equivalent of create, read, update, delete operations on records. The skill of designing a clean knowledge base transfers directly to designing a clean database schema.
  • Hardware logic gates — the truth tables of negation, conjunction, disjunction, implication, and biconditional are implemented directly in computers as AND, OR, XOR, NOR, and NOT gates. Every CPU you use executes the connectives of this lecture millions of times per second; compiler writers and hardware engineers reason about these tables constantly.
  • The Wumpus World — the classic grid-world problem for demonstrating knowledge representation and logical inference in agents; the design pattern of "general rules + percepts + entailment queries" is the template for modern knowledge-based agent design. Beyond games, the same pattern appears in diagnostic systems (symptoms + rules + what disease is entailed), in circuit fault-finding, and in any domain where certainty of deduction matters more than the average-case guess.

ACI Lecture 9 notes · Knowledge Representation Using Logics

Artificial Computational Intelligence· postgraduate· 2026-08-13

Sections Breakdown

19.1 Knowledge-Based Agents

What an agent knows, the tell/ask/update cycle, knowledge-based versus learning agents, and Prolog as a language for logic.

29.2 The Wumpus World

The 4x4 grid problem: percepts and sensors, actuators, generic pit and wumpus rules, two worked reasoning walkthroughs, and student Q&A.

39.3 What Is Logic?

Logic as a formal language: syntax, semantics, models, entailment, and what counts as a proposition.

49.4 Propositional Logic: Connectives and Truth Tables

The five connectives, their truth tables, the tricky implication row, precedence and ambiguous sentences, and connectives as hardware gates.

59.5 Wumpus World as a Propositional Knowledge Base

Symbols for pits, wumpus, breeze and stench; the R1-R5 knowledge base sentences; literals, facts and rules; and the query about cell (1,2).

69.6 Inference by Truth Table

The five steps of the truth table approach, the 128-row table on the real knowledge base, the verdict on the query, other queries, and complexity.

79.7 Logical Equivalences: Theorems for Faster Inference

Logical equivalence and the laws, proving the laws with truth tables, inference rules for the next class, and Prolog in practice.

8Exam Guidance Summary

Exam strategy for the open-book final: syllabus, allowed materials, depth expectations, and the must-know logic topics.

9Key Industry Applications

Prolog rule-based systems, modern agent loops, database CRUD, hardware logic gates, and the Wumpus World design template.

Postgraduate students in Artificial Computational Intelligence

Exam Revision Notes

Below is the distilled, exam-ready core. Every entry comes from the full explanation above. Use this section for rapid review; return to the main notes when a point needs more context.

Knowledge-Based Agents

Must-know: A knowledge-based agent is built around a knowledge base: a set of sentences in a formal representation language; every cycle it tells (percepts), asks (actions), and updates (new knowledge).

⚠️ Top pitfall: Confusing English sentences with formal logic sentences, or treating derived sentences as axioms.

Self-check: What are the three operations a knowledge-based agent performs every time it is invoked?

Connects to: 9.2 The Wumpus World

The Wumpus World

Must-know: Pit or wumpus at (x,y) gives breeze or stench (and-form) in all four adjacent cells; a breeze or stench percept gives an or-form over the four adjacent cells. No percept means no pit and no wumpus in any adjacent cell — the absence of a percept is evidence.

⚠️ Top pitfall: Using and instead of or in the reverse direction: a breeze does not tell you which of the four adjacent cells holds the pit — only that at least one does.

Self-check: The agent perceives OK at (1,1). Which two cells can it conclude are safe, and why?

Connects to: 9.1 Knowledge-Based Agents; 9.3 What Is Logic?; 9.5 Wumpus World as a Propositional Knowledge Base

What Is Logic?

Must-know: Entailment X |= Y means Y is true in every model where X is true (M(X) subset M(Y)); a proposition is any statement whose truth value can be assessed, even if false or unverified without fixed variable values.

⚠️ Top pitfall: Calling a question, instruction, or exclamation a proposition — it has no truth value; likewise 'x - y = 6' is not a proposition until x and y are given.

Self-check: In how many models is the sentence over two symbols P and Q true? How many models total exist?

Connects to: 9.2 The Wumpus World; 9.4 Propositional Logic: Connectives and Truth Tables; 9.6 Inference by Truth Table

Propositional Logic: Connectives and Truth Tables

Must-know: P implies Q is false in exactly one row: premise true and conclusion false; all other rows are true. A false premise makes the implication true. Precedence: ¬ > ∧ > ∨ > → > ↔.

⚠️ Top pitfall: Believing a false premise makes an implication false; it makes it true. Only premise-true-plus-conclusion-false falsifies it.

Self-check: What are the two parts of an implication called, and which side is which?

Connects to: 9.3 What Is Logic?; 9.5 Wumpus World as a Propositional Knowledge Base

Wumpus World as a Propositional Knowledge Base

Must-know: The KB is KB = R1 ∧ R2 ∧ R3 ∧ R4 ∧ R5 with seven unique literals P11, B11, P12, P21, P22, P31, B21; negation is an operator, not a literal, so ¬P11 does not add an eighth.

⚠️ Top pitfall: Counting negated literals twice: ¬P11 and P11 are the same literal, because negation is an operator, not a literal.

Self-check: Why are R2 and R3 written with a biconditional instead of a one-direction implication?

Connects to: 9.2 The Wumpus World; 9.4 Propositional Logic: Connectives and Truth Tables; 9.6 Inference by Truth Table

Inference by Truth Table

Must-know: The five steps: extract literals, enumerate all 2^n models, keep KB-true rows, check the query in those rows, entailment holds only if the query is true in every KB-true row; KB |= ¬P12 holds, KB |= ¬P22 does not.

⚠️ Top pitfall: Thinking the first seven columns are inferred from the KB - they are random assignments; only the rule and KB columns are computed. One KB-true row where the query is false kills the entailment.

Self-check: Why is ¬P2,2 NOT entailed even though it holds in two of the three KB-true rows?

Connects to: 9.5 Wumpus World as a Propositional Knowledge Base; 9.7 Logical Equivalences: Theorems for Faster Inference

Logical Equivalences: Theorems for Faster Inference

Must-know: Equivalences rewrite sentences without changing truth in any model; the five-step proof of ¬P12 uses biconditional elimination, and-elimination, contrapositive, modus ponens, De Morgan; there is no fixed order of applying laws - proficiency matters.

⚠️ Top pitfall: Expecting a fixed order of law application - different routes are valid, and CNF + resolution exist to make the process systematic.

Self-check: Which rule lets you conclude beta from (alpha → beta) and alpha? And what does contraposition do to alpha → beta?

Connects to: 9.6 Inference by Truth Table; 9.4 Propositional Logic: Connectives and Truth Tables

Exam Guidance Summary

Must-know: Exam strategy: syllabus = classes 1-16; only the watermarked PDF is allowed; know the five truth-table steps and the equivalence laws + modus ponens, modus tollens, and-elimination.

⚠️ Top pitfall: Preparing from the slides only (worth ~50 percent) or printing individual decks/books (not allowed).

Self-check: What is the only printed material allowed into the open book final exam?

Key Industry Applications

Must-know: The Wumpus World pattern (general rules + percepts + entailment queries) is the template for knowledge-based agent design, mirrored in diagnostics and rule-based systems.

Self-check: Which hardware component implements the truth table of conjunction?

Connects to: 9.1 Knowledge-Based Agents; 9.2 The Wumpus World; 9.4 Propositional Logic: Connectives and Truth Tables; 9.7 Logical Equivalences: Theorems for Faster Inference

Was this lecture useful?

Loading comments…
🤖

BitsNotes AI Assistant

Subject Notes Assistant

Configure AI Chat

Choose how to access the chatbot
Have your own API key?

Switch to "Bring Your Own Key" tab above for unlimited access with any OpenAI-compatible provider.

🔑 Enter API key above to fetch live models from provider, or enter model name manually.
OpenAI-Compatible API Support

Choose any provider preset (Gemini, DeepSeek, Kimi, GLM, MiniMax, Qwen, OpenAI, Groq, Ollama, etc.) or enter a custom endpoint URL.

Security & Privacy First

Your API key is sent directly from your browser to your specified provider. BitsNotes servers never store or see your key.