LogicQ

LogicQ is a Lean 4 workspace for a verified QEC compilation stack. The code is organized as small languages, each with its own syntax, semantics, and checker.

The current wired compiler path is:

ChainQ code families -> TypeChecker.TypedEnv -> Compiler LogicalOp -> Mixed IR

The longer target stack is:

ChainQ -> PPR -> PPM -> surgery/adapter -> QStab -> QClifford

Some of those languages are implemented as standalone specs before the lowering passes between them are built. The honest contract is in Compiler/CONTRACT.md.

Public Imports

The repository root intentionally has no .lean files. Import public layers through their folder-owned entrypoints:

import LogicQ.Basic
import ChainQ.Basic
import TypeChecker.Basic
import Compiler.Basic
import PPM.Basic

Each source folder has its own README with the local syntax, semantic rule, and small examples.

Folders

FolderWhat lives there
Logicallogical block and logical-qubit addresses
Physicalphysical qubits and physical Pauli strings
ChainQchain-complex/CSS code type system and code families
TypeCheckerlegality checks for logical operations
Compilersource LogicalOp -> Mixed IR compiler and demos
PPRPauli-product rotations
PPMadaptive Pauli-product measurement programs
QStabphysical stabilizer-measurement dataflow
QCliffordphysical Clifford target circuit
MagicQplanned magic-state protocol language
LatticeSurgeryplanned surgery/adapter language
Librarysource-only arXiv library and notes

Build

lake build
lake build LogicQ.Basic ChainQ.Basic TypeChecker.Basic Compiler.Basic

The project uses Lean 4.29.1 and Mathlib 4.29.1. Most of the stack is Mathlib-free; the PPR denotation uses Mathlib matrices and complex numbers.