Skip to content

Instantly share code, notes, and snippets.

View PatrickMassot's full-sized avatar

Patrick Massot PatrickMassot

View GitHub Profile
@PatrickMassot
PatrickMassot / simplicial_set.lean
Created May 28, 2018 14:56
Johan's simplicial set cleanup
import order.basic .simplex_category data.finset data.finsupp algebra.group
local notation ` [`n`] ` := fin (n+1)
/-- Simplicial set -/
class simplicial_set :=
(objs : Π n : ℕ, Type*)
(maps {m n : ℕ} {f : [m] → [n]} (hf : monotone f) : objs n → objs m)
(comp {l m n : ℕ} {f : [l] → [m]} {g : [m] → [n]} (hf : monotone f) (hg : monotone g) :
(maps hf) ∘ (maps hg) = (maps (monotone_comp hf hg)))
@PatrickMassot
PatrickMassot / subtypes.lean
Created July 19, 2018 09:55
refine_struct for subtypes
import algebra.ring
import group_theory.submonoid
import tactic.interactive
namespace tactic
open tactic.interactive
meta def derive_field_subtype : tactic unit :=
do b ← target >>= is_prop,
@PatrickMassot
PatrickMassot / extends_product.lean
Created April 27, 2018 08:45
Class extension example
/- The goal of this file is to explain why it's important that using extends in
command `class foo extends bar` creates a `foo.to_bar` function with an
instance implicit parameter.
We will define magmas with law denoted by ◆ and a commutative version.
Then we want products of such things. The goal is to reuse the work on product
magmas when defining product commutative magmas, and do so in a completely
transparent way. -/
-- Defining magmas with some notation is already covered in TPIL
@PatrickMassot
PatrickMassot / quotient_top_grop.lean
Last active October 4, 2018 07:06
Quotient additive commutative topological group
import analysis.topology.topological_structures
import group_theory.quotient_group
open function set
variables {α : Type*} [topological_space α] {β : Type*} [topological_space β]
variables {γ : Type*} [topological_space γ] {δ : Type*} [topological_space δ]
def is_open_map (f : α → β) := ∀ U : set α, is_open U → is_open (f '' U)
/-
This file defines the I-adic topology on a commutative ring R with ideal I.
The ring is wrapped in `adic_ring I := R`, which then receive all relevant type classes.
The end-product is `instance : topological_ring (adic_ring I)`.
-/
import tactic.ring
import data.pnat
import ring_theory.ideal_operations
@PatrickMassot
PatrickMassot / tasks.py
Last active January 25, 2019 10:25
Debian package builder for Lean
import tempfile
from pathlib import Path
from invoke import task
LEAN_CONTROL="""Package: lean
Version: {}
Section: math
Priority: optional
Architecture: amd64
Depends: git (>= 1.2)
@PatrickMassot
PatrickMassot / pratt.lean
Created January 25, 2019 09:42
Logic puzzle from John P. Pratt in Lean (starts at line 38)
import tactic.interactive
import tactic.linarith
@[derive decidable_eq]
inductive people : Type | Brown | Jones | Smith
constant only_child : people → Prop
constant salary : people → ℕ
@[derive decidable_eq]
@PatrickMassot
PatrickMassot / push_neg.lean
Last active March 25, 2019 23:11
A tactic pushing negations inwards while keeping names
import tactic.interactive
import algebra.order
open tactic expr
namespace push_neg
section
@PatrickMassot
PatrickMassot / apply_fun.lean
Created July 4, 2019 12:35
`apply_fun` tactic
import order.basic
open tactic interactive (parse) interactive (loc.ns)
interactive.types (texpr location) lean.parser (tk)
local postfix `?`:9001 := optional
meta def apply_fun_name (e : expr) (h : name) (M : option pexpr) : tactic unit :=
do {
H ← get_local h,
@PatrickMassot
PatrickMassot / doc_blame.lean
Last active July 11, 2019 12:50
find definitions without docstring
import tactic.interactive
open tactic declaration environment
/-- test that name was not auto-generated -/
@[reducible] def name.is_not_auto (n : name) : Prop :=
n.components.ilast ∉ [`no_confusion, `rec_on, `cases_on, `no_confusion_type, `sizeof,
`rec, `mk, `sizeof_spec, `inj_arrow, `has_sizeof_inst, `inj_eq, `inj]
/-- Print the declaration name if it's a definition without a docstring -/