File size: 5,435 Bytes
4a56cd6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import OAI.Probability.SATComputability.PacketExpressions
import OAI.Probability.SATComputability.PoissonEvaluation

namespace OAI

namespace FixedClauseThreshold.Computability

open DilutedSpinGlass Nat.Partrec FiniteArithmetic RapidForcing.EffectiveArithmetic
open scoped BigOperators Classical
local instance disorderEnumerationRatPrimcodable : Primcodable β„š := PeriodicLattice.RecursiveArithmetic.ratPrimcodable

noncomputable def signAlphabet : List (Fin 3 β†’ Bool) := Finset.univ.toList

@[fun_prop] theorem signWords_computable :
    Computable (fun k => words signAlphabet k) :=
  words_primrec.to_comp.comp (Computable.const signAlphabet) Computable.id

theorem sum_words {A : Type} [Fintype A] [DecidableEq A] (k : β„•)
    (f : List A β†’ ℝ) :
    ((words (Finset.univ.toList : List A) k).map f).sum =
      βˆ‘ x : Fin k β†’ A, f (List.ofFn x) := by
  induction k generalizing f with
  | zero => simp [words]
  | succ k ih =>
    simp only [words, List.map_flatMap, sum_flatMap_eq, List.map_map, Function.comp_def]
    simp_rw [ih]
    rw [Finset.sum_map_toList, ← (Fin.consEquiv (fun _ : Fin (k+1) => A)).sum_comp,
      Fintype.sum_prod_type]
    apply Finset.sum_congr rfl
    intro a _
    apply Finset.sum_congr rfl
    intro x _
    rw [List.ofFn_succ]
    rfl

noncomputable def averagedSiteExpression (Ξ² : β„š) (root : Code) (ms : List β„š) (k : β„•) : Code :=
  .comp (rationalExpression ((8 : β„š)^k)⁻¹)
    (sumExpressions ((words signAlphabet k).map (fun signs => siteTrialExpression Ξ² signs root ms)))

attribute [local irreducible] siteTrialExpression edgeTrialExpression

@[fun_prop] theorem averagedSiteExpression_computable :
    Computable (fun p : (β„š Γ— Code Γ— List β„š) Γ— β„• =>
      averagedSiteExpression p.1.1 p.1.2.1 p.1.2.2 p.2) := by
  have hs : Computable (fun p : (β„š Γ— Code Γ— List β„š) Γ— β„• =>
      (words signAlphabet p.2).map (fun signs =>
        siteTrialExpression p.1.1 signs p.1.2.1 p.1.2.2)) := by
    apply computable_list_map (signWords_computable.comp Computable.snd)
    unfold Computableβ‚‚
    exact siteTrialExpression_computable.comp
      (g := fun p : ((β„š Γ— Code Γ— List β„š) Γ— β„•) Γ— List (Fin 3 β†’ Bool) =>
        (p.1.1.1,p.2,p.1.1.2.1,p.1.1.2.2)) (by fun_prop)
  unfold averagedSiteExpression
  fun_prop

theorem trialLog_site_cast {k l r : β„•} (h : k = l) (Ξ² : ℝ)
    (ΞΆ : Hierarchy (r+1)) (m : Fin r β†’ ℝ) (J : Fin l β†’ Fin 3 β†’ Bool) :
    trialLog r ΞΆ m (siteLog (fun j : Fin k => satSample Ξ² (J (Fin.cast h j))) 0) =
      trialLog r ΞΆ m (siteLog (fun j => satSample Ξ² (J j)) 0) := by
  subst l
  rfl

theorem averagedSiteExpression_value (Ξ² : β„š) (root : Code) (ms : List β„š) (k : β„•) :
    expressionValue (averagedSiteExpression Ξ² root ms k) =
      (FiniteLaw.uniform : FiniteLaw (Fin k β†’ Fin 3 β†’ Bool)).expect (fun signs =>
        trialLog ms.length (rationalTreeValue (ms.length+1) (decodeTree (ms.length+1) root))
          (fun i => (ms.get i : ℝ)) (siteLog (fun j => satSample (Ξ² : ℝ) (signs j)) 0)) := by
  simp only [averagedSiteExpression, expressionValue, rationalExpression_value,
    sumExpressions_value, List.map_map, Function.comp_def, signAlphabet, sum_words]
  simp only [FiniteLaw.expect, FiniteLaw.uniform, Fintype.card_fun, Fintype.card_fin,
    Fintype.card_bool, Nat.cast_pow, Nat.cast_ofNat, Rat.cast_inv, Rat.cast_pow,
    Rat.cast_ofNat, ← Finset.mul_sum]
  norm_num
  apply Finset.sum_congr rfl
  intro J _
  rw [siteTrialExpression_value]
  simpa only [List.get_ofFn, List.get_eq_getElem, List.getElem_ofFn, Fin.cast] using
    trialLog_site_cast (List.length_ofFn (f := J)) (Ξ² : ℝ)
      (rationalTreeValue (ms.length+1) (decodeTree (ms.length+1) root))
      (fun i => (ms.get i : ℝ)) J

noncomputable def averagedEdgeExpression (Ξ² : β„š) (root : Code) (ms : List β„š) : Code :=
  .comp (rationalExpression (1/8))
    (sumExpressions (signAlphabet.map (fun J => edgeTrialExpression Ξ² J root ms)))

@[fun_prop] theorem averagedEdgeExpression_computable :
    Computable (fun p : β„š Γ— Code Γ— List β„š => averagedEdgeExpression p.1 p.2.1 p.2.2) := by
  have hs : Computable (fun p : β„š Γ— Code Γ— List β„š =>
      signAlphabet.map (fun J => edgeTrialExpression p.1 J p.2.1 p.2.2)) := by
    apply computable_list_map (Computable.const signAlphabet)
    unfold Computableβ‚‚
    exact edgeTrialExpression_computable.comp
      (g := fun p : (β„š Γ— Code Γ— List β„š) Γ— (Fin 3 β†’ Bool) =>
        (p.1.1,p.2,p.1.2.1,p.1.2.2)) (by fun_prop)
  unfold averagedEdgeExpression
  fun_prop

theorem averagedEdgeExpression_value (Ξ² : β„š) (root : Code) (ms : List β„š) :
    expressionValue (averagedEdgeExpression Ξ² root ms) =
      (FiniteLaw.uniform : FiniteLaw (Fin 3 β†’ Bool)).expect (fun J =>
        trialLog ms.length (rationalTreeValue (ms.length+1) (decodeTree (ms.length+1) root))
          (fun i => (ms.get i : ℝ)) (fun x => Real.log (edge (satInteraction (Ξ² : ℝ) J) x))) := by
  simp only [averagedEdgeExpression, expressionValue, rationalExpression_value,
    sumExpressions_value, List.map_map, Function.comp_def, signAlphabet, Finset.sum_map_toList,
    edgeTrialExpression_value]
  simp only [FiniteLaw.expect, FiniteLaw.uniform, Fintype.card_fun, Fintype.card_fin,
    Fintype.card_bool, Nat.cast_pow, Nat.cast_ofNat, Rat.cast_div, Rat.cast_one,
    Rat.cast_ofNat, ← Finset.mul_sum]
  norm_num

end FixedClauseThreshold.Computability

end OAI