File size: 2,036 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
import OAI.Computability.UniqueGames.Games.UniformTarget

namespace OAI

section

namespace UniqueGamesTheorem.Explicit.UniformRoundingTarget

open UniqueGamesTheorem.Foundations.Target
open UniqueGamesTheorem.MachineUniformRounding
open UniqueGamesTheorem.MachineUniformCopyOrder

/-- Apply the concrete largest-remainder list of occurrence IDs to the original
list. Equal records at different indices remain separate input occurrences. -/
def rows {α : Type*} (C : Nat) (es : List α) : List α :=
  (Rounding.copies (Rounding.denominator es.length 1 C) es.length
    (fun _ => 1)).map es.get

theorem rows_eq_occurrenceMajor {α : Type*} (C : Nat) (es : List α)
    (h : 0 < es.length) : rows C es = occurrenceMajor C es := by
  unfold rows
  rw [copies_uniform es.length C h]
  simp only [List.map_flatten, List.map_ofFn, Function.comp_def, List.map_replicate]
  change (List.ofFn (fun i => List.replicate C (es.get i))).flatten =
    (es.map (fun e => List.replicate C e)).flatten
  congr 1
  calc
    List.ofFn (fun i => List.replicate C (es.get i)) =
        (List.ofFn es.get).map (fun e => List.replicate C e) := List.map_ofFn.symm
    _ = es.map (fun e => List.replicate C e) := by rw [List.ofFn_get]

/-- Exact multiplicities and full permutation records agree with the machine's
copy-major target; only the enumeration order changes. -/
theorem rows_perm_construct {q : Nat} (C : Nat) (hC : 0 < C) (g : Instance q) :
    (rows C g.constraints).Perm (UniformTarget.construct C hC g).constraints := by
  rw [rows_eq_occurrenceMajor C g.constraints g.constraintCount_positive]
  exact occurrenceMajor_perm_copyMajor C g.constraints

theorem selected_count_construct {q : Nat} (C : Nat) (hC : 0 < C) (g : Instance q)
    (a : Fin g.vertices → Fin q) :
    countSatisfied a (rows C g.constraints) =
      countSatisfied a (UniformTarget.construct C hC g).constraints :=
  Integration.InstanceEquivalences.countSatisfied_perm a (rows_perm_construct C hC g)

end UniqueGamesTheorem.Explicit.UniformRoundingTarget

end

end OAI