Skip to content

Commit

Permalink
convert 追加
Browse files Browse the repository at this point in the history
  • Loading branch information
Seasawher committed Sep 24, 2023
1 parent cc3c8fe commit 3267506
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Examples/Convert.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Mathlib.Tactic.Convert

variable (a b c: Nat)


-- ANCHOR: first
example (f : Nat → Nat) (h : f (a + b) = 0) (hc: a + b = c) : f (c) = 0 := by
-- `h` はゴールと等しくないので失敗する
try exact [h]

-- `h` とゴールの差分を新たなゴールにする
convert h

-- ゴールが `⊢ c = a + b` に変わっている
show c = a + b

rw [hc]
-- ANCHOR_END: first
1 change: 1 addition & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- [constructor: 論理積∧を示す](./constructor.md)
- [contradiction: 矛盾](./contradiction.md)
- [conv: 変換モードに入る](./conv.md)
- [convert: 惜しい補題を使う](./convert.md)
- [done: 証明終了を宣言](./done.md)
- [exact: 証明を直接構成](./exact.md)
- [exists: 存在∃を示す](./exists.md)
Expand Down
9 changes: 9 additions & 0 deletions src/convert.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# convert

needs: `import Mathlib.Tactic.Convert`

ローカルコンテキストに現在のゴールに近いけれども等しくはない `h` があるとき,`exact h` としても失敗します.しかし `convert h` は成功する可能性があり,成功した場合は `h` とゴールの差分を新たなゴールとします.

```lean
{{#include ../Examples/Convert.lean:first}}
```

0 comments on commit 3267506

Please sign in to comment.