File size: 2,718 Bytes
180bc03
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import OAI.NumberTheory.TwoPoint.Bounds.IntegerClosedCatalog
import OAI.NumberTheory.TwoPoint.Bounds.TraceCatalogMaps

namespace OAI

/-! Recover the column data of the actual joined matrix paths. -/

namespace TwoPointCorrelations

open Finset
open scoped Classical

lemma ofFn_rev_eq_reverse {α : Type*} {n : ℕ} (f : Fin n → α) :
    List.ofFn (fun i => f i.rev) = (List.ofFn f).reverse := by
  apply List.ext_getElem
  · simp only [List.length_ofFn, List.length_reverse]
  · intro i hi hj
    simp only [List.getElem_ofFn, List.getElem_reverse, List.length_ofFn]
    congr 1
    apply Fin.ext
    simp only [Fin.val_rev]
    omega

def closedColumnRows {J k : ℕ} {P : Fin J → Finset ℕ} (Q : Finset ℕ)
    (a b : Fin k → ((j : Fin J) → P j) × (Q × Bool)) :
    Fin (k + k) → ((j : Fin J) → P j) × (Q × Bool) :=
  Fin.append a (fun i => ((b i.rev).1, (b i.rev).2.1, !(b i.rev).2.2))

lemma closedColumnRows_word {J k : ℕ} {P : Fin J → Finset ℕ} (Q : Finset ℕ)
    (a b : Fin k → ((j : Fin J) → P j) × (Q × Bool)) :
    integerStepWord Q (fun d => ∏ j, (d j).val) (closedColumnRows Q a b) =
      integerClosedWordCode Q (fun d => ∏ j, (d j).val) (a, b) := by
  unfold integerStepWord closedColumnRows integerClosedWordCode
  rw [List.ofFn_fin_append, List.map_append]
  congr 1
  rw [reverseWord]
  simp only [integerStepWord, List.map_reverse, List.map_ofFn, Function.comp_def]
  rw [← ofFn_rev_eq_reverse]
  simp only [SignedStep.flip]

def closedColumnAssignment {J k : ℕ} {P : Fin J → Finset ℕ} (Q : Finset ℕ)
    (a b : Fin k → ((j : Fin J) → P j) × (Q × Bool)) :
    ColumnPrimeAssignment J (k + k) P :=
  fun j i => (closedColumnRows Q a b i).1 j

def closedColumnPadding {J k : ℕ} {P : Fin J → Finset ℕ} (Q : Finset ℕ)
    (a b : Fin k → ((j : Fin J) → P j) × (Q × Bool)) : Fin (k + k) → Q :=
  fun i => (closedColumnRows Q a b i).2.1

def closedColumnForward {J k : ℕ} {P : Fin J → Finset ℕ} (Q : Finset ℕ)
    (a b : Fin k → ((j : Fin J) → P j) × (Q × Bool)) : Fin (k + k) → Bool :=
  fun i => (closedColumnRows Q a b i).2.2

theorem closedColumn_encoding_word {J k : ℕ} {P : Fin J → Finset ℕ} (Q : Finset ℕ)
    (a b : Fin k → ((j : Fin J) → P j) × (Q × Bool)) :
    columnTupleWord (closedColumnAssignment Q a b) (closedColumnForward Q a b)
      (fun i => (closedColumnPadding Q a b i).val) =
      integerClosedWordCode Q (fun d => ∏ j, (d j).val) (a, b) := by
  rw [← closedColumnRows_word]
  simp only [columnTupleWord, columnTuple, closedColumnAssignment, closedColumnForward,
    closedColumnPadding, integerStepWord, List.map_ofFn, Function.comp_def]

end TwoPointCorrelations

end OAI