← All comparisons

Fanal vs. SQIR/VOQC

POPL 2021 · Coq / QuantumLib

About SQIR/VOQC

Verified optimizer for quantum circuits in Coq. Provides a small quantum intermediate representation (SQIR) and the first formally verified circuit optimizer (VOQC). Focuses on gate-level optimization with proofs of semantic preservation.

Proof Assistant and Foundation

AspectSQIR/VOQCFanal
Proof assistantCoq (v8.x)Lean 4
Language paradigmGallina (dependently typed functional)Lean 4 (dependently typed, do-notation, monads)
Code extractionCoq extraction to OCaml (trusted)Native compilation; no extraction needed
Tactic languageLtac / Ltac2Lean 4 metaprogramming framework
Math libraryCustom matrix/complex libraries (built on QWIRE's)Mathlib (comprehensive, community-maintained)

Abstraction Level

AspectSQIR/VOQCFanal
LevelQuantum circuit (gate sequences)Program-level (Dirac notation + classical expressions)
Program modelU := U1; U2 | G q | G q1 q2 — sequence of gate applicationsLayered: CExpr -> Label -> Dirac -> LDirac -> Program
Classical controlBranching measurement only (meas q P1 P2)Native classical expressions, data types, arrays
NotationDirac notation used informally in proofs onlyFirst-class Dirac notation AST with formal semantics
Target useClose to hardware executionClose to textbook mathematical notation

Quantum State Representation

AspectSQIR/VOQCFanal
Matrix definitionFunctions N -> N -> C with phantom type dimensionsMathlib Matrix with DataType-indexed dimensions
Well-formednessExternal WF_Matrix predicate (M i j = 0 outside bounds)Enforced by Lean/Mathlib type system (Fintype indices)
Ill-typed denotationZero matrix (simplifies proofs)Option.none (explicit failure)
Gate liftingTensor products with identity matrices (apply_1, apply_2)Access path model with register atom reindexing
Register modelNatural number indices into global registerNamed register labels with hierarchical access paths

Type System

AspectSQIR/VOQCFanal
ComplexityMinimal: gate set + register size, bounds checkingRich: DataType, DiracSort, UnifiedContext, DTIso
Qubit identityConcrete numeric indices (m != n means different qubits)Named variables with structured access paths
Register arraysNot supportedFirst-class: DataType.array n t with arrayIdx
Big operatorsNot supportedbigSum and bigTsr for parametric system size
Design rationaleSimplicity — concrete indices simplified proofs vs QWIRE's abstract approachExpressiveness — named registers for algorithm-level reasoning

Optimization and Compilation

AspectSQIR/VOQCFanal
OptimizerVOQC: 5+ verified optimization passes (not propagation, Hadamard reduction, gate cancellation, rotation merging, circuit mapping)Not targeted; compilation is future work
Verified compilationSQIR -> OpenQASM translator; circuit mapping for hardware connectivityPlanned (roadmap item D)
Performance17.8% total gate reduction, 41.4% T-gate reduction on 28 benchmarksN/A
Gate set{H, X, Rz(k), CNOT} with rational rotation parametersAny operator expressible in Dirac notation
Hardware mappingVerified for Tenerife, LNN, ring, 2D grid topologiesNot yet addressed

Automation

AspectSQIR/VOQCFanal
Key tacticgridify: normalizes matrix expressions into grid normal formdirac_eq: certified term rewriting for Dirac equalities
Target domainCircuit-level matrix equivalences (up to ~5 qubits)Mathematical-level Dirac notation equalities
Gate list frameworkLibrary functions for manipulating SQIR programs as gate listsDirac term AST with evaluation semantics
Well-formedness automationPhantom types reduce proof burdenType inference functions produce typing derivations

Case Studies

AspectSQIR/VOQCFanal
GHZ state preparationVerified (arbitrary n)Not yet
Quantum teleportationVerified (fixed n=3)Not yet
Deutsch-JozsaVerifiedDirac encoding available
Grover's searchVerifiedNot yet
QPEVerifiedNot yet
Circuit optimizations28 benchmarks verified correctNot targeted
Dirac identitiesNot formalizedEncoded and verified (QCQI, Pauli, KLM)

Complementarity

AspectSQIR/VOQCFanal
Compilation backendCould serve as SQIR target for Fanal's compilation pipelineCould compile programs down to SQIR circuits
Proof technique sharinggridify tactic for matrix normalizationD-Hammer-inspired decision procedures for Dirac
Cross-verificationCircuit-level algorithm implementations as referenceProgram-level encodings for cross-validation
LimitationDifferent proof assistants (Coq vs Lean 4) — requires portingDifferent proof assistants (Lean 4 vs Coq) — requires porting

Summary: Key Differences

AspectSQIR/VOQCFanal
Proof SystemCoq (Calculus of Constructions)Lean 4 (CIC with quotients)
Abstraction LevelGate-level circuits (SQIR IR)High-level quantum programs
Primary GoalVerified circuit optimizationProgram verification & reasoning
CompilationVerified compilation to OpenQASMCompilation planned
ExpressivenessNo loops or classical controlClassical-quantum language with loops