Documentation

CslibFrontier.Computability.LocallyDecodable.Basic

Locally decodable codes #

A code C : (ι → Bool) → P → Γ encodes messages, bit strings indexed by ι, as words over the alphabet Γ indexed by the positions P. A local decoder A : LocalDecoder ι P Γ is, for each message index i, a program with private coins (ProbOracleComp) that queries positions of a received word and guesses the bit i of the message. The queries are genuine oracle calls, so the decoder may be adaptive, and its query budget is the library's ProbOracleComp.IsQueryBounded: on every path, whatever its coins and the symbols read.

The received word is the oracle: Code.decodeLaw program y answers the private coins uniformly and each query j by y j. A decoder whose expected reads do not depend on the received word has oblivious reads (Code.HasObliviousReads); every non-adaptive decoder (Code.nonadaptive), which draws its queries and its decision rule before reading anything, is one (Code.hasObliviousReads_nonadaptive).

Main definitions #

Main results #

References #

@[reducible, inline]
abbrev Cslib.Code.LocalDecoder (ι P Γ : Type) :

A local decoder for messages indexed by ι from words over the alphabet Γ indexed by the positions P: for each message index i, a program with private coins that queries positions of the received word and guesses the bit i of the message.

@[reducible, inline]
noncomputable abbrev Cslib.Code.wordOracle {P Γ : Type} (y : P → Γ) (q : ℕ ⊕ P) :
PMF (probOracleSpec (fun (x : P) => Γ) q)

The handler answering private coins uniformly and a query of the position j by y j.

noncomputable def Cslib.Code.decodeLaw {P Γ α : Type} (program : ProbOracleComp (fun (x : P) => Γ) α) (y : P → Γ) :
PMF α

The output distribution of a program with private coins run against the received word y.

def Cslib.Code.readCost {P : Type} [DecidableEq P] (j : P) :

The cost of a call that reads the position j; private coins are free.

noncomputable def Cslib.Code.expectedReads {P Γ α : Type} [DecidableEq P] (program : ProbOracleComp (fun (x : P) => Γ) α) (y : P → Γ) (j : P) :

The expected number of times program, run against the received word y, reads the position j.

@[simp]
theorem Cslib.Code.readCost_inl {P : Type} [DecidableEq P] (j : P) (n : ℕ) :
@[simp]
theorem Cslib.Code.readCost_inr {P : Type} [DecidableEq P] (j j' : P) :
readCost j (Sum.inr j') = if j' = j then 1 else 0
theorem Cslib.Code.decodeLaw_eq {P Γ α : Type} (program : ProbOracleComp (fun (x : P) => Γ) α) (y : P → Γ) :
theorem Cslib.Code.expectedReads_eq {P Γ α : Type} [DecidableEq P] (program : ProbOracleComp (fun (x : P) => Γ) α) (y : P → Γ) (j : P) :
structure Cslib.Code.IsLocalDecoder {ι P Γ : Type} [Fintype P] [DecidableEq Γ] (C : (ι → Bool) → P → Γ) (q : ℕ) (δ ε : ℝ) (A : LocalDecoder ι P Γ) :

A is a (q, δ, ε) local decoder for the code C: it makes at most q queries, and from every word within Hamming distance δ |P| of the codeword of x it outputs each bit of x with probability at least 1 / 2 + ε. This is Kerenidis and de Wolf, Definition 1 and Appendix B (arXiv:quant-ph/0208062v2), with adaptive decoders allowed.

For δ < 0 no word is within distance δ |P| of a codeword, so every decoder making at most q queries is a (q, δ, ε) local decoder; the statements below assume 0 < δ where it matters.

  • isQueryBounded (i : ι) : (A i).IsQueryBounded q

    Each bit is decoded with at most q queries on every path.

  • correct (x : ι → Bool) (y : P → Γ) (i : ι) : ↑(hammingDist y (C x)) ≤ δ * ↑(Fintype.card P) → 1 / 2 + ε ≤ ((decodeLaw (A i) y) (x i)).toReal

    Every bit is recovered from every word close to the codeword.

structure Cslib.Code.IsSmoothDecoder {ι P Γ : Type} [Fintype P] [DecidableEq P] (C : (ι → Bool) → P → Γ) (q : ℕ) (c ε : ℝ) (A : LocalDecoder ι P Γ) :

A is a (q, c, ε) smooth decoder for the code C: it makes at most q queries, outputs each bit of x from the codeword of x with probability at least 1 / 2 + ε, and on codewords reads each position at most c / |P| times in expectation.

Compared with Kerenidis and de Wolf, Definition 3 (arXiv:quant-ph/0208062v2), the decoder may be adaptive, and the bound is on expected reads, not on the probability of reading a position. Expected reads bound that probability, so the read-probability clause of the source definition follows; the non-adaptivity clause does not.

  • isQueryBounded (i : ι) : (A i).IsQueryBounded q

    Each bit is decoded with at most q queries on every path.

  • correct (x : ι → Bool) (i : ι) : 1 / 2 + ε ≤ ((decodeLaw (A i) (C x)) (x i)).toReal

    Every bit is recovered from the codeword.

  • smooth (x : ι → Bool) (i : ι) (j : P) : (expectedReads (A i) (C x) j).toReal ≤ c / ↑(Fintype.card P)

    On codewords, no position is read more than c / |P| times in expectation.

def Cslib.Code.IsLocallyDecodable {ι P Γ : Type} [Fintype P] [DecidableEq Γ] (C : (ι → Bool) → P → Γ) (q : ℕ) (δ ε : ℝ) :

The code C is a (q, δ, ε) locally decodable code: it has a (q, δ, ε) local decoder.

def Cslib.Code.IsSmoothCode {ι P Γ : Type} [Fintype P] [DecidableEq P] (C : (ι → Bool) → P → Γ) (q : ℕ) (c ε : ℝ) :

The code C is a (q, c, ε) smooth code: it has a (q, c, ε) smooth decoder.

theorem Cslib.Code.isLocallyDecodable_iff {ι P Γ : Type} [Fintype P] [DecidableEq Γ] {C : (ι → Bool) → P → Γ} {q : ℕ} {δ ε : ℝ} :
IsLocallyDecodable C q δ ε ↔ ∃ (A : LocalDecoder ι P Γ), IsLocalDecoder C q δ ε A
theorem Cslib.Code.isSmoothCode_iff {ι P Γ : Type} [Fintype P] [DecidableEq P] {C : (ι → Bool) → P → Γ} {q : ℕ} {c ε : ℝ} :
IsSmoothCode C q c ε ↔ ∃ (A : LocalDecoder ι P Γ), IsSmoothDecoder C q c ε A
theorem Cslib.Code.IsLocalDecoder.isLocallyDecodable {ι P Γ : Type} [Fintype P] [DecidableEq Γ] {C : (ι → Bool) → P → Γ} {q : ℕ} {δ ε : ℝ} {A : LocalDecoder ι P Γ} (hA : IsLocalDecoder C q δ ε A) :
theorem Cslib.Code.IsSmoothDecoder.isSmoothCode {ι P Γ : Type} [Fintype P] [DecidableEq P] {C : (ι → Bool) → P → Γ} {q : ℕ} {c ε : ℝ} {A : LocalDecoder ι P Γ} (hA : IsSmoothDecoder C q c ε A) :
IsSmoothCode C q c ε
def Cslib.Code.HasObliviousReads {P Γ α : Type} [DecidableEq P] (program : ProbOracleComp (fun (x : P) => Γ) α) :

The program reads each position equally often in expectation against every received word.

theorem Cslib.Code.hasObliviousReads_iff {P Γ α : Type} [DecidableEq P] {program : ProbOracleComp (fun (x : P) => Γ) α} :
HasObliviousReads program ↔ ∀ (y y' : P → Γ) (j : P), expectedReads program y j = expectedReads program y' j
theorem Cslib.Code.HasObliviousReads.expectedReads_eq {P Γ α : Type} [DecidableEq P] {program : ProbOracleComp (fun (x : P) => Γ) α} (h : HasObliviousReads program) (y y' : P → Γ) (j : P) :
expectedReads program y j = expectedReads program y' j

A program with oblivious reads reads each position as often against y as against y'.

The output law #

@[simp]
theorem Cslib.Code.decodeLaw_pure {P Γ α : Type} (y : P → Γ) (a : α) :
@[simp]
theorem Cslib.Code.decodeLaw_bind {P Γ α : Type} (y : P → Γ) {β : Type} (program : ProbOracleComp (fun (x : P) => Γ) α) (next : α → ProbOracleComp (fun (x : P) => Γ) β) :
decodeLaw (program >>= next) y = (decodeLaw program y).bind fun (a : α) => decodeLaw (next a) y
@[simp]
theorem Cslib.Code.decodeLaw_map {P Γ α : Type} (y : P → Γ) {β : Type} (f : α → β) (program : ProbOracleComp (fun (x : P) => Γ) α) :
decodeLaw (f <$> program) y = PMF.map f (decodeLaw program y)
@[simp]
theorem Cslib.Code.decodeLaw_query {P Γ : Type} (y : P → Γ) (j : P) :

A private coin of n bits is uniform. A rewrite lemma, used with rw: simp does not match the call OracleComp.query (.inl n) at the index type of probOracleSpec.

theorem Cslib.Code.decodeLaw_query_inr {P Γ : Type} (y : P → Γ) (j : P) :

A query of the position j is answered by y j. A rewrite lemma, used with rw, like decodeLaw_query_inl.

@[simp]
theorem Cslib.Code.decodeLaw_sample {P Γ α : Type} (y : P → Γ) (program : ProbComp α) :
theorem Cslib.Code.toReal_decodeLaw_add_not {P Γ : Type} (y : P → Γ) (program : ProbOracleComp (fun (x : P) => Γ) Bool) (b : Bool) :
((decodeLaw program y) b).toReal + ((decodeLaw program y) !b).toReal = 1

The probabilities of the two outputs of a decoder add up to one.

Expected reads #

theorem Cslib.Code.sum_readCost {P : Type} [DecidableEq P] [Fintype P] :
∑ j : P, readCost j = fun (q : ℕ ⊕ P) => ↑(Sum.elim (fun (x : ℕ) => 0) (fun (x : P) => 1) q)
theorem Cslib.Code.sum_expectedReads_le {P Γ α : Type} [DecidableEq P] [Fintype P] {program : ProbOracleComp (fun (x : P) => Γ) α} {q : ℕ} (hq : program.IsQueryBounded q) (y : P → Γ) :
∑ j : P, expectedReads program y j ≤ ↑q

A decoder making at most q queries reads at most q positions in expectation.

theorem Cslib.Code.expectedReads_le {P Γ α : Type} [DecidableEq P] {program : ProbOracleComp (fun (x : P) => Γ) α} {q : ℕ} (hq : program.IsQueryBounded q) (y : P → Γ) (j : P) :
expectedReads program y j ≤ ↑q

A decoder making at most q queries reads each position at most q times in expectation.

theorem Cslib.Code.expectedReads_ne_top {P Γ α : Type} [DecidableEq P] {program : ProbOracleComp (fun (x : P) => Γ) α} {q : ℕ} (hq : program.IsQueryBounded q) (y : P → Γ) (j : P) :
expectedReads program y j ≠ ⊤

Non-adaptive decoders #

def Cslib.Code.readAll {P Γ : Type} {q : ℕ} :
(Fin q → P) → ProbOracleComp (fun (x : P) => Γ) (Fin q → Γ)

Read the positions Q 0, …, Q (q - 1) in order, returning the symbols read.

def Cslib.Code.nonadaptive {P Γ R : Type} {q : ℕ} (coins : ProbComp R) (Q : R → Fin q → P) (output : R → (Fin q → Γ) → Bool) :
ProbOracleComp (fun (x : P) => Γ) Bool

The non-adaptive decoder that draws a random string r from coins, reads the positions Q r k for k < q, and outputs output r of the symbols read.

theorem Cslib.Code.isQueryBounded_readAll {P Γ : Type} {q : ℕ} (Q : Fin q → P) :
theorem Cslib.Code.isQueryBounded_nonadaptive {P Γ R : Type} {q : ℕ} (coins : ProbComp R) (Q : R → Fin q → P) (output : R → (Fin q → Γ) → Bool) :
(nonadaptive coins Q output).IsQueryBounded q
@[simp]
theorem Cslib.Code.decodeLaw_readAll {P Γ : Type} {q : ℕ} (Q : Fin q → P) (y : P → Γ) :
theorem Cslib.Code.decodeLaw_nonadaptive {P Γ R : Type} {q : ℕ} (coins : ProbComp R) (Q : R → Fin q → P) (output : R → (Fin q → Γ) → Bool) (y : P → Γ) :
decodeLaw (nonadaptive coins Q output) y = PMF.map (fun (r : R) => output r (y ∘ Q r)) coins.eval
@[simp]
theorem Cslib.Code.expectedReads_query {P Γ : Type} [DecidableEq P] (j' : P) (y : P → Γ) (j : P) :
theorem Cslib.Code.expectedReads_bind {P Γ α : Type} [DecidableEq P] {β : Type} (program : ProbOracleComp (fun (x : P) => Γ) α) (next : α → ProbOracleComp (fun (x : P) => Γ) β) (y : P → Γ) (j : P) :
expectedReads (program >>= next) y j = expectedReads program y j + ∑' (a : α), (decodeLaw program y) a * expectedReads (next a) y j
@[simp]
theorem Cslib.Code.expectedReads_pure {P Γ α : Type} [DecidableEq P] (a : α) (y : P → Γ) (j : P) :
expectedReads (pure a) y j = 0
theorem Cslib.Code.expectedReads_query_bind {P Γ α : Type} [DecidableEq P] (q' : ℕ ⊕ P) (cont : probOracleSpec (fun (x : P) => Γ) q' → ProbOracleComp (fun (x : P) => Γ) α) (y : P → Γ) (j : P) :
expectedReads (OracleComp.query q' >>= cont) y j = readCost j q' + ∑' (a : probOracleSpec (fun (x : P) => Γ) q'), (wordOracle y q') a * expectedReads (cont a) y j

A call reads its position, then the continuation runs on the answer.

@[simp]
theorem Cslib.Code.expectedReads_sample {P Γ α : Type} [DecidableEq P] (program : ProbComp α) (y : P → Γ) (j : P) :
theorem Cslib.Code.expectedReads_readAll {P Γ : Type} {q : ℕ} [DecidableEq P] (Q : Fin q → P) (y : P → Γ) (j : P) :
expectedReads (readAll Q) y j = ∑ k : Fin q, if Q k = j then 1 else 0
theorem Cslib.Code.expectedReads_nonadaptive {P Γ R : Type} {q : ℕ} [DecidableEq P] (coins : ProbComp R) (Q : R → Fin q → P) (output : R → (Fin q → Γ) → Bool) (y : P → Γ) (j : P) :
expectedReads (nonadaptive coins Q output) y j = ∑' (r : R), coins.eval r * ∑ k : Fin q, if Q r k = j then 1 else 0
theorem Cslib.Code.hasObliviousReads_nonadaptive {P Γ R : Type} {q : ℕ} [DecidableEq P] (coins : ProbComp R) (Q : R → Fin q → P) (output : R → (Fin q → Γ) → Bool) :
theorem Cslib.Code.expectedReads_nonadaptive_of_uniform {P Γ R : Type} {q : ℕ} [Fintype P] [Nonempty P] [DecidableEq P] (coins : ProbComp R) (Q : R → Fin q → P) (output : R → (Fin q → Γ) → Bool) (huniform : ∀ (k : Fin q), PMF.map (fun (r : R) => Q r k) coins.eval = Probability.PMF.uniformOfFintype P) (y : P → Γ) (j : P) :
expectedReads (nonadaptive coins Q output) y j = ↑q / ↑(Fintype.card P)

A non-adaptive decoder each of whose q queries is a uniform position reads every position q / |P| times in expectation, against every received word.

theorem Cslib.Code.isSmoothDecoder_nonadaptive_of_uniform {ι P Γ R : Type} {q : ℕ} [Fintype P] [Nonempty P] [DecidableEq P] {C : (ι → Bool) → P → Γ} {ε : ℝ} (coins : ι → ProbComp R) (Q : ι → R → Fin q → P) (output : ι → R → (Fin q → Γ) → Bool) (huniform : ∀ (i : ι) (k : Fin q), PMF.map (fun (r : R) => Q i r k) (coins i).eval = Probability.PMF.uniformOfFintype P) (hcorrect : ∀ (x : ι → Bool) (i : ι), 1 / 2 + ε ≤ ((decodeLaw (nonadaptive (coins i) (Q i) (output i)) (C x)) (x i)).toReal) :
IsSmoothDecoder C q (↑q) ε fun (i : ι) => nonadaptive (coins i) (Q i) (output i)

A non-adaptive decoder each of whose q queries is a uniform position is a (q, q, ε) smooth decoder as soon as it decodes codewords with probability 1 / 2 + ε.