Download data/lean/OAI/Probability/MatroidProphet/Pivots/Patterns.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 5.73 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/MatroidProphet/Pivots/Patterns.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/MatroidProphet/Pivots/Patterns.lean
-
curl -L -o Patterns.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/MatroidProphet/Pivots/Patterns.lean
5.73 kB
| import OAI.Probability.MatroidProphet.Pivots.Arbitrary | |
| import OAI.Probability.MatroidProphet.Pivots.Encoding | |
| import OAI.Probability.MatroidProphet.Pivots.OccurrenceSupport | |
| import OAI.Probability.MatroidProphet.Pivots.Scores | |
| import OAI.Probability.MatroidProphet.Pivots.Sign | |
| import Mathlib.LinearAlgebra.Dimension.Constructions | |
| namespace OAI | |
| namespace MatroidProphet | |
| namespace Pivots | |
| open Set Finset | |
| open scoped BigOperators | |
| variable {Ξ± : Type*} [Fintype Ξ±] {r q n : β} | |
| def occurrenceMark (oldMark : Fin r β Bool) (movableMark : Fin q β Bool) : | |
| Occurrence r q β Bool := Sum.elim oldMark movableMark | |
| noncomputable def markedScore (s : β) (time : Occurrence r q β β) | |
| (oldMark : Fin r β Bool) (movableMark : Fin q β Bool) (o : Occurrence r q) : β := | |
| if occurrenceMark oldMark movableMark o then (2 : β) ^ scoreExponent s time o | |
| else -(2 : β) ^ scoreExponent s time o | |
| lemma abs_markedScore (s : β) (time : Occurrence r q β β) | |
| (oldMark : Fin r β Bool) (movableMark : Fin q β Bool) (o : Occurrence r q) : | |
| |markedScore s time oldMark movableMark o| = (2 : β) ^ scoreExponent s time o := by | |
| unfold markedScore | |
| split <;> simp [abs_of_nonneg (pow_nonneg (by norm_num : (0 : β) β€ 2) _)] | |
| noncomputable def fixedOldScore (s : β) (oldMark : Fin r β Bool) (i : Fin r) : β := | |
| if oldMark i then (2 : β)^((s+1)*(i.val+1)) else -(2 : β)^((s+1)*(i.val+1)) | |
| noncomputable def constantScore (s : β) (oldMark : Fin r β Bool) : Occurrence r q β β := | |
| Sum.elim (fixedOldScore s oldMark) (fun _ => 0) | |
| noncomputable def coordinateScore : Occurrence r q β ((Fin q β β) ββ[β] β) := | |
| Sum.elim (fun _ => 0) (fun i => LinearMap.proj i) | |
| noncomputable def patternLinear (M : Matroid Ξ±) (label : Occurrence r q β Ξ±) | |
| (J : Finset (Occurrence r q)) (e : Ξ±) : (Fin q β β) ββ[β] β := | |
| β o β occurrenceSupport M label J e, coordinateScore o | |
| noncomputable def patternConstant (M : Matroid Ξ±) (label : Occurrence r q β Ξ±) | |
| (J : Finset (Occurrence r q)) (e : Ξ±) (s : β) (oldMark : Fin r β Bool) : β := | |
| β o β occurrenceSupport M label J e, constantScore s oldMark o | |
| lemma affineScore_eq_sum | |
| {Ξ± : Type u_1} [Fintype Ξ±] {r : β} {q : β} (M : Matroid Ξ±) (label : Occurrence r q β Ξ±) | |
| (J : Finset (Occurrence r q)) (e : Ξ±) (s : β) (time : Occurrence r q β β) | |
| (oldMark : Fin r β Bool) (movableMark : Fin q β Bool) : | |
| patternLinear M label J e (fun i => markedScore s time oldMark movableMark (Sum.inr i)) + | |
| patternConstant M label J e s oldMark = | |
| β o β occurrenceSupport M label J e, markedScore s time oldMark movableMark o := by | |
| simp only [patternLinear, patternConstant, LinearMap.sum_apply, β Finset.sum_add_distrib] | |
| apply Finset.sum_congr rfl | |
| intro o _ | |
| cases o <;> simp [coordinateScore, constantScore, fixedOldScore, markedScore, | |
| occurrenceMark, scoreExponent] | |
| all_goals rfl | |
| def RecordsPivots (M : Matroid Ξ±) (label : Occurrence r q β Ξ±) | |
| (test : Fin n β Ξ±) (time : Occurrence r q β β) | |
| (oldMark : Fin r β Bool) (movableMark : Fin q β Bool) (t : Finset (Fin n)) : Prop := | |
| β f, β o, IsPivot M label time (test f) o β§ | |
| (occurrenceMark oldMark movableMark o = true β f β t) | |
| lemma recordsPivots_affine (M : Matroid Ξ±) (b : β β Ξ±) (a : Fin q β Ξ±) | |
| (test : Fin n β Ξ±) (s : β) (hqs : q β€ s) | |
| (oldMark : Fin r β Bool) (movableMark : Fin q β Bool) | |
| (time : Occurrence r q β β) (horder : OldOrdered time) (htime : Function.Injective time) | |
| (hground : β o : Occurrence r q, occurrenceLabel b a o β M.E) (t : Finset (Fin n)) | |
| (hrecords : RecordsPivots M (occurrenceLabel b a) test time oldMark movableMark t) : | |
| β x, RealizesSigns | |
| (fun f => patternLinear M (occurrenceLabel b a) (retained M b a time) (test f)) | |
| (fun f => patternConstant M (occurrenceLabel b a) (retained M b a time) (test f) s oldMark) | |
| t x := by | |
| classical | |
| let label : Occurrence r q β Ξ± := occurrenceLabel b a | |
| let J := retained M b a time | |
| let w := markedScore s time oldMark movableMark | |
| let exponent := scoreExponent s time | |
| refine β¨fun i => w (Sum.inr i), ?_β© | |
| intro f | |
| rw [affineScore_eq_sum] | |
| obtain β¨o, hpivot, hmarkβ© := hrecords f | |
| have hp := pivot_mem_support_and_max M label time hground htime hpivot | |
| change o β occurrenceSupport M label J (test f) β§ | |
| (β p β occurrenceSupport M label J (test f), time p β€ time o) at hp | |
| have hmax : β p β occurrenceSupport M label J (test f), p β o β exponent p < exponent o := by | |
| intro p hp' hne | |
| apply scoreExponent_preserves_order s hqs time horder | |
| exact lt_of_le_of_ne (hp.2 p hp') (fun heq => hne (htime heq)) | |
| have hexp := scoreExponent_injective s hqs time horder htime | |
| have habs : β p β occurrenceSupport M label J (test f), |w p| = 2 ^ exponent p := | |
| fun p _ => abs_markedScore s time oldMark movableMark p | |
| have hpos := sum_positive_iff_max_exponent _ w exponent hexp hp.1 hmax habs | |
| have hneg := sum_positive_iff_max_exponent _ (fun p => -w p) exponent hexp hp.1 hmax | |
| (by intro p hp'; simpa using habs p hp') | |
| simp only [Finset.sum_neg_distrib, neg_pos] at hneg | |
| have hpow : (0 : β) < 2 ^ exponent o := pow_pos (by norm_num) _ | |
| by_cases hf : f β t | |
| Β· simp only [hf, βreduceIte] | |
| apply hpos.mpr | |
| have hm := hmark.mpr hf | |
| simp [w, markedScore, hm] | |
| Β· simp only [hf, βreduceIte] | |
| apply hneg.mpr | |
| have hm : occurrenceMark oldMark movableMark o = false := by | |
| cases h : occurrenceMark oldMark movableMark o | |
| Β· rfl | |
| Β· exact False.elim (hf (hmark.mp h)) | |
| simp [w, markedScore, hm] | |
| end Pivots | |
| end MatroidProphet | |
| end OAI | |