Documentation

CslibFrontier.Computability.PolyTime.PessimisticEstimator

Polynomial-time transfer for greedy pessimistic-estimator and multi-choice derandomization #

PolyTimeGreedyInput packages an input-parameterized instance of Cslib.PessimisticEstimator.greedy (round list, initial state, binary branch transition, and pessimistic estimator / conditional expectation) and proves plain multi-tape polynomial-time computability (Turing.MultiTapeTM.ComputableInPolyTime) whenever:

  1. rounds, init, branch, estimate, and the order comparison (· ≤ ·) on M are ComputableInPolyTime; and
  2. taking either branch on any round r ∈ rounds x grows the encoded state by at most a polynomially bounded additive budget growth x.

run_polyTime_spec and run_polyTime_spec_of_add_le pair this plain complexity certificate with the invariant and deterministic objective bound estimate x (run x) ≤ estimate x (init x) from Cslib.PessimisticEstimator.greedy_spec.

PolyTimeChoiceGreedyInput generalizes the transfer from binary choices to arbitrary finite per-round candidate lists choices : I → R → List A (such as finite-product coordinate fixing in Cslib.Algorithms.Lean.PessimisticEstimator.ProductDerandomizer), certifying ComputableInPolyTime via ComputableInPolyTime.foldlWith and foldlWithInput_of_bounded_growth.

Main definitions #

Main results #

structure Cslib.Computability.PolyTimeGreedyInput (I R S M : Type) [LE M] [DecidableRel fun (x1 x2 : M) => x1 ≤ x2] :

Input-parameterized greedy binary-choice derandomization bundle.

  • rounds : I → List R

    Ordered list of decision rounds extracted from input x.

  • init : I → S

    Initial state constructed from input x.

  • branch : I → R → Bool → S → S

    Branch transition for input x, round r, choice b, and state s.

  • estimate : I → S → M

    Pessimistic-estimator / conditional-expectation value on state s under input x.

@[reducible, inline]
abbrev Cslib.Computability.PolyTimeGreedyInput.encBranchInput {I R S : Type} (encI : I ↪ List Bool) (encS : S ↪ List Bool) (encR : R ↪ List Bool) :
((I × S) × R) × Bool ↪ List Bool

Tuple encoding (((I × S) × R) × Bool) for input-parameterized greedy branch transitions.

def Cslib.Computability.PolyTimeGreedyInput.run {I R S M : Type} [LE M] [DecidableRel fun (x1 x2 : M) => x1 ≤ x2] (G : PolyTimeGreedyInput I R S M) (x : I) :
S

Run Cslib.PessimisticEstimator.greedy on input x.

theorem Cslib.Computability.PolyTimeGreedyInput.computableInPolyTime_run {I R S M : Type} [LE M] [DecidableRel fun (x1 x2 : M) => x1 ≤ x2] (G : PolyTimeGreedyInput I R S M) {encI : I ↪ List Bool} {encR : R ↪ List Bool} {encL : List R ↪ List Bool} [Turing.MultiTapeTM.ListEncoding encR encL] [Turing.MultiTapeTM.SizedListEncoding encR encL] {encS : S ↪ List Bool} {encM : M ↪ List Bool} (hrounds : Turing.MultiTapeTM.ComputableInPolyTime G.rounds encI encL) (hinit : Turing.MultiTapeTM.ComputableInPolyTime G.init encI encS) (hbranch : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : ((I × S) × R) × Bool) => match x with | (((input, state), round), choice) => G.branch input round choice state) (encBranchInput encI encS encR) encS) (hestimate : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : I × S) => match x with | (input, state) => G.estimate input state) (Turing.MultiTapeTM.encPair encI encS) encM) (hle : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : M × M) => match x with | (m₁, m₂) => decide (m₁ ≤ m₂)) (Turing.MultiTapeTM.encPair encM encM) Turing.MultiTapeTM.encBool) {growth : I → ℕ} (hpoly : Turing.MultiTapeTM.PolyBounded (fun (x : I) => (encI x).length) growth) (hgrowth : ∀ (x : I) (s : S) (r : R) (b : Bool), r ∈ G.rounds x → (encS (G.branch x r b s)).length ≤ (encS s).length + growth x) :

Plain ComputableInPolyTime transfer for G.run when rounds, init, branch, estimate, and (· ≤ ·) are polynomial-time and each round increases (encS s).length by at most a polynomially bounded growth x.

theorem Cslib.Computability.PolyTimeGreedyInput.computableInPolyTime_run_nat {I R S : Type} (G : PolyTimeGreedyInput I R S ℕ) {encI : I ↪ List Bool} {encR : R ↪ List Bool} {encL : List R ↪ List Bool} [Turing.MultiTapeTM.ListEncoding encR encL] [Turing.MultiTapeTM.SizedListEncoding encR encL] {encS : S ↪ List Bool} (hrounds : Turing.MultiTapeTM.ComputableInPolyTime G.rounds encI encL) (hinit : Turing.MultiTapeTM.ComputableInPolyTime G.init encI encS) (hbranch : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : ((I × S) × R) × Bool) => match x with | (((input, state), round), choice) => G.branch input round choice state) (encBranchInput encI encS encR) encS) (hestimate : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : I × S) => match x with | (input, state) => G.estimate input state) (Turing.MultiTapeTM.encPair encI encS) Turing.MultiTapeTM.encNat) {growth : I → ℕ} (hpoly : Turing.MultiTapeTM.PolyBounded (fun (x : I) => (encI x).length) growth) (hgrowth : ∀ (x : I) (s : S) (r : R) (b : Bool), r ∈ G.rounds x → (encS (G.branch x r b s)).length ≤ (encS s).length + growth x) :

Specialization of computableInPolyTime_run to ℕ-valued estimators encoded in binary (encNat).

theorem Cslib.Computability.PolyTimeGreedyInput.run_polyTime_spec {I R S M : Type} [LinearOrder M] (G : PolyTimeGreedyInput I R S M) {encI : I ↪ List Bool} {encR : R ↪ List Bool} {encL : List R ↪ List Bool} [Turing.MultiTapeTM.ListEncoding encR encL] [Turing.MultiTapeTM.SizedListEncoding encR encL] {encS : S ↪ List Bool} {encM : M ↪ List Bool} (hrounds : Turing.MultiTapeTM.ComputableInPolyTime G.rounds encI encL) (hinit : Turing.MultiTapeTM.ComputableInPolyTime G.init encI encS) (hbranch : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : ((I × S) × R) × Bool) => match x with | (((input, state), round), choice) => G.branch input round choice state) (encBranchInput encI encS encR) encS) (hestimate : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : I × S) => match x with | (input, state) => G.estimate input state) (Turing.MultiTapeTM.encPair encI encS) encM) (hle : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : M × M) => match x with | (m₁, m₂) => decide (m₁ ≤ m₂)) (Turing.MultiTapeTM.encPair encM encM) Turing.MultiTapeTM.encBool) {growth : I → ℕ} (hpoly : Turing.MultiTapeTM.PolyBounded (fun (x : I) => (encI x).length) growth) (hgrowth : ∀ (x : I) (s : S) (r : R) (b : Bool), r ∈ G.rounds x → (encS (G.branch x r b s)).length ≤ (encS s).length + growth x) (Inv : I → List R → S → Prop) (hinv_init : ∀ (x : I), Inv x (G.rounds x) (G.init x)) (hinv_branch : ∀ (x : I) (r : R) (rs : List R) (s : S) (b : Bool), Inv x (r :: rs) s → Inv x rs (G.branch x r b s)) (hmin : ∀ (x : I) (r : R) (rs : List R) (s : S), Inv x (r :: rs) s → min (G.estimate x (G.branch x r true s)) (G.estimate x (G.branch x r false s)) ≤ G.estimate x s) :
Turing.MultiTapeTM.ComputableInPolyTime G.run encI encS ∧ ∀ (x : I), Inv x [] (G.run x) ∧ G.estimate x (G.run x) ≤ G.estimate x (G.init x)

Pairs the plain ComputableInPolyTime certificate for G.run with the terminal invariant and deterministic bound G.estimate x (G.run x) ≤ G.estimate x (G.init x).

theorem Cslib.Computability.PolyTimeGreedyInput.run_polyTime_spec_of_add_le {I R S M : Type} [LinearOrder M] (G : PolyTimeGreedyInput I R S M) [AddCommMonoid M] [IsOrderedCancelAddMonoid M] {encI : I ↪ List Bool} {encR : R ↪ List Bool} {encL : List R ↪ List Bool} [Turing.MultiTapeTM.ListEncoding encR encL] [Turing.MultiTapeTM.SizedListEncoding encR encL] {encS : S ↪ List Bool} {encM : M ↪ List Bool} (hrounds : Turing.MultiTapeTM.ComputableInPolyTime G.rounds encI encL) (hinit : Turing.MultiTapeTM.ComputableInPolyTime G.init encI encS) (hbranch : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : ((I × S) × R) × Bool) => match x with | (((input, state), round), choice) => G.branch input round choice state) (encBranchInput encI encS encR) encS) (hestimate : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : I × S) => match x with | (input, state) => G.estimate input state) (Turing.MultiTapeTM.encPair encI encS) encM) (hle : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : M × M) => match x with | (m₁, m₂) => decide (m₁ ≤ m₂)) (Turing.MultiTapeTM.encPair encM encM) Turing.MultiTapeTM.encBool) {growth : I → ℕ} (hpoly : Turing.MultiTapeTM.PolyBounded (fun (x : I) => (encI x).length) growth) (hgrowth : ∀ (x : I) (s : S) (r : R) (b : Bool), r ∈ G.rounds x → (encS (G.branch x r b s)).length ≤ (encS s).length + growth x) (Inv : I → List R → S → Prop) (hinv_init : ∀ (x : I), Inv x (G.rounds x) (G.init x)) (hinv_branch : ∀ (x : I) (r : R) (rs : List R) (s : S) (b : Bool), Inv x (r :: rs) s → Inv x rs (G.branch x r b s)) (havg : ∀ (x : I) (r : R) (rs : List R) (s : S), Inv x (r :: rs) s → G.estimate x (G.branch x r true s) + G.estimate x (G.branch x r false s) ≤ G.estimate x s + G.estimate x s) :
Turing.MultiTapeTM.ComputableInPolyTime G.run encI encS ∧ ∀ (x : I), Inv x [] (G.run x) ∧ G.estimate x (G.run x) ≤ G.estimate x (G.init x)

Averaging form of run_polyTime_spec when the two branch estimates sum to at most twice the current estimate.

structure Cslib.Computability.PolyTimeChoiceGreedyInput (I R A S M : Type) [LE M] [DecidableRel fun (x1 x2 : M) => x1 ≤ x2] :

Input-parameterized multi-choice greedy / conditional-expectation derandomization bundle: at each round r ∈ rounds x, evaluates estimate x (branch x r a s) across a ∈ choices x r and selects a minimizing choice.

  • rounds : I → List R

    Ordered list of decision rounds extracted from input x.

  • choices : I → R → List A

    Candidate domain choices tested at round r on input x.

  • init : I → S

    Initial state constructed from input x.

  • branch : I → R → A → S → S

    State transition for input x, round r, candidate a, and state s.

  • estimate : I → S → M

    Pessimistic-estimator / conditional-expectation value on state s under input x.

@[reducible, inline]
abbrev Cslib.Computability.PolyTimeChoiceGreedyInput.encChoiceInput {I R A S : Type} (encI : I ↪ List Bool) (encS : S ↪ List Bool) (encR : R ↪ List Bool) (encA : A ↪ List Bool) :
((I × S) × R) × A ↪ List Bool

Left-associated pair encoding (((I × S) × R) × A) for candidate branch transitions: encodes (((input, state), round), choice) as frame (frame (frame (encI input) ++ encS state) ++ encR round) ++ encA choice, framing each nested left component with Turing.MultiTapeTM.frame followed by the unframed encA choice.

def Cslib.Computability.PolyTimeChoiceGreedyInput.scanStep {I R A S M : Type} [LE M] [DecidableRel fun (x1 x2 : M) => x1 ≤ x2] (G : PolyTimeChoiceGreedyInput I R A S M) (x : I) (s : S) (r : R) (best : Option (A × M)) (a : A) :
Option (A × M)

Fold step updating the best (candidate, estimate) pair seen so far at round r.

def Cslib.Computability.PolyTimeChoiceGreedyInput.stepRound {I R A S M : Type} [LE M] [DecidableRel fun (x1 x2 : M) => x1 ≤ x2] (G : PolyTimeChoiceGreedyInput I R A S M) (x : I) (s : S) (r : R) :
S

Execute one multi-choice round r on state s (leaving s unchanged if G.choices x r is empty).

def Cslib.Computability.PolyTimeChoiceGreedyInput.run {I R A S M : Type} [LE M] [DecidableRel fun (x1 x2 : M) => x1 ≤ x2] (G : PolyTimeChoiceGreedyInput I R A S M) (x : I) :
S

Execute all rounds in G.rounds x sequentially starting from G.init x.

theorem Cslib.Computability.PolyTimeChoiceGreedyInput.computableInPolyTime_run {I R A S M : Type} [LE M] [DecidableRel fun (x1 x2 : M) => x1 ≤ x2] (G : PolyTimeChoiceGreedyInput I R A S M) {encI : I ↪ List Bool} {encR : R ↪ List Bool} {encLR : List R ↪ List Bool} [Turing.MultiTapeTM.ListEncoding encR encLR] [Turing.MultiTapeTM.SizedListEncoding encR encLR] {encA : A ↪ List Bool} {encLA : List A ↪ List Bool} [Turing.MultiTapeTM.ListEncoding encA encLA] [hSA : Turing.MultiTapeTM.SizedListEncoding encA encLA] {encS : S ↪ List Bool} {encM : M ↪ List Bool} (hrounds : Turing.MultiTapeTM.ComputableInPolyTime G.rounds encI encLR) (hchoices : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : I × R) => match x with | (input, round) => G.choices input round) (Turing.MultiTapeTM.encPair encI encR) encLA) (hinit : Turing.MultiTapeTM.ComputableInPolyTime G.init encI encS) (hbranch : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : ((I × S) × R) × A) => match x with | (((input, state), round), choice) => G.branch input round choice state) (encChoiceInput encI encS encR encA) encS) (hestimate : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : I × S) => match x with | (input, state) => G.estimate input state) (Turing.MultiTapeTM.encPair encI encS) encM) (hle : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : M × M) => match x with | (m₁, m₂) => decide (m₁ ≤ m₂)) (Turing.MultiTapeTM.encPair encM encM) Turing.MultiTapeTM.encBool) {growth : I → ℕ} (hpoly : Turing.MultiTapeTM.PolyBounded (fun (x : I) => (encI x).length) growth) (hgrowth : ∀ (x : I) (s : S) (r : R) (a : A), r ∈ G.rounds x → a ∈ G.choices x r → (encS (G.branch x r a s)).length ≤ (encS s).length + growth x) :

Plain ComputableInPolyTime transfer for G.run when rounds, choices, init, branch, estimate, and (· ≤ ·) are polynomial-time and taking any candidate a ∈ G.choices x r on any round r ∈ G.rounds x increases (encS s).length by at most a polynomially bounded growth x.

theorem Cslib.Computability.PolyTimeChoiceGreedyInput.computableInPolyTime_run_nat {I R A S : Type} (G : PolyTimeChoiceGreedyInput I R A S ℕ) {encI : I ↪ List Bool} {encR : R ↪ List Bool} {encLR : List R ↪ List Bool} [Turing.MultiTapeTM.ListEncoding encR encLR] [Turing.MultiTapeTM.SizedListEncoding encR encLR] {encA : A ↪ List Bool} {encLA : List A ↪ List Bool} [Turing.MultiTapeTM.ListEncoding encA encLA] [Turing.MultiTapeTM.SizedListEncoding encA encLA] {encS : S ↪ List Bool} (hrounds : Turing.MultiTapeTM.ComputableInPolyTime G.rounds encI encLR) (hchoices : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : I × R) => match x with | (input, round) => G.choices input round) (Turing.MultiTapeTM.encPair encI encR) encLA) (hinit : Turing.MultiTapeTM.ComputableInPolyTime G.init encI encS) (hbranch : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : ((I × S) × R) × A) => match x with | (((input, state), round), choice) => G.branch input round choice state) (encChoiceInput encI encS encR encA) encS) (hestimate : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : I × S) => match x with | (input, state) => G.estimate input state) (Turing.MultiTapeTM.encPair encI encS) Turing.MultiTapeTM.encNat) {growth : I → ℕ} (hpoly : Turing.MultiTapeTM.PolyBounded (fun (x : I) => (encI x).length) growth) (hgrowth : ∀ (x : I) (s : S) (r : R) (a : A), r ∈ G.rounds x → a ∈ G.choices x r → (encS (G.branch x r a s)).length ≤ (encS s).length + growth x) :

Specialization of computableInPolyTime_run to ℕ-valued estimators encoded in binary (encNat).

theorem Cslib.Computability.PolyTimeChoiceGreedyInput.run_spec {I R A S M : Type} [LinearOrder M] (G : PolyTimeChoiceGreedyInput I R A S M) (Inv : I → List R → S → Prop) (hinv_init : ∀ (x : I), Inv x (G.rounds x) (G.init x)) (hinv_branch : ∀ (x : I) (r : R) (rs : List R) (s : S) (a : A), Inv x (r :: rs) s → a ∈ G.choices x r → Inv x rs (G.branch x r a s)) (hmin : ∀ (x : I) (r : R) (rs : List R) (s : S), Inv x (r :: rs) s → ∃ a ∈ G.choices x r, G.estimate x (G.branch x r a s) ≤ G.estimate x s) (x : I) :
Inv x [] (G.run x) ∧ G.estimate x (G.run x) ≤ G.estimate x (G.init x)

Minimizing correctness specification for G.run: if Inv holds initially, is preserved by taking any candidate a ∈ G.choices x r, and each round admits at least one candidate in G.choices x r not increasing G.estimate x, then G.run x satisfies Inv x [] and G.estimate x (G.run x) ≤ G.estimate x (G.init x).

theorem Cslib.Computability.PolyTimeChoiceGreedyInput.run_polyTime_spec {I R A S M : Type} [LinearOrder M] (G : PolyTimeChoiceGreedyInput I R A S M) {encI : I ↪ List Bool} {encR : R ↪ List Bool} {encLR : List R ↪ List Bool} [Turing.MultiTapeTM.ListEncoding encR encLR] [Turing.MultiTapeTM.SizedListEncoding encR encLR] {encA : A ↪ List Bool} {encLA : List A ↪ List Bool} [Turing.MultiTapeTM.ListEncoding encA encLA] [Turing.MultiTapeTM.SizedListEncoding encA encLA] {encS : S ↪ List Bool} {encM : M ↪ List Bool} (hrounds : Turing.MultiTapeTM.ComputableInPolyTime G.rounds encI encLR) (hchoices : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : I × R) => match x with | (input, round) => G.choices input round) (Turing.MultiTapeTM.encPair encI encR) encLA) (hinit : Turing.MultiTapeTM.ComputableInPolyTime G.init encI encS) (hbranch : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : ((I × S) × R) × A) => match x with | (((input, state), round), choice) => G.branch input round choice state) (encChoiceInput encI encS encR encA) encS) (hestimate : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : I × S) => match x with | (input, state) => G.estimate input state) (Turing.MultiTapeTM.encPair encI encS) encM) (hle : Turing.MultiTapeTM.ComputableInPolyTime (fun (x : M × M) => match x with | (m₁, m₂) => decide (m₁ ≤ m₂)) (Turing.MultiTapeTM.encPair encM encM) Turing.MultiTapeTM.encBool) {growth : I → ℕ} (hpoly : Turing.MultiTapeTM.PolyBounded (fun (x : I) => (encI x).length) growth) (hgrowth : ∀ (x : I) (s : S) (r : R) (a : A), r ∈ G.rounds x → a ∈ G.choices x r → (encS (G.branch x r a s)).length ≤ (encS s).length + growth x) (Inv : I → List R → S → Prop) (hinv_init : ∀ (x : I), Inv x (G.rounds x) (G.init x)) (hinv_branch : ∀ (x : I) (r : R) (rs : List R) (s : S) (a : A), Inv x (r :: rs) s → a ∈ G.choices x r → Inv x rs (G.branch x r a s)) (hmin : ∀ (x : I) (r : R) (rs : List R) (s : S), Inv x (r :: rs) s → ∃ a ∈ G.choices x r, G.estimate x (G.branch x r a s) ≤ G.estimate x s) :
Turing.MultiTapeTM.ComputableInPolyTime G.run encI encS ∧ ∀ (x : I), Inv x [] (G.run x) ∧ G.estimate x (G.run x) ≤ G.estimate x (G.init x)

Pairs the plain ComputableInPolyTime certificate for G.run with the terminal invariant and minimizing bound G.estimate x (G.run x) ≤ G.estimate x (G.init x) from run_spec.