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

より厳しい `guard_hyp` タクティク

Open
#1,448 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: Really strict guard_hyp

import Lean

elab "guard_hyp_strict" hyp:ident " : " val:term : tactic => withMainContext do
    let fvarid ← getFVarId hyp
    let lDecl ←
      match (← getLCtx).find? fvarid with
      | none => throwError m!"hypothesis {hyp} not found"
      | some lDecl => pure lDecl
    let e ← elabTerm val none
    let hty ← instantiateMVars lDecl.type
    unless e.equal hty do
      throwError m!"hypothesis {hyp} has type{indentExpr hty}\nnot{indentExpr e}"

example (h : ∃ k : Nat, k = k) : True := by
  guard_hyp_strict h : ∃ l : Nat, l = l -- I hoped this would have failed
  trivial

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 linked Zulip discussion and the guard_hyp_strict elaborator shown in the issue. Confirm the intended repository change and locate the relevant Lean example or tactic entry point, since no file or test is named. Done should establish the stricter type comparison behavior illustrated by the existential example and include a way to verify it.

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.