Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 70d50ec

Browse files
committed
chore(algebra/char_zero): split (#17760)
Split `algebra/char_zero` into `algebra/char_zero/lemmas` and `algebra/char_zero/infinite` (there was already a `algebra/char_zero/defs`), with the former not importing finset. As intended, this caused a few files which had been getting their finset import by this path to require that import explicitly. I've added the finset imports explicitly on all such files, except for `tactic/positivity`, the point being that I actually want to remove the finset import from positivity. I moved the `fin{set,type}.card` positivity extensions from `tactic/positivity` to `data/fintype/card`.
1 parent 5cd3c25 commit 70d50ec

14 files changed

Lines changed: 60 additions & 28 deletions

File tree

archive/oxford_invariants/2021summer/week3_p1.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Authors: Yaël Dillies, Bhavik Mehta
55
-/
66
import algebra.big_operators.order
77
import algebra.big_operators.ring
8-
import algebra.char_zero
8+
import algebra.char_zero.lemmas
99
import data.rat.cast
1010

1111
/-!

src/algebra/algebra/basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import algebra.module.ulift
88
import algebra.ne_zero
99
import algebra.ring.aut
1010
import algebra.ring.ulift
11-
import algebra.char_zero
11+
import algebra.char_zero.lemmas
1212
import linear_algebra.span
1313
import tactic.abel
1414

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/-
2+
Copyright (c) 2020 Johan Commelin. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Johan Commelin
5+
-/
6+
import algebra.char_zero.defs
7+
import data.fintype.lattice
8+
9+
/-! # A characteristic-zero semiring is infinite -/
10+
11+
open set
12+
variables (M : Type*) [add_monoid_with_one M] [char_zero M]
13+
14+
@[priority 100] -- see Note [lower instance priority]
15+
instance char_zero.infinite : infinite M :=
16+
infinite.of_injective coe nat.cast_injective
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ Authors: Mario Carneiro
55
-/
66

77
import data.nat.cast.field
8-
import data.fintype.lattice
98
import algebra.group_power.lemmas
109

1110
/-!
@@ -47,10 +46,6 @@ section
4746

4847
variables (M : Type*) [add_monoid_with_one M] [char_zero M]
4948

50-
@[priority 100] -- see Note [lower instance priority]
51-
instance char_zero.infinite : infinite M :=
52-
infinite.of_injective coe nat.cast_injective
53-
5449
instance char_zero.ne_zero.two : ne_zero (2 : M) :=
5550
have ((2:ℕ):M) ≠ 0, from nat.cast_ne_zero.2 dec_trivial, by rwa [nat.cast_two] at this
5651

src/algebra/order/field/power.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Robert Lewis, Leonardo de Moura, Mario Carneiro, Floris van Doorn
55
-/
66
import algebra.parity
7-
import algebra.char_zero
7+
import algebra.char_zero.lemmas
88
import algebra.group_with_zero.power
99
import algebra.order.field.basic
1010

src/algebra/order/floor.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Authors: Mario Carneiro, Kevin Kappelmann
55
-/
66
import data.int.lemmas
77
import data.set.intervals.group
8+
import data.set.lattice
89
import tactic.abel
910
import tactic.linarith
1011
import tactic.positivity

src/algebra/order/hom/ring.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import algebra.order.archimedean
77
import algebra.order.hom.monoid
88
import algebra.order.ring.defs
99
import algebra.ring.equiv
10+
import tactic.wlog
1011

1112
/-!
1213
# Ordered ring homomorphisms

src/combinatorics/catalan.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Authors: Julian Kuelshammer
55
-/
66
import data.nat.choose.central
77
import algebra.big_operators.fin
8-
import algebra.char_zero
8+
import algebra.char_zero.lemmas
99
import tactic.field_simp
1010
import tactic.linear_combination
1111

src/data/enat/basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Authors: Yury Kudryashov
55
-/
66
import data.nat.lattice
77
import data.nat.succ_pred
8-
import algebra.char_zero
8+
import algebra.char_zero.lemmas
99
import algebra.order.sub.with_top
1010
import algebra.order.ring.with_top
1111

src/data/fintype/card.lean

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Authors: Mario Carneiro
66
import data.fintype.basic
77
import data.finset.card
88
import data.list.nodup_equiv_fin
9+
import tactic.positivity
910
import tactic.wlog
1011

1112
/-!
@@ -967,3 +968,22 @@ begin
967968
rw hn at hlt,
968969
exact (ih (fintype.card β) hlt _ rfl), }
969970
end
971+
972+
namespace tactic
973+
open positivity
974+
975+
private lemma card_univ_pos (α : Type*) [fintype α] [nonempty α] :
976+
0 < (finset.univ : finset α).card :=
977+
finset.univ_nonempty.card_pos
978+
979+
/-- Extension for the `positivity` tactic: `finset.card s` is positive if `s` is nonempty. -/
980+
@[positivity]
981+
meta def positivity_finset_card : expr → tactic strictness
982+
| `(finset.card %%s) := do -- TODO: Partial decision procedure for `finset.nonempty`
983+
p ← to_expr ``(finset.nonempty %%s) >>= find_assumption,
984+
positive <$> mk_app ``finset.nonempty.card_pos [p]
985+
| `(@fintype.card %%α %%i) := positive <$> mk_mapp ``fintype.card_pos [α, i, none]
986+
| e := pp e >>= fail ∘ format.bracket "The expression `"
987+
"` isn't of the form `finset.card s` or `fintype.card α`"
988+
989+
end tactic

0 commit comments

Comments
 (0)