FockMap 0.3.0
See the version list below for details.
dotnet add package FockMap --version 0.3.0
NuGet\Install-Package FockMap -Version 0.3.0
<PackageReference Include="FockMap" Version="0.3.0" />
<PackageVersion Include="FockMap" Version="0.3.0" />
<PackageReference Include="FockMap" />
paket add FockMap --version 0.3.0
#r "nuget: FockMap, 0.3.0"
#:package FockMap@0.3.0
#addin nuget:?package=FockMap&version=0.3.0
#tool nuget:?package=FockMap&version=0.3.0
FockMap
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
NuGet (recommended)
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 10, F#, Python, LaTeX, and all required tooling pre-installed. To use it:
- Install Docker and VS Code with the Dev Containers extension
- Clone the repository and open it in VS Code
- When prompted, click "Reopen in Container" (or run
Dev Containers: Reopen in Containerfrom the command palette) - 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
- New to this topic? Start with Why Encodings?
- Want a full worked example? Go to From Molecules to Qubits
- Prefer hands-on? Try Your First Encoding
- Need API details? Browse All types and functions
Documentation
- Site: johnazariah.github.io/encodings
- Tutorial path: From Molecules to Qubits
- Theory: Why Encodings?
- Mixed theory chapter: Mixed Systems
- Labs: Your First Encoding
- Guides: Architecture
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.
If you want the full derivations and internals, jump to the docs:
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 10 (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
Acknowledgements
This library is dedicated to Dr. Guang Hao Low for his guidance and inspiration in the field of quantum algorithms.
| Product | Versions 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. |
-
net10.0
- FSharp.Core (>= 10.0.103)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.