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

`grw` を紹介する

Open
#1,817 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

grw は、Mathlib.Tactic.rwSeq に定義されている戦術で、rw に似ていますが、= 以外の関係(relation)でも書き換えができる点が異なります。

たとえば次のように使えます:

example (h₁ : a < b) (h₂ : b ≤ c) : a + d ≤ c + d := by
  grw [h₁, h₂]

この例では、< といった関係をまたいで、grw が書き換えを行っています。

他にも:

example (h : a ≡ b [ZMOD n]) : a ^ 2 ≡ b ^ 2 [ZMOD n] := by
  grw [h]

ここでは合同式()に対して書き換えています。

example : (h₁ : a ∣ b) (h₂ : c ∣ a * d) : a ∣ b * d := by
  grw [h₁]
  exact h₂

約数関係()に対する書き換えも grw で可能です。

注意点

grw を使うには、関係に対応する補題(lemmas)が @[gcongr] という属性でタグ付けされている必要があります。また、関係が推移的(transitive)である必要がある場合には、IsTrans インスタンスを用意することでそれに対応できます。

要するに、grw は「等式だけでなく、いろんな関係に対して rw 的な書き換えを可能にする戦術」です。

-- ChatGPT で生成

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 grw tactic described as Mathlib.Tactic.rwSeq, and review the supplied examples for relations such as <, , congruence, and divisibility. Check where tactic introductions are organized in the repository, then add a Japanese explanation covering the examples, @[gcongr] lemmas, and the IsTrans requirement.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.