Skip to content

Commit bf0f847

Browse files
Vierkantorleanprover-community-mathlib4-botfgdorais
committed
chore(*): adaptations for batteries#1545 (#32581)
After [batteries#1545](leanprover-community/batteries#1545) is merged: - [x] Edit the lakefile to point to leanprover-community/batteries:main - [x] Run lake update batteries - [x] Merge leanprover-community/mathlib4:master - [ ] Wait for CI and merge Co-authored-by: leanprover-community-mathlib4-bot <leanprover-community-mathlib4-bot@users.noreply.github.com> Co-authored-by: Anne C.A. Baanen <vierkantor@vierkantor.com> Co-authored-by: F. G. Dorais <fgdorais@gmail.com>
1 parent da367fd commit bf0f847

File tree

5 files changed

+34
-52
lines changed

5 files changed

+34
-52
lines changed

Mathlib.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6535,6 +6535,7 @@ public import Mathlib.Tactic.ExistsI
65356535
public import Mathlib.Tactic.Explode
65366536
public import Mathlib.Tactic.Explode.Datatypes
65376537
public import Mathlib.Tactic.Explode.Pretty
6538+
public import Mathlib.Tactic.Ext
65386539
public import Mathlib.Tactic.ExtendDoc
65396540
public import Mathlib.Tactic.ExtractGoal
65406541
public import Mathlib.Tactic.ExtractLets

Mathlib/Data/Nat/Cast/Defs.lean

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,6 @@ class AddMonoidWithOne (R : Type*) extends NatCast R, AddMonoid R, One R where
7171
/-- An `AddCommMonoidWithOne` is an `AddMonoidWithOne` satisfying `a + b = b + a`. -/
7272
class AddCommMonoidWithOne (R : Type*) extends AddMonoidWithOne R, AddCommMonoid R
7373

74-
library_note2 «coercion into rings»
75-
/--
76-
Coercions such as `Nat.castCoe` that go from a concrete structure such as
77-
`ℕ` to an arbitrary ring `R` should be set up as follows:
78-
```lean
79-
instance : CoeTail ℕ R where coe := ...
80-
instance : CoeHTCT ℕ R where coe := ...
81-
```
82-
83-
It needs to be `CoeTail` instead of `Coe` because otherwise type-class
84-
inference would loop when constructing the transitive coercion `ℕ → ℕ → ℕ → ...`.
85-
Sometimes we also need to declare the `CoeHTCT` instance
86-
if we need to shadow another coercion
87-
(e.g. `Nat.cast` should be used over `Int.ofNat`).
88-
-/
89-
9074
namespace Nat
9175

9276
variable [AddMonoidWithOne R]

Mathlib/Tactic.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public import Mathlib.Tactic.ExistsI
8585
public import Mathlib.Tactic.Explode
8686
public import Mathlib.Tactic.Explode.Datatypes
8787
public import Mathlib.Tactic.Explode.Pretty
88+
public import Mathlib.Tactic.Ext
8889
public import Mathlib.Tactic.ExtendDoc
8990
public import Mathlib.Tactic.ExtractGoal
9091
public import Mathlib.Tactic.ExtractLets

Mathlib/Tactic/Basic.lean

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public meta import Mathlib.Tactic.Lemma
1212
public meta import Mathlib.Tactic.TypeStar
1313
public meta import Mathlib.Tactic.Linter.OldObtain
1414
public meta import Mathlib.Tactic.Simproc.ExistsAndEq
15+
public import Batteries.Util.LibraryNote -- For `library_note` command.
1516

1617
/-!
1718
# Basic tactics and utilities for tactic writing
@@ -157,39 +158,3 @@ def withResetServerInfo {α : Type} (t : TacticM α) :
157158
return { result?, msgs, trees }
158159

159160
end Mathlib.Tactic
160-
161-
/-- A mathlib library note: the note's content should be contained in its doc-string. -/
162-
@[expose] def LibraryNote := Unit
163-
164-
open Lean in
165-
/-- `library_note2 «my note» /-- documentation -/` creates a library note named `my note`
166-
in the `Mathlib.LibraryNote` namespace, whose content is `/-- documentation -/`.
167-
You can access this note using, for example, `#print Mathlib.LibraryNote.«my note»`.
168-
-/
169-
macro "library_note2 " name:ident ppSpace dc:docComment : command =>
170-
`($dc:docComment def $(mkIdent (`_root_.Mathlib.LibraryNote ++ name.getId)) : LibraryNote := ())
171-
172-
open Lean Elab Command in
173-
/-- Support the old `library_note "foo"` syntax, with a deprecation warning. -/
174-
elab "library_note2 " name:str ppSpace dc:docComment : command => do
175-
logWarningAt name <|
176-
"deprecation warning: library_note2 now takes an identifier instead of a string.\n" ++
177-
"Hint: replace the double quotes with «french quotes»."
178-
let name := Name.mkSimple name.getString
179-
let stx ← `(library_note2 $(mkIdent name):ident $dc:docComment)
180-
elabCommandTopLevel stx
181-
182-
library_note2 «partially-applied ext lemmas»
183-
/--
184-
When possible, `ext` lemmas are stated without a full set of arguments. As an example, for bundled
185-
homs `f`, `g`, and `of`, `f.comp of = g.comp of → f = g` is a better `ext` lemma than
186-
`(∀ x, f (of x) = g (of x)) → f = g`, as the former allows a second type-specific extensionality
187-
lemmas to be applied to `f.comp of = g.comp of`.
188-
If the domain of `of` is `ℕ` or `ℤ` and `of` is a `RingHom`, such a lemma could then make the goal
189-
`f (of 1) = g (of 1)`.
190-
191-
For bundled morphisms, there is a `ext` lemma that always applies of the form
192-
`(∀ x, ⇑f x = ⇑g x) → f = g`. When adding type-specific `ext` lemmas like the one above, we want
193-
these to be tried first. This happens automatically since the type-specific lemmas are inevitably
194-
defined later.
195-
-/

Mathlib/Tactic/Ext.lean

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/-
2+
Copyright (c) 2020 Eric Wieser. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Eric Wieser
5+
-/
6+
module
7+
8+
public import Mathlib.Tactic.Basic
9+
10+
/-!
11+
# Documentation for `ext` tactic
12+
13+
This file contains a library note on the use of the `ext` tactic and `@[ext]` attribute.
14+
-/
15+
16+
public section
17+
18+
library_note «partially-applied ext lemmas»
19+
/--
20+
When possible, `ext` lemmas are stated without a full set of arguments. As an example, for bundled
21+
homs `f`, `g`, and `of`, `f.comp of = g.comp of → f = g` is a better `ext` lemma than
22+
`(∀ x, f (of x) = g (of x)) → f = g`, as the former allows a second type-specific extensionality
23+
lemmas to be applied to `f.comp of = g.comp of`.
24+
If the domain of `of` is `ℕ` or `ℤ` and `of` is a `RingHom`, such a lemma could then make the goal
25+
`f (of 1) = g (of 1)`.
26+
27+
For bundled morphisms, there is a `ext` lemma that always applies of the form
28+
`(∀ x, ⇑f x = ⇑g x) → f = g`. When adding type-specific `ext` lemmas like the one above, we want
29+
these to be tried first. This happens automatically since the type-specific lemmas are inevitably
30+
defined later.
31+
-/

0 commit comments

Comments
 (0)