Skip to content

Commit

Permalink
ck
Browse files Browse the repository at this point in the history
  • Loading branch information
JiechengZhao committed Apr 11, 2024
1 parent 9374223 commit 723874f
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 66 deletions.
4 changes: 2 additions & 2 deletions .i18n/zh/Game.json
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@
"And now we've deduced what we wanted to prove: the goal is one of our assumptions.\nFinish the level with `exact h`.":
"现在我们已经推导出了我们想要证明的了:目标是我们的假设之一。\n用 `exact h` 完成本关。",
"And now `rw [add_zero]`": "现在使用`rw [add_zero]`",
"And finally `rfl`.": "最后是 \"rfl`\"",
"And finally `rfl`.": "最后是 `rfl`。",
"An algorithm for equality": "用于证明等价的算法",
"Although $0^0=1$ in this game, $0^n=0$ if $n>0$, i.e., if\n$n$ is a successor.":
"虽然在这个游戏中 $0^0=1$,但如果 $n>0$,即如果 $n$ 是后继数,那么 $0^n=0$。",
Expand Down Expand Up @@ -812,7 +812,7 @@
"## Summary\n\nIf `n : ℕ` is an object, and the goal mentions `n`, then `induction n with d hd`\nattempts to prove the goal by induction on `n`, with the inductive\nvariable in the successor case being `d`, and the inductive hypothesis being `hd`.\n\n### Example:\nIf the goal is\n```\n0 + n = n\n```\n\nthen\n\n`induction n with d hd`\n\nwill turn it into two goals. The first is `0 + 0 = 0`;\nthe second has an assumption `hd : 0 + d = d` and goal\n`0 + succ d = succ d`.\n\nNote that you must prove the first\ngoal before you can access the second one.":
"## 小结\n\n如果 `n : ℕ` 是一个对象,并且目标提到了 `n`,那么 `induction n with d hd`\n尝试通过对 `n` 进行归纳来证明目标,其中后继数情况下的归纳变量是 `d`,归纳假设是 `hd`。\n\n### 例子:\n如果目标是\n```\n0 + n = n\n```\n\n那么\n\n`induction n with d hd`\n\n将把它变成两个目标。第一个是 `0 + 0 = 0`;\n第二个有一个假设 `hd : 0 + d = d` 和目标\n`0 + succ d = succ d` 。\n\n注意你必须先证明第一个然后才能证第二个。",
"## Summary\n\nIf `h` is a proof of an equality `X = Y`, then `rw [h]` will change\nall `X`s in the goal to `Y`s. It's the way to \\\"substitute in\\\".\n\n## Variants\n\n* `rw [← h]` (changes `Y`s to `X`s; get the back arrow by typing `\\left ` or `\\l`.)\n\n* `rw [h1, h2]` (a sequence of rewrites)\n\n* `rw [h] at h2` (changes `X`s to `Y`s in hypothesis `h2`)\n\n* `rw [h] at h1 h2 ⊢` (changes `X`s to `Y`s in two hypotheses and the goal;\nget the `⊢` symbol with `\\|-`.)\n\n* `repeat rw [add_zero]` will keep changing `? + 0` to `?`\nuntil there are no more matches for `? + 0`.\n\n* `nth_rewrite 2 [h]` will change only the second `X` in the goal to `Y`.\n\n### Example:\n\nIf you have the assumption `h : x = y + y` and your goal is\n```\nsucc (x + 0) = succ (y + y)\n```\n\nthen\n\n`rw [add_zero]`\n\nwill change the goal into `succ x = succ (y + y)`, and then\n\n`rw [h]`\n\nwill change the goal into `succ (y + y) = succ (y + y)`, which\ncan be solved with `rfl`.\n\n### Example:\n\nYou can use `rw` to change a hypothesis as well.\nFor example, if you have two hypotheses\n```\nh1 : x = y + 3\nh2 : 2 * y = x\n```\nthen `rw [h1] at h2` will turn `h2` into `h2 : 2 * y = y + 3`.\n\n## Common errors\n\n* You need the square brackets. `rw h` is never correct.\n\n* If `h` is not a *proof* of an *equality* (a statement of the form `A = B`),\nfor example if `h` is a function or an implication,\nthen `rw` is not the tactic you want to use. For example,\n`rw [P = Q]` is never correct: `P = Q` is the theorem *statement*,\nnot the proof. If `h : P = Q` is the proof, then `rw [h]` will work.\n\n## Details\n\nThe `rw` tactic is a way to do \\\"substituting in\\\". There\nare two distinct situations where you can use this tactic.\n\n1) Basic usage: if `h : A = B` is an assumption or\nthe proof of a theorem, and if the goal contains one or more `A`s, then `rw [h]`\nwill change them all to `B`'s. The tactic will error\nif there are no `A`s in the goal.\n\n2) Advanced usage: Assumptions coming from theorem proofs\noften have missing pieces. For example `add_zero`\nis a proof that `? + 0 = ?` because `add_zero` really is a function,\nand `?` is the input. In this situation `rw` will look through the goal\nfor any subterm of the form `x + 0`, and the moment it\nfinds one it fixes `?` to be `x` then changes all `x + 0`s to `x`s.\n\nExercise: think about why `rw [add_zero]` changes the term\n`(0 + 0) + (x + 0) + (0 + 0) + (x + 0)` to\n`0 + (x + 0) + 0 + (x + 0)`\n\nIf you can't remember the name of the proof of an equality, look it up in\nthe list of lemmas on the right.\n\n## Targetted usage\n\nIf your goal is `b + c + a = b + (a + c)` and you want to rewrite `a + c`\nto `c + a`, then `rw [add_comm]` will not work because Lean finds another\naddition first and swaps those inputs instead. Use `rw [add_comm a c]` to\nguarantee that Lean rewrites `a + c` to `c + a`. This works because\n`add_comm` is a proof that `?1 + ?2 = ?2 + ?1`, `add_comm a` is a proof\nthat `a + ? = ? + a`, and `add_comm a c` is a proof that `a + c = c + a`.\n\nIf `h : X = Y` then `rw [h]` will turn all `X`s into `Y`s.\nIf you only want to change the 37th occurrence of `X`\nto `Y` then do `nth_rewrite 37 [h]`.":
"## 小结\n\n如果 `h` 是等式 `X = Y` 的证明,那么 `rw [h]` 将改变\n目标中的所有 `X`s 变为 `Y`s。这是 \"代入 \"的方法。\n\n## Variants\n\n* `rw [← h]` (将 `Y`s 更改为 `X`s;通过输入 `\\left ` 或 `\\l` 获取后箭头)。\n\n* `rw [h1, h2]`(重写序列)\n\n* `rw [h] at h2`(将假设 `h2` 中的 `X`s 改为 `Y`s)\n\n* `rw [h] at h1 h2 ⊢` (将两个假设和目标中的 `X`s 改为 `Y`s;\n用 `\\|-` 获取 `⊢` 符号)。\n\n* `repeat rw [add_zero]` 将继续将 `? + 0` 更改为 `?`。\n直到没有更多匹配的 `? + 0`。\n\n* `nth_rewrite 2 [h]` 只会将目标中的第二个 `X` 改为 `Y`。\n\n#### 示例:\n\n如果假设为 `h : x = y + y`,目标为\n```.\nsucc (x + 0) = succ (y + y)\n```.\n\n则\n\n`rw [add_zero]`\n\n会将目标改为 `succ x = succ (y + y)`,然后\n\n`rw [h]`\n\n会将目标变为 `succ (y + y) = succ (y + y)`,这\n可以用 `rfl` 解决。\n\n#### 示例:\n\n你也可以用 `rw` 来改变一个假设。\n例如,如果您有两个假设\n```\nh1 : x = y + 3\nh2 : 2 * y = x\n```\n则 `rw [h1] at h2` 将把 `h2` 变为 `h2 : 2 * y = y + 3`。\n-/\n\n## 常见错误\n\n* 需要方括号。`rw h` 永远不会正确。\n\n* 如果 `h` 不是一个 *等式* 的 *证明* (形式为 `A = B` 的定理或假设)、\n例如,如果 `h` 是一个函数或蕴涵、\n那么 `rw` 就不是您要使用的策略。例如\n`rw [P = Q]` 绝对不正确:`P = Q` 是定理*陈述、\n而不是证明。如果 `h : P = Q` 是证明,那么 `rw [h]` 也可以。\n\n## 详情\n\n`rw` 策略是 \"代入 \"的一种方法。有\n有两种不同的情况可以使用这种策略。\n\n1) 基本用法:如果 `h : A = B` 是一个假设或\n如果目标包含一个或多个 `A`s,那么 `rw [h]`\n会将它们全部改为 `B`。如果没有 OFeTl\n如果目标中没有 `A`s。\n\n2) 高级用法:来自定理证明的假设\n通常会有缺失。例如 `add_zero`\n是 `? + 0 = ?` 的证明,因为 `add_zero` 确实是一个函数、\n而 `?` 是输入。在这种情况下,`rw` 将在目标中查找\n寻找任何形式为 `x + 0` 的子项。\n就会将 `?` 固定为 `x`,然后将所有 `x + 0` 改为 `x`s。\n\n练习:想一想为什么 `rw [add_zero]` 会改变术语\n`(0 + 0) + (x + 0) + (0 + 0) + (x + 0)` 改为\n`0 + (x + 0) + 0 + (x + 0)`\n\n如果您记不起相等证明的名称,请在\n右侧的公例列表中查找。\n\n## 目标用法\n\n如果您的目标是 `b + c + a = b + (a + c)`,而您想将 `a + c` 重写为\n为 `c + a`,那么 `rw [add_comm]` 将不起作用,因为 Lean 会先找到另一个加法,然后交换这些输入\n加法,并交换这些输入。使用 `rw [add_comm a c]` 来\n保证Lean将 `a + c` 改写为 `c + a`。这是因为\n`add_comm` 是 `?1 + ?2 = ?2 + ?1` 的证明,`add_comm a` 是 `a + ? = ? + a` 的证明。\n是 `a + ? = ? + a` 的证明,而 `add_comm a c` 是 `a + c = c + a` 的证明。\n\n如果是 `h : X = Y`,那么 `rw [h]` 将把所有 `X`s 变为 `Y`s。\n如果您只想将第 37 次出现的 `X`\n改为 `Y`,则执行 `nth_rewrite 37 [h]`。",
"## 摘要\n\n如果 `h` 是等式 `X = Y` 的证明,那么 `rw [h]` 将改变\n目标中的所有 `X`s 变为 `Y`s。这是 “代入”的方法。\n\n## 变形\n\n* `rw [← h]` (将 `Y`s 更改为 `X`s;通过输入 `\\left ` 或 `\\l` 获取后箭头)。\n\n* `rw [h1, h2]`(重写序列)\n\n* `rw [h] at h2`(将假设 `h2` 中的 `X`s 改为 `Y`s)\n\n* `rw [h] at h1 h2 ⊢` (将两个假设和目标中的 `X`s 改为 `Y`s;\n用 `\\|-` 获取 `⊢` 符号)。\n\n* `repeat rw [add_zero]` 将重复把 `? + 0` 更改为 `?`。\n直到没有更多匹配的 `? + 0`。\n\n* `nth_rewrite 2 [h]` 只会将目标中的第二个 `X` 改为 `Y`。\n\n### 示例:\n\n如果假设为 `h : x = y + y`,目标为\n```\nsucc (x + 0) = succ (y + y)\n```\n\n则\n\n`rw [add_zero]`\n\n会将目标改为 `succ x = succ (y + y)`,然后\n\n`rw [h]`\n\n会将目标变为 `succ (y + y) = succ (y + y)`,这\n可以用 `rfl` 解决。\n\n### 示例:\n\n你也可以用 `rw` 来改变一个假设。\n例如,如果您有两个假设\n```\nh1 : x = y + 3\nh2 : 2 * y = x\n```\n则 `rw [h1] at h2` 将把 `h2` 变为 `h2 : 2 * y = y + 3`。\n\n## 常见错误\n\n* 需要方括号。`rw h` 永远不会正确。\n\n* 如果 `h` 不是一个 *等式* 的 *证明* (形式为 `A = B` 的定理或假设),\n比如 `h` 是一个函数或蕴涵,\n那么 `rw` 就不是您要使用的策略。再比如\n`rw [P = Q]` 绝对不正确,因为`P = Q` 是定理的*陈述*\n而不是证明。但如果 `h : P = Q` 是证明,那么 `rw [h]` 是可以用的。\n\n## 详情\n\n`rw` 策略是 “代入”的一种方法。有\n有两种不同的情况可以使用这种策略。\n\n1) 基本用法:如果 `h : A = B` 是一个假设或\n如果目标包含一个或多个 `A`s,那么 `rw [h]`会将它们全部改为 `B`。如果目标中没有 `A`s,那么策略会报错。\n\n2) 高级用法:来自定理证明的假设通常会有缺失。例如 `add_zero`\n是 `? + 0 = ?` 的证明,因为 `add_zero` 确实是一个函数、\n而 `?` 是输入。在这种情况下,`rw` 将在目标中查找\n寻找任何形式为 `x + 0` 的子项。\n就会将 `?` 固定为 `x`,然后将所有 `x + 0` 改为 `x`s。\n\n练习:想一想为什么 `rw [add_zero]` 会改变术语\n`(0 + 0) + (x + 0) + (0 + 0) + (x + 0)` 改为\n`0 + (x + 0) + 0 + (x + 0)`\n\n如果您记不起相等证明的名称,请在右侧的定理列表中查找。\n\n## 目标用法\n\n如果您的目标是 `b + c + a = b + (a + c)`,而您想将 `a + c` 重写为为 `c + a`,那么 `rw [add_comm]` 将不起作用,因为 Lean 会先找到另一个加法,然后交换这些输入\n加法,并交换这些输入。使用 `rw [add_comm a c]` 来保证Lean将 `a + c` 改写为 `c + a`。这是因为 `add_comm` 是 `?1 + ?2 = ?2 + ?1` 的证明,`add_comm a` 是 `a + ? = ? + a` 的证明。\n而 `add_comm a c` 是 `a + c = c + a` 的证明。\n\n如果是 `h : X = Y`,那么 `rw [h]` 将把所有 `X`s 变为 `Y`s。\n如果您只想将第 37 次出现的 `X` 改为 `Y`,则执行 `nth_rewrite 37 [h]`。",
"## Summary\n\nIf `h : X = Y` and there are several `X`s in the goal, then\n`nth_rewrite 3 [h]` will just change the third `X` to a `Y`.\n\n## Example\n\nIf the goal is `2 + 2 = 4` then `nth_rewrite 2 [two_eq_succ_one]`\nwill change the goal to `2 + succ 1 = 4`. In contrast, `rw [two_eq_succ_one]`\nwill change the goal to `succ 1 + succ 1 = 4`.":
"## 小结\n\n如果 `h : X = Y` 并且在目标中有多个 `X`,那么 `nth_rewrite 3 [h]` 将仅更改第三个 `X` 为 `Y`。\n\n## 示例\n\n如果目标是 `2 + 2 = 4`,那么 `nth_rewrite 2 [two_eq_succ_one]` 将目标更改为 `2 + succ 1 = 4`。相比之下,`rw [two_eq_succ_one]` 将目标更改为 `succ 1 + succ 1 = 4`。",
"## Precision rewriting\n\nIn the last level, there was `b + 0` and `c + 0`,\nand `rw [add_zero]` changed the first one it saw,\nwhich was `b + 0`. Let's learn how to tell Lean\nto change `c + 0` first by giving `add_zero` an\nexplicit input.":
Expand Down
Loading

0 comments on commit 723874f

Please sign in to comment.