lean-ja / lean-ja/lean-by-example
`macro` と `macro_rules` の使用例: MILの min max 問題を解くタクティクを自作する
Open
Nobody has claimed this yet.
メタプログラミング
メモ
宣言的コマンド
- Dominant language
- Lean
- Stars
- 188
- Forks
- 15
- Avg merge
- 9h 8m
- Merged PRs (30d)
- 6
Description
import Mathlib.Data.Real.Basic
import Mathlib.Tactic
section
variable (a b c d : ℝ)
open Lean Parser Elab Tactic
syntax "super_split" : tactic
macro_rules | `(tactic| super_split) => `(tactic| repeat split <;> super_split)
macro "minimax" : tactic =>
`(tactic| with_reducible
repeat rw [min_def _ _]
repeat rw [max_def _ _]
super_split
all_goals linarith)
example : min a b = min b a := by
minimax
example : max a b = max b a := by
minimax
example : min (min a b) c = min a (min b c) := by
minimax
example : max (max a b) c = max a (max b c) := by
minimax
Contributor guide
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
No target file or test is named. Start by reviewing the repository's existing code-example structure and the Lean snippet in this issue, then determine where an example for macro and macro_rules belongs. Done means the example is integrated in the appropriate documentation location and can be checked successfully.
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
- Needs clarification
- Newbie friendliness
- 35/100