Skip to content

Commit

Permalink
Merge branch 'nightly-testing' of github.com:leanprover-community/mat…
Browse files Browse the repository at this point in the history
…hlib4 into lean-pr-testing-3040
  • Loading branch information
nomeata committed Dec 13, 2023
2 parents 9e21655 + bb70e2a commit 0c2d077
Show file tree
Hide file tree
Showing 230 changed files with 5,732 additions and 3,649 deletions.
10 changes: 5 additions & 5 deletions Archive/Examples/IfNormalization/WithoutAesop.lean
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,21 @@ def normalize' (l : AList (fun _ : ℕ => Bool)) :
· simp_all
· have := ht₃ v
have := he₃ v
simp_all? says simp_all only [Option.elim, ne_eq, normalized, Bool.and_eq_true,
simp_all? says simp_all only [Option.elim, normalized, Bool.and_eq_true,
Bool.not_eq_true', AList.lookup_insert, imp_false]
obtain ⟨⟨⟨tn, tc⟩, tr⟩, td⟩ := ht₂
split <;> rename_i h'
· subst h'
simp_all
· simp_all? says simp_all only [ne_eq, hasNestedIf, Bool.or_self, hasConstantIf,
and_self, hasRedundantIf, Bool.or_false, beq_eq_false_iff_ne, not_false_eq_true,
· simp_all? says simp_all only [hasNestedIf, Bool.or_self, hasConstantIf, and_self,
hasRedundantIf, Bool.or_false, beq_eq_false_iff_ne, ne_eq, not_false_eq_true,
disjoint, List.disjoint, decide_True, Bool.and_self]
· have := ht₃ w
have := he₃ w
by_cases h : w = v
· subst h; simp_all
· simp_all? says simp_all only [Option.elim, ne_eq, normalized, Bool.and_eq_true,
Bool.not_eq_true', not_false_eq_true, AList.lookup_insert_ne]
· simp_all? says simp_all only [Option.elim, normalized, Bool.and_eq_true,
Bool.not_eq_true', ne_eq, not_false_eq_true, AList.lookup_insert_ne]
obtain ⟨⟨⟨en, ec⟩, er⟩, ed⟩ := he₂
split at b <;> rename_i h'
· subst h'; simp_all
Expand Down
1 change: 1 addition & 0 deletions Archive/Wiedijk100Theorems/BallotProblem.lean
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def countedSequence (p q : ℕ) : Set (List ℤ) :=
{l | l.count 1 = p ∧ l.count (-1) = q ∧ ∀ x ∈ l, x = (1 : ℤ) ∨ x = -1}
#align ballot.counted_sequence Ballot.countedSequence

open scoped List in
/-- An alternative definition of `countedSequence` that uses `List.Perm`. -/
theorem mem_countedSequence_iff_perm {p q l} :
l ∈ countedSequence p q ↔ l ~ List.replicate p (1 : ℤ) ++ List.replicate q (-1) := by
Expand Down
33 changes: 13 additions & 20 deletions Archive/Wiedijk100Theorems/Partition.lean
Original file line number Diff line number Diff line change
Expand Up @@ -384,19 +384,11 @@ theorem partialOddGF_prop [Field α] (n m : ℕ) :
α) =
coeff α n (partialOddGF m) := by
rw [partialOddGF]
-- Porting note: `convert` timeouts. Please revert to `convert` when the performance of `convert`
-- is improved.
refine Eq.trans ?_
(Eq.trans (partialGF_prop α n ((range m).map mkOdd) ?_ (fun _ => Set.univ) fun _ _ => trivial)
(Eq.symm ?_))
convert partialGF_prop α n
((range m).map mkOdd) _ (fun _ => Set.univ) (fun _ _ => trivial) using 2
· congr
simp only [true_and_iff, forall_const, Set.mem_univ]
· intro i
rw [mem_map]
rintro ⟨a, -, rfl⟩
exact Nat.succ_pos _
· congr 1
rw [Finset.prod_map]
· rw [Finset.prod_map]
simp_rw [num_series']
congr! 2 with x
ext k
Expand All @@ -406,6 +398,10 @@ theorem partialOddGF_prop [Field α] (n m : ℕ) :
apply mul_comm
rintro ⟨a_w, -, rfl⟩
apply Dvd.intro_left a_w rfl
· intro i
rw [mem_map]
rintro ⟨a, -, rfl⟩
exact Nat.succ_pos _
#align theorems_100.partial_odd_gf_prop Theorems100.partialOddGF_prop

/-- If m is big enough, the partial product's coefficient counts the number of odd partitions -/
Expand Down Expand Up @@ -438,23 +434,20 @@ theorem partialDistinctGF_prop [CommSemiring α] (n m : ℕ) :
α) =
coeff α n (partialDistinctGF m) := by
rw [partialDistinctGF]
-- Porting note: `convert` timeouts. Please revert to `convert` when the performance of `convert`
-- is improved.
refine Eq.trans ?_
(Eq.trans (partialGF_prop α n ((range m).map ⟨Nat.succ, Nat.succ_injective⟩) ?_
(fun _ => {0, 1}) fun _ _ => Or.inl rfl) (Eq.symm ?_))
convert partialGF_prop α n
((range m).map ⟨Nat.succ, Nat.succ_injective⟩) _ (fun _ => {0, 1}) (fun _ _ => Or.inl rfl)
using 2
· congr
congr! with p
rw [Multiset.nodup_iff_count_le_one]
congr! with i
rcases Multiset.count i p.parts with (_ | _ | ms) <;> simp
· simp_rw [Finset.prod_map, two_series]
congr with i
simp [Set.image_pair]
· simp only [mem_map, Function.Embedding.coeFn_mk]
rintro i ⟨_, _, rfl⟩
apply Nat.succ_pos
· congr 1
simp_rw [Finset.prod_map, two_series]
congr with i
simp [Set.image_pair]
#align theorems_100.partial_distinct_gf_prop Theorems100.partialDistinctGF_prop

/-- If m is big enough, the partial product's coefficient counts the number of distinct partitions
Expand Down
14 changes: 13 additions & 1 deletion Cache/IO.lean
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def CURLBIN :=

/-- leantar version at https://github.com/digama0/leangz -/
def LEANTARVERSION :=
"0.1.9"
"0.1.10"

def EXE := if System.Platform.isWindows then ".exe" else ""

Expand Down Expand Up @@ -361,4 +361,16 @@ def cleanCache (keep : Lean.RBTree FilePath compare := default) : IO Unit := do
for path in ← getFilesWithExtension CACHEDIR "ltar" do
if !keep.contains path then IO.FS.removeFile path

/-- Prints the LTAR file and embedded comments (in particular, the mathlib commit that built the
file) regarding the files with specified paths. -/
def lookup (hashMap : HashMap) (paths : List FilePath) : IO Unit := do
let mut err := false
for path in paths do
let some hash := hashMap.find? path | err := true
let ltar := CACHEDIR / hash.asLTar
IO.println s!"{path}: {ltar}"
for line in (← runCmd (← getLeanTar) #["-k", ltar.toString]).splitOn "\n" |>.dropLast do
println! " comment: {line}"
if err then IO.Process.exit 1

end Cache.IO
4 changes: 3 additions & 1 deletion Cache/Main.lean
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Commands:
unpack! Decompress linked already downloaded files (no skipping)
clean Delete non-linked files
clean! Delete everything on the local cache
lookup Show information about cache files for the given lean files
# Privilege required
put Run 'mk' then upload linked files missing on the server
Expand Down Expand Up @@ -59,7 +60,7 @@ def curlArgs : List String :=
["get", "get!", "get-", "put", "put!", "commit", "commit!"]

def leanTarArgs : List String :=
["get", "get!", "pack", "pack!", "unpack"]
["get", "get!", "pack", "pack!", "unpack", "lookup"]

open Cache IO Hashing Requests System in
def main (args : List String) : IO Unit := do
Expand Down Expand Up @@ -102,4 +103,5 @@ def main (args : List String) : IO Unit := do
if !(← isGitStatusClean) then IO.println "Please commit your changes first" return else
commit hashMap true (← getToken)
| ["collect"] => IO.println "TODO"
| "lookup" :: args => lookup hashMap (toPaths args)
| _ => println help
22 changes: 17 additions & 5 deletions Mathlib.lean
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ import Mathlib.Algebra.FreeAlgebra
import Mathlib.Algebra.FreeMonoid.Basic
import Mathlib.Algebra.FreeMonoid.Count
import Mathlib.Algebra.FreeNonUnitalNonAssocAlgebra
import Mathlib.Algebra.Function.Finite
import Mathlib.Algebra.Function.Indicator
import Mathlib.Algebra.Function.Support
import Mathlib.Algebra.GCDMonoid.Basic
import Mathlib.Algebra.GCDMonoid.Div
import Mathlib.Algebra.GCDMonoid.Finset
Expand Down Expand Up @@ -267,7 +270,6 @@ import Mathlib.Algebra.Homology.ShortExact.Abelian
import Mathlib.Algebra.Homology.ShortExact.Preadditive
import Mathlib.Algebra.Homology.Single
import Mathlib.Algebra.Homology.SingleHomology
import Mathlib.Algebra.IndicatorFunction
import Mathlib.Algebra.Invertible.Basic
import Mathlib.Algebra.Invertible.Defs
import Mathlib.Algebra.Invertible.GroupWithZero
Expand Down Expand Up @@ -308,6 +310,7 @@ import Mathlib.Algebra.Module.Basic
import Mathlib.Algebra.Module.BigOperators
import Mathlib.Algebra.Module.Bimodule
import Mathlib.Algebra.Module.DedekindDomain
import Mathlib.Algebra.Module.DirectLimitAndTensorProduct
import Mathlib.Algebra.Module.Equiv
import Mathlib.Algebra.Module.GradedModule
import Mathlib.Algebra.Module.Hom
Expand Down Expand Up @@ -414,6 +417,7 @@ import Mathlib.Algebra.Order.Sub.Canonical
import Mathlib.Algebra.Order.Sub.Defs
import Mathlib.Algebra.Order.Sub.Prod
import Mathlib.Algebra.Order.Sub.WithTop
import Mathlib.Algebra.Order.Support
import Mathlib.Algebra.Order.ToIntervalMod
import Mathlib.Algebra.Order.UpperLower
import Mathlib.Algebra.Order.WithZero
Expand Down Expand Up @@ -475,7 +479,6 @@ import Mathlib.Algebra.Star.SelfAdjoint
import Mathlib.Algebra.Star.StarAlgHom
import Mathlib.Algebra.Star.Subalgebra
import Mathlib.Algebra.Star.Unitary
import Mathlib.Algebra.Support
import Mathlib.Algebra.Symmetrized
import Mathlib.Algebra.TrivSqZeroExt
import Mathlib.Algebra.Tropical.Basic
Expand Down Expand Up @@ -1328,6 +1331,7 @@ import Mathlib.Combinatorics.Quiver.Push
import Mathlib.Combinatorics.Quiver.SingleObj
import Mathlib.Combinatorics.Quiver.Subquiver
import Mathlib.Combinatorics.Quiver.Symmetric
import Mathlib.Combinatorics.Schnirelmann
import Mathlib.Combinatorics.SetFamily.CauchyDavenport
import Mathlib.Combinatorics.SetFamily.Compression.Down
import Mathlib.Combinatorics.SetFamily.Compression.UV
Expand Down Expand Up @@ -1513,6 +1517,7 @@ import Mathlib.Data.Finset.Pairwise
import Mathlib.Data.Finset.Pi
import Mathlib.Data.Finset.PiInduction
import Mathlib.Data.Finset.Pointwise
import Mathlib.Data.Finset.Pointwise.Interval
import Mathlib.Data.Finset.Powerset
import Mathlib.Data.Finset.Preimage
import Mathlib.Data.Finset.Prod
Expand Down Expand Up @@ -1606,6 +1611,7 @@ import Mathlib.Data.LazyList.Basic
import Mathlib.Data.List.AList
import Mathlib.Data.List.Basic
import Mathlib.Data.List.BigOperators.Basic
import Mathlib.Data.List.BigOperators.Defs
import Mathlib.Data.List.BigOperators.Lemmas
import Mathlib.Data.List.Card
import Mathlib.Data.List.Chain
Expand Down Expand Up @@ -1673,6 +1679,7 @@ import Mathlib.Data.Matrix.Rank
import Mathlib.Data.Matrix.Reflection
import Mathlib.Data.Matrix.RowCol
import Mathlib.Data.Matroid.Basic
import Mathlib.Data.Matroid.Dual
import Mathlib.Data.Matroid.IndepAxioms
import Mathlib.Data.Matroid.Init
import Mathlib.Data.Multiset.Antidiagonal
Expand Down Expand Up @@ -2000,7 +2007,9 @@ import Mathlib.Data.ZMod.Algebra
import Mathlib.Data.ZMod.Basic
import Mathlib.Data.ZMod.Coprime
import Mathlib.Data.ZMod.Defs
import Mathlib.Data.ZMod.Factorial
import Mathlib.Data.ZMod.IntUnitsPower
import Mathlib.Data.ZMod.Module
import Mathlib.Data.ZMod.Parity
import Mathlib.Data.ZMod.Quotient
import Mathlib.Data.ZMod.Units
Expand Down Expand Up @@ -2327,6 +2336,7 @@ import Mathlib.LinearAlgebra.Basis.Bilinear
import Mathlib.LinearAlgebra.Basis.Flag
import Mathlib.LinearAlgebra.Basis.VectorSpace
import Mathlib.LinearAlgebra.BilinearForm.Basic
import Mathlib.LinearAlgebra.BilinearForm.DualLattice
import Mathlib.LinearAlgebra.BilinearForm.Hom
import Mathlib.LinearAlgebra.BilinearForm.Orthogonal
import Mathlib.LinearAlgebra.BilinearForm.Properties
Expand Down Expand Up @@ -2361,6 +2371,7 @@ import Mathlib.LinearAlgebra.ExteriorAlgebra.Basic
import Mathlib.LinearAlgebra.ExteriorAlgebra.Grading
import Mathlib.LinearAlgebra.ExteriorAlgebra.OfAlternating
import Mathlib.LinearAlgebra.FiniteDimensional
import Mathlib.LinearAlgebra.FiniteSpan
import Mathlib.LinearAlgebra.Finrank
import Mathlib.LinearAlgebra.Finsupp
import Mathlib.LinearAlgebra.FinsuppVectorSpace
Expand Down Expand Up @@ -2450,6 +2461,7 @@ import Mathlib.LinearAlgebra.QuadraticForm.TensorProduct.Isometries
import Mathlib.LinearAlgebra.Quotient
import Mathlib.LinearAlgebra.QuotientPi
import Mathlib.LinearAlgebra.Ray
import Mathlib.LinearAlgebra.Reflection
import Mathlib.LinearAlgebra.SModEq
import Mathlib.LinearAlgebra.SesquilinearForm
import Mathlib.LinearAlgebra.Span
Expand Down Expand Up @@ -2484,9 +2496,9 @@ import Mathlib.Logic.Equiv.Fin
import Mathlib.Logic.Equiv.Fintype
import Mathlib.Logic.Equiv.Functor
import Mathlib.Logic.Equiv.List
import Mathlib.Logic.Equiv.LocalEquiv
import Mathlib.Logic.Equiv.Nat
import Mathlib.Logic.Equiv.Option
import Mathlib.Logic.Equiv.PartialEquiv
import Mathlib.Logic.Equiv.Set
import Mathlib.Logic.Equiv.TransferInstance
import Mathlib.Logic.Function.Basic
Expand Down Expand Up @@ -3580,11 +3592,10 @@ import Mathlib.Topology.Instances.RealVectorSpace
import Mathlib.Topology.Instances.Sign
import Mathlib.Topology.Instances.TrivSqZeroExt
import Mathlib.Topology.Irreducible
import Mathlib.Topology.IsLocallyHomeomorph
import Mathlib.Topology.IsLocalHomeomorph
import Mathlib.Topology.List
import Mathlib.Topology.LocalAtTarget
import Mathlib.Topology.LocalExtr
import Mathlib.Topology.LocalHomeomorph
import Mathlib.Topology.LocallyConstant.Algebra
import Mathlib.Topology.LocallyConstant.Basic
import Mathlib.Topology.LocallyFinite
Expand Down Expand Up @@ -3642,6 +3653,7 @@ import Mathlib.Topology.Order.Priestley
import Mathlib.Topology.Order.ScottTopology
import Mathlib.Topology.Order.UpperLowerSetTopology
import Mathlib.Topology.Partial
import Mathlib.Topology.PartialHomeomorph
import Mathlib.Topology.PartitionOfUnity
import Mathlib.Topology.Perfect
import Mathlib.Topology.ProperMap
Expand Down
7 changes: 7 additions & 0 deletions Mathlib/Algebra/Algebra/Spectrum.lean
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,17 @@ theorem zero_mem_iff {a : A} : (0 : R) ∈ σ a ↔ ¬IsUnit a := by
rw [mem_iff, map_zero, zero_sub, IsUnit.neg_iff]
#align spectrum.zero_mem_iff spectrum.zero_mem_iff

alias ⟨not_isUnit_of_zero_mem, zero_mem⟩ := spectrum.zero_mem_iff

theorem zero_not_mem_iff {a : A} : (0 : R) ∉ σ a ↔ IsUnit a := by
rw [zero_mem_iff, Classical.not_not]
#align spectrum.zero_not_mem_iff spectrum.zero_not_mem_iff

alias ⟨isUnit_of_zero_not_mem, zero_not_mem⟩ := spectrum.zero_not_mem_iff

lemma subset_singleton_zero_compl {a : A} (ha : IsUnit a) : spectrum R a ⊆ {0}ᶜ :=
Set.subset_compl_singleton_iff.mpr <| spectrum.zero_not_mem R ha

variable {R}

theorem mem_resolventSet_of_left_right_inverse {r : R} {a b c : A} (h₁ : (↑ₐ r - a) * b = 1)
Expand Down
Loading

0 comments on commit 0c2d077

Please sign in to comment.