Topological quantum computing plugin for FSharp.Azure.Quantum. Provides anyon theory (Ising/Fibonacci/SU(2)_k), braiding compilation, gate-to-braid conversion, Majorana hardware simulator, noise models, and topological file format (.tqp). Seamlessly integrates with main package algorithms (Grover, QFT, QAOA) via IQuantumBackend interface. Requires FSharp.Azure.Quantum v1.3.10+.
$ dotnet add package FSharp.Azure.Quantum.TopologicalTopological Quantum Computing Library for F#
A topological quantum computing library for F#, implementing anyon models, fusion rules, braiding operators, and gate-to-braid compilation. While topological quantum computing is a fundamentally different paradigm -- information is encoded in the topology of anyon worldlines rather than in quantum amplitudes -- this library integrates seamlessly with the gate-based library (FSharp.Azure.Quantum) via the shared IQuantumBackend interface, enabling standard algorithms (Grover, QFT, Shor, HHL) to run on topological backends.
KauffmanBracketIQuantumBackend for seamless integration with gate-based algorithmscreateIsing, createFibonacci, create)IQuantumBackendtopological backend { ... } builder for composing programs.tqp files (human-readable format)# Build the library
dotnet build src/FSharp.Azure.Quantum.Topological/FSharp.Azure.Quantum.Topological.fsproj
# Run tests
dotnet test tests/FSharp.Azure.Quantum.Topological.Tests/FSharp.Azure.Quantum.Topological.Tests.fsproj
open FSharp.Azure.Quantum.Topological
// Define Ising anyons
let sigma = AnyonSpecies.Particle.Sigma
let ising = AnyonSpecies.AnyonType.Ising
// Fuse two sigma anyons (non-abelian!)
let outcomes = FusionRules.fuse sigma sigma ising
// Result: [Vacuum; Psi] - two possible outcomes encode a qubit
// Get braiding phase
let R = BraidingOperators.element sigma sigma AnyonSpecies.Particle.Vacuum ising
// Result: e^(i*pi/8) - topological phase from braiding
// Check quantum dimension
let d = AnyonSpecies.quantumDimension sigma
// Result: sqrt(2) ~ 1.414
open FSharp.Azure.Quantum.Topological
let backend = TopologicalUnifiedBackendFactory.createIsing 10
let program = topological backend {
let! state = initialize AnyonSpecies.AnyonType.Ising 4 // Create 4 sigma anyons
do! braid 0 // Braid anyons 0 and 1
do! braid 2 // Braid anyons 2 and 3
let! outcome = measure 0 // Measure fusion of pair 0
return outcome
}
open FSharp.Azure.Quantum.Topological
// The topological backend implements IQuantumBackend, so standard algorithms work directly
let backend = TopologicalUnifiedBackendFactory.createIsing 20
// Grover search on topological backend (gate-to-braid compilation happens automatically)
let groverResult = AlgorithmExtensions.searchSingleWithTopology 42 8 backend config
// QFT on topological backend
let qftResult = AlgorithmExtensions.qftWithTopology 4 backend qftConfig
// Shor's factoring on topological backend
let shorResult = AlgorithmExtensions.factor15WithTopology backend
let backend = TopologicalUnifiedBackendFactory.createIsing 10
// Sequential operations using Result.bind
match backend.InitializeState 2 with
| Ok state ->
match backend.ApplyOperation (QuantumOperation.Braid 0) state with
| Ok braided ->
match backend.ApplyOperation (QuantumOperation.Measure 0) braided with
| Ok measured -> printfn "Measured: %A" measured
| Error e -> printfn "Measure error: %s" e.Message
| Error e -> printfn "Braid error: %s" e.Message
| Error e -> printfn "Init error: %s" e.Message
807 unit tests covering all 29 modules across 6 architectural layers:
dotnet test tests/FSharp.Azure.Quantum.Topological.Tests/
Tests validate mathematical consistency (Pentagon/Hexagon equations, unitarity, fusion axioms), backend operations, computation expressions, format parsing, knot invariants, magic state distillation, and more.
The library follows a strictly layered architecture that mirrors the gate-based library's structure, integrating via the shared IQuantumBackend interface:
Layer 6: Builders & Formats TopologicalBuilder, TopologicalFormat, Visualization,
TopologicalHelpers
Layer 5: Compilation GateToBraid, BraidToGate, SolovayKitaev, CircuitOptimization,
AlgorithmExtensions
Layer 4: Algorithms MagicStateDistillation, ToricCode, SurfaceCode,
AnyonicErrorCorrection, ErrorPropagation
Layer 3: Operations TopologicalOperations, FusionTree
Layer 2: Backends TopologicalUnifiedBackend, TopologicalUnifiedBackendFactory
Layer 1: Mathematical Foundation AnyonSpecies, FusionRules, BraidingOperators, FMatrix,
RMatrix, ModularData, BraidGroup, BraidingConsistency,
EntanglementEntropy, KauffmanBracket, KnotConstructors
| Gate-Based (FSharp.Azure.Quantum) | Topological (This Library) |
|---|---|
| Qubits, gates, circuits | Anyons, braiding, fusion |
| Amplitude vectors | Fusion trees |
| Z-basis measurement | Fusion outcome measurement |
| Error-prone (needs QEC) | Topologically protected |
| Azure Quantum integration | Simulator + IQuantumBackend integration |
Note: While the paradigms differ, the topological backend implements IQuantumBackend from the gate-based library, enabling standard algorithms (Grover, QFT, Shor, HHL) to run on topological backends via automatic gate-to-braid compilation.
FSharp.Azure.Quantum.Topological
Layer 1: AnyonSpecies, FusionRules, BraidingOperators, FMatrix, RMatrix,
ModularData, BraidGroup, BraidingConsistency, EntanglementEntropy,
KauffmanBracket, KnotConstructors
Layer 2: TopologicalUnifiedBackend, TopologicalUnifiedBackendFactory
Layer 3: FusionTree, TopologicalOperations
Layer 4: MagicStateDistillation, ToricCode, SurfaceCode,
AnyonicErrorCorrection, ErrorPropagation
Layer 5: GateToBraid, BraidToGate, SolovayKitaev, CircuitOptimization,
AlgorithmExtensions
Layer 6: TopologicalBuilder, TopologicalBuilderExtensions, TopologicalFormat,
NoiseModels, Visualization, TopologicalHelpers, TopologicalError
Working examples are in examples/Topological/:
| Example | Description |
|---|---|
BasicFusion.fsx | Fusion rules and anyon properties |
BellState.fsx | Topological Bell state preparation |
BackendComparison.fsx | Compare simulator backends |
FormatDemo.fsx | .tqp format import/export |
MagicStateDistillation.fsx | T-gate via 15-to-1 distillation |
ModularDataExample.fsx | S/T matrices and modular invariants |
KauffmanJones.fsx | Knot invariants from braiding |
TopologicalExample.fsx | General topological operations |
TopologicalVisualization.fsx | State visualization |
ToricCodeExample.fsx | Toric code error correction |
bell-state.tqp | Sample .tqp program file |
.tqp file format referenceAnyons are quasiparticles in 2D systems with exotic exchange statistics -- neither bosonic nor fermionic. When you braid anyons around each other, the quantum state accumulates a topological phase that depends only on the braid pattern, not the specific path. This topological protection makes the stored quantum information exponentially resistant to local noise.
Ising Anyons (SU(2)_2) -- Microsoft's Majorana zero mode approach. Particles: {1, sigma, psi}. Supports Clifford gates natively; needs magic state distillation for universality. Physically realizable.
Fibonacci Anyons -- Universal for quantum computation via braiding alone. Particles: {1, tau}. Golden ratio phi appears throughout. Not yet physically realized.
SU(2)_k (General) -- Framework for arbitrary Chern-Simons levels with computational basis encoding. k=2 (Ising) and k=3 are tested. SpinJ particles with truncated spins for any level k.
Same as parent project (FSharp.Azure.Quantum).