Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Complexity/Computability/Complexity/Classes/IP.lean
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ private theorem isOraclePPTOn_bppVerifier {p : Polynomial ℕ} {V : α × List B
IsOraclePPTOn enc encBool (bppVerifier enc p V) := by
have hcount : ComputableTidilyInPolyTime (fun a => p.eval (enc a).length) enc encUnary := by
fun_prop
exact (IsPPTOn.map_with (f := fun a r => V (a, r)) hcount.sampleList hV).isOraclePPTOn
exact (IsPPTOn.map_with (f := fun a r => V (a, r)) hcount.sampleList (.of_tidy hV)).isOraclePPTOn

/-- The verifier without messages accepts every prover with the fraction of accepted random
strings. -/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ private theorem isPPTOn_relabelMessage {γ : Type} {input : γ ↪ List Bool} {G
(fst (encPair input encBits) encBits))) (snd (encPair input encBits) encBits))
exact IsPPTOn.map_with (f := fun x bits => relabel (G x) (keysOf (G x).distinctVertices.length
(keyWidth (G x).distinctVertices.length) bits)) hcount.sampleList
(computableTidilyInPolyTime_relabel (hG.comp (fst input encBits)) hkeys)
(.of_tidy (computableTidilyInPolyTime_relabel (hG.comp (fst input encBits)) hkeys))

/-- The verifier is strict oracle PPT. -/
theorem isOraclePPTOn_verifier :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ theorem IsVerifier.exists_decidesInTime
(fun w => V (a, w)) <$> BitString.sampleList (p.eval (enc a).length)
have hcount : ComputableTidilyInPolyTime (fun a => p.eval (enc a).length) enc encUnary :=
(ComputableTidilyInPolyTime.unary_eval p).comp (ComputableTidilyInPolyTime.encoding_length enc)
have hprogram : IsPPTOn enc encBool program := hcount.sampleList.map_with hV
have hprogram : IsPPTOn enc encBool program := hcount.sampleList.map_with (.of_tidy hV)
obtain ⟨k, State, hfinite, machine, c, d, heval, hhalt⟩ := hprogram.exists_halting_machine
refine ⟨k, State, hfinite, machine, c, d, fun a => ?_, fun _ => machine.exists_step_toNTM⟩
have htime : machine.toNTM.RunsInTime (enc a) (c * ((enc a).length + 1) ^ d) :=
Expand Down
2 changes: 1 addition & 1 deletion Complexity/Computability/Complexity/Classes/Padding.lean
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ theorem preimage_mem_NTIME_of_mem_NP {B : Set (List Bool)} {g : α → List Bool
have hcount : ComputableTidilyInPolyTime (fun x : List Bool => p.eval x.length)
encBits encUnary :=
(unary_eval p).comp (encoding_length encBits)
have hprogram : IsPPTOn encBits encBool program := hcount.sampleList.map_with hV.tidy
have hprogram : IsPPTOn encBits encBool program := hcount.sampleList.map_with hV
obtain ⟨k₁, State₁, hfinite₁, M_NP, c₁, d₁, heval₂, hhalt₂⟩ := hprogram.exists_halting_machine
set t₂ : α → ℕ := fun a => c₁ * (t₁ a + 1) ^ d₁
have ht₂_le (a : α) : c₁ * ((g a).length + 1) ^ d₁ ≤ t₂ a :=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ private theorem isPPTOn_sampleList_verifier {p : Polynomial ℕ} {V : α × List
have hcount : ComputableTidilyInPolyTime (fun a => p.eval (enc a).length) enc encUnary :=
(ComputableTidilyInPolyTime.unary_eval p).comp
(ComputableTidilyInPolyTime.encoding_length enc)
hcount.sampleList.map_with hV
hcount.sampleList.map_with (.of_tidy hV)

/-- **Probabilistic-program characterization of `PromiseBPP`**: a promise problem is in
`PromiseBPP` exactly when a uniform strict PPT Boolean program accepts every yes-instance with
Expand Down Expand Up @@ -804,7 +804,7 @@ theorem rpReducible_iff_exists_seeded :
(ComputableTidilyInPolyTime.encoding_length encA)
let R (a : α) : ProbComp β :=
(fun w => f (a, w)) <$> BitString.sampleList (p.eval (encA a).length)
have hR : IsPPTOn encA encB R := hcount.sampleList.map_with hf.tidy
have hR : IsPPTOn encA encB R := hcount.sampleList.map_with hf
refine ⟨R, hR, fun a ha b hb => ?_, fun a ha => ?_⟩
· simp only [R, ProbComp.eval_map, BitString.eval_sampleList,
PMF.mem_support_map_iff, BitString.mem_support_uniformList_iff] at hb
Expand Down
2 changes: 1 addition & 1 deletion Complexity/Computability/Complexity/Classes/Time.lean
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ theorem mem_BPP_iff_exists_mem_BPTIME {α : Type} {enc : α ↪ List Bool} {A :
have hcount : ComputableTidilyInPolyTime (fun a => p.eval (enc a).length) enc encUnary :=
(ComputableTidilyInPolyTime.unary_eval p).comp
(ComputableTidilyInPolyTime.encoding_length enc)
have hprogram : IsPPTOn enc encBool program := hcount.sampleList.map_with hV
have hprogram : IsPPTOn enc encBool program := hcount.sampleList.map_with (.of_tidy hV)
obtain ⟨k, State, hfinite, machine, c, d, heval, hhalt⟩ := hprogram.exists_halting_machine
refine ⟨d, c * 2 ^ d, c, k, State, hfinite, machine,
MultiTapePTM.DecidesWithBoundedErrorInTime.mono (t := fun a => c * ((enc a).length + 1) ^ d)
Expand Down
8 changes: 4 additions & 4 deletions Complexity/Computability/Probabilistic/BoundedUniform.lean
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ theorem isPPTOn_sampleUniformInterval {α : Type} {input : α ↪ List Bool}
have hfind : ComputableTidilyInPolyTime
(fun p : α × List ℕ => p.2.find? (fun value => decide (value < bound p.1)))
(encPair input (encList encUnary)) (encOption encUnary) := by fun_prop
exact hs.map_with hfind
exact hs.map_with (.of_tidy hfind)

/-- Binary bounds need only a unary sampling width and attempt count. The width is the existing
sampler's computed `log₂ bound + 1`, not a unary copy of `bound`; exponential cryptographic
Expand All @@ -80,7 +80,7 @@ theorem isPPTOn_sampleUniformInterval_binary {α : Type} {input : α ↪ List Bo
simp only [min_def, Function.comp_def, decide_eq_true_eq]
have hs : IsPPTOn input encNat (fun a => sampleBoundedIndex (bound a)) := by
apply ((isPPTOn_sampleBinaryNat.preprocess hw).map_with
(f := fun a value => min (bound a) value) hmin).congr
(f := fun a value => min (bound a) value) (.of_tidy hmin)).congr
intro a
rw [sampleBoundedIndex_eq_binary, ← hwidth_eq a]
have hfind : ComputableTidilyInPolyTime
Expand All @@ -89,7 +89,7 @@ theorem isPPTOn_sampleUniformInterval_binary {α : Type} {input : α ↪ List Bo
apply ComputableTidilyInPolyTime.findWithInput (by fun_prop)
exact ComputableTidilyInPolyTime.binary_lt.comp
((ComputableTidilyInPolyTime.snd _ _).prod (by fun_prop))
exact (hs.replicate ha).map_with hfind
exact (hs.replicate ha).map_with (.of_tidy hfind)

/-- A runtime-varying integer box is sampled in uniform strict PPT when the numerical radius,
dimension and per-coordinate attempt budget are efficiently supplied in unary. The full
Expand Down Expand Up @@ -122,7 +122,7 @@ theorem isPPTOn_sampleIntegerBox {α : Type} {input : α ↪ List Bool}
(encList (encOption encInt)) (encOption (encList encInt)) := by
unfold collectBox
fun_prop
exact (((hs.map_with hcoordinate).replicate hd).map hcollect)
exact (((hs.map_with (.of_tidy hcoordinate)).replicate hd).map hcollect)

/-- The complete framed optional output has a direct linear bound in dimension and unary
radius; failure encodes as the empty word. -/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ theorem isPPTOn_sampleCenteredBinomial :
(hcast.comp (ComputableTidilyInPolyTime.snd _ _)))
have hsecond := (hcount.preprocess
(ComputableTidilyInPolyTime.fst encUnary encUnary)).map_with
(f := fun (p : ℕ × ℕ) (negative : ℕ) => (p.2 : ℤ) - negative) hsub
(f := fun (p : ℕ × ℕ) (negative : ℕ) => (p.2 : ℤ) - negative) (.of_tidy hsub)
unfold sampleCenteredBinomial
apply hcount.bind_with
simpa only [bind_pure_comp] using hsecond
Expand Down
2 changes: 1 addition & 1 deletion Complexity/Computability/Probabilistic/Memoize.lean
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ theorem IsPPTOn.memoize {α Key Value : Type} [BEq Key] [LawfulBEq Key] {input :
(encPair valueEncoding (encList (encPair keyEncoding valueEncoding))) := by
unfold finish
fun_prop
refine (hcompute.map_with (f := finish) hpost).congr ?_
refine (hcompute.map_with (f := finish) (.of_tidy hpost)).congr ?_
intro a
rw [Cslib.memoize, lookup_eq_map_find]
cases h : (cache a).find? (fun entry => query a == entry.1) <;>
Expand Down
5 changes: 3 additions & 2 deletions Complexity/Computability/Probabilistic/PPT/Capture.lean
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module
-- upstream: candidate

public import Complexity.Computability.Probabilistic.PPT.Composition
public import Complexity.Computability.Machines.Turing.MultiTape.Complexity.PolyTime.Plain
public import Complexity.Computability.Machines.Turing.MultiTape.Probabilistic.OutputPrefix
import Complexity.Computability.Machines.Turing.MultiTape.Complexity.PolyTime.List
import Complexity.Computability.Probabilistic.Oracle.Composition
Expand Down Expand Up @@ -85,10 +86,10 @@ theorem IsPPTOn.bind_with {first : α → ProbComp β} {second : α → β → P
@[fun_prop]
theorem IsPPTOn.map_with {program : α → ProbComp β} {f : α → β → γ}
(hprogram : IsPPTOn input left program)
(hf : ComputableTidilyInPolyTime (fun pair => f pair.1 pair.2) (encPair input left) right) :
(hf : ComputableInPolyTime (fun pair => f pair.1 pair.2) (encPair input left) right) :
IsPPTOn input right (fun a => f a <$> program a) := by
simpa only [bind_pure_comp] using
hprogram.bind_with (right := right) (second := fun a b => pure (f a b)) hf.isPPTOn
hprogram.bind_with (right := right) (second := fun a b => pure (f a b)) hf.tidy.isPPTOn

/-- Select a closed probabilistic branch with an efficient Boolean condition, using the
empty-channel specialization of oracle branch selection. -/
Expand Down
2 changes: 1 addition & 1 deletion Complexity/Computability/Probabilistic/Repeat.lean
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ theorem IsPPTOn.replicate {α β : Type} {input : α ↪ List Bool} {output : β
(ComputableTidilyInPolyTime.fst input encBits) hrows
have hcoins := (ComputableTidilyInPolyTime.unary_mul.comp (hcount.prod hbudget)).sampleList
apply (hcoins.map_with (f := fun a coins =>
(BitString.listRows (count a) (budget a) coins).map (evaluate a)) hmap).congr
(BitString.listRows (count a) (budget a) coins).map (evaluate a)) (.of_tidy hmap)).congr
intro a
simpa only [ProbComp.eval_map, BitString.eval_sampleList, Function.comp_def] using
(ProbComp.eval_replicate_of_uniformList (count a) (budget a)
Expand Down
6 changes: 6 additions & 0 deletions Complexity/Computability/Probabilistic/Selection.lean
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ theorem IsPPTOn.selectBest {α : Type} {input : α ↪ List Bool}
(fun pair => OracleComp.selectStep (trials pair.1) (test pair.1) pair.2) := by
unfold OracleComp.selectStep
apply (htest'.countTrue htrials').map_with
apply ComputableInPolyTime.of_tidy
dsimp only [OracleComp.selectUpdate, stateEncoding]
polytime
have hloop := (IsPPTOn.iterateWith_spec (stateEncoding := stateEncoding)
Expand All @@ -83,6 +84,11 @@ theorem IsPPTOn.selectFrom {α β : Type} {input : α ↪ List Bool} {output :
(htest : IsPPTOn (encPair input output) encBool (fun pair => test pair.1 pair.2)) :
IsPPTOn input output
(fun a => OracleComp.selectFrom (values a) (trials a) (test a) fallback) := by
have hget : ComputableInPolyTime
(fun p : α × ℕ => ((values p.1)[p.2]?).getD fallback)
(encPair input encUnary) output := by
apply ComputableInPolyTime.of_tidy
fun_prop
unfold OracleComp.selectFrom
ppt

Expand Down
2 changes: 1 addition & 1 deletion Complexity/Computability/Probabilistic/Traverse.lean
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ theorem IsPPTOn.mapM {α β : Type} {input : α ↪ List Bool} {output : β ↪
(encPair input encBits) by fun_prop)
have hcoins := (ComputableTidilyInPolyTime.unary_mul.comp (hcount.prod hbudget)).sampleList
apply (hcoins.map_with (f := fun list tape => list.zipIdx.map
(fun q => evaluate q.1 (BitString.listRow (budget list) q.2 tape))) hrun).congr
(fun q => evaluate q.1 (BitString.listRow (budget list) q.2 tape))) (.of_tidy hrun)).congr
intro list
rw [ProbComp.eval_map, BitString.eval_sampleList]
symm
Expand Down
11 changes: 8 additions & 3 deletions Complexity/Computability/Probabilistic/UniformNat.lean
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,12 @@ theorem isPPTOn_sampleDyadicCoin {α : Type} {input : α ↪ List Bool}
(hbound : ComputableTidilyInPolyTime bound input encUnary)
(hnumerator : ComputableTidilyInPolyTime numerator input encUnary) :
IsPPTOn input encBool (fun a => sampleDyadicCoin (bound a) (numerator a)) := by
unfold sampleDyadicCoin
ppt
have hcallback : ComputableInPolyTime
(fun p : α × ℕ => decide (p.2 < numerator p.1)) (encPair input encUnary) encBool := by
apply ComputableInPolyTime.of_tidy
fun_prop
simpa only [sampleDyadicCoin, bind_pure_comp] using
(isPPTOn_sampleDyadicIndex hbound).map_with hcallback

/-- An efficiently supplied unary bound gives a strict PPT capped index sampler. -/
@[program_certificate]
Expand Down Expand Up @@ -121,6 +125,7 @@ theorem isPPTOn_sampleModNat {α : Type} {input : α ↪ List Bool} {width modul
IsPPTOn input encNat (fun a => sampleModNat (width a) (modulus a)) := by
unfold sampleModNat
exact (ComputableTidilyInPolyTime.sampleBinaryNat hwidth.tidy).map_with
(ComputableTidilyInPolyTime.binary_mod' (by fun_prop) (hmodulus.tidy.comp (by fun_prop)))
(.of_tidy (ComputableTidilyInPolyTime.binary_mod' (by fun_prop)
(hmodulus.tidy.comp (by fun_prop))))

end Cslib.Probability
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@ theorem isPPT_wordInverter {f : List Bool → List Bool}
(fun p : (ℕ × List Bool) × List Bool => evaluate p.1 p.2)
(encPair (encPair encUnary encBits) encBits) encBool)
(c d degree : ℕ) : IsPPT encBits (wordInverter f evaluate c d degree) := by
have hdecode : ComputableInPolyTime
(fun p : (((ℕ × List Bool) × Bool) × List Bool) × List Bool =>
wordDecode f
(fun query => evaluate (p.1.1.1.1, p.1.1.1.2 ++ query) p.1.2 ^^ p.1.1.2)
degree p.1.1.1.1 p.1.1.1.2 p.2)
(encPair (encPair (encPair (encPair encUnary encBits) encBool) encBits) encBits)
encBits := by
apply ComputableInPolyTime.of_tidy
fun_prop
unfold wordInverter coinBudget
ppt

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ theorem isPPTOn_evaluateCircuit (D : DecryptionCircuits E secretWidth ciphertext
hcode)).tidy
apply (isPPTOn_evaluateLayers D hencrypt hevaluate hD hn hpks heks hinputs
hcompiled.fst').map_with
apply Turing.MultiTapeTM.ComputableInPolyTime.of_tidy
apply ComputableTidilyInPolyTime.mapWithInput
(hcompiled.snd'.comp (ComputableTidilyInPolyTime.fst _ _))
exact ComputableTidilyInPolyTime.listGetD_binary [] (by fun_prop) (by fun_prop)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ theorem isPPTOn_keyGen
(ComputableTidilyInPolyTime.snd _ _).fst'
(ComputableTidilyInPolyTime.snd _ _).snd'
simpa only [bind_pure_comp] using hbits.map_with
(show ComputableTidilyInPolyTime
(.of_tidy (show ComputableTidilyInPolyTime
(fun p : (α × (List Bool × List Bool)) × List (List Bool) =>
(encPublicKey (p.1.2.1, p.2), p.1.2.2))
(encPair (encPair input (encPair encBits encBits)) (encList encBits))
(encPair encBits encBits) from
(((ComputableTidilyInPolyTime.fst _ _).snd'.fst'.prod
(ComputableTidilyInPolyTime.snd _ _)).encoded).prod
(ComputableTidilyInPolyTime.fst _ _).snd'.snd')
(ComputableTidilyInPolyTime.fst _ _).snd'.snd'))

include hencrypt in
/-- Decode any public word and encrypt under the decoded base public key. -/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ theorem isPPTOn_evaluateNode
have hcap := (computableTidilyInPolyTime_decryptionArity D hD).comp hn
have hbounded := hraw.map_with (f := fun a ciphertext =>
ciphertext.take (secretWidth (n a) + ciphertextWidth (n a)))
(ComputableTidilyInPolyTime.bitsTake.comp
(.of_tidy (ComputableTidilyInPolyTime.bitsTake.comp
((ComputableTidilyInPolyTime.snd input encBits).prod
(hcap.comp (ComputableTidilyInPolyTime.fst input encBits))))
(hcap.comp (ComputableTidilyInPolyTime.fst input encBits)))))
apply hbounded.congr
intro a
cases node a <;> rfl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ theorem isPPTOn_keyGen
IsPPTOn input (encPair encBits encBits) (fun a => keyGen E (n a) (budget a)) := by
apply (Scheme.isPPTOn_generateKeyChain hkeyGen hencrypt hn
(show ComputableTidilyInPolyTime (fun a => 2 * budget a) input encUnary by fun_prop)).map_with
apply Turing.MultiTapeTM.ComputableInPolyTime.of_tidy
apply computableTidilyInPolyTime_keyPair <;> fun_prop

include hencrypt in
Expand Down Expand Up @@ -146,6 +147,7 @@ theorem isPPTOn_evaluateCircuit {inputCount : α → ℕ}
(.of_tidy hcompiled.fst')).tidy
apply (Scheme.isPPTOn_evaluateLayers D hencrypt hevaluate hD hn hpks hlinks hinputs
hpadded).map_with
apply Turing.MultiTapeTM.ComputableInPolyTime.of_tidy
apply ComputableTidilyInPolyTime.mapWithInput
(hcompiled.snd'.comp (ComputableTidilyInPolyTime.fst _ _))
exact ComputableTidilyInPolyTime.listGetD_binary [] (by fun_prop) (by fun_prop)
Expand Down
2 changes: 1 addition & 1 deletion Complexity/Crypto/Computational/OneWay/BPP.lean
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ theorem isPPT_randomizedPreimageSearch {p : Polynomial ℕ}
exact (unary_eval p).comp ((encoding_length encPreimagePrefix).comp
((fst _ _).prod ((snd _ _).prod ((bitsReplicate false).comp (fst _ _)))))
refine IsPPTOn.map_with hlen.sampleList
(computableTidilyInPolyTime_preimageSearch_of_input ?_ (fst _ _))
(.of_tidy (computableTidilyInPolyTime_preimageSearch_of_input ?_ (fst _ _)))
exact hV.comp ((snd _ _).prod (bitsTakeWithInput (fst _ _).snd'
((unary_eval p).comp ((encoding_length encPreimagePrefix).comp (snd _ _)))))

Expand Down
2 changes: 1 addition & 1 deletion Complexity/Crypto/Computational/OneWay/MCSP.lean
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ theorem isPPTOn_mcspRun
(hV : ComputableTidilyInPolyTime V (encPair MCSP.encInstance encBits) encBool) :
IsPPTOn MCSP.encInstance encBool (mcspRun p V) :=
IsPPTOn.map_with (ComputableTidilyInPolyTime.sampleList
((unary_eval p).comp (encoding_length MCSP.encInstance))) hV
((unary_eval p).comp (encoding_length MCSP.encInstance))) (.of_tidy hV)

/-- The acceptance probability of `mcspRun` is the fraction of accepting coin strings. -/
theorem toReal_eval_mcspRun (p : Polynomial ℕ) (V : MCSP.Instance × List Bool → Bool)
Expand Down
1 change: 1 addition & 0 deletions ComplexityTests.lean
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ import ComplexityTests.PPTruthTable
import ComplexityTests.PRGStretch
import ComplexityTests.Parameterized
import ComplexityTests.PlainAutomationSupport
import ComplexityTests.PlainCapturedMap
import ComplexityTests.PlainLawfulBEq
import ComplexityTests.PolySpaceFold
import ComplexityTests.PolyTimeBinaryWord
Expand Down
41 changes: 41 additions & 0 deletions ComplexityTests/PlainCapturedMap.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/-
Copyright (c) 2026 Samuel Schlesinger. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Samuel Schlesinger
-/

import Complexity.Computability.Probabilistic.PPT.Capture
import Complexity.Tactic.PPT

/-!
# Plain deterministic callbacks with captured probabilistic input

The callback is certified on the entire framed pair of caller input and sampled value. It uses
one uniform machine, with no separate premise about the sampled value's length or distribution.
-/

open Cslib Cslib.Probability Turing.MultiTapeTM

example {α β γ : Type} {input : α ↪ List Bool} {sample : β ↪ List Bool}
{output : γ ↪ List Bool} {program : α → ProbComp β} {callback : α → β → γ}
(hp : IsPPTOn input sample program)
(hf : ComputableInPolyTime (fun p => callback p.1 p.2) (encPair input sample) output) :
IsPPTOn input output (fun a => callback a <$> program a) := by
fail_if_success (clear hf; ppt)
exact hp.map_with hf

-- A raw construction certificate can still be explicitly forgotten inside an existing proof.
example {α β γ : Type} {input : α ↪ List Bool} {sample : β ↪ List Bool}
{output : γ ↪ List Bool} {program : α → ProbComp β} {callback : α → β → γ}
(hp : IsPPTOn input sample program)
(hf : ComputableTidilyInPolyTime (fun p => callback p.1 p.2) (encPair input sample) output) :
IsPPTOn input output (fun a => callback a <$> program a) :=
hp.map_with (.of_tidy hf)

-- The output retains an actual captured word as well as the sampled word.
example {source : ℕ × List Bool → ProbComp (List Bool)}
(hs : IsPPTOn (encPair encUnary encBits) encBits source) :
IsPPTOn (encPair encUnary encBits) encBits
(fun a => (fun word => a.2 ++ word) <$> source a) := by
apply hs.map_with
fun_prop
2 changes: 1 addition & 1 deletion scripts/tidy_surface_baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@
"Complexity/Computability/Probabilistic/Oracle/Tidy.lean": 18,
"Complexity/Computability/Probabilistic/OracleSimulation.lean": 1,
"Complexity/Computability/Probabilistic/PPT.lean": 1,
"Complexity/Computability/Probabilistic/PPT/Capture.lean": 5,
"Complexity/Computability/Probabilistic/PPT/Capture.lean": 4,
"Complexity/Computability/Probabilistic/PPT/Composition.lean": 2,
"Complexity/Computability/Probabilistic/Parameter.lean": 2,
"Complexity/Computability/Probabilistic/Presample.lean": 2,
Expand Down
Loading