This repository has been archived by the owner on Nov 29, 2024. It is now read-only.
generated from Seasawher/lean-book
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/- | ||
# variable | ||
`variable` は,定理や関数の引数を宣言するための構文です. | ||
たとえば以下の関数と命題に対して,引数の `α : Type` と `l : List α` は共通です. | ||
-/ | ||
namespace variable0 --# | ||
|
||
/-- 連結リストの最後の要素を取り出す -/ | ||
def last? {α : Type} (l : List α) : Option α := | ||
match l with | ||
| [] => none | ||
| [a] => some a | ||
| _ :: xs => last? xs | ||
|
||
theorem nng_list_length {α : Type} (l : List α) : l.length >= 0 := by simp | ||
|
||
end variable0 --# | ||
|
||
/- `variable` コマンドを利用すると,共通の引数を宣言してまとめておくことができます.-/ | ||
namespace variable1 --# | ||
|
||
variable {α : Type} (l : List α) | ||
|
||
/-- 連結リストの最後の要素を取り出す -/ | ||
def last? (l : List α) : Option α := | ||
match l with | ||
| [] => none | ||
| [a] => some a | ||
| _ :: xs =>last? xs | ||
|
||
theorem nng_list_length : l.length >= 0 := by simp | ||
|
||
/- 上記の2つの例で引数の `l : List α` を省略できるかどうかに違いがありますが,これは返り値の型に現れているかどうかに依ります. -/ | ||
|
||
end variable1 --# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters