Examples Gallery

The ImandraX examples repository contains 23 verified examples covering algorithms, mathematical theorems, hardware verification, and more. All examples are written in IML and can be run in the VS Code extension.

Sorting algorithms

ExampleDescriptionKey techniques
Insertion SortProves sortedness and element preservationRewrite rules, automatic induction
Merge SortFull correctness with both automatic and manual proofsCustom measures, forward chaining, manual tactics
Quick SortCorrectness via partition into "smalls" and "bigs"Forward-chaining length lemmas

Mathematical theorems

ExampleDescriptionKey techniques
Pigeon Hole PrincipleFor arbitrary-length lists — contrast with SAT/resolution!Generalization, lemma instantiation
Cantor's PairingBijection from ℕ × ℕ to ℕArithmetic reasoning
Coins (3s and 5s)Any integer ≥ 8 is a sum of 3s and 5sConstructive proofs
Summation IdentitiesClosed forms for ∑(4k-1), ∑k, ∑k³Arithmetic induction
Farkas' LemmaProof checker for polynomial constraintsNonlinear arithmetic
Bags (Multisets)Library of multiset operations and theoremsRich library development
PermutationsPermutation via mutual subbag inclusionImports, compositional reasoning
Fulcrum TheoremsBounds on the balance-point problemArithmetic bounds

Algorithms

ExampleDescriptionKey techniques
Boyer-Moore Majority VoteMJRTY algorithm correctness and uniquenessStrategic lemma usage
Ackermann's FunctionRelationship between Ackermann and Peter's versionsLexicographic termination
Towers of HanoiSolver correctnessRecursive algorithm verification
Gilbreath's Card TrickMathematical card trick — lineage: de Bruijn → Huet → Moore → Boyer → PassmoreHistorical proof chain
Tautology CheckerSAT solver via if-normalization (Boyer-Moore '79)Decision procedure verification
Mutilated ChessboardClassic impossibility theoremCombinatorial reasoning

Compilers & machines

ExampleDescriptionKey techniques
Expression CompilerCompiler from expressions to a stack machineCustom induction schemes
Stack MachineMachine with registers and a loop program computing 1+2+...+nMachine verification

Hardware verification

ExampleDescriptionKey techniques
Ripple-Carry AdderFull adder correctness for arbitrary bit widthsAutomatic induction, bit-level reasoning

Control systems

ExampleDescriptionKey techniques
Vehicle ControllerBoyer-Green-Moore feedback controller under bounded disturbanceControl system verification

Data structures

ExampleDescriptionKey techniques
Tree FlatteningTail-recursive flatten equals naive flattenClassic induction benchmark

Learning ImandraX

ExampleDescriptionKey techniques
Simplification ExamplesDemonstrates [%simp], [%simp_only], [%norm]Tactic language tutorial