lean-ja / lean-ja/lean-by-example

ある項がインスタンスになるような型クラスをすべて列挙するコマンド

Open
#1,445 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

コード例 メタプログラミング
Dominant language
Lean
Stars
188
Forks
15
Avg merge
9h 8m
Merged PRs (30d)
6

Description

Zulip: > All instances satisfied by a type

elab "#list_instances" var:term : command => runTermElabM fun xs => do
  let vvar ← elabTerm var none
  let ce := classExtension.getState (← getEnv)
  let mut insts := #[]
  for (a, _) in ce.outParamMap do
    let const ← getConstInfo a
    match const.type with
    | .forallE _ (.sort _) (.sort _) _ =>
      let mut exp : Expr := default
      try
        exp ← mkAppM a #[vvar]
      catch _ => continue
      let some synthed ← synthInstance? exp | continue
      insts := insts.push (synthed, exp)
    | _ => pure ()
  let (_, sorted) := ((← insts.mapM fun e => return (← ppExpr e.2).pretty).zip insts).qsort (·.1 < ·.1) |>.unzip
  logInfo <| MessageData.joinSep (sorted.toList.map fun (synthed, expr) => m!"'{expr}' (via '{synthed}')") "\n"

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Zulip discussion linked in the issue and review the embedded #list_instances prototype. The issue does not identify a target file, tests, or an agreed command interface, so first determine where such commands belong and what behavior is expected. Done should include an implemented command and tests covering its instance enumeration and output.

Written by the indexing model from the issue text.

Assessment

Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.