Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rfl の説明の修正 #8

Merged
merged 1 commit into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Examples.lean
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import Examples.LeftRight
import Examples.Linarith
import Examples.Refine
import Examples.Rel
import Examples.Rfl
import Examples.Rfl.Refl
import Examples.Rfl.Rfl
import Examples.Ring
import Examples.Rw
import Examples.Show
Expand Down
2 changes: 1 addition & 1 deletion Examples/Rfl.lean → Examples/Rfl/Refl.lean
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ example : 1 + 1 = 2 := by rfl
-- 変数を含む等式
example (x : Nat) : x = x := by rfl

example (P : Prop) : P = P := by rfl
example (P : Prop) : P = P := by rfl
18 changes: 18 additions & 0 deletions Examples/Rfl/Rfl.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Mathlib.Tactic.Relation.Rfl

-- `n ≤ n` を示すために必要
import Mathlib.Data.Nat.Basic

-- ANCHOR: first
inductive MyEq {α : Type u} : α → α → Prop
| refl (a : α) : MyEq a a

attribute [refl] MyEq.refl

example (n : ℕ) : MyEq n n := by rfl
-- ANCHOR_END: first

-- ANCHOR: nat
-- `import Mathlib.Data.Nat.Basic` が必要
example (n : Nat) : n ≤ n := by rfl
-- ANCHOR_END: nat
2 changes: 1 addition & 1 deletion src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
- [push_neg: ドモルガン](./push_neg.md)
- [refine: プレースホルダを使う](./refine.md)
- [rel: 不等式を使う](./rel.md)
- [rfl: 定義そのまま](./rfl.md)
- [rfl: 関係の反射性を示す](./rfl.md)
- [ring: 環の等式を示す](./ring.md)
- [rw: 同値変形](./rw.md)
- [show: 示すべきことを宣言](./show.md)
Expand Down
29 changes: 26 additions & 3 deletions src/rfl.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
# rfl

needs: `import Mathlib.Tactic.Relation.Rfl`

named after: 反射律(reflexivity)

`rfl` は,定義から等しいものが等しいことを示すタクティクです.
`rfl` は,`refl attribute` の付けられた定理を用いて関係の反射性を示すタクティクです.

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

`@[refl]` で登録された定理を用いるので,追加でライブラリを import することにより示すことができる命題が増えます.

```lean
{{#include ../Examples/Rfl/Rfl.lean:nat}}
```

## 補足

実は `Mathlib.Tactic.Relation.Rfl` を import するかどうかにより,内部で呼び出されるタクティクが変わります.

* `Mathlib.Tactic.Relation.Rfl` ありなら [Lean.MVarId.rfl](https://leanprover-community.github.io/mathlib4_docs//Mathlib/Tactic/Relation/Rfl.html#Lean.MVarId.rfl) が,
* なしなら [Lean.MVarId.refl](https://leanprover-community.github.io/mathlib4_docs//Lean/Meta/Tactic/Refl.html#Lean.MVarId.refl) が

それぞれ参照されます.後者は `@[refl]` が付けられた一般の関係の反射性にアクセスできず,等号 `=` の反射性しか使うことができません.

後者の場合 `rfl` は,単に定義から等しいものが等しいことを示すタクティクになります.

```lean
{{#include ../Examples/Rfl.lean}}
```
{{#include ../Examples/Rfl/Refl.lean}}
```