The ARC Book
Answer • Reason • Check. ARC is a simple way to write small, trustworthy programs. Each case in this book is more than a black box that spits out a result: it is a short story with three parts. First comes the answer to a clear question. Next comes the reason why that answer follows—written in everyday language and supported by the relevant identities, rules, or ideas. Finally comes a check, a concrete test that can fail loudly if an assumption does not hold or an edge case bites. The result is computation with an auditable trail: you can see what was done, why it was valid, and how the page verifies itself.
ARC starts from three ingredients we can all recognize: Data, Logic, and Question. From these we compose a tiny program that is accountable end‑to‑end. We summarize this habit as P3—Prompt → Program → Proof—where the “proof” is practical rather than ceremonial: it is the union of the narrative explanation and the verification the page carries with it. In short:
Proof = Reason Why + Check
This book aims to be welcoming. If you are a student, you should be able to follow the line of thought. If you are a practitioner, you should be able to audit the steps. If you are simply curious, you should be able to tinker, change a value, and watch the consequences unfold. Each page is self‑contained, and each run is meant to be repeatable.
Why JavaScript (pure, in the browser)
We use plain JavaScript so that every case runs instantly in any modern browser with no installation and no build steps. JavaScript gives us exact arithmetic through BigInt, convenient arrays and data views for efficient iteration, and first‑class access to the DOM for simple, interactive visuals. By keeping the math and the interface in the same file, we make it easy to learn from the code, to profile performance with DevTools, and to modify the inputs right on the page. Using one language across all cases also keeps the style uniform; what varies is the idea, not the plumbing.
How to read a case
Begin by skimming the page: what is the question and what does the output look like? Then read the Reason Why; this is the heart of ARC—the place where we explain the steps in sentences. Finally, look at the Check. What does the page verify? A conservation law? A known identity? A bound on error? If the check fails, the page will say so. Treat the checks as part of the learning experience: they are there to make expectations explicit.
If you teach, consider assigning one case as a lab. The combination of code, commentary, and checks invites exploration and discussion; students can experiment safely because the page will complain when something important goes wrong.
P3
ARC’s discipline is easy to remember: P3 — Prompt → Program → Proof. Start with a prompt (the question, the data, and the rules you are willing to use). Write a small program that answers that prompt. Then insist on a proof‑like obligation: an explanation in words plus a check that runs. You can read more at the brief note on P3: https://josd.github.io/arc/p3/.
Examples and test cases
The collection ranges from mathematics and formal logic to routing, clinical policy, and classic puzzles. Each link below opens a self‑contained page that presents the ARC triad in place.
- A₂ (Ackermann via hyper-operations) — Compute A₂ with exact hyper-ops; print small, expand huge safely.
- Apollonian gasket — Exact tangent-circle packing via Descartes’ theorem and complex centers.
- Barbara — Barbara Term Logic example proved using Resolution.
- Bike Trip Planning — Route priorities from hazards, preferences, and declarative JSON rules.
- Binomial Theorem — Sum of all binomial coefficients.
- BMI — Compute BMI categories with explainable thresholds and sanity checks.
- Building Performance — Reason about energy/comfort metrics and verify rule-based outcomes.
- Cauchy–Schwarz inequality — Computing inner products and norms for two vectors.
- Chinese Remainder Theorem — CRT: unique solution mod product of coprime moduli.
- Clinical Care Planning — Derive care plans from observations, guidelines, and policy constraints.
- Collatz (3n+1) — Generate trajectories and check invariants for the Collatz map.
- Combinatorics — Count, choose, and permute with proofs of identities where feasible.
- Complex identities — explanatory proofs — Symbolic steps for complex-number equalities with auditable reasoning.
- Control System — Model simple feedback loops and verify stability/response conditions.
- Cryptarithm — Solve letter-to-digit puzzles with constraint checks on carry/uniqueness.
- Descartes’ circle theorem — Compute the fourth tangent circle from three using curvature relations.
- Easter (Computus) — Derive Easter dates from calendrical rules with verifiable steps.
- Eco-Route — Pick lower-emission routes by fusing traffic, grade, and policy goals.
- Eloquent JavaScript — A self‑contained research brief for Eloquent JavaScript.
- Euclid’s Infinitude of Primes — Restate the theorem, explain Euclid’s one‑line proof, and run computational checks.
- Euler’s characteristic — Compute χ = V−E+F for meshes; sanity-check against topology rules.
- Euler’s identity — The most beautiful equation in mathematics.
- Family logic — Infer kinship from base relations (parent, spouse) with consistency checks.
- Fermat’s Little Theorem — A classic property of prime numbers.
- Fibonacci golden spiral — Draw the spiral from Fibonacci rectangles and verify ratios.
- Fibonacci via Fast Doubling — Compute big Fₙ with fast-doubling recurrences and proof‑style checks.
- Ford circles — Place circles at rationals; verify tangency and Farey‑sequence links.
- Fundamental Theorem of Arithmetic — Every integer factors as a product of primes.
- Gödel Numbering — A classic Gödel numbering demonstrator.
- Gödel Undecidable — A self‑contained research brief for On Formally Undecidable Propositions.
- GPS Bike — GPS for bike trip Gent → Maasmechelen.
- GPS Clinical Bench — Benchmark clinical decisions with transparent rules and audit trails.
- Graph — French cities — Shortest paths and connectivity over a city graph with proofs.
- Grass seed — molecular germination — Model germination states and transitions with rule checks.
- Group Theory — Verify closure, identity, inverses, and associativity on examples.
- Health Information Processing — Transform clinical payloads with typed rules and validation.
- Hertog Hawking — A self‑contained book brief for On the Origin of Time.
- Infinite Game Math — A math‑centric book brief for The Infinite Game.
- Introduction to Logic — A self‑contained book brief for Introduction to Logic.
- It All Adds Up — A self‑contained book brief for It All Adds Up.
- Kakuro (Cross Sums) — Fill grid sums with unique digits using constraint propagation.
- Kaprekar’s Constant — Exhaustive sweep of every 4‑digit state in Kaprekar’s routine.
- KenKen — Latin‑square + cage arithmetic solved with explainable deductions.
- Lee — Maze routing with Lee’s algorithm; trace optimal wavefront paths.
- Leg Length Discrepancy Measurement — Leg Length Discrepancy Measurement from four landmarks.
- Leonhard Euler — A self‑contained research brief for Leonhard Euler..
- Library & Path — Toggle “laws,” search a minimal path to a target observation set.
- Light Eaters — A self‑contained book brief for The Light Eaters.
- Linked Lists — Term logic example proved using Resolution.
- Matrix basics — Add/multiply/invert with dimension/property checks.
- Matrix Determinant — det(AB) = det(A)·det(B).
- Matrix Multiplication — Not commutative (AB ≠ BA).
- N‑Queens — Place N queens without attacks; verify constraints per row/diag.
- Newton–Raphson method — Root‑finding.
- Nonogram (Picross) — Fill grid cells to match run hints using logical deductions.
- Peano Addition — 1+1=2 proved via Resolution.
- Peano Factorial — 5! = 120 proved via Resolution.
- Pentagon & pentagram — golden ratio — Construct φ‑relations in pentagons and star polygons with proofs.
- π (Chudnovsky) — High‑precision π via Chudnovsky series with error‑bound checks.
- Pick’s Theorem — Area = I + B/2 − 1 for lattice polygons; verify counts.
- Poincaré rotation on the circle — An irrational circle rotation is non‑repeating and uniform.
- Polynomial roots (Durand–Kerner) — Find all roots simultaneously; prove convergence on typical cases.
- Primes — Generate/test primes; log certs (trial factors or proofs) as checks.
- Proofs from THE BOOK — A self‑contained book brief for Proofs from THE BOOK.
- Pythagorean Theorem — Compute legs/hypotenuse and confirm with algebraic or area proofs.
- REST‑path — Explain link‑following over REST resources; verify pre/post conditions.
- Roots of Unity — Place complex n‑th roots on the unit circle; check spacing and sums/products.
- Skyscrapers — Deduce building heights from sightlines with constraint logic.
- Socrates — Classic syllogisms with explicit inference traces.
- Square tiled by 17 right triangles — Dissect a square into 17 right triangles; verify tiling constraints.
- Sudoku — Explain each step of solving a 9×9 with row/col/box checks.
- Turing Machine — Run tapes with explicit transitions; verify halting and tape contents.
- Vandermonde’s identity — Binomial‑convolution equals a single binomial.
- Wilson’s Theorem — A property of primes.
- Wind‑Turbine Maintenance — Plan maintenance from telemetry and policies with auditable outcomes.
If you spot an error, have a clearer sentence, or can propose a better check, please do. Small improvements accumulate quickly in a format like this. The only house rule is to keep examples self‑contained and in plain JavaScript so anyone can open them in a browser and learn from them.