FSharp.Azure.Quantum.Topological 0.3.9

There is a newer version of this package available.
See the version list below for details.
dotnet add package FSharp.Azure.Quantum.Topological --version 0.3.9
                    
NuGet\Install-Package FSharp.Azure.Quantum.Topological -Version 0.3.9
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FSharp.Azure.Quantum.Topological" Version="0.3.9" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FSharp.Azure.Quantum.Topological" Version="0.3.9" />
                    
Directory.Packages.props
<PackageReference Include="FSharp.Azure.Quantum.Topological" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FSharp.Azure.Quantum.Topological --version 0.3.9
                    
#r "nuget: FSharp.Azure.Quantum.Topological, 0.3.9"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package FSharp.Azure.Quantum.Topological@0.3.9
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FSharp.Azure.Quantum.Topological&version=0.3.9
                    
Install as a Cake Addin
#tool nuget:?package=FSharp.Azure.Quantum.Topological&version=0.3.9
                    
Install as a Cake Tool

FSharp.Azure.Quantum.Topological

Topological Quantum Computing Library for F#

A standalone library for topological quantum computing, implementing anyon models, fusion rules, and braiding operators. This project is architecturally independent from the gate-based quantum computing library (FSharp.Azure.Quantum), as topological quantum computing is a fundamentally different paradigm -- information is encoded in the topology of anyon worldlines rather than in quantum amplitudes.

Features

Mathematical Foundation (Layer 1)

  • Anyon Species: Ising (Majorana), Fibonacci, and SU(2)_k particle types with quantum dimensions
  • Fusion Rules: Non-abelian fusion algebra (e.g., sigma x sigma = 1 + psi)
  • Braiding Operators: R-matrices (braiding phases) and F-matrices (fusion basis changes)
  • Modular Data: S-matrix, T-matrix, topological central charge
  • Knot Invariants: Kauffman bracket and Jones polynomial via KauffmanBracket
  • Consistency Verification: Pentagon and hexagon equation checks

Backends and Operations (Layers 2-3)

  • ITopologicalBackend: Backend interface with SimulatorBackend implementation
  • Fusion Trees: Quantum state representation as recursive tree structures
  • TopologicalOperations: Braiding, fusion measurement, superposition management

Algorithms and Compilation (Layers 4-5)

  • Magic State Distillation: 15-to-1 protocol for Ising anyon universality
  • Toric Code: Topological error correction with syndrome detection
  • Gate-to-Braid Compilation: Translate gate-based circuits to braid sequences (21 gate types)
  • Solovay-Kitaev: Gate approximation for efficient braid decomposition

Developer Experience (Layer 6)

  • Computation Expressions: topological backend { ... } builder for composing programs
  • TopologicalFormat: Import/export .tqp files (human-readable format)
  • Noise Models: Configurable noise simulation for realistic error modelling
  • Visualization: State visualization and debugging utilities

Installation

# 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

Quick Start

Low-level API: Fusion and braiding primitives

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

Computation expression: Backend-agnostic programs

open FSharp.Azure.Quantum.Topological

let program backend = topological backend {
    let! ctx = initialize Ising 4       // Create 4 sigma anyons
    let! ctx = braid 0 ctx              // Braid anyons 0 and 1
    let! ctx = braid 2 ctx              // Braid anyons 2 and 3
    let! (outcome, ctx) = measure 0 ctx // Measure fusion of pair 0
    return outcome
}

Railway-oriented composition

let backend = TopologicalBackend.createSimulator AnyonType.Ising 10

backend.Initialize AnyonType.Ising 6
|> TaskResult.bind (backend.Braid 0)
|> TaskResult.bind (backend.Braid 2)
|> TaskResult.bind (fun state ->
    backend.Execute state [
        TopologicalBackend.Measure 0
        TopologicalBackend.Braid 2
        TopologicalBackend.Measure 2
    ]
)

Test Coverage

770 unit tests covering all 27 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.

Architecture

The library follows a strictly layered architecture that mirrors the gate-based library's structure but is fundamentally separate:

Layer 6: Builders & Formats      TopologicalBuilder, TopologicalFormat, Visualization
Layer 5: Compilation              GateToBraid, BraidToGate, SolovayKitaev, CircuitOptimization
Layer 4: Algorithms               MagicStateDistillation, ToricCode, ErrorPropagation
Layer 3: Operations               TopologicalOperations, FusionTree
Layer 2: Backends                 ITopologicalBackend, SimulatorBackend
Layer 1: Mathematical Foundation  AnyonSpecies, FusionRules, BraidingOperators, FMatrix,
                                  RMatrix, ModularData, BraidGroup, BraidingConsistency,
                                  EntanglementEntropy, KauffmanBracket

Why a Separate Project?

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 Standalone simulator (hardware-ready)

Namespace Structure

FSharp.Azure.Quantum.Topological
  Layer 1: AnyonSpecies, FusionRules, BraidingOperators, FMatrix, RMatrix,
           ModularData, BraidGroup, BraidingConsistency, EntanglementEntropy,
           KauffmanBracket
  Layer 2: TopologicalBackend (ITopologicalBackend + SimulatorBackend)
  Layer 3: FusionTree, TopologicalOperations
  Layer 4: MagicStateDistillation, ToricCode, ErrorPropagation
  Layer 5: GateToBraid, BraidToGate, SolovayKitaev, CircuitOptimization
  Layer 6: TopologicalBuilder, TopologicalFormat, NoiseModels, Visualization,
           TopologicalError

Examples

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

Documentation

Background: Topological Quantum Computing

What are Anyons?

Anyons 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.

Implemented Anyon Theories

  1. 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.

  2. Fibonacci Anyons -- Universal for quantum computation via braiding alone. Particles: {1, tau}. Golden ratio phi appears throughout. Not yet physically realized.

  3. SU(2)_k (General) -- Framework for arbitrary Chern-Simons levels. k=2 (Ising) and k=3 are tested.

Future Work

  • Azure Quantum Majorana: Hardware backend integration (when available)
  • Surface Code Variants: Planar codes, color codes
  • Performance: GPU acceleration, sparse matrices, parallel braiding
  • Noise Models: Thermal excitation, braiding imprecision

References

  1. Topological Quantum by Steven H. Simon (2023) -- Chapters 8-11
  2. Anyons in an exactly solved model and beyond -- Kitaev (2006)
  3. Non-Abelian Anyons and Topological Quantum Computation -- Nayak et al. (2008)
  4. Microsoft Quantum Documentation -- Majorana-based quantum computing

License

Same as parent project (FSharp.Azure.Quantum).

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.3.10 88 2/22/2026
0.3.9 89 2/19/2026
0.3.8 85 2/18/2026
0.3.7 86 2/17/2026
0.3.6 94 2/13/2026
0.3.5 93 2/10/2026
0.3.4 107 1/25/2026
0.3.3 187 12/20/2025
0.3.2 168 12/13/2025
0.3.1 428 12/11/2025
0.2.9 431 12/8/2025
0.2.1 320 12/7/2025

v0.3.8: T gate phase convention fix
- FIXED: T gate phase corrected from exp(iπ/8) to exp(iπ/4) in SolovayKitaev and GateToBraid modules, aligning with standard convention (T²=S, T⁴=Z, T⁸=I)
- FIXED: S gate phase corrected from exp(iπ/4) to exp(iπ/2) in SolovayKitaev for consistency
- FIXED: CircuitOptimization template patterns updated for correct T⁸=I periodicity (was T¹⁶=I)
- IMPROVED: GateToBraid discretization now uses π/4 multiples matching corrected T gate
- UPDATED: Fibonacci brute-force gate approximation tolerances adjusted for new T gate matrix
- Status: Ready for Azure Quantum Majorana hardware (when API available)