File size: 1,414 Bytes
97c3405
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import OAI.Combinatorics.ContingencyTables.Dense.DenseScaleMatrixProgram

namespace OAI

/-! # Computing the dense exponent directly from a binary grid matrix -/

namespace ContingencyTables.DensePrograms
open MatchingFPRAS.TreeTyped GridBoundary

def scaledData (z : ExponentData) : ExponentData := ((z.1.1,scaleMatrix z),z.2)

def scaledDataRealizer : Realizer scaledData :=
  pair (pair (composition first first) scaleMatrixRealizer) second

theorem polynomial_scaledData : PolynomialTime scaledDataRealizer :=
  polynomial_pair (polynomial_pair (polynomial_composition polynomial_first polynomial_first)
    polynomial_scaleMatrix) polynomial_second

def gridExponent (z : ExponentData) : ℕ := fullExponent (scaledData z)

def gridExponentRealizer : Realizer gridExponent :=
  composition scaledDataRealizer fullExponentRealizer

theorem polynomial_gridExponent : PolynomialTime gridExponentRealizer :=
  polynomial_composition polynomial_scaledData polynomial_fullExponent

theorem gridExponent_code {m n q K : ℕ} (R : Option (Fin m) → ℕ)
    (P : Option (Fin n) → ℕ) (d : ℕ) (a : Grid (I := Fin q) K)
    (e : Fin m×Fin n ≃ Fin q) :
    gridExponent (exponentDataCode R P d (fun i j => (corner a (e (i,j))).toNat))=
      denseExponent R P d e a := by
  unfold gridExponent scaledData
  rw [scaleMatrix_code]
  exact fullExponent_code R P d e a

end ContingencyTables.DensePrograms

end OAI