PSL is a Paninian type system for verifiable embedded firmware. It maps the structural rules of Panini's Astadhyayi (4th c. BCE) directly onto instruction-set semantics, with the goal of making entire classes of embedded bugs structurally inexpressible rather than merely caught at runtime.
The project pairs a working compiler and RISC-V firmware pipeline with machine-checked formal semantics in Lean 4.
Modern hardware/software stacks are bloated because they lack semantic precision at the ISA level. The Astadhyayi is a formally complete, unambiguous rule system — every derivation is either provably valid or structurally impossible. PSL applies those principles to a real instruction set and proves, at each step on freestanding RV32 firmware under QEMU, that Paninian logic yields a leaner, more deterministic execution model than the heuristic layers modern systems accumulate.
- 15 proof sprints complete
- 206 machine-checked assertions (153 firmware checks on RV32 QEMU + 53 verified-compilation checks)
- Differential testing: 5000/5000 passing
- Lean 4 formal spec:
compile_soundproved (zerosorrys, one axiom) - Paper: 12 pages, clean citations and tables
- Three real-world verticals complete (Sprints 11–13)
Research prototype. Proofs establish system-emulated MMIO output and RAM-backed decoder state under QEMU. They do not yet establish execution on physical silicon or an HDL gate-array implementation.
PSL maps Paninian grammatical concepts to machine semantics:
- Karakas (data-flow relations) — source (apadana), destination (karman), instrument (karana), and context (adhikarana) map to registers, memory, buses, and execution context
- Anuvrtti (context inheritance) — omitted operands are inherited from the preceding instruction, compressing code footprint
- Avrtti (bounded repetition) — loop counts are a structural property of the instruction word, eliminating off-by-one risk
- Lopa (structured erasure) — nullification with explicit boundary effects
- Vrddhi (privilege escalation) — structural expansion triggers Ring 0 clearance
- Siddha / Asiddha visibility — a deterministic globally-visible vs. shadow-cache memory model
Every operation compiles to a fixed 32-bit, big-endian instruction word:
31-28 27-24 23-16 15-08 07-00
RING_ID | COMP | OPCODE | TARGET | FLAGS/COND
A rigid layout eliminates decoding drift and keeps binaries predictable and inspectable.
src/— the PSL compiler and RV32 firmware sourceslean/— Lean 4 formal semantics and machine-checked proofsprograms/— the.pvmsource programs (one per sprint)paper/— the LaTeX paper and generated PDFdocs/— specification and supporting documentationevidence/— per-sprint proof artifacts and captured UART tracesrun_rv32_*_pipeline.py— self-asserting build/execute/verify pipelinesrun_verified_compilation_proof.py,run_differential_tests.py— proof and differential-test driversSPEC.md,STATUS.md,formal_semantics.md— deep-dive references
Each sprint produces one concept, one .pvm source file, one compiler extension, one firmware, and one self-asserting pipeline. A pipeline builds the firmware, embeds the compiled binary, runs it under QEMU (-M virt -bios none), captures UART output at MMIO 0x10000000, and asserts the expected markers. The proof is the test passing — not a simulation.
Prerequisites: Python 3.10+, a RISC-V toolchain (riscv64-unknown-elf-gcc), and qemu-system-riscv32. A Dockerfile is provided for a reproducible environment.
# Run the verified compilation proof
python run_verified_compilation_proof.py
# Run the differential test suite
python run_differential_tests.py
# Run a specific RV32 firmware sprint pipeline
python run_rv32_conditional_pipeline.pySee STATUS.md for the full toolchain flags and the per-sprint history.
SPEC.md— language and VM specificationformal_semantics.md— formal semanticsSTATUS.md— sprint-by-sprint history and current statepaper/— the accompanying papercomparative_examples.md— PSL vs. conventional examples
compiler · firmware · dsl · embedded-systems · type-theory · formal-methods · sanskrit · compcert · formal-verification · risc-v · panini · lean4