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

`simp [*] at ..` は条件付きの書き換えが(部分的に)できる

Open
#2,201 0 comments 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

/-- 整数をイメージした何か -/
opaque MyInt : Type

variable [LE MyInt] [Zero MyInt]

/-- `x ≤ 0` という前提の下では `0 ≤ x` と `x = 0` は同値 -/
@[simp]
axiom MyInt.le_zero_implies {x : MyInt} (le : x ≤ 0) : 0 ≤ x ↔ x = 0

example (x : MyInt) (le : x ≤ 0) (ge : 0 ≤ x) : x = 0 := by
  -- `simp at *` は「前提条件を満たしたときの書き換え」ができない
  fail_if_success simp at *

  -- discharger の指定が必要
  simp (disch := assumption) at *
  assumption

example (x : MyInt) (le : x ≤ 0) (ge : 0 ≤ x) : x = 0 := by
  -- `simp_all` はローカルコンテキストを自動で引数に拾ってくれる
  simp_all only [MyInt.le_zero_implies]

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

The issue provides Lean examples using simp at *, simp (disch := assumption) at *, and simp_all, but names no repository file or test. First locate the relevant example or documentation entry, then clarify the intended explanation of conditional rewriting and verify that the documented examples accurately show the expected behavior.

Written by the indexing model from the issue text.

Assessment

Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.