Skip to content

Commit 0da8435

Browse files
committed
feat(Tactic/FunProp): make fun_prop able to tag and (leanprover-community#32888)
by representing forall as a function application internally. Also tag `Measurable.imp` and `Measurable.forall` which were rejected by `fun_prop`.
1 parent 85fcdf8 commit 0da8435

3 files changed

Lines changed: 27 additions & 1 deletion

File tree

Mathlib/MeasureTheory/MeasurableSpace/Constructions.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,13 +866,15 @@ lemma Measurable.and (hp : Measurable p) (hq : Measurable q) : Measurable fun a
866866
lemma Measurable.or (hp : Measurable p) (hq : Measurable q) : Measurable fun a ↦ p a ∨ q a :=
867867
measurableSet_setOf.1 <| hp.setOf.union hq.setOf
868868

869+
@[fun_prop]
869870
lemma Measurable.imp (hp : Measurable p) (hq : Measurable q) : Measurable fun a ↦ p a → q a :=
870871
measurableSet_setOf.1 <| hp.setOf.himp hq.setOf
871872

872873
@[fun_prop]
873874
lemma Measurable.iff (hp : Measurable p) (hq : Measurable q) : Measurable fun a ↦ p a ↔ q a :=
874875
measurableSet_setOf.1 <| by simp_rw [iff_iff_implies_and_implies]; exact hq.setOf.bihimp hp.setOf
875876

877+
@[fun_prop]
876878
lemma Measurable.forall [Countable ι] {p : ι → α → Prop} (hp : ∀ i, Measurable (p i)) :
877879
Measurable fun a ↦ ∀ i, p i a :=
878880
measurableSet_setOf.1 <| by rw [setOf_forall]; exact MeasurableSet.iInter fun i ↦ (hp i).setOf

Mathlib/Tactic/FunProp/Mor.lean

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ public import Mathlib.Init
99
public meta import Lean.Meta.CoeAttr
1010
public import Lean.Meta.CoeAttr
1111

12+
import Mathlib.Tactic.TypeStar
13+
1214
/-!
1315
## `funProp` Meta programming functions like in Lean.Expr.* but for working with bundled morphisms.
1416
@@ -31,6 +33,10 @@ open Lean Meta
3133

3234
namespace Meta.FunProp
3335

36+
/-- An abbreviation of `∀ x, p x`. It is used by `fun_prop` to represent Pi types as function
37+
applications and should not occur in any place other than the implementation of `fun_prop`. -/
38+
abbrev Forall {α : Sort*} (p : α → Sort*) := ∀ x, p x
39+
3440
namespace Mor
3541

3642
/-- Is `name` a coercion from some function space to functions? -/
@@ -111,7 +117,9 @@ def app (f : Expr) (arg : Arg) : Expr :=
111117
| some coe => (coe.app f).app arg.expr
112118

113119

114-
/-- Given `e = f a₁ a₂ ... aₙ`, returns `k f #[a₁, ..., aₙ]` where `f` can be bundled morphism. -/
120+
/-- Given `e = f a₁ a₂ ... aₙ`, returns `k f #[a₁, ..., aₙ]` where `f` can be bundled morphism.
121+
122+
`∀ x, p x` is represented as `Forall p`. -/
115123
partial def withApp {α} (e : Expr) (k : Expr → Array Arg → MetaM α) : MetaM α :=
116124
go e #[]
117125
where
@@ -132,6 +140,8 @@ where
132140

133141
go (.app (.app c f) x) as
134142
| .app f a, as => go f (as.push { expr := a })
143+
| .forallE x t b bi, _ => do
144+
go (← mkAppM ``Forall #[.lam x t b bi]) #[]
135145
| f, as => k f as.reverse
136146

137147

MathlibTest/fun_prop.lean

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,17 @@ If possible, `fun_prop` theorem about `DFunLike.coe` should be state in this way
220220
221221
That should be all about `fun_prop`, I hope you will enjoy using it :)
222222
-/
223+
224+
225+
226+
/-! Test that `fun_prop` should work on `→` and `∀` -/
227+
228+
attribute [fun_prop] Measurable.imp Measurable.forall
229+
230+
example {α : Type*} [MeasurableSpace α] {p q : α → Prop} (hp : Measurable p) (hq : Measurable q) :
231+
Measurable fun x => p x → q x := by
232+
fun_prop
233+
234+
example {α ι : Type*} [MeasurableSpace α] [Countable ι] {p : ι → α → Prop}
235+
(hp : ∀ i, Measurable (p i)) : Measurable fun x => ∀ i, p i x := by
236+
fun_prop

0 commit comments

Comments
 (0)