Qubits #
theorem
toffoli_characterize
(a b c : Fin 2)
:
toffoli * Matrix.kroneckerMap (fun (x1 x2 : ℂ) => x1 * x2) (e a)
(Matrix.kroneckerMap (fun (x1 x2 : ℂ) => x1 * x2) (e b) (e c)) = if a = 1 ∧ b = 1 then
Matrix.kroneckerMap (fun (x1 x2 : ℂ) => x1 * x2) (e a)
(Matrix.kroneckerMap (fun (x1 x2 : ℂ) => x1 * x2) (e b) (e (1 - c)))
else Matrix.kroneckerMap (fun (x1 x2 : ℂ) => x1 * x2) (e a)
(Matrix.kroneckerMap (fun (x1 x2 : ℂ) => x1 * x2) (e b) (e c))
If we inspect the third qubit on input (a,1,1) we find 1-a.
theorem
partialTraceLeft_tensor_rankOne_basis
{R : Type u_1}
[RCLike R]
{k : Type u_2}
[Fintype k]
[DecidableEq k]
(i : k)
(M : Matrix (k × k) (Fin 1 × Fin 1) R)
:
partialTraceLeft (pureState' (Matrix.kroneckerMap (fun (x1 x2 : R) => x1 * x2) (e i) M)) = pureState' M
theorem
partialTraceLeft_tensor_rankOne_basis'
{R : Type u_1}
[RCLike R]
{k : Type u_2}
[Fintype k]
[DecidableEq k]
(i : k)
(M : Matrix k (Fin 1) R)
:
partialTraceLeft (pureState' (Matrix.kroneckerMap (fun (x1 x2 : R) => x1 * x2) (e i) M)) = pureState' M
theorem
negation_using_toffoli''
(a : Fin 2)
:
have t :=
toffoli * Matrix.kroneckerMap (fun (x1 x2 : ℂ) => x1 * x2) (e a)
(Matrix.kroneckerMap (fun (x1 x2 : ℂ) => x1 * x2) (e 1) (e 1));
partialTraceLeft (pureState' t) = pureState' (Matrix.kroneckerMap (fun (x1 x2 : ℂ) => x1 * x2) (e 1) (e (1 - a)))
theorem
negation_using_toffoli'
(a : Fin 2)
:
partialTraceLeft
(partialTraceLeft
(pureState'
(toffoli * Matrix.kroneckerMap (fun (x1 x2 : ℂ) => x1 * x2) (e a)
(Matrix.kroneckerMap (fun (x1 x2 : ℂ) => x1 * x2) (e 1) (e 1))))) = pureState' (e (1 - a))
May 21, 2026. Best result so far on computing negation using Toffoli gate.
Equations
- bit_from_pureState M = !![0; 1].conjTranspose * M * !![0; 1]
Instances For
theorem
negation_using_toffoli'''
(a : Fin 2)
:
bit_from_pureState
(partialTraceLeft
(partialTraceLeft
(pureState'
(toffoli * Matrix.kroneckerMap (fun (x1 x2 : ℂ) => x1 * x2) (e a)
(Matrix.kroneckerMap (fun (x1 x2 : ℂ) => x1 * x2) (e 1) (e 1))))))
0 0 = 1 - ↑↑a
theorem
scratch_off_tensor_general
{R : Type u_1}
[RCLike R]
{i : Fin 2}
(M : Matrix (Fin 2 × Fin 2) (Fin 1 × Fin 1) R)
:
partialTraceLeft
(Matrix.kroneckerMap (fun (x1 x2 : R) => x1 * x2) (e i) M * (Matrix.kroneckerMap (fun (x1 x2 : R) => x1 * x2) (e i) M).conjTranspose) = M * M.conjTranspose
theorem
scratch_off_tensor
{R : Type u_1}
[RCLike R]
{i j k : Fin 2}
:
have v :=
Matrix.kroneckerMap (fun (x1 x2 : R) => x1 * x2) (e i) (Matrix.kroneckerMap (fun (x1 x2 : R) => x1 * x2) (e j) (e k));
have B := v * v.conjTranspose;
have Bl := partialTraceLeft B;
Bl = Matrix.kroneckerMap (fun (x1 x2 : R) => x1 * x2) (e j) (e k) * (Matrix.kroneckerMap (fun (x1 x2 : R) => x1 * x2) (e j) (e k)).conjTranspose
correct acc. to https://chatgpt.com/c/6a0ba46b-6c94-83e8-8262-52b4a2dc0954 This can be used to compute negation using the Toffoli gate.
theorem
toffoli_characterize.TFAE
(a b c : Fin 2)
:
[a = 1 ∧ b = 1, toffoli * Matrix.kroneckerMap (fun (x1 x2 : ℂ) => x1 * x2) (e a)
(Matrix.kroneckerMap (fun (x1 x2 : ℂ) => x1 * x2) (e b) (e c)) = Matrix.kroneckerMap (fun (x1 x2 : ℂ) => x1 * x2) (e a)
(Matrix.kroneckerMap (fun (x1 x2 : ℂ) => x1 * x2) (e b) (e (1 - c))), toffoli * Matrix.kroneckerMap (fun (x1 x2 : ℂ) => x1 * x2) (e a)
(Matrix.kroneckerMap (fun (x1 x2 : ℂ) => x1 * x2) (e b) (e c)) ≠ Matrix.kroneckerMap (fun (x1 x2 : ℂ) => x1 * x2) (e a)
(Matrix.kroneckerMap (fun (x1 x2 : ℂ) => x1 * x2) (e b) (e c))].TFAE
The usual characterization of the behavior of the Toffoli gate:
the target bit (third bit) will be inverted if
and only if the first and second bits are both 1
from https://en.wikipedia.org/wiki/Toffoli_gate
noncomputable def
quantumCircuit
(A : Matrix (Fin 2 × Fin 2) (Fin 2 × Fin 2) ℂ)
(σ : Equiv.Perm (Fin 2 × Fin 2 × Fin 2))
:
Given a circuit A that only touches 2 qubits,
and a permutation P of 3 qubits,
get a unitary as Pᵀ Q P where Q = A ⊕ I.
Equations
- quantumCircuit A σ = ((Equiv.symm σ).toPEquiv.toMatrix * Matrix.of fun (x y : Fin 2 × Fin 2 × Fin 2) => Matrix.fromBlocks A 0 0 1 (split' x) (split' y)) * (Equiv.toPEquiv σ).toMatrix