@@ -18,8 +18,16 @@ open Lean.Elab.Tactic.GuardMsgs.WhitespaceMode
18
18
#doc (Manual) "再帰の例(Recursion Example (for inclusion elsewhere))" =>
19
19
20
20
21
- :::example "Course-of-Values Tables"
21
+ :::comment
22
+ ::example "Course-of-Values Tables"
23
+ :::
24
+ ::::example "Course-of-Values Tables"
25
+ :::comment
22
26
This definition is equivalent to {name}`List.below`:
27
+ :::
28
+
29
+ 以下の定義は {name}`List.below` と同等です:
30
+
23
31
```lean
24
32
def List.below' {α : Type u} {motive : List α → Sort u} : List α → Sort (max 1 u)
25
33
| [] => PUnit
@@ -33,17 +41,32 @@ theorem List.below_eq_below' : @List.below = @List.below' := by
33
41
congr
34
42
```
35
43
36
- In other words, for a given {tech}[動機]motive, {lean}`List.below'` is a type that contains a realization of the motive for all suffixes of the list.
44
+ :::comment
45
+ In other words, for a given {tech}[motive], {lean}`List.below'` is a type that contains a realization of the motive for all suffixes of the list.
46
+
47
+ :::
48
+
49
+ 言い換えると、与えられた {tech}[動機] に対して、 {lean}`List.below'` はリストのすべての接尾辞に対する動機の実現を含む型です。
37
50
51
+ :::comment
38
52
More recursive arguments require further nested iterations of the product type.
39
53
For instance , binary trees have two recursive occurrences.
54
+ :::
55
+
56
+ より再帰的な引数は直積型の反復をさらに入れ子にする必要があります。例えば、二分木には2 つの再帰が出現します。
57
+
40
58
```lean
41
59
inductive Tree (α : Type u) : Type u where
42
60
| leaf
43
61
| branch (left : Tree α) (val : α) (right : Tree α)
44
62
```
45
63
64
+ :::comment
46
65
It's corresponding course-of-values table contains the realizations of the motive for all subtrees:
66
+ :::
67
+
68
+ 対応する累積テーブルにはすべてのサブツリーに対する動機の実現が含まれています:
69
+
47
70
```lean
48
71
def Tree.below' {α : Type u} {motive : Tree α → Sort u} : Tree α → Sort (max 1 u)
49
72
| .leaf => PUnit
@@ -60,12 +83,22 @@ theorem Tree.below_eq_below' : @Tree.below = @Tree.below' := by
60
83
congr
61
84
```
62
85
86
+ :::comment
63
87
For both lists and trees, the `brecOn` operator expects just a single case, rather than one per constructor.
64
88
This case accepts a list or tree along with a table of results for all smaller values; from this, it should satisfy the motive for the provided value.
65
89
Dependent case analysis of the provided value automatically refines the type of the memo table, providing everything needed.
66
90
91
+ :::
92
+
93
+ リストと木のどちらについても、`brecOn` 演算子はコンストラクタごとに1 つではなく、1 つのケースだけを想定しています。このエースはリストまたは木を、すべての小さい値に対する結果のテーブルと一緒に受け入れます;これにより、このケースは与えられた値に対する動機を満たすべきです。提供された値の依存ケース分析によって、メモテーブルの型が自動的に絞り込まれ、必要なものがすべて提供されます。
94
+
95
+ :::comment
67
96
The following definitions are equivalent to {name}`List.brecOn` and {name}`Tree.brecOn`, respectively.
68
97
The primitive recursive helpers {name}`List.brecOnTable` and {name}`Tree.brecOnTable` compute the course-of-values tables along with the final results, and the actual definitions of the `brecOn` operators simply project out the result.
98
+ :::
99
+
100
+ 以下の定義はそれぞれ {name}`List.brecOn` と {name}`Tree.brecOn` に同等です。プリミティブな再帰補助関数 {name}`List.brecOnTable` と {name}`Tree.brecOnTable` は最終結果と共に累積テーブルを計算し、実際の `brecOn` 演算子の定義は単に結果を射影します。
101
+
69
102
```lean
70
103
def List.brecOnTable {α : Type u}
71
104
{motive : List α → Sort u}
@@ -169,4 +202,4 @@ info: fun motive x z step =>
169
202
#reduce fun motive x z step => Tree.brecOn (motive := motive) (.branch (.branch .leaf x .leaf) z .leaf) step
170
203
```
171
204
172
- :::
205
+ ::::
0 commit comments