Download data/lean/OAI/Probability/SATComputability/CandidateProcess.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 7.71 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/SATComputability/CandidateProcess.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/SATComputability/CandidateProcess.lean
-
curl -L -o CandidateProcess.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/SATComputability/CandidateProcess.lean
7.71 kB
| import OAI.Probability.SATComputability.BatchKilling | |
| import OAI.Probability.DilutedSpin.FiniteProducts | |
| import OAI.Probability.DilutedSpin.FiniteProjection | |
| namespace OAI | |
| namespace FixedClauseThreshold.Computability | |
| open DilutedSpinGlass | |
| open scoped BigOperators Classical | |
| noncomputable def candidateResidual {n k d : β} (U : Finset (DeletionCandidate n)) | |
| (cs : Fin d β Fin k β SignedLiteral n) : Finset (DeletionCandidate n) := | |
| U.filter (fun x => β j, Β¬β l, literalFalse x (cs j l)) | |
| def candidateAlive {n : β} (U : Finset (DeletionCandidate n)) : β := | |
| if U.Nonempty then 1 else 0 | |
| noncomputable def candidateStep {n : β} [NeZero n] (k : β) | |
| (f : Finset (DeletionCandidate n) β β) (U : Finset (DeletionCandidate n)) : β := | |
| (FiniteLaw.uniform : FiniteLaw (Fin k β SignedLiteral n)).expect | |
| (fun c => f (U.filter (fun x => Β¬β l, literalFalse x (c l)))) | |
| theorem candidateResidual_cons {n k d : β} (U : Finset (DeletionCandidate n)) | |
| (c : Fin k β SignedLiteral n) (cs : Fin d β Fin k β SignedLiteral n) : | |
| candidateResidual U (Fin.cons c cs) = | |
| candidateResidual (U.filter (fun x => Β¬β l, literalFalse x (c l))) cs := by | |
| ext x | |
| simp [candidateResidual, Fin.forall_fin_succ, and_assoc] | |
| theorem candidateResidual_empty_iff {n k d : β} (U : Finset (DeletionCandidate n)) | |
| (cs : Fin d β Fin k β SignedLiteral n) : | |
| candidateResidual U cs = β β batchKills U cs := by | |
| simp only [candidateResidual, Finset.filter_eq_empty_iff, batchKills] | |
| constructor | |
| Β· intro h x hx | |
| by_contra hn | |
| apply h hx | |
| intro j hj | |
| exact hn β¨j, hjβ© | |
| Β· intro h x hx hn | |
| obtain β¨j, hjβ© := h x hx | |
| exact hn j hj | |
| theorem candidateStep_mono {n : β} [NeZero n] (k : β) : | |
| Monotone (candidateStep (n := n) k) := by | |
| intro f g h U | |
| exact FiniteLaw.expect_mono _ (fun _ => h _) | |
| theorem candidateStep_add_const {n : β} [NeZero n] (k : β) | |
| (f : Finset (DeletionCandidate n) β β) (c : β) : | |
| candidateStep k (f + fun _ => c) = candidateStep k f + fun _ => c := by | |
| funext U | |
| exact (FiniteLaw.expect_add _ _ _).trans (by simp [candidateStep, Pi.add_apply]) | |
| theorem candidateStep_comm {n : β} [NeZero n] (k l : β) : | |
| Function.Commute (candidateStep (n := n) k) (candidateStep l) := by | |
| intro f | |
| funext U | |
| unfold candidateStep | |
| rw [FiniteLaw.expect_comm] | |
| apply FiniteLaw.expect_congr | |
| intro c | |
| apply FiniteLaw.expect_congr | |
| intro d | |
| congr 1 | |
| ext x | |
| simp only [Finset.mem_filter] | |
| tauto | |
| theorem candidateStep_iterate {n : β} [NeZero n] (k d : β) | |
| (f : Finset (DeletionCandidate n) β β) (U : Finset (DeletionCandidate n)) : | |
| (candidateStep k)^[d] f U = | |
| (FiniteLaw.uniform : FiniteLaw (Fin d β Fin k β SignedLiteral n)).expect | |
| (fun cs => f (candidateResidual U cs)) := by | |
| induction d generalizing U with | |
| | zero => simp [candidateResidual, FiniteLaw.expect, FiniteLaw.uniform] | |
| | succ d ih => | |
| rw [Function.iterate_succ_apply', candidateStep] | |
| simp_rw [ih] | |
| conv_rhs => rw [uniformFiniteLaw_pi, FiniteLaw.expect_pi_cons] | |
| rw [β uniformFiniteLaw_pi] | |
| apply FiniteLaw.expect_congr | |
| intro c | |
| apply FiniteLaw.expect_congr | |
| intro cs | |
| rw [candidateResidual_cons] | |
| theorem candidateKill_iterate {n : β} [NeZero n] | |
| (U : Finset (DeletionCandidate n)) (k d : β) : | |
| batchKillProbability U k d = 1 - (candidateStep k)^[d] candidateAlive U := by | |
| rw [candidateStep_iterate] | |
| have he (cs : Fin d β Fin k β SignedLiteral n) : | |
| (if batchKills U cs then (1 : β) else 0) = | |
| 1 - candidateAlive (candidateResidual U cs) := by | |
| rw [candidateAlive, β candidateResidual_empty_iff] | |
| by_cases h : candidateResidual U cs = β | |
| Β· simp [h] | |
| Β· simp [h, Finset.nonempty_iff_ne_empty] | |
| simp_rw [batchKillProbability, he, FiniteLaw.expect_sub, FiniteLaw.expect_const] | |
| theorem operator_iterate_add_const {X : Type*} (A : (X β β) β X β β) | |
| (hA : β f c, A (f + fun _ => c) = A f + fun _ => c) | |
| (m : β) (f : X β β) (c : β) : | |
| A^[m] (f + fun _ => c) = A^[m] f + fun _ => c := by | |
| induction m with | |
| | zero => rfl | |
| | succ m ih => rw [Function.iterate_succ_apply', ih, hA, Function.iterate_succ_apply'] | |
| theorem operator_replacement {X : Type*} (A B : (X β β) β X β β) | |
| (hA : Monotone A) (hB : Monotone B) | |
| (hAc : β f c, A (f + fun _ => c) = A f + fun _ => c) | |
| (hBc : β f c, B (f + fun _ => c) = B f + fun _ => c) | |
| (hcomm : Function.Commute A B) (f : X β β) (Ξ΄ : β) | |
| (hone : A f β€ B f + fun _ => Ξ΄) (d : β) : | |
| A^[d] f β€ B^[d] f + fun _ => (d : β)*Ξ΄ := by | |
| induction d with | |
| | zero => intro x; simp | |
| | succ d ih => | |
| have hβ := hA.iterate d hone | |
| rw [operator_iterate_add_const A hAc, hcomm.iterate_left d f] at hβ | |
| have hβ := hB ih | |
| rw [hBc, β Function.iterate_succ_apply' B d f] at hβ | |
| intro x | |
| have hβx := hβ x | |
| have hβx := hβ x | |
| simp only [Pi.add_apply] at hβx hβx | |
| rw [Function.iterate_succ_apply] | |
| change A^[d] (A f) x β€ B^[d+1] f x + ((d+1 : β) : β)*Ξ΄ | |
| push_cast | |
| linarith | |
| theorem relaxed_sequential_replacement {n : β} [NeZero n] | |
| (U : Finset (DeletionCandidate n)) {d : β} (hd : 0 < d) (L : β) : | |
| batchKillProbability U 2 L - (L : β)/(d : β)^2 β€ | |
| batchKillProbability U 3 (L*d) := by | |
| have hone : (candidateStep (n := n) 3)^[d] candidateAlive β€ | |
| candidateStep 2 candidateAlive + fun _ => 1/(d : β)^2 := by | |
| intro V | |
| by_cases hV : V.Nonempty | |
| Β· have h := relaxed_one_replacement hV hd | |
| have he : batchKillProbability V 2 1 = oneTestKill V 2 := by | |
| rw [candidateKill_iterate, Function.iterate_one, candidateStep] | |
| unfold oneTestKill | |
| rw [β FiniteLaw.expect_const (FiniteLaw.uniform : FiniteLaw (Fin 2 β SignedLiteral n)) 1, | |
| β FiniteLaw.expect_sub] | |
| apply FiniteLaw.expect_congr | |
| intro c | |
| have hf : (V.filter (fun x => Β¬β l, literalFalse x (c l))).Nonempty β | |
| Β¬testKills V c := by | |
| constructor | |
| Β· rintro β¨x, hxβ© hk | |
| exact (Finset.mem_filter.mp hx).2 (hk x (Finset.mem_filter.mp hx).1) | |
| Β· intro hk | |
| by_contra he | |
| apply hk | |
| intro x hx | |
| by_contra hh | |
| exact he β¨x, Finset.mem_filter.mpr β¨hx, hhβ©β© | |
| simp only [FiniteLaw.expect_const] | |
| by_cases hc : β x β V, β l, literalFalse x (c l) | |
| Β· have he : Β¬(V.filter (fun x => Β¬β l, literalFalse x (c l))).Nonempty := | |
| fun hne => (hf.mp hne) hc | |
| rw [candidateAlive, ite_eq_right he, ite_eq_left hc] | |
| norm_num | |
| Β· have he : (V.filter (fun x => Β¬β l, literalFalse x (c l))).Nonempty := hf.mpr hc | |
| rw [candidateAlive, ite_eq_left he, ite_eq_right hc] | |
| norm_num | |
| rw [β he, candidateKill_iterate, candidateKill_iterate, Function.iterate_one] at h | |
| exact (by dsimp only [Pi.add_apply]; linarith) | |
| Β· have he : V = β := Finset.not_nonempty_iff_eq_empty.mp hV | |
| subst V | |
| simp [candidateStep_iterate, candidateStep, candidateResidual, candidateAlive] | |
| have h := operator_replacement (candidateStep (n := n) 3)^[d] (candidateStep 2) | |
| ((candidateStep_mono 3).iterate d) (candidateStep_mono 2) | |
| (operator_iterate_add_const _ (candidateStep_add_const 3) d) | |
| (candidateStep_add_const 2) ((candidateStep_comm 3 2).iterate_left d) | |
| candidateAlive (1/(d : β)^2) hone L U | |
| rw [β Function.iterate_mul, Nat.mul_comm d L] at h | |
| rw [candidateKill_iterate, candidateKill_iterate] | |
| simp only [Pi.add_apply, mul_one_div] at h | |
| linarith | |
| end FixedClauseThreshold.Computability | |
| end OAI | |