File size: 3,351 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
import OAI.Combinatorics.ContingencyTables.Transport.TranslatedCompletionChain

namespace OAI

/-! # Exact edge flow of the completion-translation chain -/

namespace ContingencyTables.CompletionTranslation

open scoped BigOperators Classical
open CommonBasesFPRAS

variable {X I J : Type*} [Fintype X] [Nonempty X] [Fintype I] [Fintype J]

omit [Nonempty X] in
lemma completionMove_flow (R : X β†’ Option I β†’ β„•) (P : X β†’ Option J β†’ β„•)
    (htotal : βˆ€ x,(βˆ‘ i,R x i)=βˆ‘ j,P x j)
    (Adj : X β†’ X β†’ Prop) (Ξ² : ℝ) (x y : X) :
    ((blockCount R P x:ℝ)/MetropolisChain.normalizer (fun z => (blockCount R P z:ℝ)))*
      completionMove R P Adj Ξ² x y =
      if Adj x y then Ξ²*(acceptedCount R P x y:ℝ)/
        MetropolisChain.normalizer (fun z => (blockCount R P z:ℝ)) else 0 := by
  have hx : (blockCount R P x:ℝ)β‰ 0 := ne_of_gt (by exact_mod_cast blockCount_pos R P htotal x)
  unfold completionMove
  split_ifs
  Β· exact div_mul_div_cancelβ‚€' hx _ _
  Β· exact mul_zero _

/-- The flow formula includes the holding terms: those contribute zero
energy. The numerator counts literal acceptable completion translations. -/
theorem completionChain_energy (R : X β†’ Option I β†’ β„•) (P : X β†’ Option J β†’ β„•)
    (htotal : βˆ€ x,(βˆ‘ i,R x i)=βˆ‘ j,P x j)
    (Adj : X β†’ X β†’ Prop) (hsym : βˆ€ x y,Adj x y ↔ Adj y x)
    (Ξ² : ℝ) (hΞ² : 0 ≀ Ξ²) (D : β„•)
    (hdegree : βˆ€ x,(Finset.univ.filter (Adj x)).card ≀ D)
    (hproposal : (D:ℝ)*Ξ² ≀ 1/2) (H : X β†’ ℝ) :
    (completionChain R P htotal Adj hsym Ξ² hΞ² D hdegree hproposal).energy H=
      (βˆ‘ x,βˆ‘ y,if Adj x y then
        Ξ²*(acceptedCount R P x y:ℝ)*(H x-H y)^2 else 0)/
          (2*MetropolisChain.normalizer (fun z => (blockCount R P z:ℝ))) := by
  unfold completionChain
  rw [FiniteChain.ofMoves_energy]
  simp_rw [completionMove_flow R P htotal Adj Ξ²]
  have hterm (x y : X) :
      (if Adj x y then Ξ²*(acceptedCount R P x y:ℝ)/
        MetropolisChain.normalizer (fun z => (blockCount R P z:ℝ)) else 0)*(H x-H y)^2 =
      (if Adj x y then Ξ²*(acceptedCount R P x y:ℝ)*(H x-H y)^2 else 0)/
        MetropolisChain.normalizer (fun z => (blockCount R P z:ℝ)) := by
    split_ifs <;> ring
  simp_rw [hterm,← Finset.sum_div]
  ring

omit [Fintype X] [Nonempty X] in
/-- A half-acceptance estimate yields the min-weight comparison on every
actual edge, with no request for completion-count evaluation. -/
lemma completionMove_lower (R : X β†’ Option I β†’ β„•) (P : X β†’ Option J β†’ β„•)
    (htotal : βˆ€ x,(βˆ‘ i,R x i)=βˆ‘ j,P x j)
    (Adj : X β†’ X β†’ Prop) (Ξ² : ℝ) (hΞ² : 0 ≀ Ξ²) (x y : X)
    (hxy : Adj x y)
    (haccept : (blockCount R P x:ℝ)/2 ≀ acceptedCount R P x y) :
    Ξ²/2*min 1 ((blockCount R P y:ℝ)/blockCount R P x) ≀ completionMove R P Adj Ξ² x y := by
  have hx : (0:ℝ)<blockCount R P x := by exact_mod_cast blockCount_pos R P htotal x
  have hm : Ξ²/2*min 1 ((blockCount R P y:ℝ)/blockCount R P x) ≀ Ξ²/2 := by
    simpa only [mul_one] using mul_le_mul_of_nonneg_left
      (min_le_left (1:ℝ) ((blockCount R P y:ℝ)/blockCount R P x)) (by positivity : 0 ≀ Ξ²/2)
  apply hm.trans
  unfold completionMove
  rw [ite_eq_left hxy]
  apply (le_div_iffβ‚€ hx).mpr
  nlinarith [mul_nonneg hΞ² (sub_nonneg.mpr haccept)]

end ContingencyTables.CompletionTranslation

end OAI