-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce a predicate
DependsOn
- Loading branch information
1 parent
abeb840
commit 17c8be8
Showing
5 changed files
with
94 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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 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 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,64 @@ | ||
/- | ||
Copyright (c) 2024 Etienne Marion. All rights reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Etienne Marion | ||
-/ | ||
import Mathlib.Data.Set.Function | ||
|
||
/-! | ||
# Functions depending only on some variables | ||
When dealing with a function `f : Π i, α i` depending on many variables, some operations | ||
may get rid of the dependency on some variables (see `Function.updateFinset` or | ||
`MeasureTheory.lmarginal` for example). However considering this new function | ||
as having a different domain with fewer points is not comfortable in lean, as it requires the use | ||
of subtypes and can lead to tedious writing. | ||
On the other hand one wants to be able for example to call some function constant with respect to | ||
some variables and be able to infer this when applying transformations mentioned above. | ||
This is why introduce the predicate `DependsOn f s`, which states that if `x` and `y` coincide over | ||
the set `s`, then `f x = f y`. This is equivalent to `Function.FactorsThrough f s.restrict`. | ||
## Main definition | ||
* `DependsOn f s`: If `x` and `y` coincide over the set `s`, then `f x` equals `f y`. | ||
## Main statement | ||
* `dependsOn_iff_factorsThrough`: A function `f` depends on `s` if and only if it factors | ||
through `s.restrict`. | ||
## Tags | ||
depends on | ||
-/ | ||
|
||
open Set | ||
|
||
variable {ι : Type*} {α : ι → Type*} {β : Type*} | ||
|
||
/-- A function `f` depends on `s` if, whenever `x` and `y` coincide over `s`, `f x = f y`. -/ | ||
def DependsOn (f : (Π i, α i) → β) (s : Set ι) : Prop := | ||
∀ ⦃x y⦄, (∀ i ∈ s, x i = y i) → f x = f y | ||
|
||
lemma dependsOn_iff_factorsThrough {f : (Π i, α i) → β} {s : Set ι} : | ||
DependsOn f s ↔ Function.FactorsThrough f s.restrict := by | ||
rw [DependsOn, Function.FactorsThrough] | ||
simp [funext_iff] | ||
|
||
lemma dependsOn_univ (f : (Π i, α i) → β) : DependsOn f univ := | ||
fun _ _ h ↦ congrArg _ <| funext fun i ↦ h i trivial | ||
|
||
variable {f : (Π i, α i) → β} | ||
|
||
/-- A constant function does not depend on any variable. -/ | ||
lemma dependsOn_const (b : β) : DependsOn (fun _ : Π i, α i ↦ b) ∅ := by simp [DependsOn] | ||
|
||
lemma DependsOn.mono {s t : Set ι} (hst : s ⊆ t) (hf : DependsOn f s) : DependsOn f t := | ||
fun _ _ h ↦ hf fun i hi ↦ h i (hst hi) | ||
|
||
/-- A function which depends on the empty set is constant. -/ | ||
lemma DependsOn.empty (hf : DependsOn f ∅) (x y : Π i, α i) : f x = f y := hf (by simp) | ||
|
||
lemma Set.dependsOn_restrict (s : Set ι) : DependsOn (s.restrict (π := α)) s := | ||
fun _ _ h ↦ funext fun i ↦ h i.1 i.2 |
This file contains 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