-
Notifications
You must be signed in to change notification settings - Fork 330
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Tactic): add
finiteness
tactic (#18034)
Upstreamed from the [PFR](https://github.com/teorth/pfr) project. From PFR, Carleson, GibbsMeasure Co-authored-by: Heather Macbeth <[email protected]> Co-authored-by: Pietro Monticone <[email protected]>
- Loading branch information
1 parent
7bf2901
commit fe4820c
Showing
12 changed files
with
148 additions
and
14 deletions.
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
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
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) 2023 Heather Macbeth. All rights reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Heather Macbeth | ||
-/ | ||
import Mathlib.Tactic.Positivity.Core | ||
|
||
/-! | ||
# Finiteness tactic | ||
This file implements a basic `finiteness` tactic, designed to solve goals of the form `*** < ∞` and | ||
(equivalently) `*** ≠ ∞` in the extended nonnegative reals (`ENNReal`, aka `ℝ≥0∞`). | ||
It works recursively according to the syntax of the expression. It is implemented as an `aesop` rule | ||
set. | ||
## Syntax | ||
Standard `aesop` syntax applies. Namely one can write | ||
* `finiteness (add unfold [def1, def2])` to make `finiteness` unfold `def1`, `def2` | ||
* `finiteness?` for the tactic to show what proof it found | ||
* etc | ||
* Note that `finiteness` disables `simp`, so `finiteness (add simp [lemma1, lemma2])` does not do | ||
anything more than a bare `finiteness`. | ||
We also provide `finiteness_nonterminal` as a version of `finiteness` that doesn't have to close the | ||
goal. | ||
## TODO | ||
Improve `finiteness` to also deal with other situations, such as balls in proper spaces with | ||
a locally finite measure. | ||
-/ | ||
|
||
open Aesop.BuiltinRules in | ||
attribute [aesop (rule_sets := [finiteness]) safe -50] assumption intros | ||
|
||
set_option linter.unusedTactic false in | ||
add_aesop_rules safe tactic (rule_sets := [finiteness]) (by positivity) | ||
|
||
/-- Tactic to solve goals of the form `*** < ∞` and (equivalently) `*** ≠ ∞` in the extended | ||
nonnegative reals (`ℝ≥0∞`). -/ | ||
macro (name := finiteness) "finiteness" c:Aesop.tactic_clause* : tactic => | ||
`(tactic| | ||
aesop $c* | ||
(config := { introsTransparency? := some .reducible, terminal := true, enableSimp := false }) | ||
(rule_sets := [$(Lean.mkIdent `finiteness):ident, -default, -builtin])) | ||
|
||
/-- Tactic to solve goals of the form `*** < ∞` and (equivalently) `*** ≠ ∞` in the extended | ||
nonnegative reals (`ℝ≥0∞`). -/ | ||
macro (name := finiteness?) "finiteness?" c:Aesop.tactic_clause* : tactic => | ||
`(tactic| | ||
aesop? $c* | ||
(config := { introsTransparency? := some .reducible, terminal := true, enableSimp := false }) | ||
(rule_sets := [$(Lean.mkIdent `finiteness):ident, -default, -builtin])) | ||
|
||
/-- Tactic to solve goals of the form `*** < ∞` and (equivalently) `*** ≠ ∞` in the extended | ||
nonnegative reals (`ℝ≥0∞`). -/ | ||
macro (name := finiteness_nonterminal) "finiteness_nonterminal" c:Aesop.tactic_clause* : tactic => | ||
`(tactic| | ||
aesop $c* | ||
(config := { introsTransparency? := some .reducible, terminal := false, enableSimp := false, | ||
warnOnNonterminal := false }) | ||
(rule_sets := [$(Lean.mkIdent `finiteness):ident, -default, -builtin])) |
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,10 @@ | ||
/- | ||
Copyright (c) 2024 Floris van Doorn. All rights reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Floris van Doorn | ||
-/ | ||
import Aesop | ||
|
||
/-! # Finiteness tactic attribute -/ | ||
|
||
declare_aesop_rule_sets [finiteness] |
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,26 @@ | ||
import Mathlib.Tactic.Finiteness | ||
import Mathlib.Data.ENNReal.Real | ||
import Mathlib.MeasureTheory.Measure.Typeclasses | ||
|
||
open MeasureTheory | ||
open scoped ENNReal | ||
|
||
example : (1 : ℝ≥0∞) < ∞ := by finiteness | ||
example : (3 : ℝ≥0∞) ≠ ∞ := by finiteness | ||
|
||
example (a : ℝ) (b : ℕ) : ENNReal.ofReal a + b < ∞ := by finiteness | ||
|
||
example {a : ℝ≥0∞} (ha : a ≠ ∞) : a + 3 < ∞ := by finiteness | ||
example {a : ℝ≥0∞} (ha : a < ∞) : a + 3 < ∞ := by finiteness | ||
/-- | ||
Test that `finiteness_nonterminal` makes progress but does not fail on not | ||
closing the goal. | ||
-/ | ||
example {a : ℝ≥0∞} (ha : a = 0) : a + 3 < ∞ := by finiteness_nonterminal; simp [ha] | ||
|
||
example (a : ℝ) : (ENNReal.ofReal (1 + a ^ 2))⁻¹ < ∞ := by finiteness | ||
|
||
example {α : Type*} (f : α → ℕ) : ∀ i, (f i : ℝ≥0∞) ≠ ∞ := by finiteness | ||
|
||
example {_ : MeasurableSpace α} (μ : Measure α) [IsFiniteMeasure μ] (s : Set α) : μ s ≠ ∞ := by | ||
finiteness |