Skip to content

Instantly share code, notes, and snippets.

View kbuzzard's full-sized avatar

Kevin Buzzard kbuzzard

View GitHub Profile
@kbuzzard
kbuzzard / myint.lean
Created January 6, 2020 04:55
integers the maths way
import tactic
-- need to teach pairs
-- (3, 6) : ℕ × ℕ
-- x.1 is first element of x, x.2 is second
/-- The equivalence relation on ℕ² such that equivalence classes are ℤ -/
def nat2.R (a b : ℕ × ℕ) : Prop :=
a.1 + b.2 = b.1 + a.2
@kbuzzard
kbuzzard / presheaf.lean
Last active December 23, 2019 02:40
problems with pulling back presheaves
/- Theory of presheaves (of objects of a category) on a topological space
cf : https://stacks.math.columbia.edu/tag/006D
Notes: KMB has never really understood whether we should be using
category theory or not when working with sheaves on a topological space.
By explicitly avoiding this and doing everything from first principles
on the topological space side, but letting sheaves take values which are
objects of a general category is certainly something we want to do.
@kbuzzard
kbuzzard / instance.txt
Created December 22, 2019 22:55
bad instance trace
[class_instances] class-instance resolution trace
[class_instances] (0) ?x_0 : has_mul G := @ideal.has_mul ?x_1 ?x_2
failed is_def_eq
[class_instances] (0) ?x_0 : has_mul G := @submodule.has_mul ?x_3 ?x_4 ?x_5 ?x_6 ?x_7
failed is_def_eq
[class_instances] (0) ?x_0 : has_mul G := @matrix.has_mul ?x_8 ?x_9 ?x_10 ?x_11 ?x_12
failed is_def_eq
[class_instances] (0) ?x_0 : has_mul G := complex.has_mul
failed is_def_eq
[class_instances] (0) ?x_0 : has_mul G := snum.has_mul
@kbuzzard
kbuzzard / typeclass_trace.txt
Created December 4, 2019 16:41
Typeclass resolution going out of control
[class_instances] class-instance resolution trace
[class_instances] (0) ?x_0 : has_scalar k V := @continuous_linear_map.has_scalar ?x_1 ?x_2 ?x_3 ?x_4 ?x_5 ?x_6 ?x_7 ?x_8 ?x_9 ?x_10 ?x_11 ?x_12
failed is_def_eq
[class_instances] (0) ?x_0 : has_scalar k V := complex.has_scalar
failed is_def_eq
[class_instances] (0) ?x_0 : has_scalar k V := @algebra.comap.has_scalar ?x_13 ?x_14 ?x_15 ?x_16 ?x_17 ?x_18 ?x_19 ?x_20
failed is_def_eq
[class_instances] (0) ?x_0 : has_scalar k V := @algebra.has_scalar ?x_21 ?x_22 ?x_23 ?x_24 ?x_25
[class_instances] (1) ?x_23 : comm_ring k := @subalgebra.comm_ring ?x_26 ?x_27 ?x_28 ?x_29 ?x_30 ?x_31
failed is_def_eq
@kbuzzard
kbuzzard / with_top.conditionally_complete_lattice.lean
Created November 21, 2019 09:13
conditionally complete lattice structure on with_top(conditionally complete lattice)
import order.conditionally_complete_lattice
open lattice
open_locale classical
/- with_top -/
noncomputable instance with_top.conditionally_complete_lattice.has_Sup
{α : Type*} [conditionally_complete_lattice α] : has_Sup (with_top α) :=
@kbuzzard
kbuzzard / ereal.lean
Created November 17, 2019 08:03
$$[-\infty,\infty]$$ is acomplete lattice
import data.real.basic
/-- ereal : The set $$[-\infty,+\infty]$$ -/
def ereal := with_bot (with_top ℝ)
instance : linear_order ereal :=
by unfold ereal; apply_instance
instance : lattice.has_top ereal :=
by unfold ereal; apply_instance
instance : lattice.has_bot ereal :=
@kbuzzard
kbuzzard / two_adic_val_fact.lean
Created August 2, 2019 11:50
2-adic valuation of n! is < n if n isn't 0
import data.padics imo2019_4
instance two_prime : nat.prime 2 := by norm_num
lemma aux1 (n : ℕ) : padic_val_rat 2 (n + 1).fact = padic_val_rat 2 (n + 1) + padic_val_rat 2 n.fact :=
begin
rw (show (n + 1).fact = (n + 1) * n.fact, from rfl),
rw nat.cast_mul,
rw padic_val_rat.mul 2,
refl,
@kbuzzard
kbuzzard / imo2019q1.lean
Last active February 24, 2023 18:22
IMO 2019 Q1 solution formalised in Lean
-- this was compiling with mathlib in June 2020
import tactic
theorem imo2019Q1 (f : ℤ → ℤ) :
(∀ a b : ℤ, f (2 * a) + 2 * (f b) = f (f (a + b))) ↔
(∀ x, f x = 0) ∨ ∃ c, ∀ x, f x = 2 * x + c :=
begin
split, swap,
{ -- easy way: f(x)=0 and f(x)=2x+c work.
intro h,
open tactic
meta def copy_decl (d : declaration) : tactic unit :=
add_decl $ d.update_name $ d.to_name.update_prefix `kevin.interactive
@[reducible] meta def filter (d : declaration) : bool :=
d.to_name ∉ [`tactic.interactive.induction]
meta def copy_decls : tactic unit :=
do env ← get_env,
@kbuzzard
kbuzzard / perfectoid.txt
Created July 21, 2019 23:54
git grep on perfectoid project
lean-perfectoid-spaces/src$ git grep \^class\
Huber_ring/basic.lean:class Huber_ring (A : Type u) extends comm_ring A, topological_space A, topological_ring A :=
Tate_ring.lean:class Tate_ring (R : Type u) [Huber_ring R] : Prop :=
for_mathlib/linear_ordered_comm_group.lean:class linear_ordered_comm_monoid (α : Type*) extends comm_monoid α, linear_order α :=
for_mathlib/linear_ordered_comm_group.lean:class linear_ordered_comm_group (α : Type*) extends comm_group α, linear_ordered_comm_monoid α
for_mathlib/linear_ordered_comm_group.lean:class linear_ordered_comm_monoid.is_hom (f : α → β) extends is_monoid_hom f : Prop :=
for_mathlib/linear_ordered_comm_group.lean:class linear_ordered_comm_group.is_hom (f : α → β) extends is_group_hom f : Prop :=
for_mathlib/linear_ordered_comm_group.lean:class is_convex (S : set α) : Prop :=
for_mathlib/linear_ordered_comm_group.lean:class is_proper_convex (S : set α) extends is_convex S : Prop :=
for_mathlib/linear_ordered_comm_group.lean:class actual_ordered_comm_monoid (α :