@@ -67,7 +67,7 @@ Operators pop up all the time, and mathematicians have agreed
67
67
on names for some of the most common properties.
68
68
{:/}
69
69
70
- 运算符总是到处出现,而数学家们已经统一了一些最常见的性质的名称 。
70
+ 运算符随处可见,而数学家们统一了一些最常见的性质的名称 。
71
71
72
72
{::comment}
73
73
* _ Identity_ . Operator ` + ` has left identity ` 0 ` if ` 0 + n ≡ n ` , and
@@ -88,17 +88,17 @@ on names for some of the most common properties.
88
88
` p ` , and ` q ` .
89
89
{:/}
90
90
91
- * ** 幺元(Identity)** 。 对于所有的 ` n ` ,若 ` 0 + n ≡ n ` ,则 ` + ` 有左幺元 ` 0 ` ;
91
+ * ** 幺元(Identity)** : 对于所有的 ` n ` ,若 ` 0 + n ≡ n ` ,则 ` + ` 有左幺元 ` 0 ` ;
92
92
若 ` n + 0 ≡ n ` ,则 ` + ` 有右幺元 ` 0 ` 。同时为左幺元和右幺元的值称简称幺元。
93
93
幺元有时也称作** 单位元(Unit)** 。
94
94
95
- * ** 结合律(Associativity)** 。 若括号的位置无关紧要,则称运算符 ` + ` 满足结合律,
95
+ * ** 结合律(Associativity)** : 若括号的位置无关紧要,则称运算符 ` + ` 满足结合律,
96
96
即对于所有的 ` m ` 、` n ` 和 ` p ` ,有 ` (m + n) + p ≡ m + (n + p) ` 。
97
97
98
- * ** 交换律(Commutativity)** 。 若参数的顺序无关紧要,则称运算符 ` + ` 满足交换律,
98
+ * ** 交换律(Commutativity)** : 若参数的顺序无关紧要,则称运算符 ` + ` 满足交换律,
99
99
即对于所有的 ` m ` 和 ` n ` ,有 ` m + n ≡ n + m ` 。
100
100
101
- * ** 分配律(Distributivity)** 。 对于所有的 ` m ` 、` n ` 和 ` p ` ,若
101
+ * ** 分配律(Distributivity)** : 对于所有的 ` m ` 、` n ` 和 ` p ` ,若
102
102
` (m + n) * p ≡ (m * p) + (n * p) ` ,则运算符 ` * ` 对运算符 ` + ` 满足左分配律;
103
103
对于所有的 ` m ` 、` n ` 和 ` p ` ,若 ` m * (p + q) ≡ (m * p) + (m * q) ` ,则满足右分配律。
104
104
@@ -130,7 +130,7 @@ out these properties---or their lack---for instance by pointing out
130
130
that a newly introduced operator is associative but not commutative.
131
131
{:/}
132
132
133
- 正经来说,如果你在阅读技术论文时遇到了一个运算符,那么你可以考察它是否拥有一个幺元 ,
133
+ 正经来说,如果你在阅读技术论文时遇到了一个运算符,那么你可以考察它是否拥有幺元 ,
134
134
是否满足结合律或分配律,或者是否对另一个运算符满足分配律,这能为你提供一种视角。
135
135
细心的作者通常会指出它们是否满足这些性质,比如说指明一个新引入的运算符满足结合律
136
136
但不满足交换律。
@@ -165,9 +165,15 @@ associative but is not commutative.
165
165
166
166
请给出一个运算符的例子,它拥有幺元、满足结合律但不满足交换律。
167
167
168
+ {::comment}
168
169
```
169
170
-- Your code goes here
170
171
```
172
+ {:/}
173
+
174
+ ```
175
+ -- 请将代码写在此处。
176
+ ```
171
177
172
178
173
179
{::comment}
@@ -196,7 +202,7 @@ We can test the proposition by choosing specific numbers for the three
196
202
variables:
197
203
{:/}
198
204
199
- 我们可以为这三个变量选取特定的数值来测试此命题 :
205
+ 我们可以为这三个变量选取特定的数值来验证此命题 :
200
206
201
207
```
202
208
_ : (3 + 4) + 5 ≡ 3 + (4 + 5)
@@ -221,7 +227,7 @@ until one reaches the simplest term (in this case, `12`), and
221
227
then from the bottom up until one reaches the same term.
222
228
{:/}
223
229
224
- 在这里,我们将计算过程写成了等式链,一行一个式子 。这样的等式链通常非常易读,
230
+ 在这里,我们将计算过程写成了等式链,每行一个式子 。这样的等式链通常非常易读,
225
231
你可以从上到下,直到遇到最简形式(本例中为 ` 12 ` ),也可以从下到上,直到回到同样的式子。
226
232
227
233
{::comment}
@@ -234,15 +240,15 @@ sure that associativity holds for _all_ the natural numbers?
234
240
{:/}
235
241
236
242
该测试揭示了结合律可能没有它初看起来那么显然。为什么 ` 7 + 5 ` 与 ` 3 + 9 ` 相同?
237
- 我们可能需要收集更多证据,选择其它的数值来测试此命题 。但由于自然数是无限的,
243
+ 我们可能需要收集更多证据,选择其它的数值来验证此命题 。但由于自然数是无限的,
238
244
因此测试永远无法完成。那么我们还有其它可以确保结合律对于** 所有** 自然数都成立的方法吗?
239
245
240
246
{::comment}
241
247
The answer is yes! We can prove a property holds for all naturals using
242
248
_ proof by induction_ .
243
249
{:/}
244
250
245
- 答案是肯定的 !我们可以用** 归纳证明(Proof by Induction)**
251
+ 当然有 !我们可以用** 归纳证明(Proof by Induction)**
246
252
来确保某个性质对于所有的自然数都成立。
247
253
248
254
@@ -271,16 +277,16 @@ then show that the property must also hold for `suc m`.
271
277
{:/}
272
278
273
279
归纳证明遵循此定义的结构。要通过归纳证明自然数的某个性质,我们需要两个步骤。
274
- 其一是** 起始步骤** ,我们需要证明此性质对 ` zero ` 成立。其二是** 归纳步骤** ,
275
- 我们假设此性质对一个任意自然数 ` m ` 成立(我们称之为** 归纳假设(Induction
280
+ 其一是** 起始步骤** ,即需要证明此性质对 ` zero ` 成立。其二是** 归纳步骤** ,
281
+ 即假设此性质对一个任意自然数 ` m ` 成立(我们称之为** 归纳假设(Induction
276
282
Hypothesis)** ),然后证明该性质对 ` suc m ` 必定成立。
277
283
278
284
{::comment}
279
285
If we write ` P m ` for a property of ` m ` , then what we need to
280
286
demonstrate are the following two inference rules:
281
287
{:/}
282
288
283
- 若我们将 ` m ` 的某种性质(Property)写作 ` P m ` ,那么我们需要证明的就是以下两个推导规则:
289
+ 若将 ` m ` 的某种性质(Property)写作 ` P m ` ,那么我们需要证明的就是以下两个推导规则:
284
290
285
291
------
286
292
P zero
@@ -297,7 +303,7 @@ inductive hypothesis---namely that `P` holds for `m`---then it follows that
297
303
` P ` also holds for ` suc m ` .
298
304
{:/}
299
305
300
- 我们来分析一下这些规则 。第一条规则是起始步骤,它需要我们证明性质 ` P ` 对 ` zero `
306
+ 先来分析一下这些规则 。第一条规则是起始步骤,它需要我们证明性质 ` P ` 对 ` zero `
301
307
成立。第二条规则是归纳步骤,它需要我们证明若归纳假设「` P ` 对 ` m ` 成立」,
302
308
那么 ` P ` 也对 ` suc m ` 成立。
303
309
@@ -306,8 +312,7 @@ Why does this work? Again, it can be explained by a creation story.
306
312
To start with, we know no properties:
307
313
{:/}
308
314
309
- 为什么它能够起作用?同样,它也可以用创世故事来讲解。在最开始,我们对性质一无所知:
310
-
315
+ 为什么可以这样做呢?它也可以用创世故事来讲解。起初,我们对性质一无所知:
311
316
312
317
{::comment}
313
318
-- In the beginning, no properties are known.
@@ -325,8 +330,8 @@ apply:
325
330
{:/}
326
331
327
332
现在我们对所有已知的性质应用上述两条规则。起始步骤告诉我们 ` P zero ` 成立,
328
- 所以我们将它加入已知的性质集合中。归纳步骤告诉我们若(在昨天) ` P m ` 成立,
329
- 那么(在今天) ` P (suc m) ` 也成立。我们在今天之前并不知道任何性质,
333
+ 所以我们将它加入已知的性质集合中。归纳步骤告诉我们若「昨天的」 ` P m ` 成立,
334
+ 那么「今天的」 ` P (suc m) ` 也成立。我们在今天之前并不知道任何性质,
330
335
因此归纳步骤在这里不适用:
331
336
332
337
{::comment}
@@ -347,7 +352,7 @@ held yesterday, then `P (suc zero)` holds today:
347
352
348
353
然后我们重复此过程。在接下来的一天我们知道今天之前的所有性质,
349
354
以及任何通过此规则添加的性质。起始步骤告诉我们 ` P zero `
350
- 成立,当然我们已经知道这件事了 。而如今归纳步骤告诉我们,由于 ` P zero `
355
+ 成立,我们已经知道这件事了 。而如今归纳步骤告诉我们,由于 ` P zero `
351
356
在昨天成立,那么 ` P (suc zero) ` 今天也成立。
352
357
353
358
{::comment}
@@ -450,7 +455,7 @@ If we can demonstrate both of these, then associativity of addition
450
455
follows by induction.
451
456
{:/}
452
457
453
- 如果我们可以证明这两条规则,那么加法结合律就可根据归纳法来证明 。
458
+ 如果我们可以证明这两条规则,那么加法结合律就可以用归纳法来证明 。
454
459
455
460
{::comment}
456
461
Here is the proposition's statement and proof:
@@ -487,7 +492,7 @@ We have named the proof `+-assoc`. In Agda, identifiers can consist of
487
492
any sequence of characters not including spaces or the characters ` @.(){};_ ` .
488
493
{:/}
489
494
490
- 我们将此证明命名为 ` +-assoc ` 。在 Agda 中,标识符可以由除空格或 ` @.(){};_ `
495
+ 我们将此证明命名为 ` +-assoc ` 。在 Agda 中,标识符可以由除空格和 ` @.(){};_ `
491
496
之外的任何字符序列构成。
492
497
493
498
{::comment}
@@ -537,7 +542,7 @@ be shown, and reading down from the top and up from the bottom takes us to
537
542
{:/}
538
543
539
544
此式平凡成立。阅读此证明中起始步骤中的等式链,其最初和最末的式子分别匹配待证等式的两边,
540
- 从上到下或从下到上读都会让我们在中间遇到 ` n + p ` 。此步骤除了化简外不需要其他额外的解释 。
545
+ 从上到下或从下到上读都会让我们在中间遇到 ` n + p ` 。此步骤无需多言,化简即可 。
541
546
542
547
{::comment}
543
548
For the inductive case, we must show:
@@ -577,9 +582,9 @@ within angle brackets. The justification given is:
577
582
{:/}
578
583
579
584
阅读此证明中归纳步骤的等式链,其最初和最末的式子分别匹配待证等式的两边,
580
- 从上到下或从下到上读都会让我们到达上面化简等式的地方。剩下的等式 ,
581
- 不止用化简就行,因此我们需要为推理链使用一个附加的运算符 ` _≡⟨_⟩_ ` ,
582
- 为等式给出的依据会放在尖括号中 。这里给出的依据是:
585
+ 从上到下或从下到上读都会让我们到达上面化简等式的地方。剩下的等式单化简还不行 ,
586
+ 我们还需要为推理链使用一个附加的运算符 ` _≡⟨_⟩_ ` ,
587
+ 并将等式的依据放在尖括号中 。这里给出的依据是:
583
588
584
589
⟨ cong suc (+-assoc m n p) ⟩
585
590
@@ -598,8 +603,8 @@ preserved by applying that function. If `e` is evidence that `x ≡ y`,
598
603
then ` cong f e ` is evidence that ` f x ≡ f y ` , for any function ` f ` .
599
604
{:/}
600
605
601
- 若某个关系在应用给定函数后仍然保持不变 ,则称该关系满足** 合同性(Congruence)** 。
602
- 若 ` e ` 是 ` x ≡ y ` 的证据,那么对于任意函数 ` f ` ,` cong f e ` 是 ` f x ≡ f y ` 的证据。
606
+ 若某个关系在应用了给定的函数后仍然保持不变 ,则称该关系满足** 合同性(Congruence)** 。
607
+ 若 ` e ` 是 ` x ≡ y ` 的证据,那么对于任意函数 ` f ` ,` cong f e ` 就是 ` f x ≡ f y ` 的证据。
603
608
604
609
{::comment}
605
610
Here the inductive hypothesis is not assumed, but instead proved by a
@@ -622,8 +627,14 @@ recursion is one of the most appealing aspects of Agda.
622
627
623
628
## 归纳即递归
624
629
630
+ {::comment}
631
+ As a concrete example of how induction corresponds to recursion, here
632
+ is the computation that occurs when instantiating ` m ` to ` 2 ` in the
633
+ proof of associativity.
634
+ {:/}
635
+
625
636
下面是归纳如何对应于递归的具体例子,它是在结合律的证明中,将 ` m ` 实例化为 ` 2 `
626
- 时出现的计算 。
637
+ 时的计算过程 。
627
638
628
639
```
629
640
+-assoc-2 : ∀ (n p : ℕ) → (2 + n) + p ≡ 2 + (n + p)
@@ -705,8 +716,8 @@ result type may mention (or depend upon) these variables; hence they
705
716
are called _ dependent functions_ .
706
717
{:/}
707
718
708
- 是等价的。它们不同于像 ` ℕ → ℕ → ℕ ` 这样的函数类型,其中的变量
709
- 与每一个实参类型相关联,其结果类型可能会涉及 (或依赖于)这些变量,
719
+ 是等价的。和 ` ℕ → ℕ → ℕ ` 这样的函数类型不同,上述函数中的变量
720
+ 与每一个实参类型相关联,且其结果类型可能会涉及 (或依赖于)这些变量,
710
721
因此它们叫做** 依赖函数** (Dependent Function)。
711
722
712
723
@@ -783,7 +794,7 @@ The signature states that we are defining the identifier `+-identityʳ` which
783
794
provides evidence for the proposition:
784
795
{:/}
785
796
786
- 其签名描述了我们定义的标识符 ` +-identityʳ ` 提供了以下命题的证据:
797
+ 其签名说明我们定义的标识符 ` +-identityʳ ` 提供了以下命题的证据:
787
798
788
799
∀ (m : ℕ) → m + zero ≡ m
789
800
@@ -808,7 +819,7 @@ For the base case, we must show:
808
819
Simplifying with the base case of addition, this is straightforward.
809
820
{:/}
810
821
811
- 根据加法的起始步骤化简,这很直白 。
822
+ 根据加法的起始步骤化简,这很显然 。
812
823
813
824
{::comment}
814
825
For the inductive case, we must show:
@@ -913,7 +924,7 @@ The signature states that we are defining the identifier `+-suc` which provides
913
924
evidence for the proposition:
914
925
{:/}
915
926
916
- 其签名描述了我们定义的标识符 ` +-suc ` 提供了以下命题的证据:
927
+ 其签名说明我们定义的标识符 ` +-suc ` 提供了以下命题的证据:
917
928
918
929
∀ (m n : ℕ) → m + suc n ≡ suc (m + n)
919
930
@@ -938,7 +949,7 @@ For the base case, we must show:
938
949
Simplifying with the base case of addition, this is straightforward.
939
950
{:/}
940
951
941
- 根据加法的起始步骤化简,这很直白 。
952
+ 根据加法的起始步骤化简,这很显然 。
942
953
943
954
{::comment}
944
955
For the inductive case, we must show:
@@ -1026,7 +1037,7 @@ The first line states that we are defining the identifier
1026
1037
` +-comm ` which provides evidence for the proposition:
1027
1038
{:/}
1028
1039
1029
- 第一行描述了我们定义的标识符 ` +-comm ` 提供了以下命题的证据:
1040
+ 第一行说明我们定义的标识符 ` +-comm ` 提供了以下命题的证据:
1030
1041
1031
1042
∀ (m n : ℕ) → m + n ≡ n + m
1032
1043
@@ -1111,9 +1122,9 @@ the main proposition first, and the equations required to do so
1111
1122
will suggest what lemmas to prove.
1112
1123
{:/}
1113
1124
1114
- Agda 要求标识符必须在使用前定义,因此我们必须在主命题之前展示引理 ,
1115
- 如前例所示。在实践中,我们通常会先试着证明主命题,之后所需的等式会表明
1116
- 需要证明的引理 。
1125
+ Agda 要求标识符必须在使用前定义,因此我们必须在主命题之前列出引理 ,
1126
+ 如前例所示。在实践中,我们通常会先试着证明主命题,之后所需的等式会说明
1127
+ 需要证明哪些引理 。
1117
1128
1118
1129
1119
1130
{::comment}
@@ -1215,7 +1226,7 @@ proof (or, equivalently, the recursive definition) as a creation story. This
1215
1226
time we are concerned with judgments asserting associativity:
1216
1227
{:/}
1217
1228
1218
- 我们回到结合律的证明上来,把归纳证明(或等价地,递归定义 )看做一个创世故事会有助于理解。
1229
+ 我们回到结合律的证明上来,把归纳证明(或等价的递归定义 )看做一个创世故事会有助于理解。
1219
1230
这次我们专注于判断结合律的断言:
1220
1231
1221
1232
{::comment}
@@ -1470,7 +1481,6 @@ Begin by typing:
1470
1481
看看如何在 Emacs 中用 Agda 的交互式特性来构造另一种结合律的证明会很有启发性。
1471
1482
我们从输入以下内容开始:
1472
1483
1473
-
1474
1484
+-assoc′ : ∀ (m n p : ℕ) → (m + n) + p ≡ m + (n + p)
1475
1485
+-assoc′ m n p = ?
1476
1486
@@ -1511,7 +1521,7 @@ the cursor into the hole and type `C-c C-c`. You will be given
1511
1521
the prompt:
1512
1522
{:/}
1513
1523
1514
- 我们希望通过对 ` m ` 进行归纳来证明此命题。将光标移动到洞中并按下
1524
+ 我们希望对 ` m ` 进行归纳来证明此命题。将光标移动到洞中并按下
1515
1525
` C-c C-c ` 。它会给出提示:
1516
1526
1517
1527
pattern variables to case (empty for split on result):
@@ -1635,6 +1645,7 @@ is associative and commutative.
1635
1645
1636
1646
成立。无需归纳证明,只需应用前面满足结合律和交换律的结果即可。
1637
1647
1648
+ {::comment}
1638
1649
```
1639
1650
-- Your code goes here
1640
1651
```
@@ -1820,7 +1831,7 @@ for all `m`, `n`, and `p`.
1820
1831
1821
1832
对于所有 ` m ` 、` n ` 和 ` p ` 成立。
1822
1833
1823
-
1834
+ {::comment}
1824
1835
#### Exercise ` Bin-laws ` (stretch) {#Bin-laws}
1825
1836
{:/}
1826
1837
@@ -1832,7 +1843,8 @@ Exercise [Bin]({{ site.baseurl }}/Naturals/#Bin)
1832
1843
defines a datatype of bitstrings representing natural numbers
1833
1844
{:/}
1834
1845
1835
- 回想练习 [ Bin] [ plfa.Naturals#Bin ] 中定义了一种比特串数据类型来表示自然数
1846
+ 回想练习 [ Bin] ({{ site.baseurl }}/Naturals/#Bin)
1847
+ 中定义的一种表示自然数的比特串数据类型:
1836
1848
1837
1849
```
1838
1850
data Bin : Set where
@@ -1845,7 +1857,7 @@ data Bin : Set where
1845
1857
and asks you to define functions
1846
1858
{:/}
1847
1859
1848
- 并要求你定义函数
1860
+ 以及要求你定义的函数
1849
1861
1850
1862
inc : Bin → Bin
1851
1863
to : ℕ → Bin
0 commit comments