zero_clean_phase_queries_only_constant
A clean phase circuit using no queries computes a constant Boolean function.
Statement
theorem zero_clean_phase_queries_only_constant {N : ℕ} (f : (Fin N → Bool) → Bool)
(h : phase_query_computes_cleanly f 0) : ∀ x y, f x = f y- Source
- Elementary base case for clean phase query circuits.
- Verified
- 17 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 1
- phase_query_computes_cleanlyThere is a normalized finite-dimensional q-query unitary phase-query circuit that returns its initial state with phase (-1) to the power…
The proof, explained
To show that a clean phase circuit with zero queries can only compute a constant Boolean function, we assume for contradiction that there exist two inputs x and y on which f takes different values. Different values of f correspond to distinct phase factors (-1 and 1), yet because zero queries are made, the circuit applies the identical transformation to the initial state ψ regardless of the input. Equating the two resulting outputs forces every amplitude ψ(b) to be zero, contradicting the normalization requirement that the sum of squared amplitudes is 1.
Extract the components of the zero-query clean phase circuit.
The hypothesis that `f` is computed cleanly with zero queries (`phase_query_computes_cleanly f 0`) supplies a finite basis type `B` with decidable equality, a register function, a normalized state vector `ψ` satisfying `∑ b, Complex.normSq (ψ b) = 1`, a unitary matrix `U0`, an empty sequence of query step unitaries, and the computation property `hresult`. Lines 7 and 8 activate the typeclass instances for `B`.
obtain ⟨B, instF, instD, reg, ψ, hψ, U0, hU0, steps, hsteps, hresult⟩ := h letI := instF letI := instDAssume for contradiction that `f` is not constant.
We introduce arbitrary inputs `x` and `y` and assume for contradiction (`by_contra`) that `f x ≠ f y`.
intro x y by_contra hxy
The phase factors corresponding to `f x` and `f y` are distinct.
Because `f x` and `f y` take values in `Bool` and `f x ≠ f y`, one is `true` and the other is `false`. A case split on `f x` and `f y` eliminates the cases where they are equal by contradiction with `hxy`, and evaluates the remaining cases to `-1 ≠ 1` and `1 ≠ -1`.
have hs : (if f x then (-1 : ℂ) else 1) ≠ (if f y then (-1 : ℂ) else 1) := by cases hfx : f x <;> cases hfy : f y · exact (hxy (hfx.trans hfy.symm)).elim · norm_num [hfx, hfy] · norm_num [hfx, hfy] · exact (hxy (hfx.trans hfy.symm)).elim
Every amplitude `ψ b` of the initial state is zero.
For any basis element `b`, evaluating `hresult` on `x` and `y` gives the state vector produced by the circuit. Since the number of queries is zero, the list of query matrices is empty (`List.ofFn_zero`), so the fold over the circuit steps reduces directly to the initial unitary vector `U0.mulVec ψ` (`List.foldl_nil`). Thus `(U0.mulVec ψ) b` equals both `(-1)^(f x) * ψ b` and `(-1)^(f y) * ψ b`. Subtracting these equations gives `((-1)^(f x) - (-1)^(f y)) * ψ b = 0`. Since the phase difference is nonzero (`sub_ne_zero.mpr`), `mul_eq_zero.mp` implies `ψ b = 0`.
uses
List.ofFn_zero,List.foldl_nil,mul_eq_zero.mp,sub_ne_zero.mprhave hz : ∀ b, ψ b = 0 := by intro b have hx := hresult x b have hy := hresult y b simp only [List.ofFn_zero, List.foldl_nil] at hx hy have hh : ((if f x then (-1 : ℂ) else 1) - (if f y then (-1 : ℂ) else 1)) * ψ b = 0 := by linear_combination hy - hx exact (mul_eq_zero.mp hh).resolve_left (sub_ne_zero.mpr hs)
The sum of the squared norms of all amplitudes is zero.
Since `ψ b = 0` for every basis element `b`, every term `Complex.normSq (ψ b)` is zero, so the entire sum over `B` simplifies to zero.
have hsum : (∑ b, Complex.normSq (ψ b)) = 0 := by simp [hz]
The contradiction completes the proof.
Linear arithmetic derives a contradiction between `∑ b, Complex.normSq (ψ b) = 0` and the normalization hypothesis `∑ b, Complex.normSq (ψ b) = 1`.
linarith
List.ofFn_zero- Converting a function with domain `Fin 0` into a list produces the empty list.
List.foldl_nil- Folding any accumulator function over the empty list leaves the initial accumulator unchanged.
mul_eq_zero.mp- If a product of two elements is zero, at least one of the factors is zero.
sub_ne_zero.mpr- If two elements are not equal, their difference is not zero.
- The phase encoding in this circuit model represents a Boolean value `b` by the complex scalar `-1` if `b = true` and `1` if `b = false` (effectively `(-1)^b`).
- Lines 7 and 8 (`letI := instF`, `letI := instD`) register the finiteness and decidability of equality for the basis type `B` into Lean's typeclass synthesis so that finite sums and matrix operations elaborate without error.
Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.
Lean source view module on GitHub
Choose a tactic — a marked line — to see the goals Lean had before and after it, as in Lean’s infoview. Step with ← → or j k.
open scoped BigOperators/-- Zero clean phase queries imply a constant function. -/theorem zero_clean_phase_queries_only_constant {N : ℕ} (f : (Fin N → Bool) → Bool) (h : phase_query_computes_cleanly f 0) : ∀ x y, f x = f y := by obtain ⟨B, instF, instD, reg, ψ, hψ, U0, hU0, steps, hsteps, hresult⟩ := h letI := instF letI := instD intro x y by_contra hxy have hs : (if f x then (-1 : ℂ) else 1) ≠ (if f y then (-1 : ℂ) else 1) := by cases hfx : f x <;> cases hfy : f y · exact (hxy (hfx.trans hfy.symm)).elim · norm_num [hfx, hfy] · norm_num [hfx, hfy] · exact (hxy (hfx.trans hfy.symm)).elim have hz : ∀ b, ψ b = 0 := by intro b have hx := hresult x b have hy := hresult y b simp only [List.ofFn_zero, List.foldl_nil] at hx hy have hh : ((if f x then (-1 : ℂ) else 1) - (if f y then (-1 : ℂ) else 1)) * ψ b = 0 := by linear_combination hy - hx exact (mul_eq_zero.mp hh).resolve_left (sub_ne_zero.mpr hs) have hsum : (∑ b, Complex.normSq (ψ b)) = 0 := by simp [hz] linarith