Download data/lean/OAI/LinearAlgebra/MatrixMultiplication/JointExtraction/AssignmentLoss.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 6.91 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/MatrixMultiplication/JointExtraction/AssignmentLoss.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/LinearAlgebra/MatrixMultiplication/JointExtraction/AssignmentLoss.lean
-
curl -L -o AssignmentLoss.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/LinearAlgebra/MatrixMultiplication/JointExtraction/AssignmentLoss.lean
6.91 kB
| import OAI.LinearAlgebra.MatrixMultiplication.JointExtraction.CoarseAssignment | |
| namespace OAI | |
| /-! Joint tensor extraction, compatibility and entropy estimates. -/ | |
| noncomputable section | |
| namespace MatrixMultiplication.JointAssignmentLoss | |
| open JointExtraction JointCoarseAssignment | |
| attribute [local instance] Classical.propDecidable | |
| variable {A B C I V Ξ© : Type*} | |
| theorem uniqueAssignment_of_unique (candidates : Finset I) | |
| (compatible : I β V β Prop) (v : V) (i : I) | |
| (hi : i β candidates) (hc : compatible i v) | |
| (hu : β j, j β candidates β compatible j v β j = i) : | |
| uniqueAssignment candidates compatible v = some i := by | |
| classical | |
| have hex : β j, j β candidates β§ compatible j v β§ | |
| β k, k β candidates β compatible k v β k = j := β¨i, hi, hc, huβ© | |
| unfold uniqueAssignment | |
| rw [dite_eq_left hex] | |
| exact congrArg some (hu _ (Classical.choose_spec hex).1 (Classical.choose_spec hex).2.1) | |
| theorem assignUseful_of_unique (candidates : Finset I) | |
| (compatible useful : I β V β Prop) (v : V) (i : I) | |
| (hi : i β candidates) (hc : compatible i v) (huse : useful i v) | |
| (hu : β j, j β candidates β compatible j v β j = i) : | |
| assignUseful candidates compatible useful v = some i := by | |
| have hassign := uniqueAssignment_of_unique candidates compatible v i hi hc hu | |
| have hkeep : β j, uniqueAssignment candidates compatible v = some j β§ useful j v := | |
| β¨i, hassign, huseβ© | |
| simp only [assignUseful, retainAssignment, ite_eq_left hkeep] | |
| exact hassign | |
| def ambientXCollision (ambient : Finset (Triple A B C)) | |
| (hx : A β Prop) (hy : B β Prop) (hz : C β Prop) (e : Triple A B C) : Prop := | |
| β f β ambient, f β e β§ survives hx hy hz f β§ f.1 = e.1 | |
| def targetCompatibleCollision (targets : Finset (Triple A B C)) | |
| (hx : A β Prop) (hy : B β Prop) (hz : C β Prop) | |
| (compatible : Triple A B C β V β Prop) (e : Triple A B C) (v : V) : Prop := | |
| β f β targets, f β e β§ survives hx hy hz f β§ compatible f v | |
| theorem eligible_of_no_ambientXCollision | |
| (ambient targets : Finset (Triple A B C)) | |
| (hx : A β Prop) (hy : B β Prop) (hz : C β Prop) (e : Triple A B C) | |
| (ha : e β ambient) (ht : e β targets) (hs : survives hx hy hz e) | |
| (hno : Β¬ ambientXCollision ambient hx hy hz e) : | |
| e β eligible ambient targets hx hy hz := by | |
| apply (mem_eligible_iff ambient targets hx hy hz e).2 | |
| refine β¨ha, ht, hs, ?_β© | |
| intro f hf hfs hfx | |
| by_contra hne | |
| exact hno β¨f, hf, hne, hfs, hfxβ© | |
| theorem not_eligible_iff_ambientXCollision | |
| (ambient targets : Finset (Triple A B C)) | |
| (hx : A β Prop) (hy : B β Prop) (hz : C β Prop) (e : Triple A B C) | |
| (ha : e β ambient) (ht : e β targets) (hs : survives hx hy hz e) : | |
| e β eligible ambient targets hx hy hz β ambientXCollision ambient hx hy hz e := by | |
| constructor | |
| Β· intro h | |
| by_contra hno | |
| exact h (eligible_of_no_ambientXCollision ambient targets hx hy hz e ha ht hs hno) | |
| Β· rintro β¨f, hf, hne, hfs, hfxβ© he | |
| exact hne (((mem_eligible_iff ambient targets hx hy hz e).1 he).2.2.2 f hf hfs hfx) | |
| theorem assignUseful_of_no_targetCollision | |
| (ambient targets : Finset (Triple A B C)) | |
| (hx : A β Prop) (hy : B β Prop) (hz : C β Prop) | |
| (compatible useful : Triple A B C β V β Prop) (e : Triple A B C) (v : V) | |
| (he : e β eligible ambient targets hx hy hz) | |
| (hc : compatible e v) (hu : useful e v) | |
| (hno : Β¬ targetCompatibleCollision targets hx hy hz compatible e v) : | |
| assignUseful (eligible ambient targets hx hy hz) compatible useful v = some e := by | |
| apply assignUseful_of_unique _ _ _ _ _ he hc hu | |
| intro f hf hcf | |
| have hfe := (mem_eligible_iff ambient targets hx hy hz f).1 hf | |
| by_contra hne | |
| exact hno β¨f, hfe.2.1, hne, hfe.2.2.1, hcfβ© | |
| theorem assignment_failure_implies_collision | |
| (ambient targets : Finset (Triple A B C)) | |
| (hx : A β Prop) (hy : B β Prop) (hz : C β Prop) | |
| (compatible useful : Triple A B C β V β Prop) (e : Triple A B C) (v : V) | |
| (ha : e β ambient) (ht : e β targets) (hs : survives hx hy hz e) | |
| (hc : compatible e v) (hu : useful e v) | |
| (hfail : assignUseful (eligible ambient targets hx hy hz) compatible useful v β some e) : | |
| ambientXCollision ambient hx hy hz e β¨ | |
| targetCompatibleCollision targets hx hy hz compatible e v := by | |
| by_cases hX : ambientXCollision ambient hx hy hz e | |
| Β· exact Or.inl hX | |
| apply Or.inr | |
| by_contra hC | |
| have he := eligible_of_no_ambientXCollision ambient targets hx hy hz e ha ht hs hX | |
| exact hfail (assignUseful_of_no_targetCollision ambient targets hx hy hz | |
| compatible useful e v he hc hu hC) | |
| theorem retained_assignment_of_no_collision | |
| (ambient targets : Finset (Triple A B C)) | |
| (hx : A β Prop) (hy : B β Prop) (hz : C β Prop) | |
| (compatible useful : Triple A B C β V β Prop) (keep : V β Prop) | |
| (e : Triple A B C) (v : V) | |
| (ha : e β ambient) (ht : e β targets) (hs : survives hx hy hz e) | |
| (hc : compatible e v) (hu : useful e v) (hk : keep v) | |
| (hX : Β¬ ambientXCollision ambient hx hy hz e) | |
| (hC : Β¬ targetCompatibleCollision targets hx hy hz compatible e v) : | |
| retainAssignment (assignUseful (eligible ambient targets hx hy hz) compatible useful) | |
| keep v = some e := by | |
| have he := eligible_of_no_ambientXCollision ambient targets hx hy hz e ha ht hs hX | |
| have hassign := assignUseful_of_no_targetCollision ambient targets hx hy hz | |
| compatible useful e v he hc hu hC | |
| simpa only [retainAssignment, ite_eq_left hk] using hassign | |
| theorem passing_assignment_failure_subset | |
| (samples : Finset Ξ©) (ambient targets : Finset (Triple A B C)) | |
| (hx : Ξ© β A β Prop) (hy : Ξ© β B β Prop) (hz : Ξ© β C β Prop) | |
| (compatible useful : Triple A B C β V β Prop) (keep : V β Prop) | |
| (e : Triple A B C) (v : V) (ha : e β ambient) (ht : e β targets) | |
| (hc : compatible e v) (hu : useful e v) (hk : keep v) : | |
| samples.filter (fun Ο => survives (hx Ο) (hy Ο) (hz Ο) e β§ | |
| retainAssignment | |
| (assignUseful (eligible ambient targets (hx Ο) (hy Ο) (hz Ο)) compatible useful) | |
| keep v β some e) β | |
| samples.filter (fun Ο => survives (hx Ο) (hy Ο) (hz Ο) e β§ | |
| (ambientXCollision ambient (hx Ο) (hy Ο) (hz Ο) e β¨ | |
| targetCompatibleCollision targets (hx Ο) (hy Ο) (hz Ο) compatible e v)) := by | |
| intro Ο hΟ | |
| obtain β¨hΟs, hs, hfailβ© := Finset.mem_filter.1 hΟ | |
| apply Finset.mem_filter.2 | |
| refine β¨hΟs, hs, ?_β© | |
| have hfail' : assignUseful (eligible ambient targets (hx Ο) (hy Ο) (hz Ο)) | |
| compatible useful v β some e := by | |
| simpa only [retainAssignment, ite_eq_left hk] using hfail | |
| exact assignment_failure_implies_collision ambient targets (hx Ο) (hy Ο) (hz Ο) | |
| compatible useful e v ha ht hs hc hu hfail' | |
| end MatrixMultiplication.JointAssignmentLoss | |
| end | |
| end OAI | |