leanprover-community / leanprover-community/lean4-metaprogramming-book
Tactic chapter/FAQ: add creation of a fresh unique name
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 310
- Forks
- 78
- Avg merge
- 5h 37m
- Merged PRs (30d)
- 5
Description
Proposal:
Add the following q&a to the FAQ:
Q: How do I create a fresh unique name?
A: Use Lean.Core.mkFreshUserName <name-basis>.
This creates a new (unused) inaccessible name based on name-basis.
elab " faq_fresh_hyp_name " : tactic =>
Lean.Elab.Tactic.withMainContext do
-- create fresh name based on name `h`
let h := Lean.mkIdent (← Lean.Core.mkFreshUserName `h)
-- create new hypothesis with this fresh name
Lean.Elab.Tactic.evalTactic (← `(tactic| have $h : 1 + 1 = 2 := by simp))
-- use hypothesis
Lean.Elab.Tactic.evalTactic (← `(tactic| rewrite [$h:ident]))
-- remove hypothesis
Lean.Elab.Tactic.evalTactic (← `(tactic| clear $h))
example : 1 + 1 = 2 := by
faq_fresh_hyp_name
rfl
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the tactic chapter/FAQ and read the surrounding entries to match its formatting and organization. Add the proposed question, answer, and Lean example, then verify that the FAQ explains fresh unique names and that the example demonstrates creating, using, and clearing the hypothesis.
Written by the indexing model from the issue text.
Assessment
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100