Download data/lean/OAI/Combinatorics/ContingencyTables/Transport/CompletionChainFlow.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 3.35 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/ContingencyTables/Transport/CompletionChainFlow.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/ContingencyTables/Transport/CompletionChainFlow.lean
-
curl -L -o CompletionChainFlow.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/ContingencyTables/Transport/CompletionChainFlow.lean
3.35 kB
| 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 | |