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

本当に構文的に等しい `a = a` という等式しか証明しない `rfl` の派生タクティク

Open
#845 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: strict refl

import Lean

open Lean Elab Tactic

elab "real_rfl" : tactic => do
  let some (_a, lhs, rhs) := (← getMainTarget).eq? | throwError "Not an equality goal"
  if lhs == rhs then
    evalTactic (← `(tactic| rfl))
  else
    logWarning "Not a 'real' equality"

/-- error: Not an equality goal -/
#guard_msgs in
  example : True := by
    real_rfl

/--
warning: Not a 'real' equality
-/
#guard_msgs in
  example : 2 = 1 + 1 := by
    real_rfl
    rfl

example : 2 = 2 := by
  real_rfl

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 from the Lean elaborator snippet in the issue, especially getMainTarget, eq?, and evalTactic. Check how tactics and example checks are organized in the repository, then add the derived tactic so the shown #guard_msgs cases warn or fail as specified while the syntactically identical equality succeeds.

Written by the indexing model from the issue text.

Assessment

Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.