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

`macro` と `macro_rules` の使用例: MILの min max 問題を解くタクティクを自作する

Open
#425 1 comment 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

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

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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.