Repository navigation
replace measurableArgmax by argmax
#153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
8908b26
replace `measurableArgmax`
gaetanserre d01de98
refactor
gaetanserre 6f6250f
refactor
gaetanserre cf020b1
mk_all
gaetanserre 42a054f
imports and name
gaetanserre c7a2a0d
Update LeanMachineLearning/ForMathlib/MeasureTheory/Order/MeasurableA…
gaetanserre 5164171
Update LeanMachineLearning/ForMathlib/MeasureTheory/Order/MeasurableA…
gaetanserre 02d2450
Update LeanMachineLearning/ForMathlib/MeasureTheory/Order/MeasurableA…
gaetanserre dca752a
Update LeanMachineLearning/ForMathlib/MeasureTheory/Order/MeasurableA…
gaetanserre 5344af4
Use `to_dual`
gaetanserre 3c58c1e
Add pointer to `Finset.measurable_sup'`
gaetanserre 939927c
Update LeanMachineLearning/ForMathlib/MeasureTheory/Order/Lattice.lean
gaetanserre 77bb9c4
Update LeanMachineLearning/ForMathlib/MeasureTheory/Order/MeasurableA…
gaetanserre 9e4a3ff
Update LeanMachineLearning/ForMathlib/MeasureTheory/Order/MeasurableA…
gaetanserre 6429de7
Unused args
gaetanserre 53440ea
fix `to_dual` naming
gaetanserre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,10 @@ | ||
| import LMLTutorial.Front | ||
| import LMLTutorial.Pages.BasicProbability | ||
| import LMLTutorial.Pages.DefiningAlgorithm | ||
| import LMLTutorial.Pages.Installation | ||
| import LMLTutorial.Pages.MarkovKernels | ||
| import LMLTutorial.Pages.Martingales | ||
| import LMLTutorial.References | ||
| import LMLTutorial.Tutorial | ||
| module -- shake: keep-all --deprecated_module: ignore | ||
|
|
||
| public import LMLTutorial.Front | ||
| public import LMLTutorial.Pages.BasicProbability | ||
| public import LMLTutorial.Pages.DefiningAlgorithm | ||
| public import LMLTutorial.Pages.Installation | ||
| public import LMLTutorial.Pages.MarkovKernels | ||
| public import LMLTutorial.Pages.Martingales | ||
| public import LMLTutorial.References | ||
| public import LMLTutorial.Tutorial |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 0 additions & 88 deletions
88
LeanMachineLearning/ForMathlib/MeasureTheory/Constructions/BorelSpace/MeasurableArgMax.lean
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
LeanMachineLearning/ForMathlib/MeasureTheory/Order/Lattice.lean
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| /- | ||
| Copyright (c) 2026 Gaëtan Serré. All rights reserved. | ||
| Released under Apache 2.0 license as described in the file LICENSE. | ||
| Authors: Gaëtan Serré | ||
| -/ | ||
| module | ||
|
|
||
| public import Mathlib.MeasureTheory.Order.Lattice | ||
|
|
||
| /-! # Measurable inf of a finite set | ||
|
|
||
| -/ | ||
|
|
||
| @[expose] public section | ||
|
|
||
| open Finset | ||
|
|
||
| variable {α δ : Type*} [MeasurableSpace δ] [SemilatticeInf α] {m : MeasurableSpace α} | ||
| [MeasurableInf₂ α] | ||
|
|
||
| attribute [to_dual existing] MeasurableInf₂ | ||
|
|
||
| /-- Dual version of `Finset.measurable_sup'`. -/ | ||
| @[to_dual existing (attr := fun_prop)] | ||
| theorem Finset.measurable_inf' {ι : Type*} {s : Finset ι} (hs : s.Nonempty) {f : ι → δ → α} | ||
| (hf : ∀ n ∈ s, Measurable (f n)) : Measurable (s.inf' hs f) := | ||
| Finset.inf'_induction hs _ (fun _f hf _g hg => hf.inf hg) fun n hn => hf n hn | ||
92 changes: 92 additions & 0 deletions
92
LeanMachineLearning/ForMathlib/MeasureTheory/Order/MeasurableArg.lean
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| /- | ||
| Copyright (c) 2026 Gaëtan Serré. All rights reserved. | ||
| Released under Apache 2.0 license as described in the file LICENSE. | ||
| Authors: Gaëtan Serré | ||
| -/ | ||
| module | ||
|
|
||
| public import LeanMachineLearning.ForMathlib.MeasureTheory.Order.Lattice | ||
| public import Mathlib.CategoryTheory.Countable | ||
| public import Mathlib.MeasureTheory.Constructions.Polish.Basic | ||
| public import Mathlib.Order.CompletePartialOrder | ||
|
|
||
| /-! # Argmax and argmin functions on finite sets | ||
|
|
||
| We prove in particular that those functions are measurable. | ||
|
|
||
| -/ | ||
|
|
||
| @[expose] public section | ||
|
|
||
| open Finset | ||
|
|
||
| variable {ι α : Type*} [LinearOrder α] [Fintype ι] [Nonempty ι] (f : ι → α) | ||
|
|
||
| namespace Function | ||
|
|
||
| /-- The maximum value of a tuple. -/ | ||
| @[to_dual /-- The minimum value of a tuple. -/] | ||
| abbrev max : α := univ.sup' univ_nonempty f | ||
|
|
||
| @[to_dual min_le] | ||
| lemma le_max (x : ι) : f x ≤ max f := le_sup' _ (by simp) | ||
|
|
||
| end Function | ||
|
|
||
| section Argmax | ||
|
|
||
| @[to_dual exists_argmin] | ||
| lemma exists_argmax : ∃ i, f i = f.max := by | ||
| obtain ⟨i, -, hi⟩ := Finset.exists_mem_eq_sup' (by simp : Finset.univ.Nonempty) f | ||
| exact ⟨i, hi.symm⟩ | ||
|
|
||
| /-- The index of the maximum value of a tuple. -/ | ||
| @[to_dual argmin /-- The index of the minimum value of a tuple. -/] | ||
| noncomputable def argmax := (exists_argmax f).choose | ||
|
|
||
| @[to_dual argmin_spec] | ||
| lemma argmax_spec : f (argmax f) = f.max := (exists_argmax f).choose_spec | ||
|
|
||
| @[to_dual isMinOn_argmin] | ||
| lemma isMaxOn_argmax (x : ι) : f x ≤ f (argmax f) := by | ||
| rw [argmax_spec f] | ||
| exact f.le_max x | ||
|
|
||
| variable [MeasurableSpace α] | ||
|
|
||
| @[to_dual (attr := fun_prop)] | ||
| lemma measurable_max [MeasurableSup₂ α] : Measurable (fun (t : ι → α) => t.max) := by | ||
| suffices (fun f : ι → α ↦ f.max) = (univ.sup' univ_nonempty fun i f => f i) by | ||
| rw [this] | ||
| exact measurable_sup' univ_nonempty (fun i _ => measurable_pi_apply i) | ||
| ext | ||
| simp [Function.max] | ||
|
|
||
| @[to_dual (attr := fun_prop) measurable_argmin] | ||
| lemma measurable_argmax [MeasurableSpace ι] [MeasurableEq α] [MeasurableSup₂ α] : | ||
| Measurable fun f : ι → α ↦ argmax f := by | ||
| refine measurable_to_countable' fun i ↦ ?_ | ||
| simp only [Set.preimage, Set.mem_singleton_iff] | ||
| let Maximizers (f : ι → α) : Set ι := {i | f i = f.max} | ||
| suffices {f : ι → α | argmax f = i} = ⋃ (S) | ||
| (hS : ∀ x, Maximizers x = S → argmax x = i), {f | Maximizers f = S} by | ||
| rw [this] | ||
| refine MeasurableSet.iUnion fun S ↦ (.iUnion fun hS ↦ ?_) | ||
| exact measurableSet_eq_fun (by fun_prop) measurable_const | ||
| ext f | ||
| simp only [Set.mem_setOf_eq, Set.mem_iUnion, exists_prop, exists_eq_right'] | ||
| constructor | ||
| · intro hf x hx | ||
| rw [← hf] | ||
| exact Classical.choose.congr_simp hx (exists_argmax x) | ||
| · intro h | ||
| exact h f rfl | ||
|
|
||
| end Argmax | ||
|
|
||
| lemma neg_max_eq_min_neg [AddGroup α] [AddLeftMono α] [AddRightMono α] : -f.max = (-f).min := by | ||
| refine le_antisymm ?_ ?_ | ||
| · simp; grind | ||
| · simp only [inf'_le_iff, mem_univ, Pi.neg_apply, neg_le_neg_iff, sup'_le_iff, forall_const, | ||
| true_and] | ||
| exact ⟨argmax f, isMaxOn_argmax f⟩ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.