Skip to content

Instantly share code, notes, and snippets.

View khoek's full-sized avatar

Keeley Hoek khoek

View GitHub Profile
@khoek
khoek / structure_helper.lean
Created July 4, 2019 16:17
`structure_helper` take 3
import data.string data.list.defs
import tactic.core
def {u v w} list.mfilter_map {m : Type u → Type v} [alternative m] [monad m] {α : Type w} {β : Type u} (f : α → m β) : list α → m (list β)
| [] := return []
| (h :: t) := do h' ← (f h >>= λ v, pure $ list.cons v []) <|> pure [],
t' ← list.mfilter_map t,
return (h' ++ t')
namespace tactic
@khoek
khoek / structure_helper.lean
Created July 4, 2019 11:16
`structure_helper` tactic
import data.string
import tactic.core
namespace tactic
private meta def attempt_instance_build (n : name) (ns : list name) : tactic unit :=
do sorries ← ns.mmap $ λ _, to_pexpr <$> mk_sorry,
let s : structure_instance_info := {
struct := some n,
field_names := ns,
@khoek
khoek / comm_semigroup.lean
Last active April 17, 2019 07:31
`comm_semigroup` tactic
open tactic
namespace tactic
meta inductive semigroup_expr
| atom (e : expr)
| mul (l r : semigroup_expr)
namespace semigroup_expr
@khoek
khoek / rassoc.lean
Last active April 17, 2019 00:56
Semigroup Reassociator Tactic
open tactic
namespace tactic
meta inductive semigroup_expr
| atom (e : expr)
| mul (l r : semigroup_expr)
namespace semigroup_expr
meta def eval : semigroup_expr → tactic expr