How AI Actually "Thinks"

A Guide to Knowledge and Logic
Imagine you’re playing a game of Clue. You have a handful of cards, and you’re watching what other players reveal. You aren't just guessing randomly; you’re using facts to eliminate possibilities. "If Professor Plum isn't in the library, and I have the library card, then the murder didn’t happen there." This is exactly how a knowledge-based agent in AI works.
Most people think of AI as just "learning" from data (like ChatGPT), but a huge part of intelligence is about reasoning. This means taking things we already know and using logic to figure out things we don't know yet.
The Building Blocks: Propositional Logic
To help a computer reason, we have to speak its language. We use propositional logic, where simple letters (symbols) represent facts. For example, P might mean "It is raining" and Q might mean "Harry is inside."
To build complex thoughts, we use connectives:
Not (¬): Flips the truth. If P is true, ¬P is false.
And (∧): Only true if both facts are true.
Or (∨): True if at least one is true.
Implication (→): This is an "If-Then" statement. If it’s raining (P, then Harry is inside (Q).
Biconditional (↔): "If and only if." Harry is inside only if it’s raining, and vice versa.
How the AI Investigates: Models and Inference
A model is basically a "possible world." If you have two facts, there are four possible worlds (both true, both false, or one of each). As we add more facts to our Knowledge Base, we start "eliminating" worlds that are impossible.
When we want to know if something is true, we ask if the Knowledge Base entails the query. In plain English: "Based on everything I know for sure, is it impossible for this new thing to be false?"
AI uses two main ways to figure this out:
1. Model Checking: The AI looks at every single possible world. If our facts are true in a world, it checks if the query is also true. If it holds up in every single case, the AI knows it’s a fact. The downside? If you have 20 different facts, there are over a million worlds to check. That's too slow for a computer to handle.
2. Inference Rules: This is the "smart" way. Instead of checking every world, the AI uses shortcuts. One famous rule is Modus Ponens: If you know "P implies Q" and you know "P is true," you can instantly conclude "Q is true" without checking anything else.
The Power of Resolution
The most "pro" way an AI reasons is called Resolution. It relies on a trick: if you know "AA or BB" is true, and you also know "AA is false," then BB must be true.
AI programs often use a "Proof by Contradiction" here. If an AI wants to prove that Harry is in the kitchen, it starts by assuming Harry is not in the kitchen. It then mashes all its known facts together using Resolution. If it ends up with a blatant contradiction (like saying P is true and P is false at the same time), it knows its starting assumption was wrong. Therefore, Harry must be in the kitchen.
Scaling Up: First-Order Logic
Propositional logic is great, but it’s tedious. If you wanted to say "Every student in this school has a backpack," you’d need a different symbol for every single student.
That’s where First-Order Logic comes in. it uses Quantifiers:
Universal (∀): "For all." You can say "For all x, if x is a student, x has a backpack."
Existential (∃): "There exists." You can say "There is at least one person who knows the secret."