Chapter 1 · Python
Python: The Dream of Thinking Machines
Run this example
Edit and run the python example
Change the source and run it here. Use the output panel to compare your result with the expected highlights below.
Output
Run the code to see output here.
Examples
Version: 1.0
Status: Editorial Reviewed
Purpose
The examples in this chapter are conceptual and reasoning-focused rather than implementation-heavy.
Readers are introduced to the historical ideas that eventually led to Artificial Intelligence and learn how those ideas appear in real work.
Example 1
Can a Machine Think?
Imagine asking two questions.
Question 1
Can a calculator add numbers?
Everyone answers "Yes."
Question 2
Can a calculator understand why it is adding numbers?
Everyone answers "No."
Now consider a different question.
Could a machine one day reason about problems the same way humans do?
This question inspired decades of AI research.
Example 2
Mechanical Intelligence
A mechanical clock follows rules.
A calculator follows rules.
An early computer follows rules.
Alan Turing asked a revolutionary question:
If reasoning can be represented as rules, could a machine perform reasoning?
That simple question changed computing forever.
Example 3
The Chess Analogy
Imagine teaching someone chess.
Approach A
Teach every possible move.
Impossible.
Approach B
Teach principles.
Evaluate positions.
Plan ahead.
Artificial Intelligence attempts something similar.
Instead of memorizing every situation, modern AI learns patterns that generalize to new situations.
Enterprise Perspective
Although these examples are simple, the same philosophical questions continue to influence modern AI engineering.
Large Language Models do not "think" like humans.
They perform statistical inference over learned representations.
Understanding this distinction prevents unrealistic expectations about AI systems.
Example 4
From Claims Processing to AI Thinking
Imagine a health insurance team reviewing claim approvals.
A human reviewer observes:
- Patient information
- Policy coverage
- Procedure codes
- Prior authorization rules
- Historical denial reasons
The reviewer decides whether the claim should be approved, rejected, or escalated.
This is not "AI" yet.
But it contains the ingredients that AI engineers care about:
| Human work pattern | AI engineering question |
|---|---|
| Observe documents and fields | What data does the system need? |
| Apply policy rules | Which rules are deterministic? |
| Use judgment for edge cases | Which cases require human review? |
| Explain the decision | What evidence must be shown? |
| Learn from mistakes | How will feedback improve the system? |
This is why domain experts can become strong AI engineers.
They understand the real decisions before anyone chooses a model.
Example 5
From QA Testing to AI Evaluation
Alan Turing shifted the question from inner consciousness to observable behavior.
That idea matters deeply to modern AI evaluation.
A QA engineer does not need to know every internal detail of a system to test whether it behaves correctly.
They ask:
- What input did we provide?
- What output did we receive?
- Did the output satisfy the requirement?
- What edge case caused failure?
- Can the failure be reproduced?
AI evaluation uses the same discipline.
When testing an AI assistant, engineers ask:
- Did it answer correctly?
- Did it cite the right source?
- Did it refuse unsafe requests?
- Did it admit uncertainty?
- Did it behave consistently across similar inputs?
The Turing Test is not the final standard for modern AI.
But its deeper lesson remains valuable:
Intelligent behavior must be evaluated through observable evidence.
Example 2 — Runnable: The Boolean Logic Behind a Check-In Decision
Objective
See Boole's idea from this chapter — that a decision can be reduced to true/false facts and a fixed rule for combining them — actually executed, not just diagrammed.
Scenario
This is the exact rule sketched in Figure 1.6: a hotel check-in decision depends on three hard facts.
- Has the guest paid?
- Does a booking exist?
- Is the room available?
Check-in is allowed only if all three are true. There is no partial credit, no probability, no judgment call — this is precisely why Boole's insight mattered. Once reasoning is expressed as true/false facts and a rule, a machine executes it exactly, every time.
The full source is hotel_checkin_logic.py:
The actual output
GUEST DECISION FAILING FACTS
-------------------------------------------------------
G-1 ALLOW CHECK-IN none
G-2 ESCALATE / DENY paid
G-3 ESCALATE / DENY room_available
G-4 ESCALATE / DENY booking_exists
G-5 ESCALATE / DENY paid, booking_exists, room_available
The rule never changes. Only the facts do.
That is the entire idea behind Boolean logic as a computing substrate.
What This Teaches
Guest G-2 has a booking and a room, but has not paid — the rule denies check-in on that one failing fact alone. Guest G-5 fails on all three. Nothing here is a matter of degree: a fact is true or it is false, and the rule combining them is fixed in advance and fully auditable.
This is the same substrate every deterministic system in production still runs on today — pricing rules, access control, fraud holds. The Java port shows the identical logic in the handbook's primary engineering stack.