Fundamentals
The everyday canon — recursion, a sort, a search, primes, the functional triad, a little set theory. Edit and run any of them; this is the same WebAssembly interpreter as the playground.
Factorial
Recursion — base case plus recursive step.
Arbitrary precision
No int64 ceiling: integers promote to arbitrary precision automatically when a result overflows the machine word, so the discrete-math canon — factorials, binomials, powers — stays exact. 100! is 158 digits; 2^256 is the size of the 256-bit keyspace.
Euclid's GCD
The oldest algorithm still in daily use (c. 300 BCE).
Quicksort
Divide and conquer with set-builder partitions around a pivot.
Binary search
Halve the interval each step — O(log n) over a sorted array.
Primes
Trial division as a set comprehension — prime iff it has no divisor.
Map / filter / reduce
The functional triad — sum the squares of the evens.
FizzBuzz
The classic warm-up — multiples of 3, 5 and 15.
Palindrome
Fold a string's characters in reverse, then compare.
Powerset
Set theory is first-class — every subset of {1, 2, 3}.
Search & graph
Traversal and ordering over graphs — including the Datalog one-liner where a single recursive rule computes the entire transitive closure.
Reachability (Datalog)
A recursive Horn rule computes a graph's whole transitive closure.
Depth-first search
Recurse into each neighbour, tracking a visited set.
Breadth-first search
A hand-rolled queue (array + head index) explores level by level.
Dijkstra's shortest path
Weighted shortest paths from a source over a small graph.
Topological sort
DFS post-order, reversed — a valid dependency ordering.
Recursion & backtracking
Problems solved by trying and undoing — the shape of classical search.
Towers of Hanoi
Relocate a stack of disks, three pegs, recursively.
N-Queens
Backtracking: count non-attacking placements on a 6×6 board.
Permutations
Every ordering of a list, built recursively.
Dynamic programming
Overlapping subproblems solved once and cached — by array tabulation, or a dict memo keyed by the subproblem's state.
Fibonacci (memoized)
Top-down memoization — a dict caches each result, so every value is computed once.
Edit distance
Top-down, with a dict memo keyed by a compound "i,j" state — the idiom a flat array can't express directly.
Longest common subsequence
The longest order-preserving shared subsequence (length).
0/1 Knapsack
Maximum value within a weight budget, each item at most once.
Coin change
Fewest coins that make an amount, from given denominations.
Symbolic AI
Axioma's home ground: facts, rules, inference and defeasible reasoning — the classic GOFAI toolkit expressed directly. (Axioma is Datalog-flat, so these are forward-chaining and query-driven, not backtracking search.)
Forward-chaining expert system
Facts plus strict rules chain to a classification; the result is a theorem.
Family-tree inference
Parent facts; recursive ancestor, grandparent and sibling rules.
Unification by join
A shared variable bound across two relations does what unification does.
Defeasible reasoning
A strict law (theorem) survives; a default (conjecture) can be cancelled.
Rule-based NLP
Ordered morphological rules turn a noun into its English plural.
State-space reachability
States and moves as facts; a recursive rule finds every reachable state.
Problem solving
The expert systems above are forward-chaining — they push facts to conclusions. Axioma also ships three solver blocks that work the other way: state a problem, and the engine produces the answer it was never given, then checks its own work. Each one narrates its reasoning in the four phases of George Pólya's How to Solve It.
A problem to find
Pólya's worked example: a rectangular box with edges 3, 4, 12 — how long is its diagonal? Give the unknown a domain and a condition; the engine searches, finds d = 13, and re-verifies it. The answer appears nowhere in the source.
A problem to prove
Switch the directive to prove and the engine derives the goal from rules, places it on the grounding ladder, and reports the proof chain. A strict derivation reaches theorem (proved); a defeasible one would only reach conjecture (plausible).
Means-ends planning (Newell & Simon's GPS)
The 1957 General Problem Solver, made executable. State the world, the goal, and operators with pre / add / del lists; solver/gps reduces the difference by recursively achieving preconditions — backward, goal-directed search. The classic monkey-and-bananas puzzle, solved in four steps.
The solver as a function
The same engine is also an ordinary builtin — polya_solve(spec) — so a problem can be assembled from runtime data and composed into your own code. Here, a reusable box-diagonal solver built at runtime.
Turing-complete, and then some.
Recursion, loops, search, dynamic programming, a full inference engine and a Pólya/GPS problem solver — and every block above is editable and one click from the playground. The philosophical side lives next door in Symbolization.