← All comparisons

Fanal vs. Qafny

ECOOP 2024 · Dafny / Z3

About Qafny

Quantum program verification using separation logic in Dafny. Automated by Z3. Programs can be compiled to SQIR/OpenQASM. Verified Shor’s algorithm in 36 LOC, 36.3s.

Verification Approach

AspectQafnyFanal
PipelineQafny source -> type-guided proof system -> compiled to SEP -> Dafny/Z3 dischargeLean 4 definitions + theorems -> interactive/tactic proofs -> kernel-checked
SoundnessType soundness and proof system soundness/completeness proved in CoqProofs are kernel-checked by construction in Lean 4
Automation strategyEscape to classical verification infrastructure (Dafny/Z3)Build certified automation within Lean 4's type theory
MetatheoryVerified in Coq (separate from implementation)Verified in Lean 4 (same framework as implementation)

Quantum State Encoding

AspectQafnyFanal
Encoding styleOperational: arrays of basis-kets manipulated by type-guided rewritesDenotational: Dirac notation terms with matrix semantics
State typesNor (computational basis), Had (superposition), EN (entanglement)DiracSort: scalar, ket, bra, operator with DataType parameters
Entanglement trackingLoci partition quantum heap into entanglement groupsLDirac layer with disjointness premises on register atoms
No-cloning enforcementFlow-sensitive type system with frozen basis stacksPlanned at type system level
Mixed statesNot supported (pure states only)Potentially supported via density matrix semantics

Automation

AspectQafnyFanal
State rewritesAutomatic: type-guided canonical state transformationsdirac_eq tactic for certified equational reasoning
Predicate transformersF (freeze), U (unfreeze), M (measure) — automaticPlanned: assertion manipulation tactics
BackendDafny + Z3 SMT solver for final proof dischargeLean 4 kernel checks every proof step
User effortVery low: provide program + pre/postconditions + loop invariantsMedium: tactic-assisted proofs (automation under development)
Example: Shor's36.3 seconds, 36 LOCFinal verification goal (with foundational proof)

Programming Language

AspectQafnyFanal
StatusComplete, implemented languageDesign/early implementation phase
Classical constructslet-binding, sequential composition, classical if-elseCExpr layer with variables, arithmetic, booleans
Quantum operationsH, QFT, QFT^-1, OQASM oracles, dis, reducePlanned: general quantum operations
Measurementlet x = measure(y) in e with probability trackingPlanned in Program module
Quantum conditionalsif (b) e where b is Boolean guard on qubitsPlanned in Program module
Variable kindsC (classical), M (measurement result), Q (quantum array)UnifiedType: ctype, dtype, qtype

Assertion Language

AspectQafnyFanal
FormState-mapping predicates: kappa |-> q with separating conjunction *Planned: labelled Dirac notation with orthomodular lattice structure
ExpressivenessSpecialized for automation; describes pure-state arraysGeneral Dirac assertions; can express mixed states, projections, Loewner order
Predicate manipulationF, U, M transformers designed for type-guided proof rulesPlanned: proof automation for assertion implication
NaturalnessCustom notation tailored for Qafny's type systemStandard Dirac notation familiar to physicists

Trust Base

AspectQafnyFanal
Layer 1Coq proofs — type soundness, proof system soundness/completenessLean 4 kernel — small, well-studied type checker
Layer 2Qafny-to-SEP compilation — correctness is future workMathlib — community-maintained, continuously checked
Layer 3Dafny verifier + Z3 SMT solver — trustedFanal definitions — syntax, typing, semantics in Lean 4
Extra axiomsPeriodical theorems for Shor's added as Dafny assumptionsNone beyond Lean standard axioms
OverallLarge trust base with implementation gapSmall trust base with all proofs kernel-checked

Case Studies

AspectQafnyFanal
GHZVerified: 14.2s, 16 LOC, <1 day effortNot yet
Deutsch-JozsaVerified: 8.3s, 13 LOC, <1 day effortDirac encoding available
Grover's SearchVerified: 26.7s, 27 LOC, 2 days effortNot yet
Shor's AlgorithmVerified: 36.3s, 36 LOC, 5 days effortFinal verification goal
Quantum WalkVerified: 43.1s, 49 LOC, 3 days effortNot yet

Compilation

AspectQafnyFanal
To quantum circuitsQafny -> SQIR -> OpenQASM 2.0Future work
To classical codeDafny -> C#/Java/PHP (for classical parts)Not planned
Compilation correctnessTheorem 7 (tested, not fully proved)N/A yet

Summary: Key Differences

AspectQafnyFanal
Proof SystemDafny / Hoare logic + Z3Lean 4 / Dependent type theory
Trust BaseDafny verifier + Z3 (unverified)Lean 4 kernel (fully verified)
Assertion LogicSeparation logic for quantumLabelled Dirac notation + Hoare logic
AutomationHighly automated via Z3Tactic-assisted, D-Hammer integration
CompilationCompiles to SQIR / OpenQASMCompilation planned