Skip to content

Instantly share code, notes, and snippets.

@0art0
0art0 / group.lean
Created June 27, 2021 14:09
Alternative axioms of a group in LEAN
-- The First-order theory of groups
constant G : Type -- the group
constant m : G × G → G -- the multiplication symbol
notation a `*` b := m (a, b)
-- the group axioms
axiom non_empty : ∃ (g : G), true
axiom mul_assoc : ∀ (a b c : G), m (m (a, b), c) = m (a, m (b, c))
@0art0
0art0 / proof_finding.lean
Created October 10, 2021 08:37
A LEAN3 tactic to recursively construct a term of the target type using terms in the local context.
import tactic
open tactic
/-
Searches for a term `e` in the input list `vars` with type matching `tgt`.
-/
meta def find_term_tgt (tgt : expr) (vars : list expr) : tactic expr :=
vars.mfirst (λ e,
do
@0art0
0art0 / TowersOfHanoi.lean
Created February 2, 2022 18:22
An interactive Towers of Hanoi game in Lean4's tactic mode
/-
An exhaustive description of all possible moves in the game.
Moves of the form `move__nil` are to towers that are empty, while moves of the form
`move__cons` are to towers having at least one disc. The condition of the larger discs being below the
smaller ones is enforced in the latter case.
-/
inductive TowersOfHanoi (n : Nat) : List Nat → List Nat → List Nat → Type _
| move₁₂nil {a : Nat} {as cs : List Nat} :
@0art0
0art0 / findProof.lean
Last active June 6, 2022 17:03
`findProof` search tactic in Lean4
import Lean
import Lean.Elab
import Lean.Elab.Tactic
import Lean.Meta
open Lean Expr Elab Meta Tactic
set_option pp.proofs true
set_option pp.proofs.withType true
/-
import Aesop
abbrev ℕ := Nat
@[aesop norm unfold]
def InfNat := {f : ℕ → Bool // ∀ n, f n.succ → f n}
namespace InfNat
notation "ℕ∞" => InfNat
@0art0
0art0 / SymbolicAlgebra.lean
Created April 5, 2023 15:43
Unverified symbolic calculations in Lean4 using PARI/GP
import Lean
open Lean Elab Term Meta Tactic
declare_syntax_cat arith
syntax str : arith
syntax ident : arith
syntax num : arith
syntax arith "+" arith : arith
syntax arith "-" arith : arith