✦ functional · compiled · proven

Write it.
Prove it.
Ship it.

First is a functional language that compiles to native binaries via LLVM — with a built-in theorem prover. Write pure functions, then prove them correct, in the same file.

Why First

All the safety. None of the ceremony.

⚡

Native performance

Compiles to optimised LLVM IR. Proofs are erased at compile time — zero runtime overhead. Ship the same binary you would from C or Rust.

🔒

Built-in theorem prover

Tactics like ring, omega, linarith, and simp let you prove properties of functions in the same source file — no separate proof tool.

🧩

Refinement types

Annotate any parameter as {x: T | predicate}. The compiler checks call sites with Z3. Contracts live in the type, not in test files.

🤖

AI-powered errors

Pass --ai-errors to get plain-English explanations of every type error from Claude, GPT-4o, DeepSeek, or Kimi — provider-agnostic, opt-in.

↔

Effects made explicit

Pure function vs side-effecting interaction is enforced by the type system — no monads, no annotations, no discipline required.

∀

Dependent types

Length-indexed vectors, sigma types, type-returning functions, universe polymorphism — without leaving the familiar C-style syntax.


Up in under a minute

macOS
Linux
Verify
# Homebrew (recommended)
brew tap akkeshavan/first
brew install first-compiler

Installs firstc, fir, and first-lsp. Requires Homebrew.

# Auto-detects x86_64 or aarch64
curl -sSfL https://raw.githubusercontent.com/akkeshavan/first/main/scripts/install-linux.sh | bash

Downloads from GitHub Releases. Installs to /usr/local (or ~/.local without sudo). Restart your terminal after.

firstc --version
# first compiler 0.3.2
fir --help
fir new hello && cd hello && fir run
The Book

Learn First, end to end

24 chapters across two parts: First as a programming language, then First as a theorem prover. All example code runs with fir run.

Part I — First as a Programming Language
01
Getting StartedInstall, create a project, Hello World, --ai-errors
02
Functions and InteractionsPure function vs side-effecting interaction
03
Modules, Import, ExportSplit code across files; export and import
04
Basic Types and ExpressionsInt, Float, Bool, String; literals; type inference
05
Control Flowif, for-in, range, FizzBuzz
06
Records and Pattern MatchingRecord types, ADTs, match, destructuring
07
Generic TypesParametric polymorphism, generic functions and types
08
RecursionStructural recursion, tail-call optimisation
09
Interfacesinterface declarations, implementation, ToString/Eq/Ord
10
ArraysArray<T>, arrayLength, insertAt, filter, reduce
11
Date and MathDate and Math standard libraries
12
Dependent TypesVec<T,n>, Fin<n>, Pi/Sigma types, dependent pattern matching
13
Refinement Types{x: T | predicate}, call-site checking, safe division
14
Higher-Kinded TypesFunctor<F<_>>, implementing HKTs for Option
15
Building Libraries and Packagesfir.json, fir install, publishing, the ecosystem
Part II — First as a Theorem Prover
16
Introduction to Theorem ProvingWhy proofs? theorem, Eq, proof irrelevance
17
Basic Tacticsrefl, ring, omega, linarith, decide, simp, have, exact
18
Advanced Tacticsinduction, cases, calc, use, obtain, by_contra, push_neg
19
Proving Your ProgramsTheorems about functions you write; correctness proofs
20
Axioms and @[simp]axiom declarations, @[simp] attributes, trusted foundations
21
The Math Standard LibraryNat, Int, Real, Rat, Complex, Bool, Set, List
22
Type Classes in ProofsGeneric theorems with class/instance/[Constraint]
23
Contributing to first-mathlibWrite lemmas, use axiom stubs, submit PRs
24
Termination and Total Functionstotal, decreasing, well-founded recursion, vs Lean 4
Appendices
A
Math FunctionsBuilt-in Math library reference
B
ArrayBufMutable array buffers and low-level memory
C
Monadic Operators>>=, >>, return in interaction context
D
Type ReferenceComplete built-in type quick-reference
E
Concurrency and AsyncChannels, goroutine-style concurrency
F
Case Study: JSON ParserBuilding a real parser end to end

Ecosystem

First doesn't stand alone

🔧 first (compiler)

The compiler, standard library, language spec, test suite, and fir package manager. Targets macOS and Linux on x86_64 and arm64.

github.com/akkeshavan/first ↗

📐 first-examples

Runnable fir projects for every chapter of this book, plus standalone applications: a blog-post verifier, theorem-proving applications, and type-level guarantee demos.

github.com/akkeshavan/first-examples ↗

∑ first-mathlib

A growing library of formally stated mathematics: ring laws, number theory, linear algebra, analysis, topology, and combinatorics — over 20 mathematical domains.

github.com/akkeshavan/first-mathlib ↗

📗 first-book (this site)

The official book — 24 chapters plus appendices. All source is Markdown; contributions and corrections are welcome via pull request.

github.com/akkeshavan/first-book ↗