Lecture notes from Cambridge maths

Haskell implementation of Flood-It

Solutions to advent of code 2018

arithmoi is currently maintained here

Public uploads of my lecture notes

My Cambridge Lecture Notes

Personal config files

Pull request review commentleanprover-community/mathlib

feat(data/nat): a predicate for prime powers

+/-+Copyright (c) 2022 Bhavik Mehta. All rights reserved.+Released under Apache 2.0 license as described in the file LICENSE.+Authors: Bhavik Mehta+-/+import algebra.associated+import data.nat.factorization++/-!+# Prime powers++This file deals with prime powers: numbers which are positive integer powers of a single prime.+-/++variables {R : Type*} [comm_monoid_with_zero R] (n p : R) (k : ℕ)++/-- `n` is a prime power if there is a prime `p` and a positive natural `k` such that `n` can be+written as `p^k`. -/+def is_prime_pow : Prop :=+ ∃ (p : R) (k : ℕ), prime p ∧ 0 < k ∧ p ^ k = n++lemma is_prime_pow_def :+ is_prime_pow n ↔ ∃ (p : R) (k : ℕ), prime p ∧ 0 < k ∧ p ^ k = n := iff.rfl++/-- An equivalent definition for prime powers: `n` is a prime power iff there is a prime `p` and a+natural `k` such that `n` can be written as `p^(k+1)`. -/+lemma is_prime_pow_iff_pow_succ :+ is_prime_pow n ↔ ∃ (p : R) (k : ℕ), prime p ∧ p ^ (k + 1) = n :=+(is_prime_pow_def _).trans+⟨λ ⟨p, k, hp, hk, hn⟩, ⟨_, _, hp, by rwa [nat.sub_add_cancel hk]⟩,+ λ ⟨p, k, hp, hn⟩, ⟨_, _, hp, nat.succ_pos', hn⟩⟩++lemma not_is_prime_pow_zero [no_zero_divisors R] :+ ¬ is_prime_pow (0 : R) :=+begin+ simp only [is_prime_pow_def, not_exists, not_and', and_imp],+ intros x n hn hx,+ rw pow_eq_zero hx,+ simp,+end++lemma not_is_prime_pow_one : ¬ is_prime_pow (1 : R) :=+begin+ simp only [is_prime_pow_def, not_exists, not_and', and_imp],+ intros x n hn hx ht,+ exact ht.not_unit (is_unit_of_pow_eq_one x n hx hn),+end++lemma prime.is_prime_pow {p : R} (hp : prime p) : is_prime_pow p :=+⟨p, 1, hp, zero_lt_one, by simp⟩++lemma is_prime_pow.pow {n : R} (hn : is_prime_pow n)+ {k : ℕ} (hk : k ≠ 0) : is_prime_pow (n ^ k) :=+let ⟨p, k', hp, hk', hn⟩ := hn in ⟨p, k * k', hp, mul_pos hk.bot_lt hk', by rw [pow_mul', hn]⟩++lemma unique_is_prime_pow {R : Type*} [cancel_comm_monoid_with_zero R] {p₁ p₂ : R} {k₁ k₂ : ℕ}

Yup you're right, I moved this and cleaned it and forgot to remove the old version!

comment created time in 3 hours

Pull request review commentleanprover-community/mathlib

feat(data/nat): a predicate for prime powers

+/-+Copyright (c) 2022 Bhavik Mehta. All rights reserved.+Released under Apache 2.0 license as described in the file LICENSE.+Authors: Bhavik Mehta+-/+import algebra.associated+import data.nat.factorization++/-!+# Prime powers++This file deals with prime powers: numbers which are positive integer powers of a single prime.+-/++variables {R : Type*} [comm_monoid_with_zero R] (n p : R) (k : ℕ)++/-- `n` is a prime power if there is a prime `p` and a positive natural `k` such that `n` can be+written as `p^k`. -/+def is_prime_pow : Prop :=+ ∃ (p : R) (k : ℕ), prime p ∧ 0 < k ∧ p ^ k = n++lemma is_prime_pow_def :+ is_prime_pow n ↔ ∃ (p : R) (k : ℕ), prime p ∧ 0 < k ∧ p ^ k = n := iff.rfl++/-- An equivalent definition for prime powers: `n` is a prime power iff there is a prime `p` and a+natural `k` such that `n` can be written as `p^(k+1)`. -/+lemma is_prime_pow_iff_pow_succ :+ is_prime_pow n ↔ ∃ (p : R) (k : ℕ), prime p ∧ p ^ (k + 1) = n :=+(is_prime_pow_def _).trans+⟨λ ⟨p, k, hp, hk, hn⟩, ⟨_, _, hp, by rwa [nat.sub_add_cancel hk]⟩,+ λ ⟨p, k, hp, hn⟩, ⟨_, _, hp, nat.succ_pos', hn⟩⟩++lemma not_is_prime_pow_zero [no_zero_divisors R] :+ ¬ is_prime_pow (0 : R) :=+begin+ simp only [is_prime_pow_def, not_exists, not_and', and_imp],+ intros x n hn hx,+ rw pow_eq_zero hx,+ simp,+end++lemma not_is_prime_pow_one : ¬ is_prime_pow (1 : R) :=+begin+ simp only [is_prime_pow_def, not_exists, not_and', and_imp],+ intros x n hn hx ht,+ exact ht.not_unit (is_unit_of_pow_eq_one x n hx hn),+end++lemma prime.is_prime_pow {p : R} (hp : prime p) : is_prime_pow p :=+⟨p, 1, hp, zero_lt_one, by simp⟩++lemma is_prime_pow.pow {n : R} (hn : is_prime_pow n)+ {k : ℕ} (hk : k ≠ 0) : is_prime_pow (n ^ k) :=+let ⟨p, k', hp, hk', hn⟩ := hn in ⟨p, k * k', hp, mul_pos hk.bot_lt hk', by rw [pow_mul', hn]⟩++lemma unique_is_prime_pow {R : Type*} [cancel_comm_monoid_with_zero R] {p₁ p₂ : R} {k₁ k₂ : ℕ}+ (hp₁ : prime p₁) (hp₂ : prime p₂) (hk₁ : 0 < k₁) (h : associated (p₁ ^ k₁) (p₂ ^ k₂)):+ associated p₁ p₂ :=+begin+ have : p₁ ∣ p₂ ^ k₂,+ { rw ←h.dvd_iff_dvd_right,+ apply dvd_pow_self _ hk₁.ne' },+ rw ←hp₁.dvd_prime_iff_associated hp₂,+ exact hp₁.dvd_of_dvd_pow this,+end++-- lemma unique_is_prime_pow {p₁ p₂ k₁ k₂ : ℕ}

There's the associated version in algebra/associates now, I think this version can be recovered because ℕ has unique units? I'll add that version explicitly though

comment created time in 3 hours

Pull request review commentleanprover-community/mathlib

feat(data/nat): a predicate for prime powers

`+/-`

Oops yeah you're right!

comment created time in 3 hours

pull request commentleanprover-community/mathlib

feat(order/atoms): A set/finset/multiset is an atom iff it's a singleton

Even then, this special case is valuable. Can we try to get either that version, or this version in?

comment created time in 9 hours

pull request commentleanprover-community/mathlib

feat(order/atoms): A set/finset/multiset is an atom iff it's a singleton

Provided you have the time, may I bump this? I think this is something we really ought to have in mathlib!

comment created time in 12 hours

pull request commentleanprover-community/mathlib

feat(data/finset/basic): random golf

Nice golf!

bors merge

comment created time in a day

push eventleanprover-community/mathlib

commit sha 03b8b3a9a58b8ca34fe0edd65e57816e14b85564

fixup

push time in a day

push eventleanprover-community/mathlib

commit sha 427e5b59b39319af0f2793a486e475bfbb7cedf6

feat(data/nat/factorization): Evaluating a multiplicative function over prime power divisors (#11167) For any multiplicative function `f` with `f 1 = 1` and any `n > 0`, we can evaluate `f n` by evaluating `f` at `p ^ k` over the factorization of `n`. Also provides an alternative version that swaps the `0 < n` condition for an extra `f 0 = 1` condition, as suggested by @ericrbg. This allows a very simple proof that `n.factorization.prod pow = n`

commit sha 2e003c9a7fff62c7f71ff4efda94571fe449fb8d

feat(data/set/basic): add decidable instances for boolean operations (#11354) Add decidability instances for `a ∈ s ∩ t`, etc.

commit sha 4bf48590845b142999eb435f027923ee860916e1

feat(data/finsupp/pointwise): add a definition of the pointwise action of functions on finsupps (#10933) I couldn't find this, and it seems like quite a natural way to talk about multiplying functions with finsupps. I'm not sure what additional lemmas would be useful yet, as I don't have a particular application in mind at present so suggestions/additions are welcome

commit sha 8e92af1dffad1768a1e6433f2169bd5b2f125084

feat(algebra/associated): add lemmas to split #9345 (#10941) This PR contains lemmas from PR [#9345](https://github.com/leanprover-community/mathlib/pull/9345), which was starting to get quite lengthy. Co-authored-by: Anne Baanen.

commit sha 4e7e5a6e756d15c07e9eda778f0b2699f6e262ad

feat(set_theory/ordinal_arithmetic): Enumerating unbounded sets of ordinals with ordinals (#10979) This PR introduces `enum_ord`, which enumerates an unbounded set of ordinals using ordinals. This is used to build an explicit order isomorphism `enum_ord.order_iso`.

commit sha 2642c89b4b5ec03b77a4a29100514b0a74518c47

feat(analysis/inner_product_space/orientation): orientations of real inner product spaces (#11269) Add definitions and lemmas relating to orientations of real inner product spaces, in particular constructing an orthonormal basis with a given orientation in finite positive dimension. This is in a new file since nothing else about inner product spaces needs to depend on orientations.

commit sha fd5248100b83b30a1a3c6d8eef3715014559e9a9

feat(group_theory/abelianization): Add fintype instance (#11302) Adds `fintype` instance for `abelianization`.

commit sha 3b55b94857df2d8909e2c1f256eb9318b7a2c84d

feat(analysis/inner_product_space/basic): inner products of linear combinations of orthonormal vectors (#11323) There are some lemmas about the inner product of a linear combination of orthonormal vectors with one vector from that orthonormal family. Add similar lemmas where both sides of the inner product are linear combinations.

commit sha fd51bda5dd5faeda20a15da03a4e719b501e4540

feat(analysis/normed_space/linear_isometry): basis ext lemmas (#11331) Add lemmas that two linear isometries / linear isometric equivalences are equal if they are equal on basis vectors, similar to such lemmas for equality on basis vectors of other kinds of maps.

commit sha 8910f6d9f394d0a8397169ca0a94ee5586c016c0

feat(ring_theory/discriminant): remove an assumption (#11359) We remove a `nonempty` assumption.

commit sha d8a75bd0cfc5c6f13ad8638e9dba100cf6fa2d44

chore(simple_graph/basic): Fix typo in docstring: adjacent vertices, not edges (#11356)

commit sha 89bff5e7d43550b1663fb0288193c59d6bd89815

feat(algebra/big_operators): add product versions of some sum lemmas (#11358) and to_additive to get the old ones back

commit sha e8839a30b446b83721b10f70665d95ebdad3148d

refactor(logic/small, *): Infer `f : α → β` when followed by a simple condition on `f` (#11037) Co-authored-by: Yury G. Kudryashov <urkud@urkud.name> Co-authored-by: Eric Wieser <wieser.eric@gmail.com>

commit sha de9944b17982913a54d9097f9b7812007274d7e8

refactor(analysis/complex/circle): The circle group is commutative (#11368) This PR upgrades the `group circle` instance to a `comm_group circle` instance.

commit sha 624cb70721117af7d0bb3da887ea9b8f3e572bb0

feat(set_theory/ordinal_arithmetic): Extra lemmas about suprema (#11178) Proved lemmas pertaining to when suprema or least strict upper bounds are zero.

commit sha b7f8f725434b04f0ab663020eef2d91acba265f1

feat(category_theory/bicategory/functor): define oplax functors and their composition (#11277) This PR defines oplax functors between bicategories and their composition.

commit sha be594eb4ca76306410a5ecdb02999e7e35b77b68

feat(linear_algebra/finite_dimensional): Define rank of set of vectors (#11290) Added in the definition of "rank of a set of vectors" and a useful lemma about the rank when one set is a subset of the other. Read the zulip stream here: https://leanprover.zulipchat.com/#narrow/stream/113489-new-members/topic/First.20Time.20Contributing Co-authored-by: ccn <callum.cassidynolan@mail.utoronto.ca>

commit sha c500b99f3c067cec4f83263f15fdfd19674fd87e

feat(ring_theory/laurent): coe from R[[x]] to R((x)) (#11318) And actually the changes reported in #11295 Generalize `power_series.coeff_smul` Co-authored-by: Eric Wieser <wieser.eric@gmail.com>

commit sha ebbc973bfb7296325a73012556b75e61d51af86d

feat(data/mv_polynomial): assorted mv_polynomial and finsupp lemmas (#11319) Mostly around total degree, supports and homogeneous components. From flt-regular.

commit sha c03bd3287efd840268e748a46418416b501e6d22

feat(analysis/normed_space/star): add lemmas about continuity and norm of identity (#11324)

push time in a day

push eventleanprover-community/mathlib

commit sha 2bcfd7fb2a03872b4f80d71622a8e46bd073bee6

fill in some sorry

push time in a day

push eventleanprover-community/mathlib

commit sha cf1f9abc1d439704c2988c7b674db4663dbd7d44

fix properly

push time in a day

push eventleanprover-community/mathlib

commit sha 88e06f641ca8720e84bde5c8b8239ed381973338

partial proof of cor 1

push time in a day

push eventleanprover-community/mathlib

commit sha 5b76497df4997a9d94a96bb6ca6659f3a032f6bf

fix up

push time in a day

push eventleanprover-community/mathlib

commit sha 8af6a7832f4779a954013733af86ca7f7ef49346

restore arithmetic function

push time in a day

push eventleanprover-community/mathlib

commit sha 60e279ba2bfe69f937b5f69b110a440538b8f6a5

chore(*): update to lean 3.36.0 (#11253) The main breaking change is the change in elaboration of double membership binders into x hx y hy, from x y hx hy. Co-authored-by: Yury G. Kudryashov <urkud@urkud.name>

commit sha 09f698902747299a650bdb94546f14ee7b7b3b26

chore(analysis/normed_space/banach): move more to the `continuous_linear_map` NS (#11263) ## Rename * `open_mapping` → `continuous_linear_map.is_open_map`; * `open_mapping_affine` → `affine_map.is_open_map`; ### New lemmas * `continuous_linear_map.quotient_map`, * `continuous_linear_map.interior_preimage`, * `continuous_linear_map.closure_preimage`, * `continuous_linear_map.frontier_preimage`.

commit sha 25704cac29f50cd0e92c2c5a0a9cabc7d9f86f18

docs(algebra/covariant_and_contravariant): minor typos (#11293)

commit sha 84dbe31db27f908325b3f302ec5f5f2e145b2c2a

feat(topology/basic): add explicit definition of continuous_at (#11296) This was convenient in a demo.

commit sha ee136d903b12de0474236113577b7ab001a1c7f0

chore(set_theory/game/domineering): extract repeated goal into lemma and golf (#11298) `fst_pred_mem_erase_of_mem_right` and `snd_pred_mem_erase_of_mem_left` were common subgoals that appeared in two lemmas each.

commit sha 0a75fdfb102a8a00f5a81fc97aad330d1ba444bd

feat(linear_algebra/eigenspace): prove eigenvalues are exactly elements of the spectrum when the space is finite dimensional (#10961) This adds `has_eigenvalue_iff_mem_spectrum` and then uses it to golf `exists_eigenvalue` - [x] depends on: #10912 - [x] depends on: #10919 Co-authored-by: Vierkantor <vierkantor@vierkantor.com>

commit sha 22ff4ebc9bd521cc075fb5f87d55d6d029997e73

feat(combinatorics/simple_graph/matchings): even_card_vertices_of_perfect_matching (#11083) Co-authored-by: YaelDillies <yael.dillies@gmail.com>

commit sha d4846b32a88c9f0e6a5000da901b07e56f5ae7ac

chore(ring_theory/fractional_ideal): fix typo (#11311)

commit sha a58553d58d4019ea4a6815a25b964d2963ed0928

feat(data/nat/factorization): Add lemmas on factorizations of pairs of coprime numbers (#10850)

commit sha ca5e55ccca174a096a8126d7053b0918a569214c

feat(linear_algebra/basis): `basis.ext`, `basis.ext'` for semilinear maps (#11317) Extend `basis.ext` and `basis.ext'` to apply to the general (semilinear) case of `linear_map` and `linear_equiv`.

commit sha ad4ea53813e6895892ddca0b9ede7a5e47e0b836

chore(*): miscellaneous to_additive related cleanup (#11316) A few cleanup changes related to to_additive: * After https://github.com/leanprover-community/lean/pull/618 was merged, we no longer need to add namespaces manually in filtered_colimits and open subgroup * to_additive can now generate some more lemmas in big_operators/fin * to_additive now handles a proof in measure/haar better than it used to so remove a workaround there

commit sha 9c224ff6747a08ce8093289f4243ff2513072c21

split(data/set/functor): Split off `data.set.lattice` (#11327) This moves the functor structure of `set` in a new file `data.set.functor`. Also adds `alternative set` because it's quick and easy.

commit sha fadbd9599176e9076e477b0843dd3adb93c6a568

feat(field_theory/ratfunc): ratfunc.lift_on without is_domain (#11227) We might want to state results about rational functions without assuming that the base ring is an integral domain. Cf. Misconceptions about $K_X$, Kleiman, Steven; Stacks01X1 Co-authored-by: Yakov Pechersky <ypechersky@treeline.bio>

commit sha 49ba33e552ebe03482bd613e8264d88dbec2b040

feat(vscode): add a snippet for inserting a module docstring template (#11312) We already have a vscode snippet for adding copyright headers, this PR adds a similar one to generate a default module docstring with many of the common sections stubbed out. By default it takes the filename, converts underscores to spaces and capitalizes each word to create the title, as this seems a sensible default. But otherwise all text is a static default example following the documentation style page to make it easier to remember the various recommended secitons. To test do `ctrl+shift+p` to open the command pallette, type insert snippet, enter, and type module and it should show up. See also #3186

commit sha 2bb25f05603d7fb79704fe705b3e25ff47a5e674

feat(algebra/periodic): lifting to function on quotient group (#11321) I want to make more use of the type `real.angle` in `analysis.special_functions.trigonometric.angle`, including defining functions from this type in terms of periodic functions from `ℝ`. To support defining such functions, add a definition `periodic.lift` that lifts a periodic function from `α` to a function from `α ⧸ (add_subgroup.zmultiples c)`, along with a lemma `periodic.lift_coe` about the values of the resulting function.

commit sha 47a8d5a63cd90d13a9280fdb5f0fce3a7536d5b4

refactor(data/{sigma,psigma}/order): Use `lex` synonym and new notation (#11235) This introduces notations `Σₗ i, α i` and `Σₗ' i, α i` for `lex (Σ i, α i)` and `lex (Σ' i, α i)` and use them instead of the instance switch with locale `lex`.

commit sha d13b3a4a392ea7273dfa4727dbd1892e26cfd518

chore(*): update to 3.37.0c (#11325) the major breaking change this version is making `default`'s parameters implicit, as opposed to explicit. there was also some slight "free" golfing due to the better `out_param` simp support.

commit sha ce17b657926068f969a8e0bf0cc1352f0f00f587

feat(topology/algebra/monoid): to_additivize some lemmas (#11310) Uncomment a commented out to additive line that looks like its been there for 3 years (since https://github.com/leanprover-community/mathlib/commit/581cf19bf1885ef874c39c9902a93f579bc8c22d) The changes to to_additive in the past few years now make the generated lemma useful. Also to_additivize a bunch of other lemmas in this file.

commit sha 6a1093970ab41a193642f06b0de0e28f2918f54e

fix(docs/references.bib): syntax error (#11342) This broke the docs build.

commit sha 99fe7acbf797b71f9374d109bc3761eab09d1a0f

chore(data/set/function): move inv_fun_on out of `logic/function/basic` (#11330) This removes `function.inv_fun_on_eq'` as it is a duplicate of `inj_on.left_inv_on_inv_fun_on`.

push time in a day

push eventleanprover-community/mathlib

commit sha e4112340301c39643734110f44d7dcad362763af

fix properly

push time in a day

push eventleanprover-community/mathlib

commit sha ed9bd9c3bdc83e658526bc75db4c0b67e0d18f6b

fix build

push time in a day

push eventleanprover-community/mathlib

commit sha 01ad44250b99baa5e81e8bd0d15fdc8a08935c28

stuart suggestions

push time in 2 days

push eventleanprover-community/mathlib

commit sha 5240aab37539eca2318be70b4d383c936fa41f45

generalize

push time in 2 days

pull request commentleanprover-community/mathlib

feat(data/sym/sym2) eq in sym2 from distinct common members

Looks sensible to me! Let's see if Kyle has anything to add about this

bors d=kmill

comment created time in 2 days

pull request commentleanprover-community/mathlib

feat(order/antichain): Strong antichains

LGTM! Thanks!

bors merge

comment created time in 2 days

pull request commentleanprover-community/mathlib

feat(order/antichain): Strong antichains

Looks sensible! I think there's a lemma you can prove about the relation of `order_bot`

, maybe that if it's `order_bot`

then there are no strong antichains or they're all trivial?

comment created time in 2 days

pull request commentleanprover-community/mathlib

feat(data/sum/interval): The disjoint sum of two locally finite orders is locally finite

bors merge

comment created time in 3 days

Pull request review commentleanprover-community/mathlib

feat(data/sum/interval): The disjoint sum of two locally finite orders is locally finite

+/-+Copyright (c) 2022 Yaël Dillies. All rights reserved.+Released under Apache 2.0 license as described in the file LICENSE.+Authors: Yaël Dillies+-/+import data.sum.order+import order.locally_finite++/-!+# Finite intervals in a disjoint union++This file provides the `locally_finite_order` instance for the disjoint sum of two orders.++## TODO++Do the same for the lexicographic sum of orders.+-/++open function sum++namespace finset+variables {α₁ α₂ β₁ β₂ γ₁ γ₂ : Type*}++section sum_lift₂+variables (f f₁ g₁ : α₁ → β₁ → finset γ₁) (g f₂ g₂ : α₂ → β₂ → finset γ₂)++/-- Lifts maps `α₁ → β₁ → finset γ₁` and `α₂ → β₂ → finset γ₂` to a map+`α₁ ⊕ α₂ → β₁ ⊕ β₂ → finset (γ₁ ⊕ γ₂)`. Could be generalized to alternative monads if we can make

I don't think this resolves the issue, the ambiguity is still present. How about writing "`alternative`

functors" to make it clear that you mean `alternative`

as a technical term?

comment created time in 3 days