Commonplace Book
A collection of insights, proofs, and patterns at the intersection of formal methods, functional programming, and AI systems
Commonplace Book
"Commonplacing is a practice of compiling knowledge–a sort of intellectual scrapbook. From the Renaissance through the nineteenth century, educated people maintained commonplace books to collect extracts, preserve wisdom, and synthesize understanding."
This digital commonplace book represents the convergence of three intellectual streams: formal methods, functional programming, and AI-assisted verification. Following centuries of scholarly tradition—from Marcus Aurelius to John Locke to Ralph Waldo Emerson—it serves as both research log and teaching resource.
On Verification and Trust
The Verification Paradox
November 2023
"We verify programs with programs, prove theorems with proof assistants, and check our checkers with other checkers. At what point do we ground our trust?"
The recursive nature of verification reveals a fundamental epistemological challenge. Every verification tool embodies assumptions about computation and correctness. The choice of specification language itself represents a philosophical stance about what properties matter.
Formal Methods in Practice
March 2024
"In theory, formal methods are perfect. In practice, they're perfectible."
The gap between theoretical guarantees and practical application remains the central challenge. Leslie Lamport's insight resonates: "The question is not whether to use formal methods, but which formal methods to use when, and how formally to use them."
Elegant Specifications
QuickSort in TLA+
January 2024
The beauty of TLA+ lies in expressing what rather than how:
IsSorted(arr) ==
\A i, j \in DOMAIN arr : i < j => arr[i] <= arr[j]
Permutation(arr1, arr2) ==
\A x \in Values : Count(x, arr1) = Count(x, arr2)
SortSpec ==
/\ IsSorted(array')
/\ Permutation(array, array')
This specification captures the essence of sorting without prescribing an algorithm. The separation of concerns—correctness from implementation—exemplifies the power of declarative specification.
Liquid Neural Networks in TLA+
June 2024
Formalizing continuous dynamics in discrete specifications presents unique challenges:
LiquidDynamics(neuron, input) ==
LET tau == neuron.timeConstant
recurrent == SumWeightedInputs(neuron)
IN (-neuron.state + input + recurrent) / tau
StabilityInvariant ==
\A t \in Time : Energy(state[t+1]) <= Energy(state[t])
The specification bridges continuous mathematics and discrete verification, capturing essential properties while abstracting implementation details.
Functional Patterns
The Meta-Circular Evaluator
September 2023
The meta-circular evaluator remains the most elegant demonstration of Scheme's expressive power:
(define (eval exp env)
(cond ((self-evaluating? exp) exp)
((variable? exp) (lookup-variable-value exp env))
((lambda? exp)
(make-procedure (lambda-parameters exp)
(lambda-body exp)
env))
((application? exp)
(apply (eval (operator exp) env)
(list-of-values (operands exp) env)))
(else (error "Unknown expression type" exp))))
This is not merely an implementation—it's a specification of Scheme itself. The duality between implementation and specification makes it perfect for verification work.
Category Theory in Code
February 2024
Category theory provides a language for program structure that transcends specific implementations:
;; Functor laws verification
(define (verify-functor-laws fmap)
(and
;; Identity: fmap id = id
(equal? (fmap identity data) data)
;; Composition: fmap (f . g) = (fmap f) . (fmap g)
(equal? (fmap (compose f g) data)
(compose (fmap f) (fmap g) data))))
These patterns appear everywhere once you know to look for them—in monads, applicatives, and traversables.
Bridging Paradigms
LLMs for Invariant Discovery
July 2024
Using language models to suggest verification conditions represents a paradigm shift:
def suggest_invariants(code, spec):
"""AI suggests, formal methods verify."""
# LLM generates hypotheses
suggestions = llm.analyze(f"""
Given this code: {code}
And specification: {spec}
Suggest loop invariants and preconditions
based on common verification patterns.
""")
# Formal validation
return [inv for inv in suggestions
if verify_syntax(inv) and seems_reasonable(inv)]
The key insight: LLMs excel at pattern recognition across codebases. They suggest invariants that might take hours to discover manually. We use AI for hypothesis generation, not proof.
Liquid Networks Meet Verification
September 2024
Bridging continuous dynamics and discrete verification:
(define (verify-liquid-stability network)
(let ([energy-sequence (map network-energy (network-history network))])
(and (monotonic-decreasing? energy-sequence)
(bounded? (network-states network))
(converges? network 0.01))))
The mathematical foundation of liquid networks makes them more amenable to formal analysis than traditional deep learning architectures.
Research Synthesis
The Verification-Synthesis Duality
January 2025
Verification and synthesis are two sides of the same coin:
- Verification: Given program P and spec S, prove P ⊨ S
- Synthesis: Given spec S, find P such that P ⊨ S
Every verification technique suggests a dual synthesis approach: 1. Counterexample-guided synthesis uses failed proofs 2. Proof-directed synthesis mirrors proof structure in code 3. Invariant-driven development writes properties first
AI's Role in Formal Methods
February 2025
AI transforms formal methods in three ways:
- Hypothesis Generation: Suggesting likely properties from patterns
- Proof Search: Guiding heuristics with learned strategies
- Specification Mining: Extracting specs from natural language
But we must be careful—the goal is augmentation, not replacement. AI handles creative aspects while formal methods ensure correctness.
Current Investigations
Keybase as Verification Infrastructure
August 2025
Exploring Keybase's cryptographic infrastructure for distributed verification:
;; Cryptographic proof of verification
(define (sign-verification proof verifier result)
(keybase-sign
(format "VERIFY ~a ~a ~a"
(proof-hash proof)
verifier
result)))
;; Consensus mechanism
(define (proof-consensus verifications threshold)
(>= (count 'accept verifications) threshold))
The cryptographic guarantees could revolutionize distributed verification workflows.
Neural Architecture Specification Language
July 2025
Developing a DSL for verified neural architectures:
(define-architecture liquid-reservoir
(layer input (size 10))
(layer reservoir (size 100) (dynamics liquid))
(layer output (size 5))
(property stability
(forall t (< (energy t) (energy 0))))
(property separation
(forall x y (> (output-distance x y) 0.1))))
A world where neural architectures come with formal specifications, like software modules with type signatures.
Future Directions
The convergence of formal methods, functional programming, and AI is not just inevitable—it's necessary. As systems grow more complex, only their intersection provides both power and trust.
Research agenda 2025-2027: - Formal specifications for transformer architectures - Bidirectional synthesis-verification tools - Category theory as neural architecture foundation - Distributed verification networks with economic incentives
"The best way to predict the future is to implement it—correctly."