FockMap 0.3.1

dotnet add package FockMap --version 0.3.1
                    
NuGet\Install-Package FockMap -Version 0.3.1
                    
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="FockMap" Version="0.3.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FockMap" Version="0.3.1" />
                    
Directory.Packages.props
<PackageReference Include="FockMap" />
                    
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 FockMap --version 0.3.1
                    
#r "nuget: FockMap, 0.3.1"
                    
#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 FockMap@0.3.1
                    
#: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=FockMap&version=0.3.1
                    
Install as a Cake Addin
#tool nuget:?package=FockMap&version=0.3.1
                    
Install as a Cake Tool

FockMap

CI codecov NuGet License: MIT .NET 8 Platform

A practical F# library for symbolic operator algebra on Fock space and fermion-to-qubit encodings.

Learn by doing: pick an encoding, map operators to Pauli strings, and compare results.


Why FockMap

If you're exploring quantum chemistry on qubits, you usually hit this question quickly: how do I map fermions to Pauli operators?

FockMap gives you one small, consistent API for that. You can:

  • use built-in encodings (Jordan-Wigner, Bravyi-Kitaev, Parity, tree-based)
  • compare them side-by-side
  • define your own encoding with a few lines of F#
Feature OpenFermion Qiskit Nature FockMap
Define a new encoding ~200 lines Python Not supported 3–5 lines F#
Tree → encoding pipeline
Type-safe operator algebra
Pure functional, zero mutation
Symbolic Pauli algebra (no matrices) Partial
Runtime dependencies NumPy, SciPy Many None

Internally, the library uses exact symbolic Pauli algebra (not floating-point matrix multiplication), so encoded operator manipulation stays fast and predictable.

Available Encodings

Encoding Worst-Case Pauli Weight Framework Function
Jordan-Wigner $O(n)$ Index-set jordanWignerTerms
Bravyi-Kitaev $O(\log_2 n)$ Index-set bravyiKitaevTerms
Parity $O(n)$ Index-set parityTerms
Balanced Binary Tree $O(\log_2 n)$ Path-based balancedBinaryTreeTerms
Balanced Ternary Tree $O(\log_3 n)$ Path-based ternaryTreeTerms

All encodings return the same output type (PauliRegisterSequence), so you can swap schemes without rewriting downstream code.

Installation

dotnet add package FockMap

From source

git clone https://github.com/johnazariah/encodings.git
cd encodings
dotnet build
dotnet test

Dev Container (for contributors)

This repository includes a full dev container configuration with .NET 8 (LTS), F#, Python, LaTeX, and all required tooling pre-installed. To use it:

  1. Install Docker and VS Code with the Dev Containers extension
  2. Clone the repository and open it in VS Code
  3. When prompted, click "Reopen in Container" (or run Dev Containers: Reopen in Container from the command palette)
  4. The container builds, restores packages, compiles the project, and runs tests automatically

Everything is pre-configured, so you can start coding immediately.

Quick Start

open Encodings

// Encode the creation operator a†₂ on 4 modes using Jordan-Wigner
let pauliJW = jordanWignerTerms Raise 2u 4u
// → ½(ZZXI) − ½i(ZZYI)

// Same operator under Bravyi-Kitaev (O(log n) weight)
let pauliBK = bravyiKitaevTerms Raise 2u 4u

// Or Parity encoding
let pauliP = parityTerms Raise 2u 4u

// Tree-based encodings
let pauliBBT = balancedBinaryTreeTerms Raise 2u 4u
let pauliBTT = ternaryTreeTerms Raise 2u 4u

Encode a Full Hamiltonian

open Encodings

// One-electron (h) and two-electron (g) integrals for H₂ in STO-3G basis
let h = Array2D.init 4 4 (fun i j -> (* your integrals *) 0.0)
let g = Array4D.init 4 4 4 4 (fun i j k l -> (* your integrals *) 0.0)

// Encode with any scheme
let hamiltonian = computeHamiltonianWith jordanWignerTerms h g 4u

Define a Custom Encoding

open Encodings

// Build a custom tree and derive an encoding from it
let myTree = balancedBinaryTree 8
let myScheme = treeEncodingScheme myTree
let myEncode op j n = encodeOperator myScheme op j n

Where to Start

Documentation

Build docs locally (with logo/icon + Mermaid/MathJax runtime injection):

./scripts/build-docs.sh

How it Works (briefly)

FockMap exposes two fermionic encoding styles:

  • Index-set encodings (Jordan-Wigner, Bravyi-Kitaev, Parity)
  • Tree/path encodings (balanced binary and ternary trees, plus custom trees)

It also supports bosonic ladder-operator normal ordering via canonical commutation relations (CCR), alongside the fermionic CAR workflow.

For models with both statistics, use sector-tagged operators (fermion, boson) and constructMixedNormalOrdered to canonicalize mixed expressions.

For the full derivations and internals, jump to the Cookbook or the Architecture guide.

Examples

Runnable F# scripts in the examples/ directory:

Script What it does
H2_Encoding.fsx Encode the H₂ molecular Hamiltonian with all 5 encodings
Compare_Encodings.fsx Side-by-side Pauli weight comparison across encodings
Custom_Encoding.fsx Build a custom Majorana encoding from index-set functions
Custom_Tree.fsx Construct a custom tree and derive an encoding from it
Mixed_NormalOrdering.fsx Canonical mixed boson+fermion normal ordering with sector blocks
Mixed_ElectronPhonon_Toy.fsx Toy electron-phonon style mixed symbolic workflow
Mixed_HybridPipeline.fsx Encode fermion sector to Pauli while keeping boson sector symbolic
Mixed_HybridCompare.fsx Compare JW vs BK on extracted fermionic blocks in mixed terms

Run any example with:

dotnet fsi examples/H2_Encoding.fsx

Testing

# Run all tests
dotnet test

# With detailed output
dotnet test --logger "console;verbosity=detailed"

# With coverage
dotnet test --collect:"XPlat Code Coverage"

The test suite covers encoding behavior, Pauli algebra laws, and cross-encoding consistency checks.

Coverage and test counts are tracked in CI.

Cross-Platform

This library runs on Windows, macOS, and Linux via .NET 8 (LTS), Microsoft's open-source, cross-platform runtime. It is written in F#, a functional-first language that is fully open-source under the F# Software Foundation and the .NET Foundation.

No platform-specific code and no native dependencies beyond the .NET SDK.

Citation

If you use this library in your research, please cite:

@software{fockmap2026,
  author = {Azariah, John},
  title = {FockMap: A Composable Framework for Quantum Operator Encodings},
  year = {2026},
  url = {https://github.com/johnazariah/encodings}
}

A machine-readable citation file is available at CITATION.cff.

Contributing

Contributions are welcome! See CONTRIBUTING.md for:

  • How to report bugs and propose features
  • Development setup instructions
  • Coding conventions (pure functions, immutable data, XML docs)
  • Pull request process

License

MIT

Acknowledgements

This library is dedicated to Dr. Guang Hao Low for his guidance and inspiration in the field of quantum algorithms.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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.1 0 2/15/2026
0.3.0 0 2/15/2026
0.2.0 30 2/14/2026
0.1.0 27 2/14/2026