Adversary-bound SDP and space-efficient transducer tools for Boolean query complexity
Project description
query-complexity
query-complexity is a small Python package for computing adversary-bound SDPs and building the associated space-efficient phase-oracle transducers for Boolean query complexity.
The package intentionally keeps the compact one-vector transducer construction and removes the older direct-sum bit-flip implementation.
Install
From the repository root:
pip install -e .
For development tools:
pip install -e .[dev]
For MOSEK or Qiskit support:
pip install -e .[mosek,qiskit]
General Boolean functions
Use solve_adversary_sdp for arbitrary, non-symmetric Boolean functions.
import query_complexity as qc
inputs = qc.all_binary_inputs(3)
outputs = [int(x[0] and x[1] and x[2]) for x in inputs]
sol = qc.solve_adversary_sdp(
inputs,
outputs,
solver="MOSEK",
epsilon=1e-5,
)
td = qc.build_adversary_transducer(sol)
print("adversary objective:", sol.objective_value)
print("private dimension:", td.private_dim)
print("map error:", td.map_error)
Symmetric Boolean functions
For functions that depend only on Hamming weight, use the Terwilliger/orbit-reduced solver and expand it to the full Boolean basis:
import query_complexity as qc
n = 4
k = 2
sol = qc.solve_symmetric_adversary_sdp(
n,
qc.THRESHOLD_layers(n, k),
solver="MOSEK",
epsilon=1e-5,
)
td = qc.build_adversary_transducer(sol)
print("adversary objective:", sol.objective_value)
print("witness dimensions:", sol.witness_dims)
print("private dimension:", td.private_dim)
If you only want the compact orbit-level SDP solution, use:
orbit = qc.solve_symmetric_orbit_sdp(n, qc.THRESHOLD_layers(n, k))
Analytic helpers
import query_complexity as qc
sol = qc.analytic_or_solution(2)
td = qc.build_adversary_transducer(sol)
qc.show_catalysts(sol)
blocks = qc.threshold_eta_blocks(4, 2)
for r, data in blocks.items():
print(r, data["labels"], data["eta"])
Main API
solve_adversary_sdp(...): full one-vector adversary SDP for arbitrary Boolean domains.solve_symmetric_orbit_sdp(...): compact Terwilliger/orbit-reduced SDP for symmetric functions.solve_symmetric_adversary_sdp(...): symmetric solver plus expansion to the Boolean input basis.build_adversary_transducer(...): construct the input-independent transducer unitary.adversary_query(...): build the input-dependent phase oracle on the witness space.adversary_step(...): return the single-query transducer step.run_adversary_algorithm(...): simulate the repeated transducer algorithm.qiskit_adversary_circuit(...): optional dense-unitary Qiskit circuit export.analytic_or_solution(...): closed-form adversary solution for OR.threshold_eta_blocks(...): closed-form rank-one Schrijver blocks for thresholds.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file query_complexity-0.1.0.tar.gz.
File metadata
- Download URL: query_complexity-0.1.0.tar.gz
- Upload date:
- Size: 15.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0dd98aa3fcaaac65de341906f4bc0261ce6870d81b4680e46d2328ea0a489151
|
|
| MD5 |
9cdbd3bd877ebd5abfbb39756fe545f9
|
|
| BLAKE2b-256 |
ecd1b012869e5111bd5d15bc62d610e3e56157be091b4d55e383ba805500cb81
|
File details
Details for the file query_complexity-0.1.0-py3-none-any.whl.
File metadata
- Download URL: query_complexity-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bbaaab29a5f6f055cc256a117beeb86519dcdd9270fcdbf1c030eebb15b4df10
|
|
| MD5 |
cb6618affafe26dbede280bf42d44ba4
|
|
| BLAKE2b-256 |
e0ab55a6d94b71af13ceb212e6fc82d0a03d392780ecd8dcacecd7f7374466a7
|