File size: 1,915 Bytes
ea76aac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import Mathlib
import OAI.Computability.MaxCut.Machines.Printer
import OAI.Computability.MaxCut.Estimates.Anchor

namespace OAI

noncomputable section
namespace OptimalMaxCut.LongCode.InstanceAdapter
open scoped BigOperators
open MaxCutGames.Foundations.Target CounterMachine Turing
attribute [local instance] Classical.propDecidable

theorem exists_gridComputer (q : ℕ) (t : ℚ) (ht : t ∈ Set.Icc (-1:ℚ) 1) (K : ℕ) :
    ∃ pc : TM2ComputableInPolyTime (bits : Instance q → List Bool) ScaledGraph.bits
      (fun g => gridGraph g t ht K), ∀ k, Finite (pc.tm.Γ k) := by
  obtain ⟨len,hlen⟩ := RawGrid.Rep.length q (K+1)
  obtain ⟨bit,hbit⟩ := RawGrid.Rep.entry q t ht K (K+1) (Expr.Represented.arg 0)
  have htable (g : Instance q) : table len bit (bits g) = (gridGraph g t ht K).bits := by
    apply List.ext_getElem
    · simp only [table,List.length_ofFn,hlen,RawGrid.bits_length]
    · intro i hi hj
      have hi' : i<RawGrid.length q (K+1) (bits g) := by
        simpa only [RawGrid.bits_length] using hj
      have hh := RawGrid.bits_getD g t ht K i hi'
      rw [List.getElem?_eq_getElem hj] at hh
      simp only [Option.getD_some] at hh
      simp only [table,List.getElem_ofFn,hbit]
      exact hh.symm
  let first := tableComputer len bit
  let pc : TM2ComputableInPolyTime (bits : Instance q → List Bool) ScaledGraph.bits
      (fun g => gridGraph g t ht K) := {
    tm := first.tm
    inputAlphabet := first.inputAlphabet
    outputAlphabet := first.outputAlphabet
    time := first.time
    outputsFun := fun g => by
      have hh := first.outputsFun (bits g)
      change TM2OutputsInTime first.tm ((bits g).map first.inputAlphabet.symm)
        (some ((table len bit (bits g)).map first.outputAlphabet.symm)) _ at hh
      rw [htable] at hh
      exact hh }
  exact ⟨pc, tableComputer_finiteAlphabet len bit⟩

end OptimalMaxCut.LongCode.InstanceAdapter

end

end OAI