leanprover / leanprover/lean4

RFC: reusing goals

Open
#8,844 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

P-low RFC
Dominant language
Lean
Stars
9.2k
Forks
990
Avg merge
1d 17h
Merged PRs (30d)
175

Description

Proposal

The tactic refine (among other tactics) can create many goals, and sometimes it might be useful to use the result of a previous goal. It is currently possible to do this using a named metavariable, i.e. ?a, in the following example:

def foo₁ : Prop := sorry
def foo₂ : Prop := sorry
theorem foo : foo₁ → foo₂ := sorry
theorem bar : foo₁ → foo₂ → false := sorry

example (h : foo₁) : false := by
  refine bar ?a ?_
  · exact h
  · exact (foo ?a)

The goals created are foo₁ and foo₂, and for the proof of foo₂, one needs to reuse the previous proof of foo₁, which is where ?a comes in.

In the linked Zulip thread below, it has been expressed that ?a is a bit "unhygenic", so this proposal is to request a more hygenic version of ?a.

Community Feedback

Zulip discussion: #Is there code for X? > reuse previous goals?

Impact

Add 👍 to issues you consider important. If others benefit from the changes in this proposal being added, please ask them to add 👍 to it.

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 issue’s refine example using the named metavariable ?a. Investigate how goals and metavariables are represented in Lean’s tactic system; done means agreeing on and implementing a hygienic mechanism for reusing an earlier goal, with tests covering the demonstrated pattern.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.