File size: 3,175 Bytes
760f90e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import OAI.Computability.RandomMean.Complexity

namespace OAI

section
namespace MeanPayoff.RegisterBits.Compile
open BinaryData
open scoped Classical
 theorem correct_probability {K : ℕ} (P : Program K) (G : Game) (n : ℕ)
    (hh : (tree P n (RegisterBits.initial P (input G))).All (fun c => c.control=none)) :
    (2:ℚ)^(2*bound P (input G) n)*
      (tree P n (RegisterBits.initial P (input G))).probability (fun c => BinaryInput.CorrectList G c.output)≤
    ((Finset.univ.filter (fun bits : Fin (2*bound P (input G) n)→Bool =>
      CorrectOutput G (result (machine P) G (2*bound P (input G) n) bits))).card : ℚ) := by
  classical
  have hp := machine_probability P (input G) n hh (BinaryInput.CorrectList G)
  apply hp.trans
  apply Nat.cast_le.mpr
  apply Finset.card_le_card
  intro bits hb
  simp only [Finset.mem_filter,Finset.mem_univ,true_and] at hb ⊢
  obtain ⟨out,ho,hhalt,ht⟩ := hb
  exact correctList_packet G (machine P) _ out ho hhalt ht
 theorem correct_count {K : ℕ} (P : Program K) (G : Game) (n : ℕ)
    (hh : (tree P n (RegisterBits.initial P (input G))).All (fun c => c.control=none))
    (hp : 7/8≤(tree P n (RegisterBits.initial P (input G))).probability
      (fun c => BinaryInput.CorrectList G c.output)) :
    7*2^(2*bound P (input G) n)≤8*(Finset.univ.filter
      (fun bits : Fin (2*bound P (input G) n)→Bool =>
        CorrectOutput G (result (machine P) G (2*bound P (input G) n) bits))).card := by
  classical
  have hq := correct_probability P G n hh
  have hl : (2:ℚ)^(2*bound P (input G) n)*(7/8)≤
      ((Finset.univ.filter (fun bits : Fin (2*bound P (input G) n)→Bool =>
        CorrectOutput G (result (machine P) G (2*bound P (input G) n) bits))).card : ℚ) :=
    (mul_le_mul_of_nonneg_left hp (by positivity)).trans hq
  have hr : (7:ℚ)*2^(2*bound P (input G) n)≤8*
      ((Finset.univ.filter (fun bits : Fin (2*bound P (input G) n)→Bool =>
        CorrectOutput G (result (machine P) G (2*bound P (input G) n) bits))).card : ℚ) := by
    linarith only [hl]
  exact_mod_cast hr
 theorem halt_all {K : ℕ} (P : Program K) (G : Game) (n : ℕ)
    (hh : (tree P n (RegisterBits.initial P (input G))).All (fun c => c.control=none))
    (bits : Fin (2*bound P (input G) n)→Bool) :
    (result (machine P) G (2*bound P (input G) n) bits).control=none :=
  (machine_packet P (input G) n hh bits).1
end MeanPayoff.RegisterBits.Compile

end

section
namespace MeanPayoff

theorem main : MainClaim := by
  obtain ⟨K,e,h⟩ := Realizer.post_polynomial
  obtain ⟨C,hC,hbound⟩ := Realizer.total_quasi K e
  refine ⟨RegisterBits.Compile.machine Realizer.program,C,hC,fun G =>
    ⟨Realizer.total K e ⟨input G⟩,hbound ⟨input G⟩,?_,?_⟩⟩
  · exact RegisterBits.Compile.halt_all Realizer.program G (Realizer.limit K e ⟨input G⟩)
      (Realizer.tree_halts K e h ⟨input G⟩)
  · exact RegisterBits.Compile.correct_count Realizer.program G (Realizer.limit K e ⟨input G⟩)
      (Realizer.tree_halts K e h ⟨input G⟩) (Realizer.tree_success K e h G)
end MeanPayoff

theorem randomized_quasipolynomial_mean_payoff : MeanPayoff.MainClaim := MeanPayoff.main

end

end OAI