Skip to content

Instantly share code, notes, and snippets.

View Qiu233's full-sized avatar
🏡
Looking for work

Qiu Qiu233

🏡
Looking for work
View GitHub Profile
@Qiu233
Qiu233 / Partition.lean
Created March 15, 2024 17:04
Summation of cardinal of uniform partitions of finite type in Lean4.
import Mathlib
/-
The `Partition α` is a `partitions : Set (Set α)` such that:
* `⋃₀ partitions = Set.univ`,
* every distinct pair `A B ∈ partitions` are disjoint.
A `Partition α` is called **uniform** if all of its `S ∈ partitions` have the same cardinal.
Existence of `Fin n ≃ α ` equivalently means `Nat.card α = n`, for any finite type `α`.
@Qiu233
Qiu233 / SymmGroup.lean
Created March 14, 2024 21:07
Symmetric Group representation with macro for Lean4.
import Mathlib
theorem Equiv.comp_of_invFun [Nonempty α] [Nonempty β] (f : α ≃ β) (g : β ≃ γ) :
f.invFun ∘ g.invFun = (g ∘ f).invFun := by
ext t
unfold Function.invFun
if h : ∃ x, (g ∘ f) x = t
then
rw [dif_pos h]
apply (Function.Injective.comp g.injective f.injective ·)
@Qiu233
Qiu233 / LamTerm.lean
Created March 14, 2024 21:02
Simple lambda calculus representation with macro for Lean4.
import Lean
inductive LamTerm where
| var (n : Nat)
| app (M N : LamTerm)
| abs (M : LamTerm)
instance : ToString LamTerm where
toString :=
let rec f := fun t =>
@Qiu233
Qiu233 / ListComprehension.lean
Last active March 14, 2024 20:45
Simple list comprehension for Lean4, featuring `map` and variable `filter`.
import Lean
open Lean Parser.Term
local instance : Monad List where
pure x := [x]
bind la alb := la.map alb |>.join
local instance : Alternative List where
failure := []