Documentation

CslibFrontier.Computability.Interactive.ToIP

Bridge from Public-Coin Interactive Reductions to IP #

A public-coin interactive protocol (Cslib.Interactive.Verifier and Cslib.Interactive.Reduction in World.plain) exchanges typed prover messages M and public verifier challenges C according to a round specification s : Spec. In contrast, the complexity class Cslib.Complexity.IP runs a word-level oracle verifier (WordOracleComp Unit Bool) against an arbitrary stateful, randomized bit-string prover (Cslib.Complexity.Prover Unit).

This module bridges the two models:

  1. Round codecs and adversarial decoding (ProverCodec, ChallengeCodec, RoundCodecs): Each prover round specifies a bit-length cap limit, a partial parser decode : List Bool → Option M, and a fallback message default : M. Incoming prover bit strings are truncated to limit bits; any reply for which decode returns none marks the transcript invalid (causing the word-level verifier to reject) while substituting default in the typed transcript stub.
  2. Word-level verifier compilation (runWordRounds, Verifier.wordVerifierWith, Verifier.wordVerifier): Compiles a typed Interactive.Verifier into a WordOracleComp Unit Bool.
  3. Completeness transfer (honestWordProver, Reduction.Complete.acceptProb_wordVerifier): When the round codecs are lawful (RoundCodecs.Lawful), an honest typed prover compiles to a word-level prover with the exact same acceptance probability, transferring completeness error ε_c to word-level acceptance probability at least 1 - ε_c.
  4. Soundness transfer against arbitrary stateful randomized provers (optimalTypedStrategy, Verifier.Sound.acceptProb_wordVerifier): By backwards induction over the finite set BitString.shortWords c.limit of truncated bit replies in each prover round and public challenge conditioning in each verifier round, every stateful PMF word prover is bounded by an optimal plain-model typed ProverStrategy. Thus plain-model soundness with error ε_s implies word-level soundness with error ε_s against all Cslib.Complexity.Prover Unit.
  5. Statistical-distance stability and uniform IP membership (closeTo_runWordRounds, Verifier.isOraclePPTOn_wordVerifierWith, mem_IP_of_reduction_closeTo, Reduction.mem_IP): Replacing ideal challenge samplers by δ-close distributions shifts word-level acceptance probabilities by at most PerChallenge.sum s δ, and polynomial-time round codecs plus challenge samplers yield IsOraclePPTOn and membership in Cslib.Complexity.IP.

Main definitions #

Main results #

References #

Round codecs and adversarial decoding #

A bounded bit-word codec for a prover-round message type M. Honest messages are serialized by encode; raw prover replies are truncated to limit bits and parsed by decode. Malformed replies (decode w = none) cause the word-level verifier to reject while substituting default in the typed transcript stub.

  • encode : M → List Bool

    Serialize a typed prover message as a bit word.

  • decode : List Bool → Option M

    Parse a truncated bit word into an optional typed message.

  • default : M

    Fallback message used in the transcript stub when decode returns none.

  • limit : ℕ

    Maximum number of bits read from a prover reply in this round.

Total adversarial decoder obtained by falling back to c.default on none.

A prover codec is lawful when every honest message is recovered after truncation to limit bits.

def Cslib.Interactive.ProverCodec.ofTotal {M : Type} (encode : M → List Bool) (decode : List Bool → M) (default : M) (limit : ℕ) :

Build a prover codec from a total decoder that always succeeds.

theorem Cslib.Interactive.ProverCodec.lawful_ofTotal {M : Type} {encode : M → List Bool} {decode : List Bool → M} {default : M} {limit : ℕ} (h : ∀ (m : M), decode (List.take limit (encode m)) = m) :
(ofTotal encode decode default limit).Lawful
def Cslib.Interactive.ProverCodec.ofDecoder {M : Type} {enc : M ↪ List Bool} (D : Turing.MultiTapeTM.Decoder enc) (default : M) (limit : ℕ) :

Build a prover codec from an injective bit-word encoding enc and a total Decoder enc.

theorem Cslib.Interactive.ProverCodec.lawful_ofDecoder {M : Type} {enc : M ↪ List Bool} (D : Turing.MultiTapeTM.Decoder enc) (default : M) {limit : ℕ} (hlen : ∀ (m : M), (enc m).length ≤ limit) :
(ofDecoder D default limit).Lawful

Canonical codec for fixed-width bit strings BitString n.

Canonical codec for raw bit lists of length at most limit.

theorem Cslib.Interactive.ProverCodec.lawful_bits (limit : ℕ) {w : List Bool} (hw : w.length ≤ limit) :
(bits limit).decode (List.take limit ((bits limit).encode w)) = some w

A bit-word codec for a public verifier challenge type C.

  • encode : C → List Bool

    Serialize a challenge so the word-level prover can read it from the query payload.

  • decode : List Bool → C

    Recover the challenge from its serialized bit word.

A challenge codec is lawful when decode left-inverts encode.

Build a challenge codec from an injective bit-word encoding enc and a Decoder enc.

Canonical challenge codec for fixed-width bit strings BitString n.

Canonical challenge codec for a single Boolean coin.

@[reducible]

Per-round message and challenge codecs for a protocol specification s.

@[reducible]

Every round codec in s round-trips honest messages and challenges.

Word-level execution of a public-coin verifier #

Execute the rounds of s as a word-level oracle computation against an untyped bit-word prover (Operation = Unit), returning whether all prover replies decoded validly together with the resulting typed transcript.

noncomputable def Cslib.Interactive.Verifier.wordVerifierWith {Statement OutStmt : Type} {s : Spec} (V : Verifier OracleSpec.empty s Statement OutStmt) (codecs : RoundCodecs s) (smp : Spec.PerChallenge ProbComp s) (x : Statement) :

Compile a plain-model typed Interactive.Verifier into a word-level oracle verifier using the challenge samplers smp and round codecs codecs. The verifier accepts when every prover reply decodes validly and V.outputOn x returns some _.

noncomputable def Cslib.Interactive.Verifier.wordVerifier {Statement OutStmt : Type} {s : Spec} (V : Verifier OracleSpec.empty s Statement OutStmt) (codecs : RoundCodecs s) (x : Statement) :

Compile a plain-model typed Interactive.Verifier into a word-level oracle verifier using its own challenge samplers V.samplers.

Honest prover compilation and completeness transfer #

@[reducible]

State of the compiled word-level prover for an honest typed prover strategy in World.plain, defined by structural recursion on s so that HonestWordState α s : Type.

@[reducible]

Initial state of the compiled honest word-level prover at the start of s.

Single-query transition of the compiled honest word-level prover.

Compile a plain-model typed prover computation into a word-level Cslib.Complexity.Prover Unit.

theorem Cslib.Interactive.runWith_honestWordState_runWordRounds_embed {α : Type} (s : Spec) (codecs : RoundCodecs s) :
codecs.Lawful → ∀ (smp : Spec.PerChallenge ProbComp s) (P : ProbOracleComp OracleSpec.empty (ProverStrategy (ProbOracleComp OracleSpec.empty) s α)) {State : Type} (respond : Unit × List Bool → StateT State PMF (List Bool)) (embed : HonestWordState α s → State), (∀ (q : Unit × List Bool) (st : HonestWordState α s), respond q (embed st) = PMF.map (Prod.map id embed) (HonestWordState.respond s codecs q st)) → PMF.map Prod.fst (ProbOracleComp.runWith respond (runWordRounds s codecs smp) (embed (HonestWordState.init s P))) = PMF.map (fun (r : s.Transcript × α) => (true, r.1)) (plainLaw (P >>= runStrategy s smp))

Generalized simulation lemma: when respond simulates HonestWordState.respond s codecs along embed : HonestWordState α s → State, running runWordRounds produces the exact transcript distribution of plainLaw (P >>= runStrategy s smp) with validity flag true.

When codecs is lawful, running runWordRounds against HonestWordState.respond produces the exact transcript distribution of plainLaw (P >>= runStrategy s smp) with validity flag true.

theorem Cslib.Interactive.acceptProb_wordVerifier_honestWordProver {Statement OutStmt : Type} {s : Spec} {α : Type} (V : Verifier OracleSpec.empty s Statement OutStmt) (codecs : RoundCodecs s) (hLawful : codecs.Lawful) (x : Statement) (P : ProbOracleComp OracleSpec.empty (ProverStrategy (ProbOracleComp OracleSpec.empty) s α)) :
Complexity.acceptProb (V.wordVerifier codecs x) (honestWordProver codecs P) = (World.plain.eval (V.execute x P)).toOuterMeasure {(fst, out, snd) : Execution s OutStmt α | out.isSome = true}

The word-level acceptance probability of V.wordVerifier codecs x with honestWordProver equals the plain-model probability that V.execute x P outputs some _.

theorem Cslib.Interactive.Reduction.Complete.acceptProb_wordVerifier {Statement Witness OutStmt OutWit : Type} {s : Spec} {R : Reduction OracleSpec.empty OracleSpec.empty s Statement Witness OutStmt OutWit} {relIn : Statement → Witness → Prop} {relOut : OutStmt → OutWit → Prop} {ε_c : ENNReal} (hComp : Complete World.plain R relIn relOut ε_c) {codecs : RoundCodecs s} (hLawful : codecs.Lawful) {x : Statement} {w : Witness} (hrel : relIn x w) :

Completeness transfer: if a plain-model reduction R is complete with error ε_c and codecs is lawful, then for every valid statement-witness pair (x, w), the compiled honest word-level prover makes R.verifier.wordVerifier codecs x accept with probability at least 1 - ε_c.

Adversarial decoding and soundness transfer #

noncomputable def Cslib.Interactive.ProverCodec.bestDecodedMsg {M : Type} (c : ProverCodec M) (val : M → ENNReal) :
M

Choose the decoded message c.decodeOrDefault w for w ∈ BitString.shortWords c.limit that maximizes the continuation acceptance value val.

theorem Cslib.Interactive.ProverCodec.le_bestDecodedMsg {M : Type} (c : ProverCodec M) (val : M → ENNReal) (w : List Bool) {m : M} (hdec : c.decode (List.take c.limit w) = some m) :
val m ≤ val (c.bestDecodedMsg val)

Every truncated reply w.take c.limit that decodes to some m has continuation value at most val (c.bestDecodedMsg val).

Optimal plain-model typed ProverStrategy constructed by backwards induction over the rounds s to maximize the probability of satisfying accept.

theorem Cslib.Interactive.runWith_runWordRounds_le_optimalTypedStrategy (s : Spec) (codecs : RoundCodecs s) (smp : Spec.PerChallenge ProbComp s) (accept : s.Transcript → Bool) (P : Complexity.Prover Unit) (pState : P.State) :
(ProbOracleComp.runWith P.respond (runWordRounds s codecs smp) pState).toOuterMeasure {((valid, τ), snd) : (Bool × s.Transcript) × P.State | (valid && accept τ) = true} ≤ (plainLaw (runStrategy s smp (optimalTypedStrategy s codecs smp accept))).toOuterMeasure {r : s.Transcript × Unit | accept r.1 = true}

For every word-level prover P : Cslib.Complexity.Prover Unit and starting state pState, the probability that runWordRounds s codecs smp produces a valid transcript accepted by accept is bounded by the plain-model acceptance probability of optimalTypedStrategy.

theorem Cslib.Interactive.acceptProb_wordVerifier_le_optimalTypedStrategy {Statement OutStmt : Type} {s : Spec} (V : Verifier OracleSpec.empty s Statement OutStmt) (codecs : RoundCodecs s) (x : Statement) (P : Complexity.Prover Unit) :
Complexity.acceptProb (V.wordVerifier codecs x) P ≤ (World.plain.eval (V.execute x (pure (optimalTypedStrategy s codecs V.samplers fun (τ : s.Transcript) => (V.outputOn x τ).isSome)))).toOuterMeasure {(fst, out, snd) : Execution s OutStmt Unit | out.isSome = true}

For every word-level prover P : Cslib.Complexity.Prover Unit, the acceptance probability of V.wordVerifier codecs x is bounded by the plain-model acceptance probability of optimalTypedStrategy.

theorem Cslib.Interactive.Verifier.Sound.acceptProb_wordVerifier {Statement OutStmt : Type} {s : Spec} {V : Verifier OracleSpec.empty s Statement OutStmt} {langIn : Set Statement} {ε_s : ENNReal} (hSound : Sound World.plain V langIn Set.univ ε_s) (codecs : RoundCodecs s) {x : Statement} (hx : x ∉ langIn) (P : Complexity.Prover Unit) :

Soundness transfer: if V is sound with error ε_s for reducing langIn to Set.univ (every non-none output is considered acceptance), then for every x ∉ langIn and every word-level prover P : Cslib.Complexity.Prover Unit, acceptProb (V.wordVerifier codecs x) P ≤ ε_s.

theorem Cslib.Interactive.Verifier.Sound.to_univ {Statement OutStmt : Type} {s : Spec} {V : Verifier OracleSpec.empty s Statement OutStmt} {langIn : Set Statement} {langOut : Set OutStmt} {ε_s : ENNReal} (hSound : Sound World.plain V langIn langOut ε_s) (hout : ∀ x ∉ langIn, ∀ (τ : s.Transcript) (y : OutStmt), V.outputOn x τ = some y → y ∈ langOut) :
Sound World.plain V langIn Set.univ ε_s

If V is sound with error ε_s for reducing langIn to langOut and V.outputOn x τ only outputs elements of langOut when x ∉ langIn (for instance when langOut = language Accept), then V is sound for reducing langIn to Set.univ.

theorem Cslib.Interactive.Reduction.isInteractiveProof_wordVerifier {Statement Witness OutStmt OutWit : Type} {s : Spec} {R : Reduction OracleSpec.empty OracleSpec.empty s Statement Witness OutStmt OutWit} {relIn : Statement → Witness → Prop} {relOut : OutStmt → OutWit → Prop} {ε_c ε_s : ENNReal} (hComp : Complete World.plain R relIn relOut ε_c) (hSound : Verifier.Sound World.plain R.verifier (language relIn) Set.univ ε_s) {codecs : RoundCodecs s} (hLawful : codecs.Lawful) :

An interactive reduction R that is complete with error ε_c and sound with error ε_s (to Set.univ) induces a word-level IsInteractiveProof with completeness 1 - ε_c and soundness ε_s for language relIn.

Statistical-distance stability for approximate challenge samplers #

@[reducible]

Zero per-round error vector for a protocol specification s.

@[reducible]

Pointwise statistical closeness of per-round challenge samplers.

theorem Cslib.Interactive.closeTo_runWordRounds (s : Spec) (codecs : RoundCodecs s) {smp₁ smp₂ : Spec.PerChallenge ProbComp s} {δ : Spec.PerChallenge (fun (x : Type) => ENNReal) s} :
PerChallenge.CloseTo s smp₁ smp₂ δ → ∀ (P : Complexity.Prover Unit) (pState : P.State), Probability.CloseTo (ProbOracleComp.runWith P.respond (runWordRounds s codecs smp₁) pState) (ProbOracleComp.runWith P.respond (runWordRounds s codecs smp₂) pState) (PerChallenge.sum s δ)

Replacing challenge samplers smp₁ by δ-close challenge samplers smp₂ changes the word-level execution distribution of runWordRounds by at most PerChallenge.sum s δ in total variation against any stateful word prover P.

theorem Cslib.Interactive.Verifier.closeTo_wordVerifierWith {Statement OutStmt : Type} {s : Spec} (V : Verifier OracleSpec.empty s Statement OutStmt) (codecs : RoundCodecs s) {smp₁ smp₂ : Spec.PerChallenge ProbComp s} {δ : Spec.PerChallenge (fun (x : Type) => ENNReal) s} (hClose : PerChallenge.CloseTo s smp₁ smp₂ δ) (x : Statement) (P : Complexity.Prover Unit) :
Probability.CloseTo (PMF.map Prod.fst (P.run (V.wordVerifierWith codecs smp₁ x) P.init)) (PMF.map Prod.fst (P.run (V.wordVerifierWith codecs smp₂ x) P.init)) (PerChallenge.sum s δ)

If PerChallenge.CloseTo s smp₁ smp₂ δ, then the acceptance probabilities of V.wordVerifierWith codecs smp₁ x and V.wordVerifierWith codecs smp₂ x against any word-level prover P differ by at most PerChallenge.sum s δ.

theorem Cslib.Interactive.Verifier.acceptProb_wordVerifier_le_wordVerifierWith_add {Statement OutStmt : Type} {s : Spec} (V : Verifier OracleSpec.empty s Statement OutStmt) (codecs : RoundCodecs s) {smp : Spec.PerChallenge ProbComp s} {δ : Spec.PerChallenge (fun (x : Type) => ENNReal) s} (hClose : PerChallenge.CloseTo s V.samplers smp δ) (x : Statement) (P : Complexity.Prover Unit) :
theorem Cslib.Interactive.Verifier.acceptProb_wordVerifierWith_le_wordVerifier_add {Statement OutStmt : Type} {s : Spec} (V : Verifier OracleSpec.empty s Statement OutStmt) (codecs : RoundCodecs s) {smp : Spec.PerChallenge ProbComp s} {δ : Spec.PerChallenge (fun (x : Type) => ENNReal) s} (hClose : PerChallenge.CloseTo s V.samplers smp δ) (x : Statement) (P : Complexity.Prover Unit) :

Uniform polynomial-time certificates and IP membership #

@[reducible]

Per-round bit-word encodings for a protocol specification s, giving a canonical nested-pair encoding RoundEncodings.transcript : Transcript s ↪ List Bool.

@[reducible]

The nested-pair encoding of Transcript s induced by per-round encodings.

A ProverCodec M is polynomial-time with respect to encM : M ↪ List Bool when both its validity test (decode ·).isSome and its total fallback decoder decodeOrDefault are polynomial-time computable.

A prover codec whose partial decode is polynomial-time with respect to encOption encM is polynomial-time.

theorem Cslib.Interactive.ProverCodec.isPolyTime_ofTotal {M : Type} {encM : M ↪ List Bool} {encode : M → List Bool} {decode : List Bool → M} {default : M} {limit : ℕ} (hdec : Turing.MultiTapeTM.ComputableInPolyTime decode Turing.MultiTapeTM.encBits encM) :
IsPolyTime encM (ofTotal encode decode default limit)

A ProverCodec.ofTotal is polynomial-time whenever its total decoder is polynomial-time.

theorem Cslib.Interactive.ProverCodec.isPolyTime_ofDecoder {M : Type} {encM : M ↪ List Bool} (D : Turing.MultiTapeTM.Decoder encM) (default : M) (limit : ℕ) :
IsPolyTime encM (ofDecoder D default limit)

A ProverCodec.ofDecoder D default limit is automatically polynomial-time.

A ChallengeCodec C and challenge sampler smp : ProbComp C are polynomial-time with respect to encC : C ↪ List Bool when smp is IsPPTOn and c.encode is polynomial-time.

@[reducible]

Per-round polynomial-time certificate for RoundCodecs s and challenge samplers smp.

When the round codecs and challenge samplers of s are polynomial-time, runWordRounds is a uniform polynomial-time word-oracle computation (IsOraclePPTOn) for any input encoding encIn.

theorem Cslib.Interactive.Verifier.isOraclePPTOn_wordVerifierWith {Statement OutStmt : Type} {s : Spec} (V : Verifier OracleSpec.empty s Statement OutStmt) (encStmt : Statement ↪ List Bool) (encs : RoundEncodings s) (codecs : RoundCodecs s) (smp : Spec.PerChallenge ProbComp s) (hRounds : RoundCodecs.IsPolyTime encs codecs smp) (hDecide : Turing.MultiTapeTM.ComputableInPolyTime (fun (p : Statement × s.Transcript) => (V.outputOn p.1 p.2).isSome) (Turing.MultiTapeTM.encPair encStmt encs.transcript) Turing.MultiTapeTM.encBool) :

If the round codecs and challenge samplers of s are polynomial-time and the verifier's acceptance predicate (V.outputOn x τ).isSome is polynomial-time in (x, τ), then the compiled word-level verifier V.wordVerifierWith codecs smp is IsOraclePPTOn.

theorem Cslib.Interactive.Verifier.isOraclePPTOn_wordVerifier {Statement OutStmt : Type} {s : Spec} (V : Verifier OracleSpec.empty s Statement OutStmt) (encStmt : Statement ↪ List Bool) (encs : RoundEncodings s) (codecs : RoundCodecs s) (hRounds : RoundCodecs.IsPolyTime encs codecs V.samplers) (hDecide : Turing.MultiTapeTM.ComputableInPolyTime (fun (p : Statement × s.Transcript) => (V.outputOn p.1 p.2).isSome) (Turing.MultiTapeTM.encPair encStmt encs.transcript) Turing.MultiTapeTM.encBool) :

Special case of Verifier.isOraclePPTOn_wordVerifierWith when smp = V.samplers.

theorem Cslib.Interactive.mem_IP_of_reduction_closeTo {Statement Witness OutStmt OutWit : Type} {s : Spec} {R : Reduction OracleSpec.empty OracleSpec.empty s Statement Witness OutStmt OutWit} {relIn : Statement → Witness → Prop} {relOut : OutStmt → OutWit → Prop} {encStmt : Statement ↪ List Bool} {encs : RoundEncodings s} {codecs : RoundCodecs s} {smp : Spec.PerChallenge ProbComp s} {δ : Spec.PerChallenge (fun (x : Type) => ENNReal) s} {ε_c ε_s : ENNReal} (hLawful : codecs.Lawful) (hRounds : RoundCodecs.IsPolyTime encs codecs smp) (hDecide : Turing.MultiTapeTM.ComputableInPolyTime (fun (p : Statement × s.Transcript) => (R.verifier.outputOn p.1 p.2).isSome) (Turing.MultiTapeTM.encPair encStmt encs.transcript) Turing.MultiTapeTM.encBool) (hClose : PerChallenge.CloseTo s R.verifier.samplers smp δ) (hComp : Reduction.Complete World.plain R relIn relOut ε_c) (hSound : Verifier.Sound World.plain R.verifier (language relIn) Set.univ ε_s) (hεc : ε_c + PerChallenge.sum s δ ≤ 1 / 3) (hεs : ε_s + PerChallenge.sum s δ ≤ 1 / 3) :
language relIn ∈ Complexity.IP encStmt

Public-coin interactive reductions to IP: if a relation relIn admits a plain-model interactive reduction R with completeness error ε_c, soundness error ε_s (to Set.univ), lawful round codecs codecs, and challenge samplers smp within total variation δ of R.verifier.samplers such that ε_c + PerChallenge.sum s δ ≤ 1 / 3 and ε_s + PerChallenge.sum s δ ≤ 1 / 3, and the compiled word verifier is IsOraclePPTOn, then language relIn ∈ IP encStmt.

theorem Cslib.Interactive.Reduction.mem_IP {Statement Witness OutStmt OutWit : Type} {s : Spec} {R : Reduction OracleSpec.empty OracleSpec.empty s Statement Witness OutStmt OutWit} {relIn : Statement → Witness → Prop} {relOut : OutStmt → OutWit → Prop} {encStmt : Statement ↪ List Bool} {encs : RoundEncodings s} {codecs : RoundCodecs s} {ε_c ε_s : ENNReal} (hLawful : codecs.Lawful) (hRounds : RoundCodecs.IsPolyTime encs codecs R.verifier.samplers) (hDecide : Turing.MultiTapeTM.ComputableInPolyTime (fun (p : Statement × s.Transcript) => (R.verifier.outputOn p.1 p.2).isSome) (Turing.MultiTapeTM.encPair encStmt encs.transcript) Turing.MultiTapeTM.encBool) (hComp : Complete World.plain R relIn relOut ε_c) (hSound : Verifier.Sound World.plain R.verifier (language relIn) Set.univ ε_s) (hεc : ε_c ≤ 1 / 3) (hεs : ε_s ≤ 1 / 3) :
language relIn ∈ Complexity.IP encStmt

Public-coin interactive reductions to IP (exact challenge samplers): if a relation relIn admits a plain-model interactive reduction R with completeness error ε_c ≤ 1 / 3, soundness error ε_s ≤ 1 / 3 (to Set.univ), and lawful polynomial-time round codecs, then language relIn ∈ IP encStmt.