diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index ea661eb..3363eb4 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,27 +1,19 @@ -FROM node:18 +FROM mcr.microsoft.com/devcontainers/javascript-node:26-bookworm -# Set default shell to bash -SHELL ["/bin/bash", "-c"] +# The game server (leangame) in the version of the game, e.g. `v4.35.0` for +# `leanprover/lean4:v4.35.0`. It finds the game as a sibling folder in `/workspaces`, which only +# root can write to. Docker caches this step: after a tag has moved, rebuild without cache. +COPY lean-toolchain /tmp/lean-toolchain +RUN version="$(sed -E 's/.*:(v[0-9.]+).*/\1/' /tmp/lean-toolchain)" \ + && git clone --depth 1 --branch "$version" https://github.com/leanprover-community/lean4game.git /workspaces/leangame \ + && chown -R node:node /workspaces/leangame -# ADD ./* GameSkeleton/ +USER node -# install curl, git and nodejs -RUN apt-get update && \ - apt-get install -y curl && \ - apt-get install -y git && \ - apt-get install -y python3 && \ - apt-get clean +# the browser for the tests of the game server is not needed +RUN cd /workspaces/leangame && CYPRESS_INSTALL_BINARY=0 npm ci && npm cache clean --force -# install lean4game -#COPY lean-toolchain . -#COPY npm-install.sh . - -#RUN chmod +x npm-install.sh -#RUN ./npm-install.sh - -# install lean -#COPY lean-install.sh . -#RUN chmod +x lean-install.sh -#RUN ./lean-install.sh - -#CMD ["bash"] +# install elan and the Lean toolchain of the game +RUN curl https://elan.lean-lang.org/elan-init.sh -sSf \ + | sh -s -- -y --default-toolchain "$(cat /tmp/lean-toolchain)" +ENV PATH="/home/node/.elan/bin:${PATH}" diff --git a/.devcontainer/devcontainer-lock.json b/.devcontainer/devcontainer-lock.json new file mode 100644 index 0000000..62fb41f --- /dev/null +++ b/.devcontainer/devcontainer-lock.json @@ -0,0 +1,9 @@ +{ + "features": { + "ghcr.io/devcontainers/features/git:1": { + "version": "1.3.8", + "resolved": "ghcr.io/devcontainers/features/git@sha256:fd75977de13a9979000e0e78baf949adb0ca71d2398995fa22e0a36d7e7e7fe2", + "integrity": "sha256:fd75977de13a9979000e0e78baf949adb0ca71d2398995fa22e0a36d7e7e7fe2" + } + } +} diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 34113ab..a645bd5 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,19 +1,38 @@ { - "forwardPorts": [3000], - "build": {"dockerfile": "Dockerfile"}, - "onCreateCommand": "bash .devcontainer/setup.sh", - "postAttachCommand": "bash .devcontainer/run-server.sh", + "name": "game", + + "build": { + "dockerfile": "Dockerfile", + // the Dockerfile reads `lean-toolchain` + "context": ".." + }, + + "features": { + "ghcr.io/devcontainers/features/git:1": {} + }, + "customizations": { "vscode": { - "settings": { - "remote.autoForwardPorts": false - }, - "extensions": [ - "leanprover.lean4" - ] - }, - "codespaces": { - "openFiles": ["Game.lean"] + "extensions": ["leanprover.lean4"] } - } + }, + + "remoteEnv": { + // don't expose the host's forwarded SSH agent + "SSH_AUTH_SOCK": "" + }, + + "remoteUser": "node", + "containerUser": "node", + + "runArgs": ["--cap-drop=ALL", "--security-opt=no-new-privileges:true"], + + // the game server, see `start-server.sh` + "forwardPorts": [3000], + "portsAttributes": { + "3000": { "label": "Game", "onAutoForward": "openBrowserOnce" } + }, + // builds the game, see `post-create.sh` + "postCreateCommand": ".devcontainer/post-create.sh", + "postAttachCommand": ".devcontainer/start-server.sh" } diff --git a/.devcontainer/lean-toolchain b/.devcontainer/lean-toolchain deleted file mode 100644 index 14a4424..0000000 --- a/.devcontainer/lean-toolchain +++ /dev/null @@ -1 +0,0 @@ -leanprover/lean4:v4.23.0 \ No newline at end of file diff --git a/.devcontainer/post-create.sh b/.devcontainer/post-create.sh new file mode 100755 index 0000000..75ef9bf --- /dev/null +++ b/.devcontainer/post-create.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# Builds the game once the devcontainer is created. If the game depends on mathlib, the +# prebuilt mathlib is downloaded first, building it from scratch would take hours. +set -euo pipefail + +cd "$(dirname "${BASH_SOURCE[0]}")/.." + +# fails if the game doesn't depend on mathlib, which only has the executable `cache` +if ! lake exe cache get; then + # the dependencies have been fetched by now + if [ -d .lake/packages/mathlib ]; then + echo "Downloading the prebuilt mathlib failed, not building it from scratch." >&2 + echo "Run \`lake exe cache get\` and then \`lake build\` to try again." >&2 + exit 1 + fi + echo "The game doesn't depend on mathlib, nothing to download." +fi + +lake build diff --git a/.devcontainer/run-server.sh b/.devcontainer/run-server.sh deleted file mode 100644 index db306dc..0000000 --- a/.devcontainer/run-server.sh +++ /dev/null @@ -1,3 +0,0 @@ -export VITE_LEAN4GAME_SINGLE=true -export VITE_LEAN4GAME_SINGLE_NAME=$(basename "$PWD") -npm start --prefix ../lean4game diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh deleted file mode 100644 index 000ca41..0000000 --- a/.devcontainer/setup.sh +++ /dev/null @@ -1,18 +0,0 @@ -# Install Lean4 -export LEAN_VERSION="$(cat lean-toolchain)" -echo "LEAN_VERSION is: $LEAN_VERSION" -curl https://elan.lean-lang.org/elan-init.sh -sSf | sh -s -- -y --default-toolchain $LEAN_VERSION; -echo 'export PATH="$HOME/.elan/bin:$PATH"' >> ~/.bashrc -export PATH="$HOME/.elan/bin:$PATH" -lake update -R -lake build - -# Install lean4game -export LEAN_VERSION="$(cat lean-toolchain | grep -oE '[^:]+$')" -export VITE_LEAN4GAME_SINGLE=true -export VITE_LEAN4GAME_SINGLE_NAME=$(basename "$PWD") -cd .. -git clone https://github.com/leanprover-community/lean4game.git -cd lean4game -npm install -npm run build diff --git a/.devcontainer/start-server.sh b/.devcontainer/start-server.sh new file mode 100755 index 0000000..556d6f8 --- /dev/null +++ b/.devcontainer/start-server.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# Starts the game server (leangame), which the Dockerfile installs next to the game, at +# http://localhost:3000. Runs when VS Code connects to the devcontainer. Stop it with Ctrl+C +# and start it again with `.devcontainer/start-server.sh`. +set -euo pipefail + +GAME_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +GAME="$(basename "$GAME_DIR" | tr '[:upper:]' '[:lower:]')" +URL="http://localhost:3000/g/local/$GAME" + +# e.g. after reloading the window, the server may still be running +if curl --silent --fail --max-time 2 --output /dev/null http://localhost:3000; then + echo "The game server is already running: $URL" + exit 0 +fi + +echo "Starting the game server, the game will be at $URL" +echo "After changing the game, run \`lake build\` and reload the page." +cd /workspaces/leangame +exec npm start diff --git a/.docker/gitpod/Dockerfile b/.docker/gitpod/Dockerfile deleted file mode 100644 index 12cb879..0000000 --- a/.docker/gitpod/Dockerfile +++ /dev/null @@ -1,37 +0,0 @@ -# This is the Dockerfile for `leanprovercommunity/mathlib:gitpod`. - -# gitpod doesn't support multiple FROM statements, (or rather, you can't copy from one to another) -# so we just install everything in one go -FROM ubuntu:22.04 - -USER root - -RUN apt-get update && apt-get --assume-yes install sudo git curl git bash-completion python3 -y && apt-get clean - -RUN useradd -l -u 33333 -G sudo -md /home/gitpod -s /bin/bash -p gitpod gitpod \ - # passwordless sudo for users in the 'sudo' group - && sed -i.bkp -e 's/%sudo\s\+ALL=(ALL\(:ALL\)\?)\s\+ALL/%sudo ALL=NOPASSWD:ALL/g' /etc/sudoers -USER gitpod -WORKDIR /home/gitpod - -SHELL ["/bin/bash", "-c"] - -# gitpod bash prompt -RUN { echo && echo "PS1='\[\033[01;32m\]\u\[\033[00m\] \[\033[01;34m\]\w\[\033[00m\]\$(__git_ps1 \" (%s)\") $ '" ; } >> .bashrc - -# install elan -RUN curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | sh -s -- -y --default-toolchain none - -# install whichever toolchain mathlib is currently using -RUN . ~/.profile && elan toolchain install $(curl https://raw.githubusercontent.com/leanprover-community/mathlib4/master/lean-toolchain) - -ENV PATH="/home/gitpod/.local/bin:/home/gitpod/.elan/bin:${PATH}" - -# fix the infoview when the container is used on gitpod: -ENV VSCODE_API_VERSION="1.50.0" - -# ssh to github once to bypass the unknown fingerprint warning -RUN ssh -o StrictHostKeyChecking=no github.com || true - -# run sudo once to suppress usage info -RUN sudo echo finished diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e452e12..6b26e57 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,27 +4,44 @@ on: workflow_dispatch: push: branches: - - "main" + - 'main' jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 - - uses: leanprover/lean-action@v1 - with: - use-github-cache: false + # `lean-action` refuses to run without a `lake-manifest.json`, but we do not want to include + # the manifest from the `leangame` repo. + # When using this template, you can replace the following steps with + # - uses: leanprover/lean-action@v1 + # with: + # use-github-cache: false + - name: install elan + run: | + curl -sSfL https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh | sh -s -- -y --default-toolchain none + echo "$HOME/.elan/bin" >> "$GITHUB_PATH" + - name: update dependencies + run: lake update -R --keep-toolchain + - name: build game + run: | + lake build + + # The Lean server loads all `.ilean` files into RAM, which the game server does not need. + # Lake only needs the files to exist, otherwise it considers the game as not built. + - name: empty the .ilean files + run: find -L .lake -name '*.ilean' -exec truncate -s 0 {} + - name: compress built game #run: tar -czvf ../game.tar.gz . run: zip game.zip * .lake/ .i18n/ -r - name: upload compressed game folder - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7 with: name: build-for-server-import path: | game.zip - name: What next? - run: echo "To export the game to the Game Server, open https://adam.math.hhu.de/import/trigger/${GITHUB_REPOSITORY,,} \n Afterwards, you can play the game at https://adam.math.hhu.de/#/g/${GITHUB_REPOSITORY,,}" + run: echo "To load the game to the game server, visit https://adam.math.hhu.de/import. \n Afterwards, you can play the game at https://adam.math.hhu.de/g/${GITHUB_REPOSITORY,,}" diff --git a/.github/workflows/build_non_main.yml b/.github/workflows/build_non_main.yml index 1d42c9d..65e3f6a 100644 --- a/.github/workflows/build_non_main.yml +++ b/.github/workflows/build_non_main.yml @@ -5,12 +5,25 @@ on: pull_request: push: branches-ignore: - - "main" + - 'main' jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: leanprover/lean-action@v1 - with: - use-github-cache: false + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + + # `lean-action` refuses to run without a `lake-manifest.json`, but we do not want to include + # the manifest from the `leangame` repo. + # When using this template, you can replace the following steps with + # - uses: leanprover/lean-action@v1 + # with: + # use-github-cache: false + - name: install elan + run: | + curl -sSfL https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh | sh -s -- -y --default-toolchain none + echo "$HOME/.elan/bin" >> "$GITHUB_PATH" + - name: update dependencies + run: lake update -R --keep-toolchain + - name: build game + run: | + lake build diff --git a/.gitignore b/.gitignore index ea386d6..b0f755d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,5 @@ -build/ -lake-packages/ -.lake/ -**/.DS_Store -.i18n/**/*.mo -Game/Levels/levels.txt -/ntg4.txt +.DS_Store + +# Lean +**/.lake +**/.i18n/**/*.mo diff --git a/.gitpod.yml b/.gitpod.yml deleted file mode 100644 index 11c8eb4..0000000 --- a/.gitpod.yml +++ /dev/null @@ -1,12 +0,0 @@ -image: - file: .docker/gitpod/Dockerfile - -vscode: - extensions: - - leanprover.lean4 - -tasks: - - init: | - lake exe cache get - - command: | - sudo apt-get --assume-yes install gcc diff --git a/.i18n/en/Game.pot b/.i18n/en/Game.pot index db93811..79b7754 100644 --- a/.i18n/en/Game.pot +++ b/.i18n/en/Game.pot @@ -1,396 +1,795 @@ msgid "" -msgstr "Project-Id-Version: Game v4.23.0\n" +msgstr "Project-Id-Version: Game v4.36.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-11-06\n" +"POT-Creation-Date: 2026-11-21\n" "Last-Translator: \n" "Language-Team: none\n" "Language: en\n" "Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit" +"Content-Transfer-Encoding: 8bit\n" +"X-Poedit-Basepath: ../..\n" +"X-Poedit-SearchPath-0: ." -#: Game.Levels.LinCong.L04_sol_nec -msgid "Solvability: Necessary Condition" +#. §0: $a \\equiv b \\pmod m$ +#. §1: $a$ +#. §2: $b$ +#. §3: $m$ +#. §4: $(a - b)$ +#. §5: $m$ +#. §6: $m$ +#. §7: $(a - b)$ +#. §8: $$m \\mid (a - b)$$ +#. §9: $a$ +#. §10: $b$ +#. §11: $m$ +#. §12: $15 \\equiv 3 \\pmod{12}$ +#. §13: $17 \\equiv 5 \\pmod{12}$ +#. §14: $12 \\mid (17 - 5)$ +#. §15: $12 \\mid 12$ +#. §16: $23 \\equiv 2 \\pmod 7$ +#. §17: $7 \\mid (23 - 2)$ +#. §18: $7 \\mid 21$ +#. §19: $10 \\equiv 0 \\pmod 5$ +#. §20: $5 \\mid (10 - 0)$ +#. §21: $5 \\mid 10$ +#. §22: $a \\equiv b \\pmod m$ +#. §23: `ModEq` +#. §24: `unfold ModEq` +#. §25: `m ∣ a - b` +#. §26: `unfold ModEq` +#. §27: `≡` +#. §28: `\\==` +#: Game/Doc/Definitions.lean:4 +msgid "**Modular Congruence (§0)**\n" +"\n" +"We say that §1 is **congruent** to §2 modulo §3 if their difference §4 is a multiple of §5.\n" +"Formally, it means §6 divides §7:\n" +"§8\n" +"\n" +"**Intuition:**\n" +"This is a mathematical way of saying that §9 and §10 leave the *same remainder* when divided by §11. Think of a clock: 15:00 and 3:00 point to the same place because §12.\n" +"\n" +"**Examples:**\n" +"* §13 because §14, which simplifies to §15.\n" +"* §16 because §17, which is §18.\n" +"* §19 because §20, which is §21.\n" +"\n" +"**How it works in Lean:**\n" +"We created a custom notation §22 to represent a function called §23. When you see this notation in your goal or hypotheses, you can use the §24 tactic. This will strip away the formatting and reveal the underlying divisibility statement: §25.\n" +"\n" +"To work with this definition, use: §26\n" +"\n" +"*(To type the congruence symbol §27, type §28 and press Space)*" +msgstr "" + +#. §0: $d$ +#. §1: $a$ +#. §2: $b$ +#. §3: `IsGCD(a, b) d` +#. §4: $d$ +#. §5: $d \\mid a$ +#. §6: $d \\mid b$ +#. §7: $d$ +#. §8: $x, y$ +#. §9: $a \\cdot x + b \\cdot y = d$ +#. §10: $$\\text{IsGCD}(a, b) d \\iff (d \\mid a \\land d \\mid b) \\land \\exists x, y \\in \\mathbb{Z},\\ a x + b y = d$$ +#. §11: $d$ +#. §12: $d \\geq 0$ +#. §13: $d$ +#. §14: `IsGCD(2, 3) 1` +#. §15: $1 \\mid 2$ +#. §16: $1 \\mid 3$ +#. §17: $2 \\cdot (-1) + 3 \\cdot 1 = 1$ +#. §18: `IsGCD(12, 18) 6` +#. §19: $6 \\mid 12$ +#. §20: $6 \\mid 18$ +#. §21: $12 \\cdot (-1) + 18 \\cdot 1 = 6$ +#. §22: `IsGCD(2, 3) (-1)` +#. §23: `IsGCD(a, b) d` +#. §24: `unfold IsGCD` +#. §25: `(d ∣ a ∧ d ∣ b) ∧ ∃ x y, a * x + b * y = d` +#. §26: `constructor` +#. §27: `∧` +#. §28: `use` +#. §29: `IsGCD(a, b) d` +#. §30: `have` +#. §31: `IsGCD a b d` +#. §32: `unfold IsGCD` +#: Game/Doc/Definitions.lean:29 +msgid "**The Greatest Common Divisor, Bézout-style**\n" +"\n" +"In this game, we say §0 **is a greatest common divisor** of §1 and §2 — written §3 — if **two** conditions hold together:\n" +"\n" +"1. §4 is a **common divisor**: §5 and §6.\n" +"2. §7 can be written as a **Bézout combination**: there exist integers §8 such that §9.\n" +"\n" +"§10\n" +"\n" +"**Intuition:**\n" +"Working with \"largest\" directly is awkward in Lean: comparing sizes doesn't play well with negative numbers, and proving something is *the* biggest usually means comparing it to every other common divisor one at a time. The Bézout condition sidesteps all of that. It turns out (and you will prove it in the very next level!) that *any* §11 satisfying condition 2, together with condition 1, is automatically bigger than every other common divisor — for free, with a short proof. So instead of taking \"greatest\" as the definition, we derive it as a theorem.\n" +"\n" +"This definition alone does not force §12 or force §13 to be unique. In this game we will always keep a specific, non-negative witness in mind.\n" +"\n" +"**Examples:**\n" +"* §14, since §15, §16, and §17.\n" +"* §18, since §19, §20, and §21.\n" +"* §22 is *also* technically true, up to sign — in this game we always keep the non-negative witness in mind.\n" +"\n" +"**How it works in Lean:**\n" +"When you see §23 in your goal, §24 reveals the raw conjunction: §25. Use §26 to split the outer §27, and §28 to supply the Bézout witnesses.\n" +"\n" +"The notation §29 is just syntactic sugar to make the goals easier to read. When writing your own code (for example, when defining a new hypothesis with §30), you need to use the standard Lean syntax without parentheses or commas: §31.\n" +"\n" +"To work with this definition, use: §32" +msgstr "" + +#. §0: $a \\mid b$ +#. §1: $a$ +#. §2: $b$ +#. §3: $a \\mid b$ +#. §4: $b$ +#. §5: $a$ +#. §6: $k$ +#. §7: $$b = a \\cdot k$$ +#. §8: $a \\mid b$ +#. §9: $b$ +#. §10: $a$ +#. §11: $3 \\mid 12$ +#. §12: $12 = 3 \\cdot 4$ +#. §13: $k = 4$ +#. §14: $5 \\mid -15$ +#. §15: $-15 = 5 \\cdot (-3)$ +#. §16: $k = -3$ +#. §17: $7 \\mid 0$ +#. §18: $0 = 7 \\cdot 0$ +#. §19: $k = 0$ +#. §20: $4 \\mid 14$ +#. §21: $k$ +#. §22: $14 = 4 \\cdot k$ +#. §23: $a \\mid b$ +#. §24: `∃ k, b = a * k` +#. §25: $k$ +#. §26: `use` +#. §27: `use 4` +#. §28: `∣` +#. §29: `\\mid` +#. §30: `\\|` +#: Game/Doc/Definitions.lean:59 +msgid "**Divisibility (§0)**\n" +"\n" +"We say that an integer §1 **divides** an integer §2 (written as §3) if §4 is a multiple of §5.\n" +"Formally, this means there exists some integer §6 such that:\n" +"§7\n" +"\n" +"**Intuition:**\n" +"Thinking of §8 as \"§9 can be built entirely out of copies of §10\" often makes it easier to reason about than the formal existential statement.\n" +"\n" +"**Examples:**\n" +"* §11 is true because §12 (here our witness is §13).\n" +"* §14 is true because §15 (here §16).\n" +"* §17 is true because §18 (here §19).\n" +"* §20 is **false**, because there is no integer §21 that makes §22.\n" +"\n" +"**How it works in Lean:**\n" +"When you see §23 in your goal, Lean translates this under the hood to an \"exists\" statement: §24.\n" +"To prove it, you must provide the exact value of §25 using the §26 tactic (for example, §27).\n" +"\n" +"*(To type the divides symbol §28, type §29 or §30 and press Space!)*" +msgstr "" + +#. §0: `use` +#. §1: `∃ k, 12 = 3 * k` +#. §2: `use 4` +#. §3: `12 = 3 * 4` +#. §4: `∃ x y : ℤ, 2 * x + 3 * y = 1` +#. §5: `use -1, 1` +#: Game/Doc/Tactics.lean:3 +msgid "The §0 tactic is used to provide a \"witness\" to prove that something exists.\n" +"If your goal is §1, typing §2 changes the goal to §3.\n" +"\n" +"**Multiple arguments:**\n" +"If your goal has multiple existentials, for example §4, you can provide multiple witnesses separated by commas: §5." +msgstr "" + +#. §0: `intro` +#. §1: $\\\\forall$ +#. §2: $\\\\implies$ +#. §3: `∀ a, P a` +#. §4: `intro a` +#. §5: `a` +#: Game/Doc/Tactics.lean:13 +msgid "The §0 tactic is used to introduce variables from a \"For all\" (§1) statement\n" +"or to assume the premise of an implication (§2).\n" +"For example, if the goal is §3, typing §4 moves §5 into your context." +msgstr "" + +#. §0: `ring` +#. §1: `x + y = y + x` +#. §2: `x * 1 = x` +#. §3: `ring` +#. §4: `+` +#. §5: `-` +#. §6: `*` +#. §7: `^` +#. §8: `ℤ` +#. §9: `ℚ` +#. §10: `ℝ` +#. §11: `/` +#. §12: `%` +#: Game/Doc/Tactics.lean:21 +msgid "The §0 tactic automatically proves algebraic equalities by expanding and rearranging expressions.\n" +"It is a powerful tool so you don't have to manually apply basic axioms like commutativity or distributivity (e.g., §1 or §2).\n" +"\n" +"**What it works with:**\n" +"§3 works on equations involving addition (§4), subtraction (§5), multiplication (§6), and natural number exponents (§7) within commutative rings (such as integers §8, rationals §9, or reals §10).\n" +"\n" +"**What it does NOT work with:**\n" +"It cannot handle division (§11), modulo arithmetic (§12) or non-commutative structures (like matrices)." +msgstr "" + +#. §0: `obtain` +#. §1: $\\exists$ +#. §2: $\\wedge$ +#. §3: `h : x ∣ y` +#. §4: `∃ k, y = x * k` +#. §5: `obtain ⟨k, hk⟩ := h` +#. §6: `k` +#. §7: `hk : y = x * k` +#. §8: `⟨` +#. §9: `⟩` +#. §10: `\\<` +#. §11: `\\>` +#. §12: `IsGCD(c, m) 1` +#. §13: `∧` +#. §14: `∃` +#. §15: `obtain ⟨_, x, y, hxy⟩ := h` +#. §16: `_` +#. §17: `x` +#. §18: `y` +#. §19: `hxy` +#. §20: `∧` +#. §21: `obtain` +#. §22: `h.1.1` +#. §23: `h.1.2` +#: Game/Doc/Tactics.lean:34 +msgid "The §0 tactic extracts a witness from a hypothesis that contains an \"exists\" (§1) or a logical AND (§2).\n" +"If you have a hypothesis §3 (which means §4), you can type\n" +"§5 to get the variable §6 and the equation §7.\n" +"*(To type §8 and §9, write §10 and §11, then press Space.)*\n" +"\n" +"**Nested and multiple arguments:**\n" +"For more complex hypotheses, such as §12 (which contains multiple nested §13 and §14), you can extract everything at once by providing up to 4 arguments.\n" +"For example: §15.\n" +"The underscore §16 is used to discard parts of the hypothesis you don't need (like the divisibility facts), while binding the Bézout witnesses to §17 and §18 and the equation to §19.\n" +"\n" +"**Dot notation alternative:**\n" +"If a hypothesis is just a nested logical AND (§20), you can extract its pieces directly using **dot notation** without destroying the original hypothesis via §21. For example, §22 gets the first fact, and §23 gets the second." +msgstr "" + +#. §0: `rw` +#. §1: `h : A = B` +#. §2: `rw [h]` +#. §3: `A` +#. §4: `B` +#. §5: `rw [h1, h2]` +#. §6: `rw` +#. §7: `←` +#. §8: `\\l` +#. §9: `rw [← h]` +#. §10: `rw` +#. §11: `h1` +#. §12: `at` +#. §13: `rw [h_eq] at h1` +#. §14: `at *` +#. §15: `rw [h_eq] at *` +#: Game/Doc/Tactics.lean:51 +msgid "The §0 (rewrite) tactic replaces a term with an equivalent term based on an equality you have.\n" +"If you have §1, typing §2 will replace §3 with §4 in your goal.\n" +"\n" +"**Multiple arguments:**\n" +"You can chain rewrites by putting multiple hypotheses in the brackets, separated by commas: §5. Lean will apply them sequentially.\n" +"\n" +"**Rewriting backwards:**\n" +"By default, §6 replaces the left side of an equality with the right side. To rewrite from right to left, use the §7 symbol (type §8 and Space): §9.\n" +"\n" +"**Targeting hypotheses:**\n" +"By default, §10 changes the goal. You can rewrite inside a hypothesis §11 by using §12: §13.\n" +"You can also rewrite everywhere (in all hypotheses and the goal at once) using §14: §15." +msgstr "" + +#. §0: `unfold` +#. §1: `a ≡ b (mod m)` +#. §2: `unfold ModEq` +#. §3: `m ∣ a - b` +#. §4: `IsGCD(a, b) d` +#. §5: `unfold IsGCD` +#. §6: `(d ∣ a ∧ d ∣ b) ∧ ∃ x y, a * x + b * y = d` +#. §7: `unfold` +#. §8: `h` +#. §9: `unfold ModEq at h` +#. §10: `unfold ModEq at *` +#: Game/Doc/Tactics.lean:68 +msgid "The §0 tactic replaces a definition with its underlying meaning.\n" +"If your goal contains §1, typing §2 will change it to §3.\n" +"Similarly, if your goal contains §4, typing §5 will change it to §6.\n" +"\n" +"**Targeting hypotheses:**\n" +"By default, §7 applies only to the goal. You can unfold a definition inside a specific hypothesis §8 by typing §9.\n" +"To unfold it everywhere (in all hypotheses and the goal at once), use §10." +msgstr "" + +#. §0: `have` +#. §1: `h` +#. §2: `X = Y` +#. §3: `have` +#. §4: `a ≡ b (mod m)` +#. §5: `x ∣ y` +#. §6: `IsGCD(a, b) 1` +#. §7: `:=` +#. §8: `have h : a ≡ b (mod m)` +#. §9: `` +#: Game/Doc/Tactics.lean:80 +msgid "The §0 tactic allows you to prove intermediate steps. Once proven, a new hypothesis §1 is added to your context for the rest of the proof.\n" +"\n" +"You are not limited to basic equalities (§2). You can use §3 for any proposition, such as modular equivalences (§4), divisibility (§5), or predicates like §6.\n" +"\n" +"\n" +"**Important:** In this game, the assignment syntax (§7) is disabled. You must state the assumption and provide the proof on the following line.\n" +"\n" +"**Using a proof block:**\n" +"You can state the assumption and provide the proof on the following lines. This sets your intermediate assumption as the current goal:\n" +"§8\n" +"§9" +msgstr "" + +#. §0: `exact` +#. §1: `mod_trans (a b c m : ℤ) (h1 : ...) (h2 : ...)` +#. §2: `a` +#. §3: `b` +#. §4: `c` +#. §5: `m` +#. §6: `h1` +#. §7: `h2` +#. §8: `exact mod_trans a b c m step1 step2` +#. §9: `a * c` +#. §10: `2^100` +#. §11: `(a * c)` +#. §12: `exact mod_trans a * c ...` +#. §13: `a` +#. §14: `c` +#. §15: `exact mod_trans (a * c) (b * c) (b * d) m step1 step2` +#: Game/Doc/Tactics.lean:96 +msgid "The §0 tactic closes a goal if you provide a theorem that perfectly matches the goal.\n" +"\n" +"**How to use theorems:**\n" +"When you look at a theorem in the **Theorems** tab, you will see its signature, like §1.\n" +"To use it, you must pass the arguments exactly in that order, separated by spaces: first all the variables (§2, §3, §4, §5), and then the proofs for the hypotheses (§6, §7).\n" +"For example: §8\n" +"\n" +"**Using parentheses:**\n" +"If any of your arguments is a complex expression (like §9 or §10), you **must** wrap it in parentheses: §11.\n" +"Otherwise, Lean will read §12 as trying to pass §13 as the first argument, and then multiply the whole tactic result by §14, which will cause an error!\n" +"Correct usage: §15" msgstr "" -#: Game.Levels.DivRules.L01_div10 -msgid "The remainder of a number modulo 10 is its last digit." +#. §0: `induction'` +#. §1: `n` +#. §2: `induction' n with d ih` +#. §3: `n = 0` +#. §4: `n = d + 1` +#. §5: `ih` +#: Game/Doc/Tactics.lean:112 +msgid "The §0 tactic is used to prove statements for all natural numbers §1.\n" +"Typing §2 splits your goal into two cases: the base case (§3) and the inductive step (§4), giving you the induction hypothesis §5." msgstr "" -#: Game.Levels.Problems.L01_large_powers -msgid "Huge Powers" +#. §0: `constructor` +#. §1: $\\wedge$ +#. §2: `P ∧ Q` +#. §3: `P` +#. §4: `Q` +#: Game/Doc/Tactics.lean:119 +msgid "The §0 tactic is used to prove goals consisting of a logical AND (§1).\n" +"It splits the goal §2 into two separate goals: §3 and §4." msgstr "" -#. §0: $a \\equiv b \\pmod m$ -#. §1: $m$ -#. §2: $m$ -#: Game.Levels.Congruence -msgid "Welcome to World 3: Meet the Congruence!\n" +#. §0: $a$ +#. §1: $a$ +#. §2: $b$ +#. §3: $a \\mid a \\cdot b$ +#. §4: $a$ +#. §5: $a$ +#. §6: $b$ +#. §7: `dvd_mul_right_int a b` +#. §8: `a ∣ a * b` +#: Game/Doc/Theorems/Divisibility.lean:4 +msgid "**Multiples of §0**\n" "\n" -"Here we introduce one of the central concepts of number theory: **Modular Congruences** (§0).\n" +"For any integers §1 and §2: §3.\n" "\n" -"First, you will prove that congruence modulo §1 forms an equivalence relation (reflexive, symmetric, and transitive) and learn how to shift numbers by multiples of the modulus. Then, you will learn how to manipulate the modulus §2 itself — scaling it up, shrinking it to a divisor, and splitting a product modulus apart!" -msgstr "" - -#: Game.Levels.DivRules.L05_div9 -msgid "Beautiful! Two lines of code prove a rule that feels like magic in middle school. Because polynomials preserve congruences, substituting 10 for 1 works perfectly." +"**Intuition:**\n" +"Any product containing §4 as a factor is immediately a multiple of §5 (with §6 itself acting as the witness). In Lean, §7 directly proves §8." msgstr "" -#: Game.Levels.Divisibility.L01_first_proof -msgid "Your First Proof" +#. §0: $a$ +#. §1: $1 \\mid a$ +#: Game/Doc/Theorems/Divisibility.lean:15 +msgid "**One Divides Everything**\n" +"\n" +"For any integer §0: §1." msgstr "" -#: Game.Levels.Divisors.L05_dvd_trans -msgid "Divisibility is transitive." +#. §0: $a \\mid a$ +#: Game/Doc/Theorems/Divisibility.lean:23 +msgid "**Reflexivity of Divisibility**\n" +"\n" +"Every integer divides itself: §0." msgstr "" -#: GameServer.RpcHandlers -msgid "intermediate goal solved! 🎉" +#. §0: $a$ +#. §1: $a \\mid 0$ +#: Game/Doc/Theorems/Divisibility.lean:31 +msgid "**Every Integer Divides Zero**\n" +"\n" +"For any integer §0: §1." msgstr "" -#. §0: $x \\equiv a \\pmod m$ -#. §1: $x \\equiv a \\pmod n$ -#. §2: $x \\equiv a \\pmod{m \\cdot n}$ -#. §3: $x - a$ -#. §4: $m$ -#. §5: $n$ -#. §6: $m$ -#. §7: $n$ -#. §8: $m \\cdot n$ -#. §9: $m = n = 2$ -#. §10: $m \\cdot n = 4$ -#. §11: $x - a = 2$ -#. §12: $12$ -#. §13: $3$ -#. §14: $4$ -#. §15: $12$ -#. §16: $3 \\cdot 4 = 12$ -#: Game.Doc.Theorems.LinCong -msgid "**Glued Modulus**\n" +#. §0: $a \\cdot k = b$ +#. §1: $a \\mid b$ +#. §2: `h : a * k = b` +#. §3: `dvd_intro_int a b k h` +#. §4: `a ∣ b` +#. §5: $k$ +#: Game/Doc/Theorems/Divisibility.lean:39 +msgid "**Divisibility from Equality**\n" "\n" -"If §0 and §1 with coprime moduli, then §2.\n" +"If §0, then §1.\n" "\n" "**Intuition:**\n" -"§3 is a multiple of both §4 and §5 separately. If §6 and §7 share no common factor, the only way a number can be built from both is by being a multiple of their product §8 — nothing is double-counted. This is exactly why coprimality matters: if §9, a number could be a multiple of both without being a multiple of §10 (e.g. §11).\n" -"\n" -"**Example:** §12 is a multiple of both §13 and §14 (coprime!), and indeed §15 is a multiple of §16." -msgstr "" - -#: Game.Levels.GCD.L03_coprime_forward -msgid "Coprimality gives a Bézout identity." -msgstr "" - -#. §0: `ring` -#: Game.Levels.Divisibility.L02_negative_multiples -msgid "Spot on! Negative witnesses work just like positive ones, and §0 will soon become your best friend once variables enter the picture." +"If you already have an explicit equation §2 in your hypotheses, applying §3 proves §4 directly without needing to rewrite and supply the witness §5 manually." msgstr "" -#. §0: $a \\cdot 0 = 0$ -#. §1: $a$ +#. §0: $0 \\mid a$ +#. §1: $a = 0$ #. §2: $0$ -#: Game.Levels.Divisibility.L06_dvd_zero -msgid "Perfect! Because §0, §1 always divides §2." -msgstr "" - -#: Game.Levels.Problems -msgid "Welcome to the Grand Finale: Problems!\n" +#. §3: $a \\mid 0$ +#. §4: $0 \\cdot k = 0$ +#. §5: $k$ +#. §6: $0$ +#. §7: $0$ +#. §8: `h : 0 ∣ a` +#. §9: `eq_zero_of_zero_dvd_int a h` +#. §10: `a = 0` +#: Game/Doc/Theorems/Divisibility.lean:50 +msgid "**Only Zero Is Divisible by Zero**\n" "\n" -"You've conquered both branches of the game and built a massive toolkit of abstract theorems — from modular arithmetic and divisibility rules to the GCD, Euclid's Lemma, and the Chinese Remainder Theorem.\n" +"If §0, then §1.\n" "\n" -"In this final world, we will use your theorems to crush concrete numerical problems that would be too massive to compute directly. Let's put your theory to the ultimate test!" +"**Intuition:**\n" +"While every integer divides §2 (§3), the reverse is much stricter: since §4 for any §5, the only number that §6 can divide is §7 itself. In Lean, given §8, applying §9 yields §10." msgstr "" -#. §0: $c_0 - c_1 + c_2 - c_3 \\dots$ -#. §1: $10 \\equiv -1 \\pmod{11}$ -#. §2: $c_2 \\cdot 10^2 + c_1 \\cdot 10 + c_0$ -#. §3: $(-1)^2 = 1$ -#. §4: $(-1)^1 = -1$ -#. §5: $c_2 - c_1 + c_0$ -#. §6: `polynomial_cong` -#: Game.Levels.DivRules.L07_div11 -msgid "Welcome to the final boss of Divisibility Rules!\n" +#. §0: $d \\mid a$ +#. §1: $d \\mid (a \\cdot b)$ +#. §2: $b$ +#. §3: $a$ +#. §4: $k$ +#. §5: $d$ +#. §6: $a = d \\cdot k$ +#. §7: $a \\cdot b$ +#. §8: $k \\cdot b$ +#. §9: $d$ +#. §10: $3 \\mid 6$ +#. §11: $3 \\mid (6 \\cdot 5) = 30$ +#. §12: $a \\cdot x + b \\cdot y = d$ +#. §13: $c$ +#. §14: $a$ +#. §15: $b$ +#. §16: $c$ +#. §17: $a \\cdot x$ +#. §18: $b \\cdot y$ +#: Game/Doc/Theorems/Divisibility.lean:61 +msgid "**A Divisor of a Factor Divides the Product**\n" "\n" -"For our final trick: the alternating sum of digits rule for 11.\n" -"A number is divisible by 11 if §0 is divisible by 11.\n" +"If §0, then §1 for any integer §2.\n" "\n" -"Why does this work? Because §1.\n" -"When we evaluate the \"polynomial\" of the digits (§2) at -1 instead of 10, the powers of -1 naturally alternate: §3, but §4.\n" -"So the polynomial magically turns into §5 (the alternating sum)!\n" +"**Intuition:**\n" +"If §3 is built out of §4 copies of §5 (i.e. §6), then §7 is built out of §8 copies of §9.\n" +"For example, §10, so §11 as well.\n" "\n" -"Once again, §6 will do all the heavy lifting — and just like with 9, the same idea scales to numbers of any length." -msgstr "" - -#: Game.Levels.Divisibility -msgid "Divisibility Club" -msgstr "" - -#: Game.Levels.Divisibility.L08_rewriting_backwards -msgid "If a * k = b, then a divides b." -msgstr "" - -#: Game.Levels.Problems.L04_lincong -msgid "Solving Linear Congruences" +"This little lemma is a \"brick\" you will reuse constantly throughout the game: whenever you have a Bézout-style identity §12 and you know some §13 divides §14 or §15, this lemma lets you conclude §16 divides the whole term §17 or §18." msgstr "" -#. §0: $10 \\equiv 1 \\pmod 9$ -#: Game.Doc.Theorems.DivRules -msgid "**Divisibility by 9**\n" +#. §0: $a \\mid b$ +#. §1: $a \\mid c$ +#. §2: $a \\mid (b + c)$ +#. §3: $a$ +#. §4: $b$ +#. §5: $k_1$ +#. §6: $a$ +#. §7: $c$ +#. §8: $k_2$ +#. §9: $a$ +#. §10: $b + c$ +#. §11: $k_1 + k_2$ +#. §12: $a$ +#. §13: `h1 : a ∣ b` +#. §14: `h2 : a ∣ c` +#. §15: `dvd_add_int a b c h1 h2` +#. §16: `a ∣ b + c` +#: Game/Doc/Theorems/Divisibility.lean:75 +msgid "**Sums of Multiples**\n" "\n" -"A number is congruent to the sum of its digits modulo 9.\n" -"This works beautifully because any number can be written as a polynomial evaluated at 10, and §0." -msgstr "" - -#. §0: `a = d * k1` -#. §1: `b = d * k2` -#. §2: `a * x + b * y` -#. §3: `(d * k1) * x + (d * k2) * y` -#. §4: `d` -#. §5: `use` -#: Game.Levels.Divisors.L06_dvd_lin_comb -msgid "Once you substitute §0 and §1, the sum §2 becomes §3. Factor out §4 to see what witness to §5!" -msgstr "" - -#. §0: `unfold` -#. §1: `a ≡ b (mod m)` -#. §2: `unfold ModEq` -#. §3: `m ∣ a - b` -#. §4: `IsGCD(a, b) d` -#. §5: `unfold IsGCD` -#. §6: `(d ∣ a ∧ d ∣ b) ∧ ∃ x y, a * x + b * y = d` -#. §7: `unfold` -#. §8: `h` -#. §9: `unfold ModEq at h` -#. §10: `unfold ModEq at *` -#: Game.Doc.Tactics -msgid "The §0 tactic replaces a definition with its underlying meaning.\n" -"If your goal contains §1, typing §2 will change it to §3.\n" -"Similarly, if your goal contains §4, typing §5 will change it to §6.\n" +"If §0 and §1, then §2.\n" "\n" -"**Targeting hypotheses:**\n" -"By default, §7 applies only to the goal. You can unfold a definition inside a specific hypothesis §8 by typing §9.\n" -"To unfold it everywhere (in all hypotheses and the goal at once), use §10." -msgstr "" - -#: Game.Levels.LinCong.L02_inv_reverse -msgid "Great! Reversibility is confirmed. Having a modular inverse is *exactly equivalent* to being coprime to the modulus." +"**Intuition:**\n" +"Multiples of §3 are closed under addition. If §4 is made of §5 blocks of §6 and §7 is made of §8 blocks of §9, then their sum §10 is made of §11 blocks of §12. In Lean, given §13 and §14, §15 proves §16." msgstr "" -#: Game.Doc.Theorems.DivRules -msgid "**Divisibility by 2**\n" +#. §0: $x$ +#. §1: $y$ +#. §2: $y$ +#. §3: $z$ +#. §4: $x$ +#. §5: $z$ +#. §6: $y$ +#. §7: $x$ +#. §8: $z$ +#. §9: $y$ +#. §10: $z$ +#. §11: $3 \\cdot 4 = 12$ +#. §12: $x$ +#. §13: `h1 : x ∣ y` +#. §14: `h2 : y ∣ z` +#. §15: `dvd_trans_int x y z h1 h2` +#. §16: `x ∣ z` +#: Game/Doc/Theorems/Divisibility.lean:86 +msgid "**Transitivity of Divisibility**\n" "\n" -"Since 2 divides 10, the remainder of any number modulo 2 depends entirely on its last digit." -msgstr "" - -#. §0: $a \\equiv b \\pmod m$ -#. §1: $a^n \\equiv b^n \\pmod m$ -#. §2: $n$ -#: Game.Doc.Theorems.Congruence -msgid "**Powers of Congruences**\n" +"If §0 divides §1, and §2 divides §3, then §4 divides §5.\n" "\n" -"If §0, then §1 for any natural number §2." +"**Intuition:**\n" +"Think of it as building blocks. If a stick §6 is made of exactly 3 blocks of §7,\n" +"and a stick §8 is made of exactly 4 sticks of §9, then §10 is made of §11 blocks of §12.\n" +"Divisibility chains perfectly! In Lean, if you have §13 and §14, applying §15 proves §16." msgstr "" -#. §0: $5 \\mid 10$ -#. §1: $10 \\cdot k + d \\equiv d \\pmod{10}$ -#. §2: $5 \\mid 10$ -#. §3: `mod_shrink` -#. §4: $10 \\cdot k + d \\equiv d \\pmod 5$ -#. §5: `have h5 : (5 : ℤ) ∣ 10` -#: Game.Levels.DivRules.L03_div5 -msgid "As promised at the end of the last level, let's finish off the pair: since §0 too, the exact same trick that worked for 2 also nails the rule for 5.\n" +#. §0: $d \\mid a$ +#. §1: $d \\mid b$ +#. §2: $d \\mid (a \\cdot x + b \\cdot y)$ +#. §3: $x$ +#. §4: $y$ +#. §5: `dvd_mul_of_dvd_left_int` +#. §6: `dvd_add_int` +#. §7: $a$ +#. §8: $b$ +#. §9: $a \\cdot x + b \\cdot y$ +#: Game/Doc/Theorems/Divisibility.lean:99 +msgid "**Divisibility of Linear Combinations**\n" "\n" -"If §1 (Level 1), and §2, then §3 immediately gives us §4 as well.\n" +"If §0 and §1, then §2 for any integers §3 and §4.\n" "\n" -"**Syntax Tip:** Same reminder as last time — write §5 so Lean doesn't default to natural numbers." +"**Intuition:**\n" +"This combines §5 (scaling) and §6 (addition) into one powerful rule: any common divisor of §7 and §8 automatically divides any linear combination §9. You will rely on this heavily when working with Greatest Common Divisors and Bézout's identity!" msgstr "" -#: Game.Levels.DivRules.L02_div2 -msgid "Divisibility by 2" +#: Game/Levels/Divisibility/L01_first_proof.lean:11 +msgid "Your First Proof" msgstr "" -#. §0: $a, k, m$ -#. §1: $d_1, d_2$ -#. §2: `IsGCD(a + m * k, m) d1` -#. §3: `IsGCD(a, m) d2` -#. §4: $d_1 = d_2$ -#. §5: $\\gcd(a + mk, m) = \\gcd(a, m)$ +#. §0: `3 ∣ 12` +#. §1: `a ∣ b` +#. §2: `∣` +#. §3: `\\mid` +#. §4: `3 ∣ 12` +#. §5: `∃ k, 12 = 3 * k` #. §6: $k$ -#. §7: $a$ -#. §8: $m$ -#. §9: $m$ -#: Game.Doc.Theorems.GCD -msgid "**Shift Invariance of the GCD**\n" +#. §7: `use` +#. §8: `use 4` +#. §9: $k$ +#. §10: $4$ +#. §11: $12$ +#. §12: $3 \\cdot 4$ +#: Game/Levels/Divisibility/L01_first_proof.lean:16 +msgid "Welcome to your first level! In Lean, you write proofs by using **tactics**. Tactics are commands that manipulate the goal until it is solved.\n" "\n" -"For any integers §0, and non-negative gcd-witnesses §1:\n" -"if §2 and §3, then §4.\n" +"Our first statement is §0, which is read as \"3 divides 12\".\n" +"Whenever a new mathematical concept is introduced, it appears in your **Definitions** tab on the right. Click on §1 there right now to see what divisibility means formally!\n" "\n" -"**Why this matters:**\n" -"This is the *engine* of the Euclidean Algorithm for computing GCDs: §5 for any integer §6. In particular, replacing §7 by its remainder after dividing by §8 never changes the GCD with §9 — which is exactly what lets the Euclidean Algorithm shrink its numbers step by step until it reaches the answer." +"*(To type §2, write §3 and press Space.)*\n" +"\n" +"Lean sees §4 as §5.\n" +"To prove this, you need to provide the number §6. You can do this with the §7 tactic.\n" +"Type §8. Lean will automatically substitute §9 with §10 and close the goal since §11 equals §12!" msgstr "" -#: Game.Levels.Divisors.L03_dvd_mul -msgid "If d divides a, then d divides a * b for any integer b." +#: Game/Levels/Divisibility/L01_first_proof.lean:29 +msgid "The exercise statement: 3 divides 12." msgstr "" -#: Game.Levels.Congruence.L03_dvd_imp_mod_zero -msgid "Divisibility implies congruence to zero modulo m." +#. §0: `use` +#: Game/Levels/Divisibility/L01_first_proof.lean:33 +msgid "Congratulations! You have just written your first proof in Lean 4!\n" +"You used §0 to provide a witness, and Lean automatically closed the obvious equality." msgstr "" -#. §0: `mod_add_multiple` -#: Game.Levels.Congruence.L06_add_mul_mod -msgid "Short and sweet. This fact (§0) will be a lifesaver when we prove divisibility rules and solve linear congruences!" +#: Game/Levels/Divisibility/L02_negative_multiples.lean:7 +msgid "Negative Multiples" msgstr "" -#: Game.Levels.DivRules.L01_div10 -msgid "Perfect! The last digit is exactly the remainder modulo 10." +#. §0: $\\mathbb{Z}$ +#. §1: `5 ∣ -15` +#. §2: $k$ +#. §3: $-15 = 5 \\cdot k$ +#. §4: `use` +#. §5: `ring` +#. §6: `use` +#. §7: `ring` +#: Game/Levels/Divisibility/L02_negative_multiples.lean:11 +msgid "Divisibility isn't limited to positive numbers — it works across all integers (§0), including negative ones!\n" +"\n" +"Here we want to prove §1, which means finding an integer §2 such that §3.\n" +"Once you provide the witness with §4, finish off the arithmetic using a powerful new tactic: §5.\n" +"\n" +"**Tip:** Every time you unlock a new tactic (like §6 or §7), it is added to the **Tactics** tab on the right. Check that tab anytime you want to read what a tactic does or see examples of how to use it!" msgstr "" -#: Game.Levels.Problems.L03_crt -msgid "The Oracle of CRT" +#: Game/Levels/Divisibility/L02_negative_multiples.lean:20 +msgid "5 divides -15." msgstr "" -#: Game.Doc.Theorems.DivRules -msgid "**Divisibility by 5**\n" -"\n" -"Since 5 divides 10, the remainder of any number modulo 5 depends entirely on its last digit — same idea as the rule for 2." +#. §0: `ring` +#: Game/Levels/Divisibility/L02_negative_multiples.lean:25 +msgid "Spot on! Negative witnesses work just like positive ones, and §0 will soon become your best friend once variables enter the picture." msgstr "" -#: Game.Levels.Problems.L05_euclid -msgid "Spot on! Euclid's Lemma is an incredibly powerful tool for analyzing equations with integers, and now you know how to apply it to concrete numbers." +#: Game/Levels/Divisibility/L03_dvd_mul_right.lean:7 +msgid "Multiples of a" msgstr "" -#: Game.Levels.Congruence.L04_mod_symm -msgid "Congruence modulo m is symmetric." +#. §0: $a$ +#. §1: $b$ +#. §2: $a$ +#. §3: $a \\cdot b$ +#. §4: $k$ +#. §5: $a \\cdot b = a \\cdot k$ +#. §6: $k$ +#: Game/Levels/Divisibility/L03_dvd_mul_right.lean:9 +msgid "Now let's move from numerals to integer variables §0 and §1.\n" +"\n" +"We want to prove that §2 divides §3. By definition, this means finding some §4 such that §5.\n" +"Look closely at the equation — the witness §6 is hiding in plain sight!" msgstr "" -#: Game.Levels.GCD.L04_coprime_backward -msgid "Bézout Gives You Coprimality (⟸)" +#: Game/Levels/Divisibility/L03_dvd_mul_right.lean:16 +msgid "Any integer a divides a * b." msgstr "" -#: Game.Levels.ModArith.L04_mul_const -msgid "Multiplying a congruence by a constant." +#. §0: $b$ +#. §1: $k$ +#. §2: $a \\cdot b = a \\cdot b$ +#. §3: `use b` +#. §4: `dvd_mul_right_int` +#: Game/Levels/Divisibility/L03_dvd_mul_right.lean:20 +msgid "Easy! Since substituting §0 for §1 makes both sides of §2 completely identical, §3 closes the goal immediately.\n" +"\n" +"**New Theorem Unlocked!** Whenever you prove a general statement like this, it is saved in your **Theorems** tab on the right (this one is called §4). Take a look at the **Theorems** tab now — you can click on any theorem there to read its documentation and see how to reuse it in future proofs!" msgstr "" -#. §0: $x_1$ -#. §1: $x_2$ -#. §2: $a \\cdot x \\equiv b \\pmod m$ -#. §3: $m$ -#. §4: $m_1 = m / d$ -#. §5: `mod_cancel_general` -#: Game.Levels.LinCong.L06_sol_equiv -msgid "If §0 and §1 are both solutions to §2, how are they related?\n" -"\n" -"They are not necessarily congruent modulo §3, but they **are** congruent modulo §4.\n" -"This perfectly mirrors §5 from the GCD world. You can reuse it directly!" +#: Game/Levels/Divisibility/L04_one_dvd.lean:7 +msgid "One Divides Everything" msgstr "" -#. §0: $c$ -#. §1: $a \\cdot c \\equiv b \\cdot c \\pmod m$ -#: Game.Levels.GCD -msgid "Welcome to In Search of the GCD!\n" +#. §0: $1$ +#. §1: $a$ +#. §2: $1 \\mid a$ +#. §3: $a = 1 \\cdot k$ +#. §4: $k$ +#. §5: $k$ +#. §6: `use` +#. §7: $a$ +#. §8: $1 \\cdot a$ +#. §9: `ring` +#: Game/Levels/Divisibility/L04_one_dvd.lean:9 +msgid "Next, let's prove that §0 divides any integer §1.\n" "\n" -"Can we cancel a common factor §0 from both sides of a congruence §1? Not always! To safely cancel factors in modular arithmetic, we need to deeply understand the Greatest Common Divisor (GCD).\n" +"Remember that §2 means §3 for some §4. What should §5 be?\n" "\n" -"In this world, we will define the GCD using Bézout's identity, prove its properties, unlock the ultimate tool for number theory — the General Cancellation Law — and finish by proving the shift invariance that powers the Euclidean Algorithm. Let's find that GCD!" +"Unlike the previous level, after you §6 your witness, the two sides of the equation (§7 and §8) won't look syntactically identical to Lean. Close the algebra using §9!" msgstr "" -#. §0: $\\equiv$ -#. §1: $a \\equiv b \\pmod m$ -#. §2: $c \\equiv d \\pmod m$ -#. §3: $$a + c \\equiv b + d \\pmod m$$ -#: Game.Levels.ModArith.L01_add -msgid "Knowing that §0 is an equivalence relation is great, but the real magic of modular arithmetic is that it respects **algebraic operations**.\n" -"\n" -"First up is addition: if §1 and §2, then we can add the two congruences side-by-side:\n" -"§3" +#: Game/Levels/Divisibility/L04_one_dvd.lean:17 +msgid "1 divides every integer." msgstr "" -#: Game.Levels.Divisibility.L03_dvd_mul_right -msgid "Any integer a divides a * b." +#. §0: `use` +#. §1: $a = 1 \\cdot a$ +#. §2: `ring` +#. §3: `one_dvd_int` +#: Game/Levels/Divisibility/L04_one_dvd.lean:22 +msgid "Great job! Whenever §0 leaves you with an algebraic identity like §1, §2 cleans it right up. §3 is now added to your toolkit!" msgstr "" -#. §0: $10 \\cdot k + d$ -#. §1: $100 \\cdot k + d$ -#. §2: $d = 56$ -#. §3: $100 \\cdot k + d \\equiv d \\pmod 4$ -#. §4: $100 = 25 \\cdot 4$ -#. §5: `mod_add_multiple` -#: Game.Levels.DivRules.L04_div4 -msgid "A number is divisible by 4 if its last two digits form a number divisible by 4.\n" -"\n" -"Instead of separating the last digit, we separate the last *two* digits! Just like in Level 1, where we wrote a number as §0 using the last digit, here we write it as §1 using the last *two* digits. For example, **3456 = 34 * 100 + 56**, where §2 is exactly the last two digits.\n" -"\n" -"We want to show §3.\n" -"Notice that §4. Use §5 just like in Level 1!" +#: Game/Levels/Divisibility/L05_dvd_refl.lean:7 +msgid "A Number Divides Itself" msgstr "" -#. §0: `exact` -#. §1: `constructor` -#: Game.Levels.Congruence.L09_mod_split -msgid "🎉 AMAZING! 🎉\n" -"\n" -"You have conquered World 3! You now know how to work with congruences, reuse theorems with §0, split conjunctions with §1, and break apart a product modulus.\n" -"\n" -"The map now splits into **two parallel paths** — you can tackle them in whichever order you prefer:\n" -"- **In Search of the GCD** → **Linear Congruences and CRT**: discover Bézout's identity, cancellation laws, Euclid's Lemma, and the Chinese Remainder Theorem.\n" -"- **Modular Arithmetic** → **Divisibility Rules**: add, multiply, and raise congruences to powers, prove polynomial congruences, and unlock all classic divisibility rules!" +#. §0: $a$ +#. §1: $k$ +#. §2: $a = a \\cdot k$ +#: Game/Levels/Divisibility/L05_dvd_refl.lean:9 +msgid "Now let's practice what we just learned. Prove that any integer §0 divides itself.\n" +"Think about what §1 should be so that §2." msgstr "" -#: Game.Levels.Problems -msgid "Problems" +#: Game/Levels/Divisibility/L05_dvd_refl.lean:14 +msgid "Every integer divides itself." msgstr "" -#. §0: `x = «{u}» * «{k}»` -#. §1: `use «{u}» * «{k}»` -#: Game.Levels.LinCong.L05_sol_suff -msgid "As the introduction says, try §0. §1" +#. §0: `dvd_refl_int` +#: Game/Levels/Divisibility/L05_dvd_refl.lean:19 +msgid "Nice! You are starting to recognize patterns — we call this property **reflexivity** (§0)." +msgstr "" + +#: Game/Levels/Divisibility/L06_dvd_zero.lean:7 +msgid "Everything Divides Zero" msgstr "" #. §0: $a$ -#. §1: $m$ -#. §2: $\\gcd(a, m) = 1$ -#. §3: $x$ -#. §4: $a \\cdot x \\equiv 1 \\pmod m$ -#. §5: $a$ -#. §6: $m$ -#. §7: $a \\cdot x + m \\cdot y = 1$ -#. §8: $x$ -#. §9: `unfold IsGCD` -#: Game.Levels.LinCong.L01_inv_exists -msgid "First, let's explore **modular inverses**. If §0 and §1 are coprime (§2), does there exist an §3 such that §4?\n" -"\n" -"Yes! And Bézout's identity gives us exactly the proof. Since §5 and §6 are coprime, we know §7. The §8 from this identity is exactly the inverse we are looking for.\n" -"\n" -"Use §9 to extract Bézout's coefficients, and then use algebra!" +#. §1: $0 = a \\cdot k$ +#. §2: $k$ +#: Game/Levels/Divisibility/L06_dvd_zero.lean:9 +msgid "A common misconception in standard school math is confusing \"dividing by zero\" (which is undefined) with \"dividing zero\".\n" +"Here, we want to prove that any number §0 *divides* zero.\n" +"By our definition, this just means §1 for some §2." msgstr "" -#: Game.Levels.DivRules.L03_div5 -msgid "The remainder modulo 5 depends only on the last digit." +#: Game/Levels/Divisibility/L06_dvd_zero.lean:15 +msgid "Any integer divides zero." msgstr "" -#. §0: `«{a}» * «{x}» + «{m}» * (-«{k}») = 1` -#. §1: `(«{a}» * «{x}» - 1) - «{m}» * «{k}» + 1` -#. §2: `«{a}» * «{x}» - 1 = «{m}» * «{k}»` -#: Game.Levels.LinCong.L02_inv_reverse -msgid "To verify §0, rewrite it as §1, then substitute §2. What remains is pure arithmetic." +#. §0: $a \\cdot 0 = 0$ +#. §1: $a$ +#. §2: $0$ +#: Game/Levels/Divisibility/L06_dvd_zero.lean:20 +msgid "Perfect! Because §0, §1 always divides §2." msgstr "" -#. §0: $m$ -#. §1: $a \\equiv b \\pmod m$ -#. §2: $m$ -#. §3: $(a - b)$ -#. §4: `a ≡ b (mod m)` -#. §5: `≡` -#. §6: `\\==` -#. §7: `unfold ModEq` -#. §8: $17 \\equiv 5 \\pmod 6$ -#: Game.Levels.Congruence.L01_concrete -msgid "Welcome to World 3! Here we introduce one of the most powerful ideas in number theory: **Congruences**.\n" -"\n" -"Often, we don't care about a number itself, only about the remainder it leaves when divided by some modulus §0 — just like reading a 12-hour clock. Formally, we say that §1 if §2 divides their difference §3.\n" +#: Game/Levels/Divisibility/L07_rewriting.lean:7 +msgid "Rewriting" +msgstr "" + +#. §0: `hx : x = 42` +#. §1: `hy : y = 69` +#. §2: `rw` +#. §3: `rw [hx, hy]` +#. §4: `x` +#. §5: `42` +#. §6: `y` +#. §7: `69` +#. §8: `(x - 42)` +#. §9: `(y - 69)` +#: Game/Levels/Divisibility/L07_rewriting.lean:11 +msgid "That goal looks terrifying! Fortunately, you don't have to expand those fifth powers by hand.\n" "\n" -"In Lean, this is written as §4 (to type §5, write §6 and press Space). Check your **Definitions** tab for more details!\n" +"Look at your hypotheses: §0 and §1.\n" +"You can substitute these values into the goal using the **rewrite** tactic, written §2.\n" "\n" -"Whenever you see this notation, type §7 to reveal the divisibility statement hiding underneath. Let's test it out on a concrete example: show that §8." +"Type §3 to replace every §4 with §5 and every §6 with §7. Look closely at what happens to §8 and §9 on the right-hand side!" +msgstr "" + +#: Game/Levels/Divisibility/L07_rewriting.lean:20 +msgid "Substituting known values with rw simplifies a monstrous divisibility goal." +msgstr "" + +#. §0: `rw [hx, hy]` +#. §1: `a ∣ 0` +#: Game/Levels/Divisibility/L07_rewriting.lean:28 +msgid "Crisis averted! Once §0 substituted the numbers, the entire right-hand side collapsed into zero, turning a scary polynomial into the simple §1 pattern from the previous level." +msgstr "" + +#: Game/Levels/Divisibility/L08_rewriting_backwards.lean:7 +msgid "Rewriting Backwards" msgstr "" #. §0: `rw [h]` @@ -402,7 +801,7 @@ msgstr "" #. §6: `rw [← h]` #. §7: `←` #. §8: `\\l` -#: Game.Levels.Divisibility.L08_rewriting_backwards +#: Game/Levels/Divisibility/L08_rewriting_backwards.lean:9 msgid "By default, §0 replaces the left-hand side of an equation §1 with its right-hand side.\n" "\n" "Here, our hypothesis is §2, and our goal is §3.\n" @@ -413,167 +812,210 @@ msgid "By default, §0 replaces the left-hand side of an equation §1 with its r "*(To type §7, write §8 and press Space.)*" msgstr "" -#: Game.Levels.LinCong -msgid "Linear Congruences and CRT" +#: Game/Levels/Divisibility/L08_rewriting_backwards.lean:20 +msgid "If a * k = b, then a divides b." msgstr "" -#. §0: $a$ -#. §1: `dvd_add_int` -#. §2: `rw [hk1, hk2]` -#. §3: `use k1 + k2` -#: Game.Levels.Divisors.L04_dvd_add -msgid "Awesome! You just proved that multiples of §0 are closed under addition (§1). Notice that it doesn't matter whether you §2 before or after §3 — both orders just work!" +#. §0: `rw [← h]` +#. §1: `a ∣ a * k` +#. §2: `use k` +#: Game/Levels/Divisibility/L08_rewriting_backwards.lean:25 +msgid "Nicely done! Rewriting backwards with §0 turned the goal into §1, where §2 could finish it in one step." msgstr "" -#. §0: `«{a}» * («{x0}» + «{t}» * «{m1}») = «{a}» * «{x0}» + («{a1}» * «{t}») * «{m}»` -#. §1: `mod_add_multiple` -#. §2: `«{a}» = «{a1}» * «{d}»` -#. §3: `«{m}» = «{m1}» * «{d}»` -#: Game.Levels.LinCong.L07_sol_shift -msgid "You want to show §0, so that §1 applies directly. Substitute §2 and §3" +#: Game/Levels/Divisibility.lean:14 +msgid "Divisibility Club" msgstr "" -#. §0: $a$ -#. §1: $b$ -#. §2: $a$ -#. §3: $a \\cdot b$ -#. §4: $k$ -#. §5: $a \\cdot b = a \\cdot k$ -#. §6: $k$ -#: Game.Levels.Divisibility.L03_dvd_mul_right -msgid "Now let's move from numerals to integer variables §0 and §1.\n" +#. §0: $a \\mid b$ +#. §1: `use` +#. §2: `ring` +#. §3: `rw` +#: Game/Levels/Divisibility.lean:16 +msgid "Welcome to World 1: The Divisibility Club!\n" "\n" -"We want to prove that §2 divides §3. By definition, this means finding some §4 such that §5.\n" -"Look closely at the equation — the witness §6 is hiding in plain sight!" +"In this first world, you will learn the basics of Lean 4, how to interact with the system, and how to write your very first formal proofs. Together, we will explore the fundamental concept of number theory: divisibility (§0).\n" +"\n" +"Starting from simple numerical examples, you will master essential proof tactics (§1, §2, and §3) and prove the first universal properties of divisibility.\n" +"\n" +"Take your time, read the explanations carefully, and have fun!" msgstr "" -#. §0: $b$ -#. §1: $k$ -#. §2: $a \\cdot b = a \\cdot b$ -#. §3: `use b` -#. §4: `dvd_mul_right_int` -#: Game.Levels.Divisibility.L03_dvd_mul_right -msgid "Easy! Since substituting §0 for §1 makes both sides of §2 completely identical, §3 closes the goal immediately.\n" -"\n" -"**New Theorem Unlocked!** Whenever you prove a general statement like this, it is saved in your **Theorems** tab on the right (this one is called §4). Take a look at the **Theorems** tab now — you can click on any theorem there to read its documentation and see how to reuse it in future proofs!" +#: Game/Levels/Divisors/L01_eq_zero_of_zero_dvd.lean:7 +msgid "Only Zero Is Divisible by Zero" msgstr "" -#. §0: $d$ -#. §1: $a$ -#. §2: $b$ -#. §3: `IsGCD(a, b) d` -#. §4: $d$ -#. §5: $d \\mid a$ -#. §6: $d \\mid b$ -#. §7: $d$ -#. §8: $x, y$ -#. §9: $a \\cdot x + b \\cdot y = d$ -#. §10: $$\\text{IsGCD}(a, b) d \\iff (d \\mid a \\land d \\mid b) \\land \\exists x, y \\in \\mathbb{Z},\\ a x + b y = d$$ -#. §11: $d$ -#. §12: $d \\geq 0$ -#. §13: $d$ -#. §14: `IsGCD(2, 3) 1` -#. §15: $1 \\mid 2$ -#. §16: $1 \\mid 3$ -#. §17: $2 \\cdot (-1) + 3 \\cdot 1 = 1$ -#. §18: `IsGCD(12, 18) 6` -#. §19: $6 \\mid 12$ -#. §20: $6 \\mid 18$ -#. §21: $12 \\cdot (-1) + 18 \\cdot 1 = 6$ -#. §22: `IsGCD(2, 3) (-1)` -#. §23: `IsGCD(a, b) d` -#. §24: `unfold IsGCD` -#. §25: `(d ∣ a ∧ d ∣ b) ∧ ∃ x y, a * x + b * y = d` -#. §26: `constructor` -#. §27: `∧` -#. §28: `use` -#. §29: `IsGCD(a, b) d` -#. §30: `have` -#. §31: `IsGCD a b d` -#. §32: `unfold IsGCD` -#: Game.Doc.Definitions -msgid "**The Greatest Common Divisor, Bézout-style**\n" -"\n" -"In this game, we say §0 **is a greatest common divisor** of §1 and §2 — written §3 — if **two** conditions hold together:\n" -"\n" -"1. §4 is a **common divisor**: §5 and §6.\n" -"2. §7 can be written as a **Bézout combination**: there exist integers §8 such that §9.\n" -"\n" -"§10\n" -"\n" -"**Intuition:**\n" -"Working with \"largest\" directly is awkward in Lean: comparing sizes doesn't play well with negative numbers, and proving something is *the* biggest usually means comparing it to every other common divisor one at a time. The Bézout condition sidesteps all of that. It turns out (and you will prove it in the very next level!) that *any* §11 satisfying condition 2, together with condition 1, is automatically bigger than every other common divisor — for free, with a short proof. So instead of taking \"greatest\" as the definition, we derive it as a theorem.\n" -"\n" -"This definition alone does not force §12 or force §13 to be unique. In this game we will always keep a specific, non-negative witness in mind.\n" +#. §0: $0$ +#. §1: `a ∣ 0` +#. §2: $0$ +#. §3: `0 ∣ a` +#. §4: $0$ +#. §5: `h : 0 ∣ a` +#. §6: `0 ∣ a` +#. §7: $k$ +#. §8: $a = 0 \\cdot k$ +#. §9: $k$ +#. §10: `h` +#. §11: `obtain` +#. §12: `obtain ⟨k, hk⟩ := h` +#. §13: `⟨` +#. §14: `⟩` +#. §15: `\\<` +#. §16: `\\>` +#. §17: `k` +#. §18: `hk : a = 0 * k` +#. §19: `rw [hk]` +#. §20: `ring` +#: Game/Levels/Divisors/L01_eq_zero_of_zero_dvd.lean:11 +msgid "In World 1, we proved that everything divides §0 (§1). What if we flip it around and ask what §2 can divide (§3)?\n" +"Only §4 itself!\n" "\n" -"**Examples:**\n" -"* §14, since §15, §16, and §17.\n" -"* §18, since §19, §20, and §21.\n" -"* §22 is *also* technically true, up to sign — in this game we always keep the non-negative witness in mind.\n" +"Notice a crucial difference here: §5 is now a **hypothesis**, not the goal.\n" +"Since §6 means there exists some §7 such that §8, how do we unpack that §9 from §10?\n" "\n" -"**How it works in Lean:**\n" -"When you see §23 in your goal, §24 reveals the raw conjunction: §25. Use §26 to split the outer §27, and §28 to supply the Bézout witnesses.\n" +"We use the §11 tactic! Type §12.\n" "\n" -"The notation §29 is just syntactic sugar to make the goals easier to read. When writing your own code (for example, when defining a new hypothesis with §30), you need to use the standard Lean syntax without parentheses or commas: §31.\n" +"*(To type §13 and §14, write §15 and §16, then press Space.)*\n" "\n" -"To work with this definition, use: §32" +"Lean will extract the witness §17 along with the equation §18. From there, §19 and §20 will finish the proof!" msgstr "" -#: Game.Levels.ModArith.L02_sub -msgid "Subtracting Congruences" +#: Game/Levels/Divisors/L01_eq_zero_of_zero_dvd.lean:25 +msgid "If 0 divides a, then a = 0." msgstr "" -#: Game.Levels.ModArith.L06_pow -msgid "Powers of Congruences" +#. §0: `a ∣ b` +#. §1: `use` +#. §2: `a ∣ b` +#. §3: `obtain` +#: Game/Levels/Divisors/L01_eq_zero_of_zero_dvd.lean:31 +msgid "Great work! Here is the golden rule of divisibility in Lean:\n" +"- When §0 is in the **goal**, you build it with §1.\n" +"- When §2 is in a **hypothesis**, you unpack it with §3." msgstr "" -#. §0: $a \\equiv b \\pmod m$ -#. §1: $b \\equiv c \\pmod m$ -#. §2: $a \\equiv c \\pmod m$ -#. §3: $a = b$ -#. §4: $b = c \\implies a = c$ -#: Game.Doc.Theorems.Congruence -msgid "**Transitivity of Modular Congruence**\n" +#: Game/Levels/Divisors/L02_multiples_of_6.lean:7 +msgid "Multiples of 6" +msgstr "" + +#. §0: $6$ +#. §1: $x$ +#. §2: `h : 6 ∣ x` +#. §3: $3$ +#. §4: $x$ +#. §5: `h` +#. §6: `obtain ⟨k, hk⟩ := h` +#. §7: `hk : x = 6 * k` +#. §8: $6 \\cdot k = 3 \\cdot (2 \\cdot k)$ +#. §9: `use` +#. §10: `3 ∣ x` +#: Game/Levels/Divisors/L02_multiples_of_6.lean:9 +msgid "Now let's combine unpacking a hypothesis with proving a new divisibility goal!\n" "\n" -"If §0 and §1, then §2.\n" +"Suppose §0 divides §1 (§2). Does §3 also divide §4?\n" +"Yes! Unpack §5 using §6 to get §7.\n" "\n" -"**Meaning:** This theorem proves that modular arithmetic is a true *equivalence relation*. It means you can chain congruences together step-by-step to reach a conclusion, exactly like you can chain regular equations (§3 and §4)." +"Since §8, what witness should you §9 to prove §10?" msgstr "" -#: Game.Levels.Divisibility.L05_dvd_refl -msgid "A Number Divides Itself" +#: Game/Levels/Divisors/L02_multiples_of_6.lean:18 +msgid "Every multiple of 6 is also a multiple of 3." msgstr "" -#: Game.Levels.ModArith -msgid "Modular Arithmetic" +#. §0: `obtain` +#. §1: `use` +#. §2: `rw` +#. §3: `ring` +#: Game/Levels/Divisors/L02_multiples_of_6.lean:25 +msgid "Spot on! This four-step rhythm — §0, §1, §2, §3 — is the bread and butter of divisibility proofs." msgstr "" -#. §0: $\\equiv \\pmod m$ -#. §1: $P(a) \\equiv P(b) \\pmod m$ -#: Game.Levels.ModArith -msgid "Welcome to Modular Arithmetic!\n" +#: Game/Levels/Divisors/L03_dvd_mul.lean:7 +msgid "A Divisor of a Factor Divides the Product" +msgstr "" + +#. §0: $d$ +#. §1: $a$ +#. §2: $d$ +#. §3: $a \\cdot b$ +#. §4: $b$ +#. §5: $a$ +#. §6: $d$ +#. §7: $a$ +#. §8: $d$ +#. §9: `obtain` +#. §10: `use` +#. §11: `rw` +#. §12: `ring` +#: Game/Levels/Divisors/L03_dvd_mul.lean:9 +msgid "Let's generalize the trick from the previous level into a universal building block.\n" "\n" -"In the Congruence world, you proved that §0 is an equivalence relation. Now we unlock its real algebraic power: you can safely add, subtract, multiply, and raise congruences to powers, just like regular equations!\n" +"If §0 divides §1, does §2 also divide §3 for *any* integer §4?\n" +"Yes! If §5 is a multiple of §6, then any multiple of §7 is automatically a multiple of §8 too.\n" "\n" -"By the end of this world, you will combine all of these operations to prove that **polynomials preserve congruences** (§1) — the master key to proving the classic divisibility rules!" +"You already have the exact four-step rhythm you need: §9 the witness from your hypothesis, §10 the right scaled witness for the new goal, §11, and finish with §12." msgstr "" -#. §0: $m$ -#. §1: $m$ -#. §2: $a \\equiv b \\pmod m$ -#. §3: $c$ -#. §4: $$a \\cdot c \\equiv b \\cdot c \\pmod{m \\cdot c}$$ -#: Game.Levels.Congruence.L07_mod_scale -msgid "So far, the modulus §0 has stayed fixed. What if we want to change the modulus §1 itself?\n" +#: Game/Levels/Divisors/L03_dvd_mul.lean:18 +msgid "If d divides a, then d divides a * b for any integer b." +msgstr "" + +#. §0: `a = d * k` +#. §1: `a * b` +#. §2: `d * (k * b)` +#. §3: `k` +#. §4: `b` +#: Game/Levels/Divisors/L03_dvd_mul.lean:21 +msgid "Once you know §0, substituting into §1 gives §2. So the multiplier the goal is asking for is your existing §3, scaled by §4." +msgstr "" + +#. §0: `dvd_mul_of_dvd_left_int` +#: Game/Levels/Divisors/L03_dvd_mul.lean:26 +msgid "Perfect! Keep §0 close at hand — you'll use this theorem again and again in future worlds." +msgstr "" + +#: Game/Levels/Divisors/L04_dvd_add.lean:7 +msgid "Sums of Multiples" +msgstr "" + +#. §0: $a$ +#. §1: $a \\mid b$ +#. §2: $a \\mid c$ +#. §3: $a$ +#. §4: $b + c$ +#. §5: `h1 : a ∣ b` +#. §6: `h2 : a ∣ c` +#. §7: `obtain` +#. §8: `obtain ⟨k1, hk1⟩ := h1` +#. §9: `obtain ⟨k2, hk2⟩ := h2` +#. §10: $b + c = a \\cdot k_1 + a \\cdot k_2 = a \\cdot (k_1 + k_2)$ +#. §11: `a ∣ b + c` +#: Game/Levels/Divisors/L04_dvd_add.lean:9 +msgid "What happens when we add two multiples of §0 together?\n" +"If §1 and §2, then §3 must also divide their sum §4.\n" "\n" -"If §2, then multiplying everything (including the modulus) by §3 preserves the congruence:\n" -"§4\n" +"This time you have **two** divisibility hypotheses: §5 and §6.\n" +"Unpack both of them using §7, making sure to give their witnesses different names:\n" +"- §8\n" +"- §9\n" "\n" -"Unfold the definition and look closely at the algebra you've got." +"Since §10, you can easily spot the witness for §11!" msgstr "" -#: Game.Levels.DivRules.L06_div3 -msgid "Beautiful. The structural similarity of mathematics really shines here." +#: Game/Levels/Divisors/L04_dvd_add.lean:21 +msgid "If a divides b and a divides c, then a divides b + c." +msgstr "" + +#. §0: $a$ +#. §1: `dvd_add_int` +#. §2: `rw [hk1, hk2]` +#. §3: `use k1 + k2` +#: Game/Levels/Divisors/L04_dvd_add.lean:29 +msgid "Awesome! You just proved that multiples of §0 are closed under addition (§1). Notice that it doesn't matter whether you §2 before or after §3 — both orders just work!" +msgstr "" + +#: Game/Levels/Divisors/L05_dvd_trans.lean:7 +msgid "Chain of Divisors" msgstr "" #. §0: $x$ @@ -593,7 +1035,7 @@ msgstr "" #. §14: $z = y \\cdot k_2$ #. §15: $x \\cdot k_1$ #. §16: $x$ -#: Game.Levels.Divisors.L05_dvd_trans +#: Game/Levels/Divisors/L05_dvd_trans.lean:9 msgid "If §0 divides §1, and §2 divides §3, does §4 divide §5?\n" "Yes! This fundamental property is called **transitivity**.\n" "\n" @@ -604,268 +1046,99 @@ msgid "If §0 divides §1, and §2 divides §3, does §4 divide §5?\n" "Now chain the two equations together: if you replace §13 inside §14 with §15, what multiplier is sitting next to §16?" msgstr "" -#. §0: `gcd_symm` -#: Game.Levels.GCD.L05_gcd_symm -msgid "Nice and easy! This lemma will be saved as §0. It will save you from doing boring manual variable-swapping when you tackle the Chinese Remainder Theorem later on." -msgstr "" - -#. §0: `gcd_is_greatest` -#. §1: `«{h1}»` -#. §2: `«{d2}» ∣ «{d1}»` -#: Game.Levels.GCD.L09_gcd_shift -msgid "Almost there! Apply §0 on §1 to show §2." -msgstr "" - -#: Game.Levels.GCD.L07_gcd_div_coprime -msgid "Dividing by the GCD Gives Coprime Numbers" -msgstr "" - -#. §0: `induction'` -#. §1: `n` -#. §2: `induction' n with d ih` -#. §3: `n = 0` -#. §4: `n = d + 1` -#. §5: `ih` -#: Game.Doc.Tactics -msgid "The §0 tactic is used to prove statements for all natural numbers §1.\n" -"Typing §2 splits your goal into two cases: the base case (§3) and the inductive step (§4), giving you the induction hypothesis §5." -msgstr "" - -#: Game.Levels.Congruence.L01_concrete -msgid "Concrete verification of modular congruence." -msgstr "" - -#: Game.Levels.LinCong.L01_inv_exists -msgid "Existence of the Inverse" -msgstr "" - -#. §0: $0 \\mid a$ -#. §1: $a = 0$ -#. §2: $0$ -#. §3: $a \\mid 0$ -#. §4: $0 \\cdot k = 0$ -#. §5: $k$ -#. §6: $0$ -#. §7: $0$ -#. §8: `h : 0 ∣ a` -#. §9: `eq_zero_of_zero_dvd_int a h` -#. §10: `a = 0` -#: Game.Doc.Theorems.Divisibility -msgid "**Only Zero Is Divisible by Zero**\n" -"\n" -"If §0, then §1.\n" -"\n" -"**Intuition:**\n" -"While every integer divides §2 (§3), the reverse is much stricter: since §4 for any §5, the only number that §6 can divide is §7 itself. In Lean, given §8, applying §9 yields §10." -msgstr "" - -#. §0: `one_dvd_int` -#: Game.Levels.GCD.L04_coprime_backward -msgid "Remember the theorem §0 from World 1? It proves that 1 divides everything." -msgstr "" - -#. §0: `IsGCD(c, m) 1` -#. §1: $x, y$ -#. §2: $c \\cdot x + m \\cdot y = 1$ -#: Game.Doc.Theorems.GCD -msgid "**Coprimality Implies a Bézout Identity**\n" -"\n" -"If §0, then there exist integers §1 with §2." -msgstr "" - -#: Game.Levels.Divisors.L01_eq_zero_of_zero_dvd -msgid "If 0 divides a, then a = 0." +#: Game/Levels/Divisors/L05_dvd_trans.lean:20 +msgid "Divisibility is transitive." msgstr "" -#: Game.Levels.LinCong.L02_inv_reverse -msgid "Inverse Implies Coprimality" +#. §0: `«{z}»` +#. §1: `«{x}»` +#. §2: `«{k1}»` +#. §3: `«{k2}»` +#. §4: `«{x}»` +#: Game/Levels/Divisors/L05_dvd_trans.lean:27 +msgid "The goal now expresses §0 purely in terms of §1, §2, and §3 — nothing else is left. Look at what's multiplying §4; that's the single witness the goal is asking you to supply." msgstr "" -#: Game -msgid "In this game, you will learn the foundations of number theory.\n" -"Starting with basic divisibility, you will construct a full toolkit for\n" -"modular arithmetic (congruences) and prove theorems like a real mathematician." +#. §0: `«{z}» = «{y}» * «{k2}»` +#. §1: `«{y}» = «{x}» * «{k1}»` +#. §2: `«{z}» = («{x}» * «{k1}») * «{k2}» = «{x}» * («{k1}» * «{k2}»)` +#. §3: `«{k1}»` +#. §4: `«{k2}»` +#. §5: `«{x}»` +#. §6: `«{z}»` +#: Game/Levels/Divisors/L05_dvd_trans.lean:29 +msgid "Think it through: §0, and §1, so §2. A single number built from §3 and §4 already turns §5 into §6 — that's the witness this goal wants." msgstr "" -#. §0: $a \\equiv b \\pmod m$ -#. §1: $c \\equiv d \\pmod m$ -#. §2: $$a - c \\equiv b - d \\pmod m$$ -#: Game.Levels.ModArith.L02_sub -msgid "Where addition goes, subtraction follows. If §0 and §1, then:\n" -"§2\n" +#. §0: $k_1$ +#. §1: $k_2$ +#. §2: `dvd_trans_int` +#: Game/Levels/Divisors/L05_dvd_trans.lean:35 +msgid "Brilliant! By multiplying the two witnesses §0 and §1, you proved that divisibility chains together seamlessly (§2).\n" "\n" -"This rule is what lets us move terms from one side of a congruence to the other, just like in standard equations." +"Now, one last challenge stands between you and the end of World 2!" msgstr "" -#. §0: `euclids_lemma` -#. §1: `«{m}» ∣ «{k2}»` -#: Game.Levels.LinCong.L10_crt_glue -msgid "Now apply §0 to extract a new witness showing that §1." +#: Game/Levels/Divisors/L06_dvd_lin_comb.lean:7 +msgid "Linear Combinations (Boss)" msgstr "" -#. §0: $d \\mid a$ -#. §1: $d \\mid (a \\cdot b)$ +#. §0: $a \\cdot x + b \\cdot y$ +#. §1: $a$ #. §2: $b$ -#. §3: $a$ -#. §4: $k$ -#. §5: $d$ -#. §6: $a = d \\cdot k$ -#. §7: $a \\cdot b$ -#. §8: $k \\cdot b$ -#. §9: $d$ -#. §10: $3 \\mid 6$ -#. §11: $3 \\mid (6 \\cdot 5) = 30$ -#. §12: $a \\cdot x + b \\cdot y = d$ -#. §13: $c$ -#. §14: $a$ -#. §15: $b$ -#. §16: $c$ -#. §17: $a \\cdot x$ -#. §18: $b \\cdot y$ -#: Game.Doc.Theorems.Divisibility -msgid "**A Divisor of a Factor Divides the Product**\n" -"\n" -"If §0, then §1 for any integer §2.\n" -"\n" -"**Intuition:**\n" -"If §3 is built out of §4 copies of §5 (i.e. §6), then §7 is built out of §8 copies of §9.\n" -"For example, §10, so §11 as well.\n" -"\n" -"This little lemma is a \"brick\" you will reuse constantly throughout the game: whenever you have a Bézout-style identity §12 and you know some §13 divides §14 or §15, this lemma lets you conclude §16 divides the whole term §17 or §18." -msgstr "" - -#. §0: $a \\equiv b \\pmod m$ -#. §1: $c \\equiv d \\pmod m$ -#. §2: $(a + c) \\equiv (b + d) \\pmod m$ -#. §3: $m$ -#. §4: $12 \\equiv 2 \\pmod{10}$ -#. §5: $25 \\equiv 5 \\pmod{10}$ -#. §6: $12 + 25 = 37$ -#. §7: $\\equiv 7 \\pmod{10}$ -#. §8: $2 + 5 = 7$ -#: Game.Doc.Theorems.Congruence -msgid "**Adding Congruences**\n" -"\n" -"If §0 and §1, then §2.\n" -"\n" -"**Intuition:**\n" -"If two pairs of numbers have the same remainder when divided by §3, their sums will also have the same remainder.\n" -"For example, modulo 10 (which just looks at the last digit):\n" -"If §4 and §5, then §6, which is §7.\n" -"Notice that §8. We just added the remainders safely!" -msgstr "" - -#. §0: $\\equiv$ -#. §1: $=$ -#. §2: $m$ -#. §3: $m$ -#. §4: $$a \\equiv a \\pmod m$$ -#: Game.Levels.Congruence.L02_mod_refl -msgid "Why did mathematicians invent the §0 symbol to look so much like §1? Because congruences obey almost all the same laws as standard equality!\n" -"\n" -"Over the next few levels, we will prove that congruence modulo §2 is an **equivalence relation**. The first requirement is **reflexivity**: every integer is congruent to itself modulo §3:\n" -"§4" -msgstr "" - -#. §0: $a \\equiv a \\pmod m$ -#: Game.Doc.Theorems.Congruence -msgid "**Reflexivity of Congruences**\n" -"\n" -"Every integer is congruent to itself: §0." -msgstr "" - -#. §0: `have h1 : 17 ≡ 2 (mod 5)` -#: Game.Levels.Problems.L01_large_powers -msgid "Start by proving the base congruences. Create a hypothesis §0." -msgstr "" - -#: Game.Levels.DivRules -msgid "Divisibility Rules" -msgstr "" - -#. §0: $a \\cdot c \\equiv b \\cdot c \\pmod m$ -#. §1: `IsGCD(c, m) d` -#. §2: $d \\neq 0$ -#. §3: $c = c_1 \\cdot d$ -#. §4: $m = m_1 \\cdot d$ -#. §5: $a \\equiv b \\pmod{m_1}$ -#. §6: $c$ -#. §7: $c$ -#. §8: $m$ -#. §9: $d$ -#. §10: `IsGCD(c, m) d` -#. §11: $d = 1$ -#: Game.Doc.Theorems.GCD -msgid "**The General Cancellation Law**\n" -"\n" -"If §0, §1 with §2, §3 and §4, then §5.\n" -"\n" -"**Intuition:**\n" -"This is the fully general version of \"dividing\" a congruence: you can always cancel a factor §6 out of a congruence, as long as you also divide the modulus by whatever §7 and §8 have in common (§9, where §10). The coprime case (Level 6) is just the special case §11, where the modulus doesn't need to shrink at all." -msgstr "" - -#. §0: $a \\equiv b \\pmod{m \\cdot n}$ -#. §1: $$a \\equiv b \\pmod m \\quad \\text{AND} \\quad a \\equiv b \\pmod n$$ -#. §2: `∧` -#. §3: `P ∧ Q` -#. §4: `constructor` -#. §5: `P` -#. §6: `Q` -#: Game.Levels.Congruence.L09_mod_split -msgid "Welcome to the final boss of World 3!\n" -"\n" -"If §0, then the congruence holds modulo each factor individually:\n" -"§1\n" +#. §3: $d$ +#. §4: $a$ +#. §5: $b$ +#. §6: $d$ +#. §7: $a \\cdot x + b \\cdot y$ +#. §8: $d \\mid a \\implies d \\mid a \\cdot x$ +#. §9: $d \\mid u$ +#. §10: $d \\mid v \\implies d \\mid u + v$ +#. §11: `ha` +#. §12: `hb` +#. §13: `obtain` +#: Game/Levels/Divisors/L06_dvd_lin_comb.lean:9 +msgid "Welcome to the final boss of World 2!\n" "\n" -"Notice that your goal is a logical conjunction (§2). In Lean, whenever you need to prove §3, use the **§4** tactic to split the goal into two separate subgoals: first prove §5, then prove §6.\n" +"An expression of the form §0 is called a **linear combination** of §1 and §2.\n" +"Here you will prove one of the most important facts in all of number theory: if §3 divides both §4 and §5, then §6 divides **any** linear combination §7!\n" "\n" -"How you prove each half — whether by unfolding definitions directly or by reusing theorems you've already built — is entirely up to you!" -msgstr "" - -#: Game.Levels.Problems.L06_shrink_shift -msgid "Masterfully done! You used divisibility to shrink the modulus, manually computed a small remainder, and used transitivity to glue it all together.\n" +"This combines the scaling principle from Level 3 (§8) with the addition principle from Level 4 (§9 and §10) into a single proof.\n" "\n" -"This is exactly how number theory problems are solved in practice." +"Unpack both §11 and §12 with §13, substitute them into the goal, and construct the combined witness!" msgstr "" - -#. §0: $a \\cdot c \\equiv b \\cdot c \\pmod m$ -#. §1: `IsGCD(c, m) d` -#. §2: $d \\neq 0$ -#. §3: $c = c_1 \\cdot d$ -#. §4: $m = m_1 \\cdot d$ -#. §5: $a \\equiv b \\pmod{m_1}$ -#. §6: `IsGCD(a, b) d` -#. §7: `have` -#. §8: `IsGCD a b d` -#. §9: `gcd_div_coprime` -#. §10: `IsGCD(c_1, m_1) 1` -#. §11: $c = c_1 \\cdot d$ -#. §12: $m = m_1 \\cdot d$ -#. §13: $d$ -#. §14: `mul_left_cancel₀` -#. §15: `have h1' : (a * c1) ≡ (b * c1) (mod m1)` -#. §16: `ModEq` -#. §17: `mod_cancel_coprime` -#. §18: `have` -#. §19: `exact` -#: Game.Levels.GCD.L08_cancel_general -msgid "Time to combine the last two levels into the *fully general* cancellation law — no coprimality assumption required!\n" -"\n" -"If §0 and §1 with §2, and we write §3, §4 (exactly as in Level 7), then §5.\n" -"\n" -"**Lean Syntax Tip:** The notation §6 is just syntactic sugar to make the goals easier to read. When writing your own code (for example, when defining a new hypothesis with §7), you need to use the standard Lean syntax without parentheses or commas: §8.\n" + +#: Game/Levels/Divisors/L06_dvd_lin_comb.lean:20 +msgid "If d divides a and b, then d divides any linear combination a * x + b * y." +msgstr "" + +#. §0: `a = d * k1` +#. §1: `b = d * k2` +#. §2: `a * x + b * y` +#. §3: `(d * k1) * x + (d * k2) * y` +#. §4: `d` +#. §5: `use` +#: Game/Levels/Divisors/L06_dvd_lin_comb.lean:24 +msgid "Once you substitute §0 and §1, the sum §2 becomes §3. Factor out §4 to see what witness to §5!" +msgstr "" + +#. §0: $k_1 \\cdot x + k_2 \\cdot y$ +#. §1: `dvd_lin_comb_int` +#. §2: `use` +#. §3: `obtain` +#. §4: `rw` +#. §5: `ring` +#: Game/Levels/Divisors/L06_dvd_lin_comb.lean:29 +msgid "🎉 INCREDIBLE! 🎉\n" "\n" -"**Strategy:** Assemble, don't reprove.\n" -"1. Apply §9 (Level 7) to get §10.\n" -"2. Unfold the congruence hypothesis, substitute §11 and §12, and cancel the shared factor §13 (using §14 again). This will leave you with a plain algebraic equation!\n" -"3. **Reassemble the congruence:** create the specific hypothesis you need using §15. Prove it by unfolding §16 and using the cancelled equation from step 2.\n" -"4. Feed both pieces into §17 (Level 6) to finish in one line!\n" +"You have conquered World 2! By combining scaling and addition of witnesses into §0, you proved that common divisors always divide linear combinations (§1) — a theorem that will later power Bézout's Identity and the Greatest Common Divisor.\n" "\n" -"Build small intermediate facts with §18, then §19 the final theorem!" +"You've mastered the foundational tactics §2, §3, §4, and §5.\n" +"Get ready for World 3, where we will introduce a massive new concept built directly on divisibility: **Modular Congruences**!" msgstr "" -#: Game.Levels.Problems.L08_system -msgid "System of Congruences (Boss)" +#: Game/Levels/Divisors.lean:9 +msgid "Algebra of Divisors" msgstr "" #. §0: `a ∣ b` @@ -873,7 +1146,7 @@ msgstr "" #. §2: `a ∣ b` #. §3: `obtain` #. §4: $d \\mid a \\cdot x + b \\cdot y$ -#: Game.Levels.Divisors +#: Game/Levels/Divisors.lean:11 msgid "Welcome to World 2: Algebra of Divisors!\n" "\n" "In World 1, you learned how to prove the divisibility goal §0 by supplying a witness with §1.\n" @@ -882,1656 +1155,1623 @@ msgid "Welcome to World 2: Algebra of Divisors!\n" "In this world, you will unlock the §3 tactic to extract witnesses from your hypotheses. Using it, you will build a toolkit of algebraic rules showing how divisibility behaves across products, sums, chains (transitivity), and finally **linear combinations** (§4) — the cornerstone for Bézout's identity and the GCD!" msgstr "" -#. §0: $a \\equiv b \\pmod m$ -#. §1: $n$ -#. §2: $$a^n \\equiv b^n \\pmod m$$ -#. §3: $n$ -#. §4: $n \\in \\mathbb{N}$ -#. §5: `induction' n with d ih` -#. §6: $n = 0$ -#. §7: $a^0 \\equiv b^0 \\pmod m$ -#. §8: $d$ -#. §9: `ih` -#. §10: $d + 1$ -#. §11: `rw [pow_succ]` -#. §12: $a^{d+1}$ -#. §13: $a^d \\cdot a$ -#. §14: $b^{d+1}$ -#. §15: $b^d \\cdot b$ -#. §16: `mod_mul` -#: Game.Levels.ModArith.L06_pow -msgid "Since we can multiply congruences, what happens if we multiply a congruence §0 by itself §1 times? We get powers:\n" -"§2\n" +#. §0: $a \\equiv a \\pmod m$ +#: Game/Doc/Theorems/Congruence.lean:4 +msgid "**Reflexivity of Congruences**\n" "\n" -"Because the exponent §3 is an arbitrary natural number (§4), we must prove this using **mathematical induction**.\n" +"Every integer is congruent to itself: §0." +msgstr "" + +#. §0: $m \\mid a$ +#. §1: $a \\equiv 0 \\pmod m$ +#. §2: $m$ +#. §3: $0$ +#. §4: $m$ +#: Game/Doc/Theorems/Congruence.lean:12 +msgid "**Divisible Means Congruent to Zero**\n" "\n" -"Type §5 to split the proof into two goals:\n" -"1. **Base case (§6):** Prove §7.\n" -"2. **Inductive step:** Assuming the statement holds for §8 (hypothesis §9), prove it for §10.\n" +"If §0, then §1.\n" "\n" -"*Tip:* In the inductive step, use §11 (twice!) to rewrite §12 as §13 and §14 as §15, then finish with §16!" +"**Intuition:**\n" +"Being divisible by §2 is the exact same thing as leaving a remainder of §3 modulo §4." msgstr "" #. §0: $a \\equiv b \\pmod m$ -#. §1: $a$ -#. §2: $b$ -#. §3: $d$ +#. §1: $b \\equiv a \\pmod m$ +#. §2: $a$ +#. §3: $b$ #. §4: $m$ -#. §5: $$d \\mid m \\implies a \\equiv b \\pmod d$$ -#. §6: `unfold ModEq at *` -#. §7: `h2 : d ∣ m` -#. §8: `h1 : m ∣ a - b` -#. §9: `d ∣ a - b` -#. §10: `h1` -#. §11: `h2` -#. §12: `obtain` -#. §13: `dvd_trans_int` -#. §14: `exact` -#. §15: `dvd_trans_int (x y z : ℤ) (h1 : x ∣ y) (h2 : y ∣ z) : x ∣ z` -#. §16: `exact` -#. §17: `a - b` -#. §18: `exact dvd_trans_int d m (a - b) h2 h1` -#: Game.Levels.Congruence.L08_mod_dvd -msgid "Think of a 12-hour clock: if two events happen at the same hour on a 12-hour cycle, they also line up on a 6-hour or 4-hour cycle.\n" -"In general, if §0, then §1 and §2 remain congruent modulo any divisor §3 of §4:\n" -"§5\n" -"\n" -"Once you run §6, look at what you have:\n" -"- §7\n" -"- §8\n" -"- Goal: §9\n" -"\n" -"We *could* unpack §10 and §11 with §12, or we can reuse §13 from World 2!\n" +#. §5: $b$ +#. §6: $a$ +#. §7: $17 \\equiv 5 \\pmod{12}$ +#. §8: $17 - 5 = 12$ +#. §9: $5 \\equiv 17 \\pmod{12}$ +#. §10: $5 - 17 = -12$ +#. §11: $12$ +#. §12: $12 \\cdot -1$ +#: Game/Doc/Theorems/Congruence.lean:23 +msgid "**Symmetry of Congruences**\n" "\n" -"**How to apply theorems (§14):**\n" -"Check the **Theorems** tab on the right. A theorem's signature tells you what inputs it expects and in what order:\n" -"§15\n" -"Whenever a theorem directly matches your goal, you can close the goal in one step using **§16**, followed by the theorem's name and its arguments separated by spaces.\n" +"If §0, then §1.\n" "\n" -"**Syntax Tip: Parentheses!**\n" -"When passing a compound expression like §17 as a single argument, you **must** wrap it in parentheses:\n" -"§18" -msgstr "" - -#: Game.Levels.LinCong.L06_sol_equiv -msgid "Congruent Solutions" +"**Intuition:**\n" +"If the difference between §2 and §3 is a multiple of §4, the difference between §5 and §6 is just the same multiple with a negative sign.\n" +"For example, §7 because §8.\n" +"Conversely, §9 because §10, which is still a multiple of §11 (§12)." msgstr "" -#. §0: $a \\cdot x \\equiv 1 \\pmod m$ -#. §1: $x$ -#. §2: $\\text{IsGCD}(a, m) 1$ -#: Game.Doc.Theorems.LinCong -msgid "**Reverse Inverse**\n" +#. §0: $a \\equiv b \\pmod m$ +#. §1: $b \\equiv c \\pmod m$ +#. §2: $a \\equiv c \\pmod m$ +#. §3: $a = b$ +#. §4: $b = c \\implies a = c$ +#: Game/Doc/Theorems/Congruence.lean:36 +msgid "**Transitivity of Modular Congruence**\n" "\n" -"If §0 for some §1, then §2." -msgstr "" - -#. §0: `have` -#. §1: `at *` -#: Game.Levels.Congruence.L04_mod_symm -msgid "Beautiful! You used §0 to build a bridge between the algebra you had and the algebra you needed, and learned how to modify everything at once with §1." +"If §0 and §1, then §2.\n" +"\n" +"**Meaning:** This theorem proves that modular arithmetic is a true *equivalence relation*. It means you can chain congruences together step-by-step to reach a conclusion, exactly like you can chain regular equations (§3 and §4)." msgstr "" -#: Game.Levels.DivRules.L05_div9 -msgid "Divisibility by 9 (The Magic of Polynomials)" +#. §0: $a \\equiv b \\pmod m$ +#. §1: $c \\equiv d \\pmod m$ +#. §2: $(a + c) \\equiv (b + d) \\pmod m$ +#. §3: $m$ +#. §4: $12 \\equiv 2 \\pmod{10}$ +#. §5: $25 \\equiv 5 \\pmod{10}$ +#. §6: $12 + 25 = 37$ +#. §7: $\\equiv 7 \\pmod{10}$ +#. §8: $2 + 5 = 7$ +#: Game/Doc/Theorems/Congruence.lean:46 +msgid "**Adding Congruences**\n" +"\n" +"If §0 and §1, then §2.\n" +"\n" +"**Intuition:**\n" +"If two pairs of numbers have the same remainder when divided by §3, their sums will also have the same remainder.\n" +"For example, modulo 10 (which just looks at the last digit):\n" +"If §4 and §5, then §6, which is §7.\n" +"Notice that §8. We just added the remainders safely!" msgstr "" #. §0: $a \\equiv b \\pmod m$ -#. §1: $d \\mid m$ -#. §2: $a \\equiv b \\pmod d$ -#: Game.Doc.Theorems.Congruence -msgid "**Shrinking the Modulus**\n" +#. §1: $c \\equiv d \\pmod m$ +#. §2: $(a - c) \\equiv (b - d) \\pmod m$ +#: Game/Doc/Theorems/Congruence.lean:60 +msgid "**Subtracting Congruences**\n" "\n" "If §0 and §1, then §2." msgstr "" -#: Game.Levels.DivRules.L04_div4 -msgid "The remainder modulo 4 depends only on the last two digits." -msgstr "" - -#. §0: $0$ -#. §1: `a ∣ 0` -#. §2: $0$ -#. §3: `0 ∣ a` -#. §4: $0$ -#. §5: `h : 0 ∣ a` -#. §6: `0 ∣ a` -#. §7: $k$ -#. §8: $a = 0 \\cdot k$ -#. §9: $k$ -#. §10: `h` -#. §11: `obtain` -#. §12: `obtain ⟨k, hk⟩ := h` -#. §13: `⟨` -#. §14: `⟩` -#. §15: `\\<` -#. §16: `\\>` -#. §17: `k` -#. §18: `hk : a = 0 * k` -#. §19: `rw [hk]` -#. §20: `ring` -#: Game.Levels.Divisors.L01_eq_zero_of_zero_dvd -msgid "In World 1, we proved that everything divides §0 (§1). What if we flip it around and ask what §2 can divide (§3)?\n" -"Only §4 itself!\n" -"\n" -"Notice a crucial difference here: §5 is now a **hypothesis**, not the goal.\n" -"Since §6 means there exists some §7 such that §8, how do we unpack that §9 from §10?\n" -"\n" -"We use the §11 tactic! Type §12.\n" -"\n" -"*(To type §13 and §14, write §15 and §16, then press Space.)*\n" +#. §0: $a \\equiv b \\pmod m$ +#. §1: $(a + c) \\equiv (b + c) \\pmod m$ +#. §2: $c$ +#: Game/Doc/Theorems/Congruence.lean:68 +msgid "**Adding a Constant**\n" "\n" -"Lean will extract the witness §17 along with the equation §18. From there, §19 and §20 will finish the proof!" -msgstr "" - -#: Game.Levels.Congruence.L02_mod_refl -msgid "Modular Arithmetic: Reflexivity" -msgstr "" - -#. §0: `«{m}» ∣ («{a}» * «{x}» - 1)` -#. §1: `«{hxy}»` -#. §2: `«{a}» * «{x}» - 1 = -«{m}» * «{y}»` -#. §3: `use -«{y}»` -#: Game.Levels.LinCong.L01_inv_exists -msgid "Your goal is §0. From §1 you know §2, so try §3." -msgstr "" - -#: Game.Levels.DivRules.L07_div11 -msgid "Divisibility by 11 (Boss)" -msgstr "" - -#: Game.Levels.Divisors.L06_dvd_lin_comb -msgid "Linear Combinations (Boss)" +"If §0, then §1 for any integer §2." msgstr "" -#. §0: `obtain` -#. §1: `use` -#. §2: `rw` -#. §3: `ring` -#: Game.Levels.Divisors.L02_multiples_of_6 -msgid "Spot on! This four-step rhythm — §0, §1, §2, §3 — is the bread and butter of divisibility proofs." +#. §0: $a \\equiv b \\pmod m$ +#. §1: $a \\cdot c \\equiv b \\cdot c \\pmod m$ +#: Game/Doc/Theorems/Congruence.lean:76 +msgid "**Multiplying by a Constant**\n" +"\n" +"If §0, then §1." msgstr "" -#. §0: $c_2$ -#. §1: $c_1$ -#. §2: $c_0$ -#. §3: $c_2 \\cdot 10^2 + c_1 \\cdot 10 + c_0$ -#. §4: $c_2 \\cdot 1^2 + c_1 \\cdot 1 + c_0$ -#. §5: $10 \\equiv 1 \\pmod 9$ -#. §6: `polynomial_cong` -#: Game.Levels.DivRules.L05_div9 -msgid "Here is the famous rule: \"A number is divisible by 9 if the sum of its digits is divisible by 9\".\n" -"\n" -"To prove this, we need a formal way to write a number digit by digit. Think about how our base-10 system works. A 3-digit number like **345** is literally **3 * 100 + 4 * 10 + 5**.\n" -"If we call the individual digits §0, §1, and §2, the number is written exactly as §3.\n" -"\n" -"Notice anything? This is a polynomial evaluated at 10!\n" -"We want to show it is congruent to the sum of its digits: §4, which is the exact same polynomial evaluated at 1.\n" +#. §0: $a \\equiv b \\pmod m$ +#. §1: $c \\equiv d \\pmod m$ +#. §2: $(a \\cdot c) \\equiv (b \\cdot d) \\pmod m$ +#. §3: $12 \\equiv 2$ +#. §4: $13 \\equiv 3$ +#. §5: $12 \\cdot 13 = 156$ +#. §6: $156 \\equiv 6 \\pmod{10}$ +#. §7: $2 \\cdot 3$ +#. §8: $6$ +#: Game/Doc/Theorems/Congruence.lean:84 +msgid "**Multiplying Congruences**\n" "\n" -"Since §5, your ultimate weapon §6 from Modular Arithmetic will solve this instantly.\n" +"If §0 and §1, then §2.\n" "\n" -"*(We prove this here for 3-digit numbers as a clean, concrete illustration — the exact same argument, with a longer polynomial, proves it for numbers of any length.)*" +"**Intuition:**\n" +"Just like addition, you can multiply remainders directly!\n" +"Modulo 10: §3 and §4.\n" +"If we multiply them: §5.\n" +"And §6. Notice that §7 is exactly §8." msgstr "" #. §0: $k$ -#: Game.Levels.Congruence.L07_mod_scale -msgid "Nice! Notice how the witness §0 didn't even need to change!" +#. §1: $a + k \\cdot m \\equiv a \\pmod m$ +#: Game/Doc/Theorems/Congruence.lean:98 +msgid "**Shifting by a Multiple of the Modulus**\n" +"\n" +"For any integer §0: §1." msgstr "" -#: Game.Levels.Problems.L07_quadratic -msgid "Quadratic Congruence" +#. §0: `pow_succ` +#. §1: $a^{n+1} = a^n \\cdot a$ +#. §2: `rw [pow_succ]` +#: Game/Doc/Theorems/Congruence.lean:106 +msgid "§0 is a theorem from Mathlib that states §1.\n" +"Use §2 when dealing with powers in induction." msgstr "" -#: Game.Levels.Problems.L05_euclid -msgid "Euclid in Practice" +#. §0: $a \\equiv b \\pmod m$ +#. §1: $a^n \\equiv b^n \\pmod m$ +#. §2: $n$ +#: Game/Doc/Theorems/Congruence.lean:113 +msgid "**Powers of Congruences**\n" +"\n" +"If §0, then §1 for any natural number §2." msgstr "" -#. §0: $m \\mid (a \\cdot c)$ -#. §1: $\\text{gcd}(c, m) = 1$ -#. §2: $m \\mid a$ -#. §3: $m \\mid (a \\cdot c)$ -#. §4: $a \\cdot c \\equiv 0 \\cdot c \\pmod m$ -#. §5: $c$ -#. §6: $m$ -#. §7: $c$ -#. §8: `mod_cancel_coprime` -#: Game.Levels.LinCong.L08_euclid -msgid "We are about to build the Chinese Remainder Theorem, but first, we need a legendary stepping stone: **Euclid's Lemma**.\n" -"\n" -"If §0 and §1, then §2.\n" +#. §0: $a \\equiv b \\pmod m$ +#. §1: $a \\cdot c \\equiv b \\cdot c \\pmod{m \\cdot c}$ +#: Game/Doc/Theorems/Congruence.lean:121 +msgid "**Scaling the Modulus**\n" "\n" -"Notice that §3 is exactly the same as saying §4.\n" -"Since §5 is coprime to §6, can we just cancel §7? Yes, you have §8!" +"If §0, then §1." msgstr "" -#. §0: `«{a}» * «{x}» - 1 = «{m}» * «{k}»` -#. §1: `«{a}» * «{x}» + «{m}» * (-«{k}») = 1` -#. §2: `«{x}»` -#. §3: `«{k}»` -#: Game.Levels.LinCong.L02_inv_reverse -msgid "You know §0. Rearranged, §1 — exactly a Bézout identity for 1, using the same §2 and the negation of §3." +#. §0: $a \\equiv b \\pmod m$ +#. §1: $d \\mid m$ +#. §2: $a \\equiv b \\pmod d$ +#: Game/Doc/Theorems/Congruence.lean:129 +msgid "**Shrinking the Modulus**\n" +"\n" +"If §0 and §1, then §2." msgstr "" -#. §0: `mod_add_multiple` -#. §1: `mod_shrink` -#. §2: `polynomial_cong` -#: Game.Levels.DivRules -msgid "Welcome to Divisibility Rules!\n" +#. §0: $a \\equiv b \\pmod{m \\cdot n}$ +#. §1: $a \\equiv b \\pmod m$ +#. §2: $a \\equiv b \\pmod n$ +#. §3: $(a - b)$ +#. §4: $15$ +#. §5: $3 \\cdot 5$ +#. §6: $3$ +#. §7: $5$ +#: Game/Doc/Theorems/Congruence.lean:137 +msgid "**Splitting the Modulus**\n" "\n" -"Do you remember learning divisibility rules in school? \"A number is divisible by 9 if the sum of its digits is divisible by 9\", or \"A number is divisible by 10 if it ends in 0\".\n" +"If §0, then §1 and §2.\n" "\n" -"In this world, we won't just memorize these rules — we will prove them! With §0, §1, and §2 in your toolkit, you'll see how all of these classic rules fall out in just a couple of lines." +"**Intuition:**\n" +"If a difference §3 is a multiple of §4 (§5), it must logically be a multiple of §6 and a multiple of §7.\n" +"So if two numbers are congruent modulo 15, they are automatically congruent modulo 3 and modulo 5.\n" +"This is a crucial stepping stone towards the Chinese Remainder Theorem!" msgstr "" -#. §0: $k_1$ -#. §1: $k_2$ -#. §2: `dvd_trans_int` -#: Game.Levels.Divisors.L05_dvd_trans -msgid "Brilliant! By multiplying the two witnesses §0 and §1, you proved that divisibility chains together seamlessly (§2).\n" +#. §0: $a \\equiv b \\pmod m$ +#. §1: $P(a) \\equiv P(b) \\pmod m$ +#. §2: $P$ +#. §3: $m$ +#. §4: $m$ +#: Game/Doc/Theorems/Congruence.lean:150 +msgid "**Polynomial Congruences**\n" "\n" -"Now, one last challenge stands between you and the end of World 2!" -msgstr "" - -#. §0: $b/d$ -#. §1: $x$ -#: Game.Levels.LinCong.L05_sol_suff -msgid "Beautiful! You multiplied the Bézout coefficients by §0 to constructively find the solution §1." +"If §0, then §1 for any integer polynomial §2.\n" +"\n" +"**Intuition:**\n" +"This is the reason modular arithmetic is genuinely useful and not just a curiosity: congruence mod §3 is compatible with *every* polynomial operation, so you can reduce numbers mod §4 at any point in a calculation without changing the final remainder. It's what makes \"clock arithmetic\" behave like real arithmetic." msgstr "" -#: Game.Levels.GCD.L01_gcd_def -msgid "Meeting the GCD" +#: Game/Levels/Congruence/L01_concrete.lean:14 +msgid "Your First Congruence" msgstr "" -#. §0: `lin_cong_suff` -#. §1: $x = u \\cdot (b/d) = 3 \\cdot 3 = 9$ -#. §2: $5 \\cdot 9 = 45 \\equiv 3 \\pmod 7$ -#: Game.Levels.Problems.L04_lincong -msgid "Excellent! The theorem constructed the solution under the hood.\n" +#. §0: $m$ +#. §1: $a \\equiv b \\pmod m$ +#. §2: $m$ +#. §3: $(a - b)$ +#. §4: `a ≡ b (mod m)` +#. §5: `≡` +#. §6: `\\==` +#. §7: `unfold ModEq` +#. §8: $17 \\equiv 5 \\pmod 6$ +#: Game/Levels/Congruence/L01_concrete.lean:19 +msgid "Welcome to World 3! Here we introduce one of the most powerful ideas in number theory: **Congruences**.\n" "\n" -"If you trace the algebra of §0, it gives §1, and indeed §2. Abstract theory gives concrete results!" -msgstr "" - -#. §0: $a \\mid b$ -#. §1: $a \\mid c$ -#. §2: $a \\mid (b + c)$ -#. §3: $a$ -#. §4: $b$ -#. §5: $k_1$ -#. §6: $a$ -#. §7: $c$ -#. §8: $k_2$ -#. §9: $a$ -#. §10: $b + c$ -#. §11: $k_1 + k_2$ -#. §12: $a$ -#. §13: `h1 : a ∣ b` -#. §14: `h2 : a ∣ c` -#. §15: `dvd_add_int a b c h1 h2` -#. §16: `a ∣ b + c` -#: Game.Doc.Theorems.Divisibility -msgid "**Sums of Multiples**\n" +"Often, we don't care about a number itself, only about the remainder it leaves when divided by some modulus §0 — just like reading a 12-hour clock. Formally, we say that §1 if §2 divides their difference §3.\n" "\n" -"If §0 and §1, then §2.\n" +"In Lean, this is written as §4 (to type §5, write §6 and press Space). Check your **Definitions** tab for more details!\n" "\n" -"**Intuition:**\n" -"Multiples of §3 are closed under addition. If §4 is made of §5 blocks of §6 and §7 is made of §8 blocks of §9, then their sum §10 is made of §11 blocks of §12. In Lean, given §13 and §14, §15 proves §16." +"Whenever you see this notation, type §7 to reveal the divisibility statement hiding underneath. Let's test it out on a concrete example: show that §8." msgstr "" -#: Game.Levels.ModArith.L03_add_const -msgid "Adding a constant to both sides of a congruence." +#: Game/Levels/Congruence/L01_concrete.lean:29 +msgid "Concrete verification of modular congruence." msgstr "" -#. §0: $m/d$ -#: Game.Doc.Theorems.LinCong -msgid "**Shifting the Solution**\n" -"\n" -"Any shift of a solution by a multiple of §0 yields another valid solution." +#. §0: $17 - 5 = 12 = 6 \\cdot 2$ +#: Game/Levels/Congruence/L01_concrete.lean:35 +msgid "Congratulations on proving your first congruence!\n" +"Because §0, 17 and 5 leave the exact same remainder when divided by 6.\n" +"Now let's leave specific numbers behind and build the general theory!" msgstr "" -#. §0: `«{d1}» ∣ «{a}»` -#. §1: `«{d1}» ∣ «{m}»` -#. §2: `gcd_is_greatest` -#. §3: `«{h2}»` -#. §4: `«{d1}» ∣ «{d2}»` -#: Game.Levels.GCD.L09_gcd_shift -msgid "Now that you know §0 and §1, use the theorem §2 (from Level 2) on §3 to show that §4." +#: Game/Levels/Congruence/L02_mod_refl.lean:7 +msgid "Modular Arithmetic: Reflexivity" msgstr "" -#. §0: $x, y$ -#. §1: $c \\cdot x + m \\cdot y = 1$ -#. §2: `IsGCD(c, m) 1` -#: Game.Doc.Theorems.GCD -msgid "**A Bézout Identity with 1 Implies Coprimality**\n" +#. §0: $\\equiv$ +#. §1: $=$ +#. §2: $m$ +#. §3: $m$ +#. §4: $$a \\equiv a \\pmod m$$ +#: Game/Levels/Congruence/L02_mod_refl.lean:9 +msgid "Why did mathematicians invent the §0 symbol to look so much like §1? Because congruences obey almost all the same laws as standard equality!\n" "\n" -"If there exist integers §0 with §1, then §2." +"Over the next few levels, we will prove that congruence modulo §2 is an **equivalence relation**. The first requirement is **reflexivity**: every integer is congruent to itself modulo §3:\n" +"§4" msgstr "" -#: Game.Levels.ModArith.L06_pow -msgid "Powers of congruences." +#: Game/Levels/Congruence/L02_mod_refl.lean:16 +msgid "Every integer is congruent to itself." msgstr "" -#: Game.Levels.DivRules.L02_div2 -msgid "Nice! Exactly the same logic applies to 5, since 5 ∣ 10 too — that's exactly what the next level does." +#. §0: $a - a = 0$ +#. §1: $m \\mid 0$ +#. §2: $a \\equiv a \\pmod m$ +#: Game/Levels/Congruence/L02_mod_refl.lean:22 +msgid "Great! Because §0, and §1, it immediately follows that §2.\n" +"One property down, two to go." msgstr "" -#: Game.Levels.GCD.L05_gcd_symm -msgid "The GCD is symmetric." +#: Game/Levels/Congruence/L03_dvd_imp_mod_zero.lean:7 +msgid "Divisible Means Congruent to Zero" msgstr "" -#: Game.Levels.ModArith.L07_poly -msgid "Polynomials preserve congruences." +#. §0: $a$ +#. §1: $m$ +#. §2: $a$ +#. §3: $m$ +#. §4: $0$ +#. §5: $a \\equiv 0 \\pmod m$ +#: Game/Levels/Congruence/L03_dvd_imp_mod_zero.lean:9 +msgid "Before continuing with equivalence relations, let's build a direct bridge between divisibility and congruences.\n" +"\n" +"What does it mean for a number §0 to be divisible by §1 in the language of congruences? It simply means that dividing §2 by §3 leaves a remainder of §4 — or in other words, §5." msgstr "" -#. §0: $d \\mid b$ -#: Game.Levels.LinCong.L04_sol_nec -msgid "Nice! You successfully extracted the divisibility parts of the GCD to prove §0." +#: Game/Levels/Congruence/L03_dvd_imp_mod_zero.lean:15 +msgid "Divisibility implies congruence to zero modulo m." msgstr "" -#: Game.Levels.Divisibility.L06_dvd_zero -msgid "Any integer divides zero." +#. §0: $a \\equiv 0 \\pmod m$ +#. §1: $m$ +#. §2: $a$ +#: Game/Levels/Congruence/L03_dvd_imp_mod_zero.lean:23 +msgid "Divisibility and congruence to zero are two sides of the same coin!\n" +"Whenever you see §0, you can immediately translate it in your head as \"§1 divides §2\"." msgstr "" -#. §0: $m$ -#. §1: $n$ -#. §2: $m \\cdot n$ -#. §3: $m$ -#. §4: $n$ -#. §5: $x \\equiv a \\pmod m$ -#. §6: $x \\equiv a \\pmod n$ -#. §7: $m \\mid (x - a)$ -#. §8: $n \\mid (x - a)$ -#. §9: `euclids_lemma` -#. §10: `IsGCD(n, m) 1` -#. §11: `IsGCD(m, n) 1` -#. §12: `gcd_symm` -#. §13: $x - a$ -#. §14: $m \\mid (k_2 \\cdot n)$ -#. §15: `gcd_symm` -#. §16: `euclids_lemma` -#. §17: `IsGCD n m 1` -#. §18: $m$ -#. §19: $k_2$ -#. §20: `have` -#: Game.Levels.LinCong.L10_crt_glue -msgid "Welcome to the final boss of Linear Congruences and CRT!\n" -"\n" -"Everything you've built in this branch — Bézout's identity, the cancellation laws, Euclid's Lemma, and CRT existence from the last level — comes together right here.\n" -"\n" -"The second half of CRT: if two numbers share the same remainder modulo §0 and modulo §1 separately, they share the same remainder modulo §2 — provided §3 and §4 are coprime.\n" -"\n" -"Formally: §5 and §6 means §7 and §8. Extract the witnesses, equate them, and reach for **Euclid's Lemma**.\n" -"\n" -"**One trap to watch for:** §9 expects coprimality as §10, but your hypothesis is §11 — arguments swapped! Fortunately, you already proved §12 in the GCD world for this exact moment.\n" +#: Game/Levels/Congruence/L04_mod_symm.lean:7 +msgid "Symmetry of Congruences" +msgstr "" + +#. §0: $a \\equiv b \\pmod m$ +#. §1: $b \\equiv a \\pmod m$ +#. §2: `at` +#. §3: `unfold` +#. §4: `rw` +#. §5: `at` +#. §6: `unfold ModEq at h` +#. §7: `h` +#. §8: `unfold ModEq at *` +#. §9: `have` +#. §10: $a - b = m \\cdot k$ +#. §11: $b - a$ +#. §12: `have h_eq : b - a = -(a - b)` +#. §13: `ring` +#. §14: `h_eq` +#. §15: `rw [h_eq]` +#. §16: `rw` +#. §17: `rw [← h_eq]` +#. §18: `\\l` +#: Game/Levels/Congruence/L04_mod_symm.lean:12 +msgid "The second property of an equivalence relation is **symmetry**: if §0, then §1.\n" "\n" -"**Strategy:**\n" -"1. **Equate the witnesses:** Extract the witnesses for §13, set them equal, and deduce that §14.\n" -"2. **Swap the GCD:** Apply §15 to your coprimality hypothesis so it matches the argument order §16 expects (§17).\n" -"3. **Apply Euclid's Lemma:** Use the lemma to conclude that §18 must entirely divide §19.\n" -"4. **Finish the algebra:** Substitute this new divisibility witness back into your original equation.\n" +"Before we dive into the proof, let's learn two crucial Lean features:\n" "\n" -"Take it one §20 at a time — you already have every tool you need." -msgstr "" - -#. §0: $x$ -#. §1: $x \\equiv a \\pmod m$ -#. §2: $x \\equiv b \\pmod n$ -#. §3: $x$ -#. §4: $m$ -#. §5: $n$ -#. §6: $m \\cdot u + n \\cdot v = 1$ -#. §7: $x = a \\cdot n \\cdot v + b \\cdot m \\cdot u$ -#: Game.Levels.LinCong.L09_crt_exists -msgid "If we want a number §0 to satisfy two separate congruences simultaneously:\n" -"§1 and §2\n" -"When does such an §3 exist?\n" +"1. **The §2 keyword:** By default, tactics like §3 or §4 only affect your *goal*. To modify hypotheses, use §5:\n" +"* §6 unfolds the definition inside hypothesis §7.\n" +"* §8 unfolds it *everywhere* (in all hypotheses and the goal at once).\n" "\n" -"The **Chinese Remainder Theorem (CRT)** guarantees a solution whenever §4 and §5 are coprime!\n" -"If §6, we can explicitly construct the solution:\n" -"§7.\n" +"2. **The §9 tactic:** Often, you need an intermediate algebraic fact before you can rewrite your goal. For example, here you know §10, but your goal contains §11.\n" +"If you type §12, Lean will pause and ask you to prove this equation first (using §13). Once proved, §14 is added to your assumptions so you can §15 to change the main goal!\n" "\n" -"Try it! Use your algebra skills and the Bézout identity to prove this explicitly." +"*(Tip: Remember that §16 replaces the left side of an equation with the right side, unless you use a left arrow §17 via §18.)*" msgstr "" -#. §0: $x \\equiv 23 \\pmod{100}$ -#. §1: $x$ -#. §2: `mod_shrink` -#. §3: $x \\equiv 23 \\pmod 4$ -#. §4: `mod_trans` -#. §5: `have` -#: Game.Levels.Problems.L06_shrink_shift -msgid "Let's combine multiple theorems into one elegant deduction.\n" -"If you know that §0, what is the remainder of §1 when divided by 4?\n" -"\n" -"Since 4 divides 100, we can safely shrink the modulus using §2. This will give us §3.\n" -"But 23 is not a standard remainder! We need to step from 23 down to 3 modulo 4, using §4.\n" -"\n" -"This level tests your ability to chain §5 statements and piece together different theorems." +#: Game/Levels/Congruence/L04_mod_symm.lean:28 +msgid "Congruence modulo m is symmetric." msgstr "" -#: Game.Levels.ModArith.L01_add -msgid "If two pairs of numbers are congruent, their sums are congruent." +#. §0: `have` +#. §1: `at *` +#: Game/Levels/Congruence/L04_mod_symm.lean:40 +msgid "Beautiful! You used §0 to build a bridge between the algebra you had and the algebra you needed, and learned how to modify everything at once with §1." msgstr "" -#: Game.Levels.Divisibility.L03_dvd_mul_right -msgid "Multiples of a" +#: Game/Levels/Congruence/L05_mod_trans.lean:7 +msgid "Transitivity of Congruences" msgstr "" -#: Game.Levels.GCD.L09_gcd_shift -msgid "🎉 MAGNIFICENT! 🎉\n" -"\n" -"You have conquered the GCD world! You built a working theory of the greatest common divisor from a single Bézout-style definition, proved it truly deserves the name \"greatest\", derived the coprime and general cancellation laws, and finished by proving the very fact that powers the Euclidean Algorithm.\n" +#. §0: $a \\equiv b \\pmod m$ +#. §1: $b \\equiv c \\pmod m$ +#. §2: $a \\equiv c \\pmod m$ +#: Game/Levels/Congruence/L05_mod_trans.lean:9 +msgid "The final pillar of an equivalence relation is **transitivity**:\n" +"If §0 and §1, then §2.\n" "\n" -"To be continued in **Linear Congruences and CRT**, where all of this comes together to solve linear congruences and prove the Chinese Remainder Theorem!" +"This is the property that allows us to chain long sequences of congruences together, stepping from one expression to the next just like we do with standard equalities." msgstr "" -#. §0: $x_0$ -#. §1: $m_1 = m / d$ -#. §2: $a(x_0 + t \\cdot m_1) \\equiv b \\pmod m$ -#. §3: $a = a_1 \\cdot d$ -#. §4: `IsGCD` -#. §5: $m$ -#. §6: `mod_add_multiple` -#: Game.Levels.LinCong.L07_sol_shift -msgid "Conversely, if we shift a valid solution §0 by any multiple of §1, we get another valid solution.\n" -"§2.\n" -"\n" -"Use §3 (from §4) and the property of shifting modulo §5 (§6) to finish the job!" +#: Game/Levels/Congruence/L05_mod_trans.lean:17 +msgid "Congruence modulo m is transitive." msgstr "" -#: Game.Levels.DivRules.L07_div11 -msgid "🎉 AMAZING! 🎉\n" -"\n" -"You have proven every major divisibility rule! What seemed like a list of random tricks in school is actually a beautiful, unified theory based on modular arithmetic and polynomials.\n" -"\n" -"Once you have also completed the **GCD** and **Linear Congruences** branch, the grand finale world — **Problems** — will unlock!" +#. §0: `«{a}» - «{b}» = «{m}» * «{k1}»` +#. §1: `«{b}» - «{c}» = «{m}» * «{k2}»` +#. §2: `«{a}» - «{c}» = «{m}» * («{k1}» + «{k2}»)` +#. §3: `«{k1}»` +#. §4: `«{k2}»` +#: Game/Levels/Congruence/L05_mod_trans.lean:22 +msgid "You know §0 and §1. Add those two equations: §2. So the multiplier you need combines §3 and §4 by addition." msgstr "" #. §0: $m$ -#: Game.Levels.Congruence.L05_mod_trans +#: Game/Levels/Congruence/L05_mod_trans.lean:31 msgid "Excellent! Reflexivity, symmetry, and transitivity are now complete — congruence modulo §0 is officially an equivalence relation." msgstr "" -#: Game.Levels.LinCong.L08_euclid -msgid "Incredible! A simple cancellation yields one of the oldest and most fundamental theorems in number theory." +#: Game/Levels/Congruence/L06_add_mul_mod.lean:7 +msgid "Shifting by the Modulus" msgstr "" -#: Game.Levels.Congruence.L08_mod_dvd -msgid "Shrinking the Modulus" +#. §0: $m$ +#. §1: $m$ +#. §2: $$a + k \\cdot m \\equiv a \\pmod m$$ +#: Game/Levels/Congruence/L06_add_mul_mod.lean:9 +msgid "In modular arithmetic, the modulus §0 essentially acts like zero. That means adding or subtracting any multiple of §1 to a number doesn't change its remainder at all:\n" +"§2\n" +"\n" +"Let's prove this fundamental shifting rule!" msgstr "" -#. §0: $\\text{IsGCD}(a, m) 1$ -#. §1: $x$ -#. §2: $a \\cdot x \\equiv 1 \\pmod m$ -#. §3: $a \\cdot x + m \\cdot y = 1$ -#. §4: $a \\cdot x = 1 - m \\cdot y$ -#. §5: $a \\cdot x$ -#. §6: $1$ -#. §7: $m$ -#. §8: $\\equiv 1 \\pmod m$ -#. §9: $\\gcd(3, 7) = 1$ -#. §10: $3 \\cdot (-2) + 7 \\cdot 1 = 1$ -#. §11: $x = -2$ -#. §12: $3 \\cdot (-2) = -6$ -#. §13: $-6 \\equiv 1 \\pmod 7$ -#. §14: $-6 - 1 = -7 = 7 \\cdot (-1)$ -#: Game.Doc.Theorems.LinCong -msgid "**Modular Inverse Existence**\n" -"\n" -"If §0, then there exists an integer §1 such that §2.\n" +#: Game/Levels/Congruence/L06_add_mul_mod.lean:17 +msgid "Shifting a number by a multiple of m." +msgstr "" + +#. §0: `mod_add_multiple` +#: Game/Levels/Congruence/L06_add_mul_mod.lean:23 +msgid "Short and sweet. This fact (§0) will be a lifesaver when we prove divisibility rules and solve linear congruences!" +msgstr "" + +#: Game/Levels/Congruence/L07_mod_scale.lean:7 +msgid "Scaling the Modulus" +msgstr "" + +#. §0: $m$ +#. §1: $m$ +#. §2: $a \\equiv b \\pmod m$ +#. §3: $c$ +#. §4: $$a \\cdot c \\equiv b \\cdot c \\pmod{m \\cdot c}$$ +#: Game/Levels/Congruence/L07_mod_scale.lean:9 +msgid "So far, the modulus §0 has stayed fixed. What if we want to change the modulus §1 itself?\n" "\n" -"**Intuition:**\n" -"Coprimality gives §3, i.e. §4 — meaning §5 is exactly §6 *shifted by a multiple of §7*. That's precisely what \"§8\" means.\n" +"If §2, then multiplying everything (including the modulus) by §3 preserves the congruence:\n" +"§4\n" "\n" -"For example: §9, and §10. So §11 works: §12, and indeed §13 (since §14)." +"Unfold the definition and look closely at the algebra you've got." msgstr "" -#. §0: $a$ -#. §1: $a \\mid 0$ -#: Game.Doc.Theorems.Divisibility -msgid "**Every Integer Divides Zero**\n" -"\n" -"For any integer §0: §1." +#: Game/Levels/Congruence/L07_mod_scale.lean:19 +msgid "Scaling the modulus." +msgstr "" + +#. §0: $k$ +#: Game/Levels/Congruence/L07_mod_scale.lean:31 +msgid "Nice! Notice how the witness §0 didn't even need to change!" +msgstr "" + +#: Game/Levels/Congruence/L08_mod_dvd.lean:7 +msgid "Shrinking the Modulus" msgstr "" #. §0: $a \\equiv b \\pmod m$ #. §1: $a$ #. §2: $b$ -#. §3: $m$ -#. §4: $c_2 a^2 + c_1 a + c_0 \\equiv c_2 b^2 + c_1 b + c_0 \\pmod m$ -#. §5: `mod_pow` -#. §6: `mod_add` -#. §7: `mod_mul_const` -#. §8: `mod_refl` -#: Game.Levels.ModArith.L07_poly -msgid "Welcome to the final boss of Modular Arithmetic!\n" +#. §3: $d$ +#. §4: $m$ +#. §5: $$d \\mid m \\implies a \\equiv b \\pmod d$$ +#. §6: `unfold ModEq at *` +#. §7: `h2 : d ∣ m` +#. §8: `h1 : m ∣ a - b` +#. §9: `d ∣ a - b` +#. §10: `h1` +#. §11: `h2` +#. §12: `obtain` +#. §13: `dvd_trans_int` +#. §14: `exact` +#. §15: `dvd_trans_int (x y z : ℤ) (h1 : x ∣ y) (h2 : y ∣ z) : x ∣ z` +#. §16: `exact` +#. §17: `a - b` +#. §18: `exact dvd_trans_int d m (a - b) h2 h1` +#: Game/Levels/Congruence/L08_mod_dvd.lean:11 +msgid "Think of a 12-hour clock: if two events happen at the same hour on a 12-hour cycle, they also line up on a 6-hour or 4-hour cycle.\n" +"In general, if §0, then §1 and §2 remain congruent modulo any divisor §3 of §4:\n" +"§5\n" "\n" -"All the tools you've built — reflexivity, addition, scaling, and powers of congruences — combine into one satisfying finishing move: if §0, then **any** polynomial with integer coefficients evaluated at §1 and §2 stays congruent modulo §3 too.\n" +"Once you run §6, look at what you have:\n" +"- §7\n" +"- §8\n" +"- Goal: §9\n" "\n" -"Let's prove it for a quadratic: §4.\n" +"We *could* unpack §10 and §11 with §12, or we can reuse §13 from World 2!\n" "\n" -"Nothing new to invent here — just snap together §5, §6, §7, and §8 piece by piece, and enjoy watching it all just... work." +"**How to apply theorems (§14):**\n" +"Check the **Theorems** tab on the right. A theorem's signature tells you what inputs it expects and in what order:\n" +"§15\n" +"Whenever a theorem directly matches your goal, you can close the goal in one step using **§16**, followed by the theorem's name and its arguments separated by spaces.\n" +"\n" +"**Syntax Tip: Parentheses!**\n" +"When passing a compound expression like §17 as a single argument, you **must** wrap it in parentheses:\n" +"§18" msgstr "" -#: Game.Levels.Congruence.L06_add_mul_mod -msgid "Shifting a number by a multiple of m." +#: Game/Levels/Congruence/L08_mod_dvd.lean:34 +msgid "Decreasing the modulus to a divisor." msgstr "" #. §0: `exact` #. §1: `mod_shrink` -#: Game.Levels.Congruence.L08_mod_dvd +#: Game/Levels/Congruence/L08_mod_dvd.lean:39 msgid "Beautiful! You have unlocked the power of theorem reuse with §0, and proved that you can always step down from a modulus to any of its divisors (§1)." msgstr "" -#. §0: `lin_cong_suff` -#: Game.Levels.Problems.L04_lincong -msgid "Apply your theorem! Look at the arguments for §0 in your theorems tab." +#: Game/Levels/Congruence/L09_mod_split.lean:7 +msgid "Splitting the Modulus (Boss)" msgstr "" -#. §0: `IsGCD(c, m) d` -#. §1: $d \\neq 0$ -#. §2: $c = c_1 \\cdot d$ -#. §3: $m = m_1 \\cdot d$ -#. §4: `IsGCD(c_1, m_1) 1` -#. §5: $\\text{IsGCD}(12, 18) 6$ -#. §6: $6$ -#. §7: $2$ -#. §8: $3$ -#. §9: $\\text{IsGCD}(2, 3) 1$ -#: Game.Doc.Theorems.GCD -msgid "**Dividing by the GCD Gives Coprime Numbers**\n" +#. §0: $a \\equiv b \\pmod{m \\cdot n}$ +#. §1: $$a \\equiv b \\pmod m \\quad \\text{AND} \\quad a \\equiv b \\pmod n$$ +#. §2: `∧` +#. §3: `P ∧ Q` +#. §4: `constructor` +#. §5: `P` +#. §6: `Q` +#: Game/Levels/Congruence/L09_mod_split.lean:11 +msgid "Welcome to the final boss of World 3!\n" "\n" -"If §0, §1, §2 and §3, then §4.\n" +"If §0, then the congruence holds modulo each factor individually:\n" +"§1\n" "\n" -"**Intuition:**\n" -"This matches your intuition exactly: §5, and dividing both by §6 gives §7 and §8, which indeed satisfy §9. Once you factor out everything two numbers have in common, whatever is left over shares nothing." +"Notice that your goal is a logical conjunction (§2). In Lean, whenever you need to prove §3, use the **§4** tactic to split the goal into two separate subgoals: first prove §5, then prove §6.\n" +"\n" +"How you prove each half — whether by unfolding definitions directly or by reusing theorems you've already built — is entirely up to you!" +msgstr "" + +#: Game/Levels/Congruence/L09_mod_split.lean:23 +msgid "Splitting the modulus into a product." +msgstr "" + +#. §0: `exact` +#. §1: `constructor` +#: Game/Levels/Congruence/L09_mod_split.lean:37 +msgid "🎉 AMAZING! 🎉\n" +"\n" +"You have conquered World 3! You now know how to work with congruences, reuse theorems with §0, split conjunctions with §1, and break apart a product modulus.\n" +"\n" +"The map now splits into **two parallel paths** — you can tackle them in whichever order you prefer:\n" +"- **In Search of the GCD** → **Linear Congruences and CRT**: discover Bézout's identity, cancellation laws, Euclid's Lemma, and the Chinese Remainder Theorem.\n" +"- **Modular Arithmetic** → **Divisibility Rules**: add, multiply, and raise congruences to powers, prove polynomial congruences, and unlock all classic divisibility rules!" +msgstr "" + +#: Game/Levels/Congruence.lean:13 +msgid "Meet the Congruence" +msgstr "" + +#. §0: $a \\equiv b \\pmod m$ +#. §1: $m$ +#. §2: $m$ +#: Game/Levels/Congruence.lean:15 +msgid "Welcome to World 3: Meet the Congruence!\n" +"\n" +"Here we introduce one of the central concepts of number theory: **Modular Congruences** (§0).\n" +"\n" +"First, you will prove that congruence modulo §1 forms an equivalence relation (reflexive, symmetric, and transitive) and learn how to shift numbers by multiples of the modulus. Then, you will learn how to manipulate the modulus §2 itself — scaling it up, shrinking it to a divisor, and splitting a product modulus apart!" +msgstr "" + +#: Game/Levels/ModArith/L01_add.lean:15 +msgid "Adding Congruences" +msgstr "" + +#. §0: $\\equiv$ +#. §1: $a \\equiv b \\pmod m$ +#. §2: $c \\equiv d \\pmod m$ +#. §3: $$a + c \\equiv b + d \\pmod m$$ +#: Game/Levels/ModArith/L01_add.lean:17 +msgid "Knowing that §0 is an equivalence relation is great, but the real magic of modular arithmetic is that it respects **algebraic operations**.\n" +"\n" +"First up is addition: if §1 and §2, then we can add the two congruences side-by-side:\n" +"§3" +msgstr "" + +#: Game/Levels/ModArith/L01_add.lean:25 +msgid "If two pairs of numbers are congruent, their sums are congruent." msgstr "" -#. §0: `x = «{a}» * «{n}» * «{v}» + «{b}» * «{m}» * «{u}»` -#. §1: `use` -#: Game.Levels.LinCong.L09_crt_exists -msgid "As explained in the introduction, the witness is §0. §1 it" +#: Game/Levels/ModArith/L01_add.lean:38 +msgid "Excellent! You just proved your first arithmetic rule for congruences." msgstr "" -#. §0: `3 ∣ 12` -#. §1: `a ∣ b` -#. §2: `∣` -#. §3: `\\mid` -#. §4: `3 ∣ 12` -#. §5: `∃ k, 12 = 3 * k` -#. §6: $k$ -#. §7: `use` -#. §8: `use 4` -#. §9: $k$ -#. §10: $4$ -#. §11: $12$ -#. §12: $3 \\cdot 4$ -#: Game.Levels.Divisibility.L01_first_proof -msgid "Welcome to your first level! In Lean, you write proofs by using **tactics**. Tactics are commands that manipulate the goal until it is solved.\n" -"\n" -"Our first statement is §0, which is read as \"3 divides 12\".\n" -"Whenever a new mathematical concept is introduced, it appears in your **Definitions** tab on the right. Click on §1 there right now to see what divisibility means formally!\n" -"\n" -"*(To type §2, write §3 and press Space.)*\n" +#: Game/Levels/ModArith/L02_sub.lean:7 +msgid "Subtracting Congruences" +msgstr "" + +#. §0: $a \\equiv b \\pmod m$ +#. §1: $c \\equiv d \\pmod m$ +#. §2: $$a - c \\equiv b - d \\pmod m$$ +#: Game/Levels/ModArith/L02_sub.lean:9 +msgid "Where addition goes, subtraction follows. If §0 and §1, then:\n" +"§2\n" "\n" -"Lean sees §4 as §5.\n" -"To prove this, you need to provide the number §6. You can do this with the §7 tactic.\n" -"Type §8. Lean will automatically substitute §9 with §10 and close the goal since §11 equals §12!" +"This rule is what lets us move terms from one side of a congruence to the other, just like in standard equations." msgstr "" -#: Game.Levels.Divisibility.L08_rewriting_backwards -msgid "Rewriting Backwards" +#: Game/Levels/ModArith/L02_sub.lean:16 +msgid "Subtracting congruences modulo m." msgstr "" -#: Game.Levels.ModArith.L05_mul -msgid "Masterful! You just constructed a multi-step proof entirely by gluing together previous theorems. This is how real mathematics is built!" +#: Game/Levels/ModArith/L02_sub.lean:29 +msgid "Nicely done! Subtraction is just addition in disguise, and modular arithmetic handles it effortlessly." msgstr "" -#: Game.Levels.Divisors.L04_dvd_add -msgid "Sums of Multiples" +#: Game/Levels/ModArith/L03_add_const.lean:7 +msgid "Adding a Constant" msgstr "" -#. §0: $a \\cdot c \\equiv b \\cdot c \\pmod m$ +#. §0: $a \\equiv b \\pmod m$ #. §1: $c$ -#. §2: $m$ -#. §3: `IsGCD(c, m) 1` -#. §4: $a \\equiv b \\pmod m$ -#. §5: $c$ -#. §6: $c$ -#. §7: $m$ -#. §8: $c = 2$ -#. §9: $m = 4$ -#. §10: $2 \\cdot 1 \\equiv 2 \\cdot 3 \\pmod 4$ -#. §11: $6 - 2 = 4$ -#. §12: $1 \\equiv 3 \\pmod 4$ -#. §13: $3 - 1 = 2$ -#. §14: $4$ -#. §15: $c$ -#. §16: $m$ -#. §17: $c \\cdot x + m \\cdot y = 1$ -#. §18: $x, y$ -#. §19: $x$ -#. §20: $c$ -#. §21: `have` -#. §22: `ring` -#. §23: `rw` -#: Game.Levels.GCD.L06_cancel_coprime -msgid "Here is the central theorem of this world — and one of the most useful facts in all of number theory.\n" -"\n" -"If §0, and §1 is coprime to §2 (§3), can we conclude §4? In other words: can we *cancel* the common factor §5 from both sides of a congruence?\n" +#. §2: $$a + c \\equiv b + c \\pmod m$$ +#. §3: $a \\equiv b \\pmod m$ +#. §4: `h` +#. §5: $c \\equiv c \\pmod m$ +#. §6: `mod_refl` +#. §7: `mod_add` +#. §8: `have` +#. §9: `exact` +#. §10: `have h_refl : c ≡ c (mod m)` +#. §11: `exact mod_refl c m` +#. §12: `mod_add` +#. §13: `exact` +#: Game/Levels/ModArith/L03_add_const.lean:9 +msgid "If §0, adding the same integer §1 to both sides preserves the congruence:\n" +"§2\n" "\n" -"**Yes** — but only because §6 and §7 are coprime! Without that assumption this would be false: take §8, §9. Then §10 (since §11), yet §12 is false (§13 is not a multiple of §14). Coprimality is essential.\n" +"We *could* unfold definitions and do the algebra again, but real mathematicians don't reinvent the wheel — they reuse what they've already proved!\n" "\n" -"**The key idea:** since §15 and §16 are coprime, we have §17 for some §18 (that's exactly what you proved in Level 3!). Multiplying our congruence's underlying equation by §19 makes the extra factor §20 effectively disappear, leaving exactly what we want.\n" +"Notice that:\n" +"- We know §3 by hypothesis §4.\n" +"- We know §5 by §6 (from the Congruence world).\n" +"- We can combine these two facts using §7 (from Level 1)!\n" "\n" -"This proof is long, but every single step is either a §21 (a pure algebra identity, closed by §22) or an §23 that plugs in a hypothesis. Take it one line at a time." +"You can combine §8 and §9 to build proofs step by step:\n" +"1. First, state the intermediate fact you need: §10.\n" +"2. Prove this new subgoal right away using §11.\n" +"3. Finally, close the main goal by feeding both congruences into §12 with §13!" msgstr "" -#. §0: $a \\equiv b \\pmod m$ -#. §1: $c \\equiv d \\pmod m$ -#. §2: $(a - c) \\equiv (b - d) \\pmod m$ -#: Game.Doc.Theorems.Congruence -msgid "**Subtracting Congruences**\n" -"\n" -"If §0 and §1, then §2." +#: Game/Levels/ModArith/L03_add_const.lean:26 +msgid "Adding a constant to both sides of a congruence." msgstr "" -#: Game.Levels.Divisors.L01_eq_zero_of_zero_dvd -msgid "Only Zero Is Divisible by Zero" +#. §0: `have` +#. §1: `exact` +#: Game/Levels/ModArith/L03_add_const.lean:33 +msgid "You have mastered combining §0 and §1 to chain existing theorems together! This is how large mathematical libraries are constructed." msgstr "" -#: Game.Levels.GCD.L03_coprime_forward -msgid "Coprimality Gives You Bézout (⟹)" +#: Game/Levels/ModArith/L04_mul_const.lean:7 +msgid "Multiplying by a Common Factor" msgstr "" -#. §0: $m/d$ -#. §1: $a \\cdot x \\equiv b \\pmod m$ -#. §2: $m/d$ -#: Game.Doc.Theorems.LinCong -msgid "**Congruent Solutions modulo §0**\n" +#. §0: $c$ +#. §1: $a \\equiv b \\pmod m$ +#. §2: $a \\cdot c \\equiv b \\cdot c \\pmod m$ +#: Game/Levels/ModArith/L04_mul_const.lean:9 +msgid "Now let's move from addition to multiplication. As a first step, let's show that we can scale both sides of a congruence by any integer §0:\n" +"If §1, then §2.\n" "\n" -"All solutions to §1 are congruent modulo §2." +"This simple scaling rule will be our stepping stone to multiplying any two congruences together in the next level." msgstr "" -#: Game.Levels.ModArith.L02_sub -msgid "Nicely done! Subtraction is just addition in disguise, and modular arithmetic handles it effortlessly." +#: Game/Levels/ModArith/L04_mul_const.lean:17 +msgid "Multiplying a congruence by a constant." msgstr "" -#: Game.Levels.Congruence.L05_mod_trans -msgid "Congruence modulo m is transitive." +#. §0: `mod_mul_const` +#: Game/Levels/ModArith/L04_mul_const.lean:30 +msgid "Very smooth. Keep §0 in mind — you're going to put it to work right now!" msgstr "" -#: Game.Levels.GCD.L07_gcd_div_coprime -msgid "Dividing by the gcd produces coprime numbers." +#: Game/Levels/ModArith/L05_mul.lean:7 +msgid "Multiplying Congruences" msgstr "" -#. §0: $a \\cdot c \\equiv b \\cdot c \\pmod m$ -#. §1: `IsGCD(c, m) 1` -#. §2: $a \\equiv b \\pmod m$ -#: Game.Doc.Theorems.GCD -msgid "**Cancellation Law for Coprime Factors**\n" +#. §0: $a \\equiv b \\pmod m$ +#. §1: $c \\equiv d \\pmod m$ +#. §2: $a \\cdot c \\equiv b \\cdot d \\pmod m$ +#. §3: `have` +#. §4: `exact` +#. §5: `mod_trans` +#. §6: $a \\cdot c$ +#. §7: $b \\cdot c$ +#. §8: $b \\cdot c$ +#. §9: $b \\cdot d$ +#. §10: `mod_mul_const` +#. §11: $a \\cdot c$ +#. §12: `exact mod_trans (a * c) (b * c) (b * d) m step1 step2_symm` +#. §13: `mod_mul_const` +#. §14: $c \\equiv d$ +#. §15: $b$ +#. §16: $c \\cdot b \\equiv d \\cdot b$ +#. §17: $b \\cdot c \\equiv b \\cdot d$ +#. §18: `have` +#. §19: `rw` +#. §20: `mod_trans` +#: Game/Levels/ModArith/L05_mul.lean:9 +msgid "We know we can add and subtract congruences, but can we multiply them?\n" +"If §0 and §1, is §2?\n" "\n" -"If §0 and §1, then §2.\n" +"Just like in Level 3, instead of doing algebra from scratch, we can glue together our previous theorems using §3 and §4!\n" +"Think about transitivity (§5). We can step from §6 to §7, and then from §8 to §9, using §10 (from Level 4) for each step.\n" "\n" -"**Intuition:**\n" -"Multiplying both sides of a congruence by the same number is always safe. This theorem shows the *reverse* direction — cancelling out a common factor — is *also* safe, but only when that factor shares no common divisor with the modulus. Coprimality is precisely the condition under which \"dividing\" makes sense in modular arithmetic." +"**Reminder: Parentheses!**\n" +"When passing compound expressions like §11 as arguments to a theorem, remember to wrap them in parentheses so Lean knows they are a single argument:\n" +"§12\n" +"\n" +"**Watch out for the order of multiplication!**\n" +"Applying §13 to §14 with multiplier §15 gives §16. You will need to manually flip the order to §17 using a §18 block and §19 before chaining everything together with §20." msgstr "" -#: Game.Levels.Divisibility.L04_one_dvd -msgid "One Divides Everything" +#: Game/Levels/ModArith/L05_mul.lean:24 +msgid "If two pairs of numbers are congruent, their products are congruent." msgstr "" -#: Game.Levels.GCD.L05_gcd_symm -msgid "Symmetry of the GCD" +#. §0: `«{c}» * «{b}» ≡ «{d}» * «{b}»` +#. §1: `«{b}» * «{c}» ≡ «{b}» * «{d}»` +#: Game/Levels/ModArith/L05_mul.lean:32 +msgid "You know that §0. Because multiplication is commutative, this is equivalent to §1. Try proving this flipped version first, so you can smoothly chain everything together with transitivity." msgstr "" -#. §0: $a - a = 0$ -#. §1: $m \\mid 0$ -#. §2: $a \\equiv a \\pmod m$ -#: Game.Levels.Congruence.L02_mod_refl -msgid "Great! Because §0, and §1, it immediately follows that §2.\n" -"One property down, two to go." +#: Game/Levels/ModArith/L05_mul.lean:45 +msgid "Masterful! You just constructed a multi-step proof entirely by gluing together previous theorems. This is how real mathematics is built!" msgstr "" -#. §0: $a$ -#. §1: $m$ -#. §2: $a$ -#. §3: $m$ -#. §4: $a \\cdot x \\equiv 1 \\pmod m$ -#. §5: $a \\cdot x - 1 = m \\cdot k$ -#. §6: $1$ -#. §7: `bezout_imp_coprime` -#: Game.Levels.LinCong.L02_inv_reverse -msgid "Does it work the other way? If §0 has a modular inverse modulo §1, must §2 and §3 be coprime?\n" -"\n" -"Absolutely. If §4, it means §5, which you can rearrange into a Bézout identity for §6. You proved in the GCD world (§7) that this forces the GCD to be 1!" +#: Game/Levels/ModArith/L06_pow.lean:7 +msgid "Powers of Congruences" msgstr "" -#. §0: $d$ -#. §1: $a$ -#. §2: $b$ -#. §3: $b$ -#. §4: $a$ -#. §5: `IsGCD(a, b) d ⟹ IsGCD(b, a) d` -#: Game.Levels.GCD.L05_gcd_symm -msgid "Before we move on to the cancellation laws, let's prove a very simple but handy property: symmetry.\n" +#. §0: $a \\equiv b \\pmod m$ +#. §1: $n$ +#. §2: $$a^n \\equiv b^n \\pmod m$$ +#. §3: $n$ +#. §4: $n \\in \\mathbb{N}$ +#. §5: `induction' n with d ih` +#. §6: $n = 0$ +#. §7: $a^0 \\equiv b^0 \\pmod m$ +#. §8: $d$ +#. §9: `ih` +#. §10: $d + 1$ +#. §11: `rw [pow_succ]` +#. §12: $a^{d+1}$ +#. §13: $a^d \\cdot a$ +#. §14: $b^{d+1}$ +#. §15: $b^d \\cdot b$ +#. §16: `mod_mul` +#: Game/Levels/ModArith/L06_pow.lean:13 +msgid "Since we can multiply congruences, what happens if we multiply a congruence §0 by itself §1 times? We get powers:\n" +"§2\n" "\n" -"If §0 is a greatest common divisor of §1 and §2, then it is also a greatest common divisor of §3 and §4.\n" -"Formally: §5.\n" +"Because the exponent §3 is an arbitrary natural number (§4), we must prove this using **mathematical induction**.\n" "\n" -"You will need to unpack the definition, swap the two divisibility facts, and swap the order of the Bézout coefficients!" +"Type §5 to split the proof into two goals:\n" +"1. **Base case (§6):** Prove §7.\n" +"2. **Inductive step:** Assuming the statement holds for §8 (hypothesis §9), prove it for §10.\n" +"\n" +"*Tip:* In the inductive step, use §11 (twice!) to rewrite §12 as §13 and §14 as §15, then finish with §16!" msgstr "" -#. §0: $d = \\gcd(a, m)$ -#. §1: $a \\cdot x \\equiv b \\pmod m$ -#. §2: $d \\mid b$ -#: Game.Doc.Theorems.LinCong -msgid "**Solvability (Necessary Condition)**\n" +#: Game/Levels/ModArith/L06_pow.lean:27 +msgid "Powers of congruences." +msgstr "" + +#. §0: `mod_mul` +#: Game/Levels/ModArith/L06_pow.lean:36 +msgid "Fantastic! You just performed your first proof by induction, effortlessly reducing powers to multiplication with §0.\n" "\n" -"If §0 and §1 has a solution, then §2." +"Now, one last challenge stands between you and the end of Modular Arithmetic!" +msgstr "" + +#: Game/Levels/ModArith/L07_poly.lean:7 +msgid "Polynomial Congruences (Boss)" msgstr "" #. §0: $a \\equiv b \\pmod m$ -#. §1: $c \\equiv d \\pmod m$ -#. §2: $(a \\cdot c) \\equiv (b \\cdot d) \\pmod m$ -#. §3: $12 \\equiv 2$ -#. §4: $13 \\equiv 3$ -#. §5: $12 \\cdot 13 = 156$ -#. §6: $156 \\equiv 6 \\pmod{10}$ -#. §7: $2 \\cdot 3$ -#. §8: $6$ -#: Game.Doc.Theorems.Congruence -msgid "**Multiplying Congruences**\n" +#. §1: $a$ +#. §2: $b$ +#. §3: $m$ +#. §4: $c_2 a^2 + c_1 a + c_0 \\equiv c_2 b^2 + c_1 b + c_0 \\pmod m$ +#. §5: `mod_pow` +#. §6: `mod_add` +#. §7: `mod_mul_const` +#. §8: `mod_refl` +#: Game/Levels/ModArith/L07_poly.lean:9 +msgid "Welcome to the final boss of Modular Arithmetic!\n" +"\n" +"All the tools you've built — reflexivity, addition, scaling, and powers of congruences — combine into one satisfying finishing move: if §0, then **any** polynomial with integer coefficients evaluated at §1 and §2 stays congruent modulo §3 too.\n" "\n" -"If §0 and §1, then §2.\n" +"Let's prove it for a quadratic: §4.\n" "\n" -"**Intuition:**\n" -"Just like addition, you can multiply remainders directly!\n" -"Modulo 10: §3 and §4.\n" -"If we multiply them: §5.\n" -"And §6. Notice that §7 is exactly §8." +"Nothing new to invent here — just snap together §5, §6, §7, and §8 piece by piece, and enjoy watching it all just... work." msgstr "" -#. §0: `«{m}» ∣ («{a}» - «{b}»)` -#. §1: `«{c}» * «{x}» + «{m}» * «{y}» = 1` -#. §2: `(«{a}» - «{b}»)` -#. §3: `(«{a}» - «{b}») * («{c}» * «{x}» + «{m}» * «{y}»)` -#. §4: `«{m}»` -#. §5: `use «{k}» * «{x}» + («{a}» - «{b}») * «{y}»` -#: Game.Levels.GCD.L06_cancel_coprime -msgid "You need a witness for §0. We know §1. Multiplying §2 by this gives §3. With some algebra, the §4 can be factored out. Try to §5." +#: Game/Levels/ModArith/L07_poly.lean:19 +msgid "Polynomials preserve congruences." msgstr "" -#. §0: `rw [hx, hy]` -#. §1: `a ∣ 0` -#: Game.Levels.Divisibility.L07_rewriting -msgid "Crisis averted! Once §0 substituted the numbers, the entire right-hand side collapsed into zero, turning a scary polynomial into the simple §1 pattern from the previous level." +#. §0: `polynomial_cong` +#. §1: `polynomial_cong` +#. §2: `mod_shrink` +#. §3: `mod_add_multiple` +#: Game/Levels/ModArith/L07_poly.lean:55 +msgid "🎉 AMAZING! 🎉\n" +"\n" +"You have conquered Modular Arithmetic! You've built a complete algebraic toolkit for congruences and proved §0.\n" +"\n" +"Next up in this branch is **Divisibility Rules**, where you will see how §1, §2, and §3 turn the famous school divisibility rules for 2, 3, 4, 5, 9, 10, and 11 into two-line proofs!" msgstr "" -#: Game.Levels.DivRules.L05_div9 -msgid "The sum of digits rule for 9." +#: Game/Levels/ModArith.lean:10 +msgid "Modular Arithmetic" msgstr "" -#. §0: $17^{100} + 12^{100}$ -#. §1: $17^{100}$ -#. §2: $17 \\equiv 2 \\pmod 5$ -#. §3: $12 \\equiv 2 \\pmod 5$ -#. §4: `have` -#. §5: `mod_pow` -#. §6: `mod_add` -#: Game.Levels.Problems.L01_large_powers -msgid "Let's start with a classic competition problem: what is the remainder of §0 when divided by 5?\n" +#. §0: $\\equiv \\pmod m$ +#. §1: $P(a) \\equiv P(b) \\pmod m$ +#: Game/Levels/ModArith.lean:12 +msgid "Welcome to Modular Arithmetic!\n" "\n" -"If you try to compute §1 directly, the universe will end before you finish. But you know that congruences preserve addition and powers! Since §2 and §3, you can use your abstract theorems to simplify the bases before applying the exponent.\n" +"In the Congruence world, you proved that §0 is an equivalence relation. Now we unlock its real algebraic power: you can safely add, subtract, multiply, and raise congruences to powers, just like regular equations!\n" "\n" -"**Strategy:**\n" -"Create intermediate facts using §4 for the base numbers, then raise them to the 100th power using §5, and finally add them together using §6." +"By the end of this world, you will combine all of these operations to prove that **polynomials preserve congruences** (§1) — the master key to proving the classic divisibility rules!" msgstr "" -#: Game.Levels.Divisibility.L06_dvd_zero -msgid "Everything Divides Zero" +#. §0: $10 \\cdot k + d \\equiv d \\pmod{10}$ +#: Game/Doc/Theorems/DivRules.lean:4 +msgid "**Divisibility by 10**\n" +"\n" +"The remainder of any number modulo 10 is exactly its last digit.\n" +"§0." msgstr "" -#. §0: $x = 17$ -#: Game.Levels.Problems.L03_crt -msgid "Excellent! You didn't even have to find the number yourself (though if you do the math, §0 works perfectly). Your abstract theorem did all the work.\n" +#: Game/Doc/Theorems/DivRules.lean:13 +msgid "**Divisibility by 2**\n" "\n" -"This is the true power of mathematics!" +"Since 2 divides 10, the remainder of any number modulo 2 depends entirely on its last digit." msgstr "" -#. §0: `«{d1}»` -#. §1: `«{a}»` -#. §2: `«{a}»` -#. §3: `(«{a}» + «{m}» * «{k}») - «{m}» * «{k}»` -#: Game.Levels.GCD.L09_gcd_shift -msgid "First step: show that §0 divides §1. Think of §2 as §3." +#: Game/Doc/Theorems/DivRules.lean:21 +msgid "**Divisibility by 5**\n" +"\n" +"Since 5 divides 10, the remainder of any number modulo 5 depends entirely on its last digit — same idea as the rule for 2." msgstr "" -#. §0: $k_1 \\cdot x + k_2 \\cdot y$ -#. §1: `dvd_lin_comb_int` -#. §2: `use` -#. §3: `obtain` -#. §4: `rw` -#. §5: `ring` -#: Game.Levels.Divisors.L06_dvd_lin_comb -msgid "🎉 INCREDIBLE! 🎉\n" -"\n" -"You have conquered World 2! By combining scaling and addition of witnesses into §0, you proved that common divisors always divide linear combinations (§1) — a theorem that will later power Bézout's Identity and the Greatest Common Divisor.\n" +#. §0: $100 \\cdot k + d \\equiv d \\pmod 4$ +#: Game/Doc/Theorems/DivRules.lean:30 +msgid "**Divisibility by 4**\n" "\n" -"You've mastered the foundational tactics §2, §3, §4, and §5.\n" -"Get ready for World 3, where we will introduce a massive new concept built directly on divisibility: **Modular Congruences**!" +"Since 4 divides 100, the remainder of any number modulo 4 depends only on its last two digits.\n" +"§0." msgstr "" -#. §0: `a = d * k` -#. §1: `a * b` -#. §2: `d * (k * b)` -#. §3: `k` -#. §4: `b` -#: Game.Levels.Divisors.L03_dvd_mul -msgid "Once you know §0, substituting into §1 gives §2. So the multiplier the goal is asking for is your existing §3, scaled by §4." +#. §0: $10 \\equiv 1 \\pmod 9$ +#: Game/Doc/Theorems/DivRules.lean:39 +msgid "**Divisibility by 9**\n" +"\n" +"A number is congruent to the sum of its digits modulo 9.\n" +"This works beautifully because any number can be written as a polynomial evaluated at 10, and §0." msgstr "" -#: Game.Levels.LinCong.L09_crt_exists -msgid "Chinese Remainder Theorem: Existence" +#: Game/Doc/Theorems/DivRules.lean:48 +msgid "**Divisibility by 3**\n" +"\n" +"Since 3 divides 9, a number is congruent to the sum of its digits modulo 3, just like with 9." msgstr "" -#. §0: `mod_cancel_coprime` -#. §1: `«{h_swap}»` -#. §2: `«{h_gcd}»` -#: Game.Levels.Problems.L02_cancel -msgid "Now you can finish the proof using §0 with your swapped hypothesis §1 and §2!" +#. §0: $10 \\equiv -1 \\pmod{11}$ +#: Game/Doc/Theorems/DivRules.lean:56 +msgid "**Divisibility by 11**\n" +"\n" +"A number is congruent to the alternating sum of its digits modulo 11.\n" +"This works because §0, so evaluating the digit polynomial at 10 is congruent to evaluating it at -1!" msgstr "" -#. §0: $d$ -#. §1: $a$ -#. §2: $d$ -#. §3: $a \\cdot b$ -#. §4: $b$ -#. §5: $a$ -#. §6: $d$ -#. §7: $a$ -#. §8: $d$ -#. §9: `obtain` -#. §10: `use` -#. §11: `rw` -#. §12: `ring` -#: Game.Levels.Divisors.L03_dvd_mul -msgid "Let's generalize the trick from the previous level into a universal building block.\n" -"\n" -"If §0 divides §1, does §2 also divide §3 for *any* integer §4?\n" -"Yes! If §5 is a multiple of §6, then any multiple of §7 is automatically a multiple of §8 too.\n" -"\n" -"You already have the exact four-step rhythm you need: §9 the witness from your hypothesis, §10 the right scaled witness for the new goal, §11, and finish with §12." +#: Game/Levels/DivRules/L01_div10.lean:14 +msgid "Divisibility by 10" msgstr "" -#. §0: $1$ -#. §1: $a$ -#. §2: $1 \\mid a$ -#. §3: $a = 1 \\cdot k$ -#. §4: $k$ -#. §5: $k$ -#. §6: `use` -#. §7: $a$ -#. §8: $1 \\cdot a$ -#. §9: `ring` -#: Game.Levels.Divisibility.L04_one_dvd -msgid "Next, let's prove that §0 divides any integer §1.\n" +#. §0: $10 \\cdot k + d$ +#. §1: $d$ +#. §2: $k$ +#. §3: $10 \\cdot k + d \\equiv d \\pmod{10}$ +#. §4: `mod_add_multiple` +#: Game/Levels/DivRules/L01_div10.lean:16 +msgid "Let's start with the easiest rule: a number is divisible by 10 if and only if its last digit is 0.\n" "\n" -"Remember that §2 means §3 for some §4. What should §5 be?\n" +"How do we write \"the last digit\" in math? Think about how numbers are built. You can split any number into its last digit and \"everything else\" multiplied by 10. For example, **347 = 34 * 10 + 7**.\n" +"So, any integer can mathematically be written as §0, where §1 is the last digit and §2 is the rest of the number.\n" "\n" -"Unlike the previous level, after you §6 your witness, the two sides of the equation (§7 and §8) won't look syntactically identical to Lean. Close the algebra using §9!" +"We want to prove that §3.\n" +"This is a direct consequence of §4 from the Congruence world! You just need to massage the equation slightly." msgstr "" -#: Game.Levels.GCD.L03_coprime_forward -msgid "Straightforward! You've now confirmed one half of the equivalence: coprimality *implies* a Bézout identity." +#: Game/Levels/DivRules/L01_div10.lean:26 +msgid "The remainder of a number modulo 10 is its last digit." msgstr "" -#: Game.Levels.Congruence.L07_mod_scale -msgid "Scaling the modulus." +#: Game/Levels/DivRules/L01_div10.lean:34 +msgid "Perfect! The last digit is exactly the remainder modulo 10." msgstr "" -#. §0: `a ∣ b` -#. §1: `use` -#. §2: `a ∣ b` -#. §3: `obtain` -#: Game.Levels.Divisors.L01_eq_zero_of_zero_dvd -msgid "Great work! Here is the golden rule of divisibility in Lean:\n" -"- When §0 is in the **goal**, you build it with §1.\n" -"- When §2 is in a **hypothesis**, you unpack it with §3." +#: Game/Levels/DivRules/L02_div2.lean:7 +msgid "Divisibility by 2" msgstr "" -#. §0: $a \\equiv b \\pmod m$ -#. §1: $(a + c) \\equiv (b + c) \\pmod m$ -#. §2: $c$ -#: Game.Doc.Theorems.Congruence -msgid "**Adding a Constant**\n" +#. §0: $2 \\mid 10$ +#. §1: $10 \\cdot k + d \\equiv d \\pmod{10}$ +#. §2: `mod_shrink` +#. §3: $2 \\mid 10$ +#. §4: `have` +#. §5: `have h2 : 2 ∣ 10` +#. §6: `ℕ` +#. §7: `ℤ` +#. §8: `have h2 : (2 : ℤ) ∣ 10` +#. §9: `ℤ` +#. §10: `\\Z` +#: Game/Levels/DivRules/L02_div2.lean:9 +msgid "What about divisibility by 2? Since §0, we can just shrink the modulus of the previous rule!\n" +"If §1, it must also be true modulo 2.\n" "\n" -"If §0, then §1 for any integer §2." +"Use §2 from the Congruence world. You will need to explicitly prove that §3 first using a §4 block.\n" +"\n" +"**Syntax Tip:** If you just write §5, Lean will assume 2 and 10 are natural numbers (§6), but our theorems expect integers (§7). To fix this, you must explicitly tell Lean the type of at least one number.\n" +"Write your statement like this: §8 *(To type §9, write §10 and press Space.)*" msgstr "" -#: Game.Levels.LinCong.L05_sol_suff -msgid "Solvability: Sufficient Condition" +#: Game/Levels/DivRules/L02_div2.lean:19 +msgid "The remainder modulo 2 depends only on the last digit." msgstr "" -#: Game.Levels.Divisors.L03_dvd_mul -msgid "A Divisor of a Factor Divides the Product" +#: Game/Levels/DivRules/L02_div2.lean:30 +msgid "Nice! Exactly the same logic applies to 5, since 5 ∣ 10 too — that's exactly what the next level does." msgstr "" -#. §0: $x$ -#. §1: $x \\equiv 7 \\pmod{10}$ -#. §2: $x \\equiv 2 \\pmod 3$ -#. §3: `crt_exists` -#. §4: `IsGCD(10, 3) 1` -#. §5: `IsGCD 10 3 1` -#. §6: `have` -#: Game.Levels.Problems.L03_crt -msgid "Is there a number that ends in 7 (modulo 10) but leaves a remainder of 2 when divided by 3?\n" -"In other words, does there exist an §0 such that §1 and §2?\n" -"\n" -"Instead of guessing, we can use the §3 theorem you proved in the Linear Congruences world. It guarantees a solution exists as long as the moduli are coprime.\n" -"\n" -"All you need to do is prove §4 and feed it to the theorem!\n" -"*(Remember the syntax tip from the previous level: you need to use the standard Lean syntax §5 in your §6 block.)*" +#: Game/Levels/DivRules/L03_div5.lean:7 +msgid "Divisibility by 5" msgstr "" -#: Game.Levels.Problems.L07_quadratic -msgid "Brilliant!\n" +#. §0: $5 \\mid 10$ +#. §1: $10 \\cdot k + d \\equiv d \\pmod{10}$ +#. §2: $5 \\mid 10$ +#. §3: `mod_shrink` +#. §4: $10 \\cdot k + d \\equiv d \\pmod 5$ +#. §5: `have h5 : (5 : ℤ) ∣ 10` +#: Game/Levels/DivRules/L03_div5.lean:9 +msgid "As promised at the end of the last level, let's finish off the pair: since §0 too, the exact same trick that worked for 2 also nails the rule for 5.\n" "\n" -"Whether you used clever algebra to factor the polynomial, or applied the heavy machinery of the Chinese Remainder Theorem, you proved you can handle complex congruences. Both paths are perfectly valid!\n" +"If §1 (Level 1), and §2, then §3 immediately gives us §4 as well.\n" "\n" -"Now, take a deep breath. Only one challenge remains..." +"**Syntax Tip:** Same reminder as last time — write §5 so Lean doesn't default to natural numbers." msgstr "" -#. §0: `∧` -#. §1: `constructor` -#: Game.Levels.GCD.L01_gcd_def -msgid "Your goal is an §0 (AND). Use the §1 tactic to split it into two separate goals." +#: Game/Levels/DivRules/L03_div5.lean:17 +msgid "The remainder modulo 5 depends only on the last digit." msgstr "" -#. §0: $\\gcd(m, n) = 1$ -#. §1: $x$ -#. §2: $x$ -#. §3: $u, v$ -#. §4: $m \\cdot u + n \\cdot v = 1$ -#. §5: $n \\cdot v$ -#. §6: $1$ -#. §7: $m$ -#. §8: $n$ -#. §9: $m \\cdot u$ -#. §10: $1$ -#. §11: $n$ -#. §12: $m$ -#. §13: $x = a \\cdot n \\cdot v + b \\cdot m \\cdot u$ -#. §14: $a$ -#. §15: $m$ -#. §16: $b$ -#. §17: $n$ -#. §18: $x \\equiv 2 \\pmod 3$ -#. §19: $x \\equiv 3 \\pmod 5$ -#. §20: $3 \\cdot 2 + 5 \\cdot (-1) = 1$ -#. §21: $u = 2, v = -1$ -#. §22: $x = 2 \\cdot 5 \\cdot (-1) + 3 \\cdot 3 \\cdot 2 = -10 + 18 = 8$ -#. §23: $8 \\equiv 2 \\pmod 3$ -#. §24: $8 \\equiv 3 \\pmod 5$ -#: Game.Doc.Theorems.LinCong -msgid "**CRT Existence**\n" -"\n" -"If §0, then there exists an §1 solving both congruences.\n" +#. §0: `mod_add_multiple` +#. §1: `mod_shrink` +#: Game/Levels/DivRules/L03_div5.lean:28 +msgid "Done! Together with the last two levels, you now have the full \"last digit\" family for free: 10, 2, and 5 all fall directly out of §0 and §1." +msgstr "" + +#: Game/Levels/DivRules/L04_div4.lean:7 +msgid "Divisibility by 4" +msgstr "" + +#. §0: $10 \\cdot k + d$ +#. §1: $100 \\cdot k + d$ +#. §2: $d = 56$ +#. §3: $100 \\cdot k + d \\equiv d \\pmod 4$ +#. §4: $100 = 25 \\cdot 4$ +#. §5: `mod_add_multiple` +#: Game/Levels/DivRules/L04_div4.lean:9 +msgid "A number is divisible by 4 if its last two digits form a number divisible by 4.\n" "\n" -"**Intuition:**\n" -"Build §2 from two pieces using Bézout witnesses §3 with §4. The term §5 behaves like \"§6\" modulo §7 (and vanishes modulo §8), while §9 behaves like \"§10\" modulo §11 (and vanishes modulo §12). So §13 picks up §14's value mod §15 and §16's value mod §17 simultaneously.\n" +"Instead of separating the last digit, we separate the last *two* digits! Just like in Level 1, where we wrote a number as §0 using the last digit, here we write it as §1 using the last *two* digits. For example, **3456 = 34 * 100 + 56**, where §2 is exactly the last two digits.\n" "\n" -"**Example:** solving §18 and §19: here §20, so §21. This gives §22. Check: §23 ✓ and §24 ✓." +"We want to show §3.\n" +"Notice that §4. Use §5 just like in Level 1!" +msgstr "" + +#: Game/Levels/DivRules/L04_div4.lean:18 +msgid "The remainder modulo 4 depends only on the last two digits." msgstr "" -#: Game.Levels.DivRules.L04_div4 +#: Game/Levels/DivRules/L04_div4.lean:20 msgid "Since 100 = 25 * 4, the term 100 * k is already a multiple of 4. Restate the goal as d plus that multiple of 4, in the shape mod_add_multiple expects." msgstr "" -#. §0: `x - a` -#. §1: `have h_eq : «{m}» * «{k1}» = «{n}» * «{k2}»` -#: Game.Levels.LinCong.L10_crt_glue -msgid "Following the strategy, start by creating an equation that sets your two expressions for §0 equal to each other: §1" +#: Game/Levels/DivRules/L04_div4.lean:28 +msgid "Exactly! Since 4 divides 100, everything above the tens place just vanishes modulo 4." msgstr "" -#: Game.Levels.GCD.L02_gcd_greatest -msgid "The GCD Really Is the Greatest" +#: Game/Levels/DivRules/L05_div9.lean:7 +msgid "Divisibility by 9 (The Magic of Polynomials)" msgstr "" -#. §0: $\\text{IsGCD}(a,b)$ -#. §1: `IsGCD(a, b) d` -#. §2: `have` -#. §3: `IsGCD a b d` -#. §4: $1$ -#. §5: $2$ -#. §6: $3$ -#. §7: `IsGCD(2, 3) 1` -#. §8: `unfold IsGCD` -#. §9: `∧` -#. §10: `∧` -#. §11: `∃` -#. §12: `constructor` -#. §13: `∧` -#. §14: `d ∣ a ∧ d ∣ b` -#. §15: `use` -#. §16: `ring` -#. §17: `ring` -#. §18: `use -1, 1` -#. §19: $x = -1$ -#. §20: $y = 1$ -#. §21: `ring` -#. §22: $2 \\cdot (-1) + 3 \\cdot 1 = 1$ -#: Game.Levels.GCD.L01_gcd_def -msgid "Time to meet the star of this world: the **Greatest Common Divisor**.\n" -"\n" -"Instead of defining §0 as \"the largest number that divides both\", we use an equivalent but far more Lean-friendly definition, based on **Bézout's identity**. Check the **Definitions** tab for the full explanation!\n" +#. §0: $c_2$ +#. §1: $c_1$ +#. §2: $c_0$ +#. §3: $c_2 \\cdot 10^2 + c_1 \\cdot 10 + c_0$ +#. §4: $c_2 \\cdot 1^2 + c_1 \\cdot 1 + c_0$ +#. §5: $10 \\equiv 1 \\pmod 9$ +#. §6: `polynomial_cong` +#: Game/Levels/DivRules/L05_div9.lean:9 +msgid "Here is the famous rule: \"A number is divisible by 9 if the sum of its digits is divisible by 9\".\n" "\n" -"**Lean Syntax Tip:** The notation §1 is just syntactic sugar to make the goals easier to read. When writing your own code (for example, when defining a new hypothesis with §2), you need to use the standard Lean syntax without parentheses or commas: §3.\n" +"To prove this, we need a formal way to write a number digit by digit. Think about how our base-10 system works. A 3-digit number like **345** is literally **3 * 100 + 4 * 10 + 5**.\n" +"If we call the individual digits §0, §1, and §2, the number is written exactly as §3.\n" "\n" -"As a warm-up, let's confirm that §4 is a greatest common divisor of §5 and §6: §7.\n" +"Notice anything? This is a polynomial evaluated at 10!\n" +"We want to show it is congruent to the sum of its digits: §4, which is the exact same polynomial evaluated at 1.\n" "\n" -"Start with §8 to reveal the raw conjunction. Your goal is then an §9 of an §10 and an §11. You already know §12 splits an §13 into two goals — you'll need it *twice*, since the first part (§14) is itself a conjunction.\n" +"Since §5, your ultimate weapon §6 from Modular Arithmetic will solve this instantly.\n" "\n" -"For the two divisibility goals, §15 the right witness and close with §16 (remember: §17 happily proves concrete numeric equalities too, not just general algebraic ones!). For the Bézout goal, §18 to supply §19 and §20 at once, then §21 again to check §22." +"*(We prove this here for 3-digit numbers as a clean, concrete illustration — the exact same argument, with a longer polynomial, proves it for numbers of any length.)*" msgstr "" -#. §0: `exact` -#. §1: `mod_trans (a b c m : ℤ) (h1 : ...) (h2 : ...)` -#. §2: `a` -#. §3: `b` -#. §4: `c` -#. §5: `m` -#. §6: `h1` -#. §7: `h2` -#. §8: `exact mod_trans a b c m step1 step2` -#. §9: `a * c` -#. §10: `2^100` -#. §11: `(a * c)` -#. §12: `exact mod_trans a * c ...` -#. §13: `a` -#. §14: `c` -#. §15: `exact mod_trans (a * c) (b * c) (b * d) m step1 step2` -#: Game.Doc.Tactics -msgid "The §0 tactic closes a goal if you provide a theorem that perfectly matches the goal.\n" -"\n" -"**How to use theorems:**\n" -"When you look at a theorem in the **Theorems** tab, you will see its signature, like §1.\n" -"To use it, you must pass the arguments exactly in that order, separated by spaces: first all the variables (§2, §3, §4, §5), and then the proofs for the hypotheses (§6, §7).\n" -"For example: §8\n" -"\n" -"**Using parentheses:**\n" -"If any of your arguments is a complex expression (like §9 or §10), you **must** wrap it in parentheses: §11.\n" -"Otherwise, Lean will read §12 as trying to pass §13 as the first argument, and then multiply the whole tactic result by §14, which will cause an error!\n" -"Correct usage: §15" +#: Game/Levels/DivRules/L05_div9.lean:23 +msgid "The sum of digits rule for 9." msgstr "" -#: Game.Levels.Problems.L02_cancel -msgid "Excellent! You proved a concrete GCD on the fly to unlock the power of your cancellation theorem." +#: Game/Levels/DivRules/L05_div9.lean:32 +msgid "Beautiful! Two lines of code prove a rule that feels like magic in middle school. Because polynomials preserve congruences, substituting 10 for 1 works perfectly." msgstr "" -#. §0: $a \\mid b$ -#. §1: $a$ -#. §2: $b$ -#. §3: $a \\mid b$ -#. §4: $b$ -#. §5: $a$ -#. §6: $k$ -#. §7: $$b = a \\cdot k$$ -#. §8: $a \\mid b$ -#. §9: $b$ -#. §10: $a$ -#. §11: $3 \\mid 12$ -#. §12: $12 = 3 \\cdot 4$ -#. §13: $k = 4$ -#. §14: $5 \\mid -15$ -#. §15: $-15 = 5 \\cdot (-3)$ -#. §16: $k = -3$ -#. §17: $7 \\mid 0$ -#. §18: $0 = 7 \\cdot 0$ -#. §19: $k = 0$ -#. §20: $4 \\mid 14$ -#. §21: $k$ -#. §22: $14 = 4 \\cdot k$ -#. §23: $a \\mid b$ -#. §24: `∃ k, b = a * k` -#. §25: $k$ -#. §26: `use` -#. §27: `use 4` -#. §28: `∣` -#. §29: `\\mid` -#. §30: `\\|` -#: Game.Doc.Definitions -msgid "**Divisibility (§0)**\n" -"\n" -"We say that an integer §1 **divides** an integer §2 (written as §3) if §4 is a multiple of §5.\n" -"Formally, this means there exists some integer §6 such that:\n" -"§7\n" -"\n" -"**Intuition:**\n" -"Thinking of §8 as \"§9 can be built entirely out of copies of §10\" often makes it easier to reason about than the formal existential statement.\n" -"\n" -"**Examples:**\n" -"* §11 is true because §12 (here our witness is §13).\n" -"* §14 is true because §15 (here §16).\n" -"* §17 is true because §18 (here §19).\n" -"* §20 is **false**, because there is no integer §21 that makes §22.\n" +#: Game/Levels/DivRules/L06_div3.lean:7 +msgid "Divisibility by 3" +msgstr "" + +#. §0: $3 \\mid 9$ +#. §1: `mod_shrink` +#. §2: `have h3 : (3 : ℤ) ∣ 9` +#: Game/Levels/DivRules/L06_div3.lean:9 +msgid "If the rule for 9 works, the rule for 3 must come for free, because §0.\n" "\n" -"**How it works in Lean:**\n" -"When you see §23 in your goal, Lean translates this under the hood to an \"exists\" statement: §24.\n" -"To prove it, you must provide the exact value of §25 using the §26 tactic (for example, §27).\n" +"Just like you shrank the modulus from 10 down to 2 and 5 earlier, shrink the modulus from 9 to 3 here using §1.\n" "\n" -"*(To type the divides symbol §28, type §29 or §30 and press Space!)*" +"**Syntax Tip:** When writing your divisibility fact, make sure to specify the type so Lean doesn't default to natural numbers: §2" msgstr "" -#: Game.Levels.ModArith.L03_add_const -msgid "Adding a Constant" +#: Game/Levels/DivRules/L06_div3.lean:17 +msgid "The sum of digits rule for 3." msgstr "" -#. §0: $a \\equiv b \\pmod m$ -#. §1: $b \\equiv a \\pmod m$ -#. §2: $a$ -#. §3: $b$ -#. §4: $m$ -#. §5: $b$ -#. §6: $a$ -#. §7: $17 \\equiv 5 \\pmod{12}$ -#. §8: $17 - 5 = 12$ -#. §9: $5 \\equiv 17 \\pmod{12}$ -#. §10: $5 - 17 = -12$ -#. §11: $12$ -#. §12: $12 \\cdot -1$ -#: Game.Doc.Theorems.Congruence -msgid "**Symmetry of Congruences**\n" -"\n" -"If §0, then §1.\n" -"\n" -"**Intuition:**\n" -"If the difference between §2 and §3 is a multiple of §4, the difference between §5 and §6 is just the same multiple with a negative sign.\n" -"For example, §7 because §8.\n" -"Conversely, §9 because §10, which is still a multiple of §11 (§12)." +#: Game/Levels/DivRules/L06_div3.lean:28 +msgid "Beautiful. The structural similarity of mathematics really shines here." msgstr "" -#. §0: $m \\mid a$ -#. §1: $a \\equiv 0 \\pmod m$ -#. §2: $m$ -#. §3: $0$ -#. §4: $m$ -#: Game.Doc.Theorems.Congruence -msgid "**Divisible Means Congruent to Zero**\n" -"\n" -"If §0, then §1.\n" -"\n" -"**Intuition:**\n" -"Being divisible by §2 is the exact same thing as leaving a remainder of §3 modulo §4." +#: Game/Levels/DivRules/L07_div11.lean:7 +msgid "Divisibility by 11 (Boss)" msgstr "" -#: Game.Levels.GCD.L08_cancel_general -msgid "The fully general cancellation law for congruences." +#. §0: $c_0 - c_1 + c_2 - c_3 \\dots$ +#. §1: $10 \\equiv -1 \\pmod{11}$ +#. §2: $c_2 \\cdot 10^2 + c_1 \\cdot 10 + c_0$ +#. §3: $(-1)^2 = 1$ +#. §4: $(-1)^1 = -1$ +#. §5: $c_2 - c_1 + c_0$ +#. §6: `polynomial_cong` +#: Game/Levels/DivRules/L07_div11.lean:9 +msgid "Welcome to the final boss of Divisibility Rules!\n" +"\n" +"For our final trick: the alternating sum of digits rule for 11.\n" +"A number is divisible by 11 if §0 is divisible by 11.\n" +"\n" +"Why does this work? Because §1.\n" +"When we evaluate the \"polynomial\" of the digits (§2) at -1 instead of 10, the powers of -1 naturally alternate: §3, but §4.\n" +"So the polynomial magically turns into §5 (the alternating sum)!\n" +"\n" +"Once again, §6 will do all the heavy lifting — and just like with 9, the same idea scales to numbers of any length." msgstr "" -#: Game.Levels.GCD.L04_coprime_backward -msgid "A Bézout identity implies coprimality." +#: Game/Levels/DivRules/L07_div11.lean:22 +msgid "The alternating sum of digits rule for 11." msgstr "" -#. §0: $a$ -#. §1: $a$ -#. §2: $b$ -#. §3: $a \\mid a \\cdot b$ -#. §4: $a$ -#. §5: $a$ -#. §6: $b$ -#. §7: `dvd_mul_right_int a b` -#. §8: `a ∣ a * b` -#: Game.Doc.Theorems.Divisibility -msgid "**Multiples of §0**\n" +#: Game/Levels/DivRules/L07_div11.lean:31 +msgid "🎉 AMAZING! 🎉\n" "\n" -"For any integers §1 and §2: §3.\n" +"You have proven every major divisibility rule! What seemed like a list of random tricks in school is actually a beautiful, unified theory based on modular arithmetic and polynomials.\n" "\n" -"**Intuition:**\n" -"Any product containing §4 as a factor is immediately a multiple of §5 (with §6 itself acting as the witness). In Lean, §7 directly proves §8." +"Once you have also completed the **GCD** and **Linear Congruences** branch, the grand finale world — **Problems** — will unlock!" msgstr "" -#. §0: `mod_cancel_coprime` -#: Game.Levels.GCD.L06_cancel_coprime -msgid "That's the heart of this world, conquered! §0 is now yours — it is the single most important tool you will use going forward." +#: Game/Levels/DivRules.lean:11 +msgid "Divisibility Rules" msgstr "" -#: Game.Levels.Problems.L08_system -msgid "🎉 CONGRATULATIONS ON COMPLETING THE NUMBER THEORY GAME! 🎉\n" +#. §0: `mod_add_multiple` +#. §1: `mod_shrink` +#. §2: `polynomial_cong` +#: Game/Levels/DivRules.lean:14 +msgid "Welcome to Divisibility Rules!\n" +"\n" +"Do you remember learning divisibility rules in school? \"A number is divisible by 9 if the sum of its digits is divisible by 9\", or \"A number is divisible by 10 if it ends in 0\".\n" +"\n" +"In this world, we won't just memorize these rules — we will prove them! With §0, §1, and §2 in your toolkit, you'll see how all of these classic rules fall out in just a couple of lines." +msgstr "" + +#. §0: `IsGCD(a, b) d` +#. §1: $c$ +#. §2: $a$ +#. §3: $b$ +#. §4: $c \\mid a$ +#. §5: $c \\mid b$ +#. §6: $c \\mid d$ +#. §7: $2$ +#. §8: $3$ +#. §9: $12$ +#. §10: $18$ +#. §11: $2 \\mid 6$ +#. §12: $3 \\mid 6$ +#. §13: $6 = \\text{IsGCD}(12, 18)$ +#. §14: $d$ +#. §15: $a$ +#. §16: $b$ +#. §17: $a \\cdot x + b \\cdot y = d$ +#. §18: $a$ +#. §19: $b$ +#. §20: $d$ +#: Game/Doc/Theorems/GCD.lean:4 +msgid "**The Bézout Definition Really Gives the Greatest Common Divisor**\n" "\n" -"You have defeated the final boss by elegantly solving a system of congruences and applying Euclid's Lemma!\n" +"If §0, and §1 is *any* common divisor of §2 and §3 (i.e. §4 and §5), then §6.\n" "\n" -"You started from the simplest definition of divisibility and built a massive, formally verified mathematical theory. You conquered congruences, modular arithmetic, divisibility rules, the greatest common divisor, and the Chinese Remainder Theorem — and then used your abstract tools to crush real numerical problems.\n" +"**Intuition:**\n" +"This is what actually justifies the name \"IsGCD\": our Bézout-style definition doesn't just hand you *a* common divisor, it hands you the *greatest* one — every other common divisor is forced to divide it too. For example, §7 and §8 both divide §9 and §10, and indeed §11 and §12, where §13's witness.\n" "\n" -"Thank you for playing!" +"The proof works because §14 is built from §15 and §16 via §17: anything that divides both §18 and §19 automatically divides this whole combination, and hence divides §20." msgstr "" -#. §0: `«{x}»` -#. §1: `have h_exists : ∃ k, («{a}» * k) ≡ 1 (mod «{m}»)` -#: Game.Levels.LinCong.L03_inv_unique -msgid "Following step 1 of the strategy, create a proof that *some* inverse exists using §0 as the witness: §1." +#. §0: `IsGCD(c, m) 1` +#. §1: $x, y$ +#. §2: $c \\cdot x + m \\cdot y = 1$ +#: Game/Doc/Theorems/GCD.lean:17 +msgid "**Coprimality Implies a Bézout Identity**\n" +"\n" +"If §0, then there exist integers §1 with §2." msgstr "" -#: Game.Levels.Congruence.L03_dvd_imp_mod_zero -msgid "Divisible Means Congruent to Zero" +#. §0: $x, y$ +#. §1: $c \\cdot x + m \\cdot y = 1$ +#. §2: `IsGCD(c, m) 1` +#: Game/Doc/Theorems/GCD.lean:25 +msgid "**A Bézout Identity with 1 Implies Coprimality**\n" +"\n" +"If there exist integers §0 with §1, then §2." msgstr "" -#: Game.Levels.Divisors.L04_dvd_add -msgid "If a divides b and a divides c, then a divides b + c." +#. §0: `IsGCD(a, b) d` +#. §1: `IsGCD(b, a) d` +#: Game/Doc/Theorems/GCD.lean:33 +msgid "**Symmetry of the GCD**\n" +"\n" +"If §0, then §1." msgstr "" -#: Game.Levels.Congruence.L02_mod_refl -msgid "Every integer is congruent to itself." +#. §0: $a \\cdot c \\equiv b \\cdot c \\pmod m$ +#. §1: `IsGCD(c, m) 1` +#. §2: $a \\equiv b \\pmod m$ +#: Game/Doc/Theorems/GCD.lean:41 +msgid "**Cancellation Law for Coprime Factors**\n" +"\n" +"If §0 and §1, then §2.\n" +"\n" +"**Intuition:**\n" +"Multiplying both sides of a congruence by the same number is always safe. This theorem shows the *reverse* direction — cancelling out a common factor — is *also* safe, but only when that factor shares no common divisor with the modulus. Coprimality is precisely the condition under which \"dividing\" makes sense in modular arithmetic." msgstr "" -#: Game.Levels.ModArith.L02_sub -msgid "Subtracting congruences modulo m." +#. §0: `mul_left_cancel₀` +#. §1: `a ≠ 0` +#. §2: `a * b = a * c` +#. §3: `b = c` +#: Game/Doc/Theorems/GCD.lean:52 +msgid "The §0 theorem lets you cancel a common non-zero factor from an equation:\n" +"if §1 and §2, then §3.\n" +"This works because the integers have no \"zero divisors\": the only way a product can vanish is if one of its factors does, so a non-zero factor can always be safely divided out of an equation." msgstr "" -#. §0: $x \\cdot 3$ -#. §1: $x$ -#. §2: $x$ -#. §3: `euclids_lemma` -#. §4: $m \\mid (a \\cdot c)$ -#. §5: $\\gcd(c, m) = 1$ -#. §6: $m \\mid a$ -#. §7: $m = 10$ -#. §8: $a = x$ -#. §9: $c = 3$ -#: Game.Levels.Problems.L05_euclid -msgid "If a number is a multiple of 10, and we know it's written as §0, does 10 divide §1?\n" -"Yes! Because 3 and 10 share no common factors, the 10 must entirely divide the §2.\n" +#. §0: `IsGCD(c, m) d` +#. §1: $d \\neq 0$ +#. §2: $c = c_1 \\cdot d$ +#. §3: $m = m_1 \\cdot d$ +#. §4: `IsGCD(c_1, m_1) 1` +#. §5: $\\text{IsGCD}(12, 18) 6$ +#. §6: $6$ +#. §7: $2$ +#. §8: $3$ +#. §9: $\\text{IsGCD}(2, 3) 1$ +#: Game/Doc/Theorems/GCD.lean:60 +msgid "**Dividing by the GCD Gives Coprime Numbers**\n" "\n" -"This is exactly §3 from the Linear Congruences world: if §4 and §5, then §6.\n" +"If §0, §1, §2 and §3, then §4.\n" "\n" -"Let's prove this explicitly for §7, §8, and §9." +"**Intuition:**\n" +"This matches your intuition exactly: §5, and dividing both by §6 gives §7 and §8, which indeed satisfy §9. Once you factor out everything two numbers have in common, whatever is left over shares nothing." msgstr "" -#: Game.Levels.Divisibility.L02_negative_multiples -msgid "Negative Multiples" +#. §0: $a \\cdot c \\equiv b \\cdot c \\pmod m$ +#. §1: `IsGCD(c, m) d` +#. §2: $d \\neq 0$ +#. §3: $c = c_1 \\cdot d$ +#. §4: $m = m_1 \\cdot d$ +#. §5: $a \\equiv b \\pmod{m_1}$ +#. §6: $c$ +#. §7: $c$ +#. §8: $m$ +#. §9: $d$ +#. §10: `IsGCD(c, m) d` +#. §11: $d = 1$ +#: Game/Doc/Theorems/GCD.lean:71 +msgid "**The General Cancellation Law**\n" +"\n" +"If §0, §1 with §2, §3 and §4, then §5.\n" +"\n" +"**Intuition:**\n" +"This is the fully general version of \"dividing\" a congruence: you can always cancel a factor §6 out of a congruence, as long as you also divide the modulus by whatever §7 and §8 have in common (§9, where §10). The coprime case (Level 6) is just the special case §11, where the modulus doesn't need to shrink at all." msgstr "" -#. §0: $k$ -#. §1: $a + k \\cdot m \\equiv a \\pmod m$ -#: Game.Doc.Theorems.Congruence -msgid "**Shifting by a Multiple of the Modulus**\n" +#. §0: $0 \\le d_1$ +#. §1: $0 \\le d_2$ +#. §2: $d_1 \\mid d_2$ +#. §3: $d_2 \\mid d_1$ +#. §4: $d_1 = d_2$ +#. §5: $\\mathbb{Z}$ +#: Game/Doc/Theorems/GCD.lean:82 +msgid "**Antisymmetry of Divisibility (for non-negative integers)**\n" "\n" -"For any integer §0: §1." +"If §0, §1, §2, and §3, then §4.\n" +"\n" +"**Why we need it:**\n" +"Divisibility on all of §5 only forms a *pre-order*: two different numbers can divide each other, as long as one is the negative of the other. Restricted to non-negative integers, though, divisibility becomes a genuine **partial order**: \"mutual divisibility\" really does collapse to equality.\n" +"\n" +"In this boss level, we will show two gcd-witnesses divide each other, and use exactly this theorem to conclude they must be the *same* number." msgstr "" -#: GameServer.RpcHandlers -msgid "level completed with warnings… 🎭" +#. §0: $a, k, m$ +#. §1: $d_1, d_2$ +#. §2: `IsGCD(a + m * k, m) d1` +#. §3: `IsGCD(a, m) d2` +#. §4: $d_1 = d_2$ +#. §5: $\\gcd(a + mk, m) = \\gcd(a, m)$ +#. §6: $k$ +#. §7: $a$ +#. §8: $m$ +#. §9: $m$ +#: Game/Doc/Theorems/GCD.lean:95 +msgid "**Shift Invariance of the GCD**\n" +"\n" +"For any integers §0, and non-negative gcd-witnesses §1:\n" +"if §2 and §3, then §4.\n" +"\n" +"**Why this matters:**\n" +"This is the *engine* of the Euclidean Algorithm for computing GCDs: §5 for any integer §6. In particular, replacing §7 by its remainder after dividing by §8 never changes the GCD with §9 — which is exactly what lets the Euclidean Algorithm shrink its numbers step by step until it reaches the answer." msgstr "" -#: Game.Levels.DivRules.L03_div5 -msgid "Divisibility by 5" +#: Game/Levels/GCD/L01_gcd_def.lean:15 +msgid "Meeting the GCD" msgstr "" -#. §0: $100 \\cdot k + d \\equiv d \\pmod 4$ -#: Game.Doc.Theorems.DivRules -msgid "**Divisibility by 4**\n" +#. §0: $\\text{IsGCD}(a,b)$ +#. §1: `IsGCD(a, b) d` +#. §2: `have` +#. §3: `IsGCD a b d` +#. §4: $1$ +#. §5: $2$ +#. §6: $3$ +#. §7: `IsGCD(2, 3) 1` +#. §8: `unfold IsGCD` +#. §9: `∧` +#. §10: `∧` +#. §11: `∃` +#. §12: `constructor` +#. §13: `∧` +#. §14: `d ∣ a ∧ d ∣ b` +#. §15: `use` +#. §16: `ring` +#. §17: `ring` +#. §18: `use -1, 1` +#. §19: $x = -1$ +#. §20: $y = 1$ +#. §21: `ring` +#. §22: $2 \\cdot (-1) + 3 \\cdot 1 = 1$ +#: Game/Levels/GCD/L01_gcd_def.lean:19 +msgid "Time to meet the star of this world: the **Greatest Common Divisor**.\n" "\n" -"Since 4 divides 100, the remainder of any number modulo 4 depends only on its last two digits.\n" -"§0." +"Instead of defining §0 as \"the largest number that divides both\", we use an equivalent but far more Lean-friendly definition, based on **Bézout's identity**. Check the **Definitions** tab for the full explanation!\n" +"\n" +"**Lean Syntax Tip:** The notation §1 is just syntactic sugar to make the goals easier to read. When writing your own code (for example, when defining a new hypothesis with §2), you need to use the standard Lean syntax without parentheses or commas: §3.\n" +"\n" +"As a warm-up, let's confirm that §4 is a greatest common divisor of §5 and §6: §7.\n" +"\n" +"Start with §8 to reveal the raw conjunction. Your goal is then an §9 of an §10 and an §11. You already know §12 splits an §13 into two goals — you'll need it *twice*, since the first part (§14) is itself a conjunction.\n" +"\n" +"For the two divisibility goals, §15 the right witness and close with §16 (remember: §17 happily proves concrete numeric equalities too, not just general algebraic ones!). For the Bézout goal, §18 to supply §19 and §20 at once, then §21 again to check §22." msgstr "" -#. §0: `crt_exists` -#. §1: `exact` -#: Game.Levels.Problems.L03_crt -msgid "Now let §0 do the heavy lifting! Look at its signature in the theorems list and apply it with §1." +#: Game/Levels/GCD/L01_gcd_def.lean:33 +msgid "A first, concrete example: IsGCD(2, 3) 1." msgstr "" -#. §0: `dvd_mul_of_dvd_left_int` -#: Game.Levels.Divisors.L03_dvd_mul -msgid "Perfect! Keep §0 close at hand — you'll use this theorem again and again in future worlds." +#. §0: `∧` +#. §1: `constructor` +#: Game/Levels/GCD/L01_gcd_def.lean:36 +msgid "Your goal is an §0 (AND). Use the §1 tactic to split it into two separate goals." +msgstr "" + +#. §0: `∧` +#. §1: `constructor` +#: Game/Levels/GCD/L01_gcd_def.lean:38 +msgid "The first goal is *also* an §0. Use §1 again!" msgstr "" #. §0: `2 * x + 3 * y = 1` #. §1: `x = -1` #. §2: `y = 1` #. §3: `use -1, 1` -#: Game.Levels.GCD.L01_gcd_def +#: Game/Levels/GCD/L01_gcd_def.lean:44 msgid "To show §0, try §1 and §2. Type §3. (use can take multiple witnesses separated by commas)" msgstr "" -#. §0: $2 \\mid 10$ -#. §1: $10 \\cdot k + d \\equiv d \\pmod{10}$ -#. §2: `mod_shrink` -#. §3: $2 \\mid 10$ -#. §4: `have` -#. §5: `have h2 : 2 ∣ 10` -#. §6: `ℕ` -#. §7: `ℤ` -#. §8: `have h2 : (2 : ℤ) ∣ 10` -#. §9: `ℤ` -#. §10: `\\Z` -#: Game.Levels.DivRules.L02_div2 -msgid "What about divisibility by 2? Since §0, we can just shrink the modulus of the previous rule!\n" -"If §1, it must also be true modulo 2.\n" -"\n" -"Use §2 from the Congruence world. You will need to explicitly prove that §3 first using a §4 block.\n" -"\n" -"**Syntax Tip:** If you just write §5, Lean will assume 2 and 10 are natural numbers (§6), but our theorems expect integers (§7). To fix this, you must explicitly tell Lean the type of at least one number.\n" -"Write your statement like this: §8 *(To type §9, write §10 and press Space.)*" -msgstr "" - -#: Game.Levels.LinCong.L03_inv_unique -msgid "Exactly! Using the cancellation law on congruences works wonderfully here." +#. §0: `constructor` +#: Game/Levels/GCD/L01_gcd_def.lean:49 +msgid "Well done! You built a proof of a conjunction-inside-a-conjunction by nesting §0. Next, let's see why this definition really deserves the name \"greatest\" common divisor." msgstr "" -#: Game.Levels.Problems.L07_quadratic -msgid "There are two paths to solve this: a short one and a long one. It is worth thinking a bit about algebraic transformations." +#: Game/Levels/GCD/L02_gcd_greatest.lean:7 +msgid "The GCD Really Is the Greatest" msgstr "" -#: Game.Levels.LinCong.L01_inv_exists -msgid "Perfect! You have proven that every number coprime to the modulus has a modular inverse." +#. §0: $d$ +#. §1: `IsGCD(a, b) d` +#. §2: $a$ +#. §3: $b$ +#. §4: $d$ +#. §5: `IsGCD(a, b) d` +#. §6: $c$ +#. §7: $a$ +#. §8: $b$ +#. §9: $c \\mid a$ +#. §10: $c \\mid b$ +#. §11: $c \\mid d$ +#. §12: $d = a \\cdot x + b \\cdot y$ +#. §13: $a$ +#. §14: $b$ +#. §15: `dvd_lin_comb_int` +#. §16: $a$ +#. §17: $b$ +#. §18: $a \\cdot x + b \\cdot y$ +#. §19: `unfold IsGCD at h` +#. §20: $x, y$ +#. §21: $a \\cdot x + b \\cdot y = d$ +#. §22: `obtain` +#. §23: `⟨⟨hda, hdb⟩, x, y, hxy⟩` +#. §24: $c \\mid d$ +#. §25: `rw [← hxy]` +#. §26: $c \\mid a \\cdot x + b \\cdot y$ +#. §27: `dvd_lin_comb_int` +#: Game/Levels/GCD/L02_gcd_greatest.lean:9 +msgid "Now for the payoff of our definition: let's show that any §0 satisfying §1 is truly a *greatest* common divisor — meaning every other common divisor of §2 and §3 also divides §4.\n" +"\n" +"Formulation: if §5 holds, and §6 is *any* common divisor of §7 and §8 (§9 and §10), then §11.\n" +"\n" +"Why is this so easy with our Bézout-style definition? Because §12 is a **linear combination** of §13 and §14 — and in the final boss of World 2 (§15), you already proved that any common divisor of §16 and §17 divides *every* linear combination §18!\n" +"\n" +"**Strategy:**\n" +"1. §19 to reveal the two divisibility facts and the Bézout witnesses §20 with §21. Since this is a nested conjunction-with-an-existential, §22 can peel apart all the layers at once with a pattern like §23.\n" +"2. Rewrite the goal §24 backwards using §25 to turn it into §26.\n" +"3. Close the goal in one line using §27 from World 2!" msgstr "" -#. §0: $10 \\equiv -1 \\pmod{11}$ -#: Game.Doc.Theorems.DivRules -msgid "**Divisibility by 11**\n" -"\n" -"A number is congruent to the alternating sum of its digits modulo 11.\n" -"This works because §0, so evaluating the digit polynomial at 10 is congruent to evaluating it at -1!" +#: Game/Levels/GCD/L02_gcd_greatest.lean:23 +msgid "Any gcd witness dominates every common divisor." msgstr "" -#: Game.Levels.DivRules.L04_div4 -msgid "Divisibility by 4" +#. §0: `dvd_lin_comb_int` +#: Game/Levels/GCD/L02_gcd_greatest.lean:30 +msgid "Excellent! Because you already conquered linear combinations in World 2 (§0), proving that our Bézout-style GCD dominates every other common divisor took just four lines!" msgstr "" -#: Game.Levels.Divisibility.L04_one_dvd -msgid "1 divides every integer." +#: Game/Levels/GCD/L03_coprime_forward.lean:7 +msgid "Coprimality Gives You Bézout (⟹)" msgstr "" -#. §0: $a \\mid a$ -#: Game.Doc.Theorems.Divisibility -msgid "**Reflexivity of Divisibility**\n" +#. §0: $c$ +#. §1: $m$ +#. §2: $1$ +#. §3: `IsGCD(c, m) 1` +#. §4: $x, y$ +#. §5: $c \\cdot x + m \\cdot y = 1$ +#. §6: $\\implies$ +#. §7: $\\impliedby$ +#. §8: `unfold IsGCD at h` +#. §9: `obtain` +#. §10: `use` +#. §11: $x$ +#. §12: $y$ +#. §13: `_` +#. §14: `obtain ⟨_, x, y, hxy⟩ := h` +#: Game/Levels/GCD/L03_coprime_forward.lean:9 +msgid "Two integers §0 and §1 are called **coprime** (or *relatively prime*) exactly when their greatest common divisor is §2: §3.\n" "\n" -"Every integer divides itself: §0." +"By our definition, this immediately gives us a Bézout identity: there exist integers §4 with §5.\n" +"\n" +"**Note:** an \"if and only if\" statement like this one is always split into two separate levels in this game — one per direction of the arrow. This level is the \"§6\" direction; the next one is \"§7\".\n" +"\n" +"This direction is really just unpacking the definition: §8 to get access to the pieces, §9 to peel them apart, and hand the pieces straight back with §10.\n" +"\n" +"**Note:** Since we only need §11 and §12 and don't care about the divisibility facts, we can use an underscore §13 to discard that part of the pattern: §14." msgstr "" -#: Game.Levels.DivRules.L04_div4 -msgid "Exactly! Since 4 divides 100, everything above the tens place just vanishes modulo 4." +#: Game/Levels/GCD/L03_coprime_forward.lean:22 +msgid "Coprimality gives a Bézout identity." msgstr "" -#. §0: $d \\mid a$ -#. §1: $d \\mid b$ -#. §2: $d \\mid (a \\cdot x + b \\cdot y)$ -#. §3: $x$ -#. §4: $y$ -#. §5: `dvd_mul_of_dvd_left_int` -#. §6: `dvd_add_int` -#. §7: $a$ -#. §8: $b$ -#. §9: $a \\cdot x + b \\cdot y$ -#: Game.Doc.Theorems.Divisibility -msgid "**Divisibility of Linear Combinations**\n" -"\n" -"If §0 and §1, then §2 for any integers §3 and §4.\n" -"\n" -"**Intuition:**\n" -"This combines §5 (scaling) and §6 (addition) into one powerful rule: any common divisor of §7 and §8 automatically divides any linear combination §9. You will rely on this heavily when working with Greatest Common Divisors and Bézout's identity!" +#: Game/Levels/GCD/L03_coprime_forward.lean:29 +msgid "Straightforward! You've now confirmed one half of the equivalence: coprimality *implies* a Bézout identity." msgstr "" -#. §0: `polynomial_cong` -#. §1: `polynomial_cong` -#. §2: `mod_shrink` -#. §3: `mod_add_multiple` -#: Game.Levels.ModArith.L07_poly -msgid "🎉 AMAZING! 🎉\n" -"\n" -"You have conquered Modular Arithmetic! You've built a complete algebraic toolkit for congruences and proved §0.\n" -"\n" -"Next up in this branch is **Divisibility Rules**, where you will see how §1, §2, and §3 turn the famous school divisibility rules for 2, 3, 4, 5, 9, 10, and 11 into two-line proofs!" +#: Game/Levels/GCD/L04_coprime_backward.lean:7 +msgid "Bézout Gives You Coprimality (⟸)" msgstr "" -#. §0: $m \\mid (a \\cdot c)$ -#. §1: $c$ -#. §2: $m$ -#. §3: $m \\mid a$ -#: Game.Doc.Theorems.LinCong -msgid "**Euclid's Lemma**\n" +#. §0: $x, y$ +#. §1: $c \\cdot x + m \\cdot y = 1$ +#. §2: `IsGCD(c, m) 1` +#. §3: `one_dvd_int` +#. §4: $1$ +#. §5: `1 ∣ c` +#. §6: `1 ∣ m` +#: Game/Levels/GCD/L04_coprime_backward.lean:9 +msgid "Now the other direction: if there exist integers §0 with §1, does that mean §2?\n" "\n" -"If §0 and §1 is coprime to §2, then §3." +"Yes — and to prove it, remember §3 from World 1: *every* integer is divisible by §4. So the \"common divisor\" half of the definition (§5 and §6) comes completely for free! All that's left is to hand back the Bézout identity you were already given." msgstr "" -#: Game.Levels.Congruence.L05_mod_trans -msgid "Transitivity of Congruences" +#: Game/Levels/GCD/L04_coprime_backward.lean:16 +msgid "A Bézout identity implies coprimality." msgstr "" -#: Game.Levels.Divisibility.L02_negative_multiples -msgid "5 divides -15." +#. §0: `one_dvd_int` +#: Game/Levels/GCD/L04_coprime_backward.lean:21 +msgid "Remember the theorem §0 from World 1? It proves that 1 divides everything." msgstr "" -#: Game.Levels.Congruence.L01_concrete -msgid "Your First Congruence" +#. §0: `IsGCD(c, m) 1` +#: Game/Levels/GCD/L04_coprime_backward.lean:27 +msgid "Beautiful! Together, the last two levels show that §0 and \"a Bézout identity with 1 exists\" are two ways of saying exactly the same thing. From now on, feel free to think of *coprime* simply as \"Bézout equals 1\"." msgstr "" -#: Game -msgid "Number Theory Game" +#: Game/Levels/GCD/L05_gcd_symm.lean:7 +msgid "Symmetry of the GCD" msgstr "" -#. §0: $x$ -#. §1: $y$ -#. §2: $y$ -#. §3: $z$ -#. §4: $x$ -#. §5: $z$ -#. §6: $y$ -#. §7: $x$ -#. §8: $z$ -#. §9: $y$ -#. §10: $z$ -#. §11: $3 \\cdot 4 = 12$ -#. §12: $x$ -#. §13: `h1 : x ∣ y` -#. §14: `h2 : y ∣ z` -#. §15: `dvd_trans_int x y z h1 h2` -#. §16: `x ∣ z` -#: Game.Doc.Theorems.Divisibility -msgid "**Transitivity of Divisibility**\n" +#. §0: $d$ +#. §1: $a$ +#. §2: $b$ +#. §3: $b$ +#. §4: $a$ +#. §5: `IsGCD(a, b) d ⟹ IsGCD(b, a) d` +#: Game/Levels/GCD/L05_gcd_symm.lean:9 +msgid "Before we move on to the cancellation laws, let's prove a very simple but handy property: symmetry.\n" "\n" -"If §0 divides §1, and §2 divides §3, then §4 divides §5.\n" +"If §0 is a greatest common divisor of §1 and §2, then it is also a greatest common divisor of §3 and §4.\n" +"Formally: §5.\n" "\n" -"**Intuition:**\n" -"Think of it as building blocks. If a stick §6 is made of exactly 3 blocks of §7,\n" -"and a stick §8 is made of exactly 4 sticks of §9, then §10 is made of §11 blocks of §12.\n" -"Divisibility chains perfectly! In Lean, if you have §13 and §14, applying §15 proves §16." +"You will need to unpack the definition, swap the two divisibility facts, and swap the order of the Bézout coefficients!" msgstr "" -#. §0: $x$ -#. §1: $y$ -#. §2: $a$ -#. §3: $m$ -#. §4: $a \\cdot x \\equiv 1 \\pmod m$ -#. §5: $a \\cdot y \\equiv 1 \\pmod m$ -#. §6: $a \\cdot x \\equiv a \\cdot y \\pmod m$ -#. §7: $a$ -#. §8: $a$ -#. §9: $m$ -#. §10: `mod_cancel_coprime` -#. §11: `inv_implies_coprime` -#. §12: `∃ k, a * k ≡ 1` -#. §13: $x$ -#. §14: $a \\cdot x \\equiv a \\cdot y \\pmod m$ -#. §15: `mod_cancel_coprime` -#. §16: $x \\cdot a \\equiv y \\cdot a$ -#: Game.Levels.LinCong.L03_inv_unique -msgid "If §0 and §1 are both inverses of §2 modulo §3, are they the same?\n" -"\n" -"We know §4 and §5. This implies §6. Since §7 has an inverse, §8 and §9 are coprime. You can now use your ultimate weapon from the GCD world: §10!\n" -"\n" -"**Strategy:**\n" -"1. **Prove coprimality:** The theorem §11 (from the previous level) requires a proof that *some* inverse exists (§12). You can provide §13 as the witness to build this existence proof, and then extract the coprimality fact.\n" -"2. **Equate the terms:** Use symmetry and transitivity to link your two main hypotheses into §14.\n" -"3. **Cancel the factor:** Prepare your congruence for §15. The theorem expects the common factor to be on the *right* side (§16), so you will need to swap the multiplication order before applying the cancellation law." +#: Game/Levels/GCD/L05_gcd_symm.lean:18 +msgid "The GCD is symmetric." msgstr "" -#. §0: `«{d2}» ∣ «{a}» + «{m}» * «{k}»` -#. §1: `«{d2}» ∣ «{a}»` -#. §2: `«{d2}» ∣ «{m}»` -#: Game.Levels.GCD.L09_gcd_shift -msgid "Symmetrically, show §0 using the fact that §1 and §2." +#. §0: `gcd_symm` +#: Game/Levels/GCD/L05_gcd_symm.lean:33 +msgid "Nice and easy! This lemma will be saved as §0. It will save you from doing boring manual variable-swapping when you tackle the Chinese Remainder Theorem later on." msgstr "" -#. §0: `constructor` -#: Game.Levels.GCD.L01_gcd_def -msgid "Well done! You built a proof of a conjunction-inside-a-conjunction by nesting §0. Next, let's see why this definition really deserves the name \"greatest\" common divisor." +#: Game/Levels/GCD/L06_cancel_coprime.lean:8 +msgid "The Cancellation Law (Coprime Case)" msgstr "" -#. §0: `hx : x = 42` -#. §1: `hy : y = 69` -#. §2: `rw` -#. §3: `rw [hx, hy]` -#. §4: `x` -#. §5: `42` -#. §6: `y` -#. §7: `69` -#. §8: `(x - 42)` -#. §9: `(y - 69)` -#: Game.Levels.Divisibility.L07_rewriting -msgid "That goal looks terrifying! Fortunately, you don't have to expand those fifth powers by hand.\n" +#. §0: $a \\cdot c \\equiv b \\cdot c \\pmod m$ +#. §1: $c$ +#. §2: $m$ +#. §3: `IsGCD(c, m) 1` +#. §4: $a \\equiv b \\pmod m$ +#. §5: $c$ +#. §6: $c$ +#. §7: $m$ +#. §8: $c = 2$ +#. §9: $m = 4$ +#. §10: $2 \\cdot 1 \\equiv 2 \\cdot 3 \\pmod 4$ +#. §11: $6 - 2 = 4$ +#. §12: $1 \\equiv 3 \\pmod 4$ +#. §13: $3 - 1 = 2$ +#. §14: $4$ +#. §15: $c$ +#. §16: $m$ +#. §17: $c \\cdot x + m \\cdot y = 1$ +#. §18: $x, y$ +#. §19: $x$ +#. §20: $c$ +#. §21: `have` +#. §22: `ring` +#. §23: `rw` +#: Game/Levels/GCD/L06_cancel_coprime.lean:10 +msgid "Here is the central theorem of this world — and one of the most useful facts in all of number theory.\n" "\n" -"Look at your hypotheses: §0 and §1.\n" -"You can substitute these values into the goal using the **rewrite** tactic, written §2.\n" +"If §0, and §1 is coprime to §2 (§3), can we conclude §4? In other words: can we *cancel* the common factor §5 from both sides of a congruence?\n" "\n" -"Type §3 to replace every §4 with §5 and every §6 with §7. Look closely at what happens to §8 and §9 on the right-hand side!" -msgstr "" - -#. §0: $3 \\mid 9$ -#. §1: `mod_shrink` -#. §2: `have h3 : (3 : ℤ) ∣ 9` -#: Game.Levels.DivRules.L06_div3 -msgid "If the rule for 9 works, the rule for 3 must come for free, because §0.\n" +"**Yes** — but only because §6 and §7 are coprime! Without that assumption this would be false: take §8, §9. Then §10 (since §11), yet §12 is false (§13 is not a multiple of §14). Coprimality is essential.\n" "\n" -"Just like you shrank the modulus from 10 down to 2 and 5 earlier, shrink the modulus from 9 to 3 here using §1.\n" +"**The key idea:** since §15 and §16 are coprime, we have §17 for some §18 (that's exactly what you proved in Level 3!). Multiplying our congruence's underlying equation by §19 makes the extra factor §20 effectively disappear, leaving exactly what we want.\n" "\n" -"**Syntax Tip:** When writing your divisibility fact, make sure to specify the type so Lean doesn't default to natural numbers: §2" +"This proof is long, but every single step is either a §21 (a pure algebra identity, closed by §22) or an §23 that plugs in a hypothesis. Take it one line at a time." msgstr "" -#. §0: $\\mathbb{Z}$ -#. §1: `5 ∣ -15` -#. §2: $k$ -#. §3: $-15 = 5 \\cdot k$ -#. §4: `use` -#. §5: `ring` -#. §6: `use` -#. §7: `ring` -#: Game.Levels.Divisibility.L02_negative_multiples -msgid "Divisibility isn't limited to positive numbers — it works across all integers (§0), including negative ones!\n" -"\n" -"Here we want to prove §1, which means finding an integer §2 such that §3.\n" -"Once you provide the witness with §4, finish off the arithmetic using a powerful new tactic: §5.\n" -"\n" -"**Tip:** Every time you unlock a new tactic (like §6 or §7), it is added to the **Tactics** tab on the right. Check that tab anytime you want to read what a tactic does or see examples of how to use it!" +#: Game/Levels/GCD/L06_cancel_coprime.lean:23 +msgid "Cancelling a factor coprime to the modulus." msgstr "" -#. §0: `mod_mul_const` -#: Game.Levels.ModArith.L04_mul_const -msgid "Very smooth. Keep §0 in mind — you're going to put it to work right now!" +#. §0: `«{m}» ∣ («{a}» - «{b}»)` +#. §1: `«{c}» * «{x}» + «{m}» * «{y}» = 1` +#. §2: `(«{a}» - «{b}»)` +#. §3: `(«{a}» - «{b}») * («{c}» * «{x}» + «{m}» * «{y}»)` +#. §4: `«{m}»` +#. §5: `use «{k}» * «{x}» + («{a}» - «{b}») * «{y}»` +#: Game/Levels/GCD/L06_cancel_coprime.lean:30 +msgid "You need a witness for §0. We know §1. Multiplying §2 by this gives §3. With some algebra, the §4 can be factored out. Try to §5." msgstr "" -#: Game.Levels.Congruence.L07_mod_scale -msgid "Scaling the Modulus" +#. §0: `mod_cancel_coprime` +#: Game/Levels/GCD/L06_cancel_coprime.lean:44 +msgid "That's the heart of this world, conquered! §0 is now yours — it is the single most important tool you will use going forward." msgstr "" -#: Game.Levels.ModArith.L05_mul -msgid "Multiplying Congruences" +#: Game/Levels/GCD/L07_gcd_div_coprime.lean:7 +msgid "Dividing by the GCD Gives Coprime Numbers" msgstr "" -#. §0: $a \\equiv b \\pmod m$ -#. §1: $c \\equiv d \\pmod m$ -#. §2: $a \\cdot c \\equiv b \\cdot d \\pmod m$ -#. §3: `have` -#. §4: `exact` -#. §5: `mod_trans` -#. §6: $a \\cdot c$ -#. §7: $b \\cdot c$ -#. §8: $b \\cdot c$ -#. §9: $b \\cdot d$ -#. §10: `mod_mul_const` -#. §11: $a \\cdot c$ -#. §12: `exact mod_trans (a * c) (b * c) (b * d) m step1 step2_symm` -#. §13: `mod_mul_const` -#. §14: $c \\equiv d$ -#. §15: $b$ -#. §16: $c \\cdot b \\equiv d \\cdot b$ -#. §17: $b \\cdot c \\equiv b \\cdot d$ -#. §18: `have` -#. §19: `rw` -#. §20: `mod_trans` -#: Game.Levels.ModArith.L05_mul -msgid "We know we can add and subtract congruences, but can we multiply them?\n" -"If §0 and §1, is §2?\n" +#. §0: $d$ +#. §1: $c$ +#. §2: $m$ +#. §3: $c$ +#. §4: $m$ +#. §5: $d$ +#. §6: $c = c_1 \\cdot d$ +#. §7: $m = m_1 \\cdot d$ +#. §8: $c_1$ +#. §9: $m_1$ +#. §10: $d \\neq 0$ +#. §11: $d = 0$ +#. §12: $c = m = 0$ +#. §13: $d$ +#. §14: `unfold IsGCD at h` +#. §15: $c \\cdot x + m \\cdot y = d$ +#. §16: $c = c_1 \\cdot d$ +#. §17: $m = m_1 \\cdot d$ +#. §18: $c_1 \\cdot d \\cdot x + m_1 \\cdot d \\cdot y = d$ +#. §19: $d \\cdot (c_1 \\cdot x + m_1 \\cdot y) = d \\cdot 1$ +#. §20: $d \\neq 0$ +#. §21: `mul_left_cancel₀` +#. §22: $c_1, m_1$ +#. §23: $x, y$ +#: Game/Levels/GCD/L07_gcd_div_coprime.lean:9 +msgid "Here's a natural question: if §0 is a gcd of §1 and §2, and we divide both §3 and §4 by §5 (writing §6 and §7), are the quotients §8 and §9 coprime?\n" "\n" -"Just like in Level 3, instead of doing algebra from scratch, we can glue together our previous theorems using §3 and §4!\n" -"Think about transitivity (§5). We can step from §6 to §7, and then from §8 to §9, using §10 (from Level 4) for each step.\n" +"Yes — and this is exactly what will let us reduce a *general* cancellation problem to the coprime case you just solved.\n" "\n" -"**Reminder: Parentheses!**\n" -"When passing compound expressions like §11 as arguments to a theorem, remember to wrap them in parentheses so Lean knows they are a single argument:\n" -"§12\n" +"We need §10 for this level. (If §11 then §12 too, and \"dividing by §13\" doesn't make sense — you'll see exactly where this hypothesis is used.)\n" "\n" -"**Watch out for the order of multiplication!**\n" -"Applying §13 to §14 with multiplier §15 gives §16. You will need to manually flip the order to §17 using a §18 block and §19 before chaining everything together with §20." +"**Strategy:** §14 to get the Bézout identity §15. Substitute §16 and §17 to get §18, i.e. §19. Since §20, you can *cancel* it from both sides using the new theorem §21, leaving exactly the Bézout identity you need for §22 — with the very same §23!" msgstr "" -#: Game.Levels.DivRules.L01_div10 -msgid "Divisibility by 10" +#: Game/Levels/GCD/L07_gcd_div_coprime.lean:23 +msgid "Dividing by the gcd produces coprime numbers." msgstr "" -#. §0: `«{a}» - «{b}» = «{m}» * «{k1}»` -#. §1: `«{b}» - «{c}» = «{m}» * «{k2}»` -#. §2: `«{a}» - «{c}» = «{m}» * («{k1}» + «{k2}»)` -#. §3: `«{k1}»` -#. §4: `«{k2}»` -#: Game.Levels.Congruence.L05_mod_trans -msgid "You know §0 and §1. Add those two equations: §2. So the multiplier you need combines §3 and §4 by addition." +#. §0: `mul_left_cancel₀` +#. §1: `«{d}» * something = «{d}» * 1` +#: Game/Levels/GCD/L07_gcd_div_coprime.lean:36 +msgid "To use §0, you need to set up an equation of the exact form §1." msgstr "" -#. §0: $a \\cdot x \\equiv 1 \\pmod m$ -#. §1: $a \\cdot y \\equiv 1 \\pmod m$ -#. §2: $x \\equiv y \\pmod m$ -#: Game.Doc.Theorems.LinCong -msgid "**Uniqueness of Inverse**\n" -"\n" -"If §0 and §1, then §2." +#. §0: `gcd_div_coprime` +#: Game/Levels/GCD/L07_gcd_div_coprime.lean:45 +msgid "Great! §0 is now saved — it's the missing piece that will let us cancel factors that aren't necessarily coprime to the modulus, in the very next level." msgstr "" -#. §0: $a \\cdot x \\equiv b \\pmod m$ -#. §1: $d = \\gcd(a, m)$ -#. §2: $x$ -#. §3: $d$ -#. §4: $b$ -#. §5: `dvd_mul_of_dvd_left_int` -#: Game.Levels.LinCong.L04_sol_nec -msgid "We now move to general linear equations: §0.\n" -"When does this have a solution?\n" -"\n" -"Let §1. If a solution §2 exists, it is strictly necessary that §3 divides §4.\n" -"Unfold the definitions, and apply §5 from World 2!" +#: Game/Levels/GCD/L08_cancel_general.lean:7 +msgid "The General Cancellation Law" msgstr "" -#. §0: $a \\equiv b \\pmod m$ -#. §1: $a \\cdot c \\equiv b \\cdot c \\pmod m$ -#: Game.Doc.Theorems.Congruence -msgid "**Multiplying by a Constant**\n" +#. §0: $a \\cdot c \\equiv b \\cdot c \\pmod m$ +#. §1: `IsGCD(c, m) d` +#. §2: $d \\neq 0$ +#. §3: $c = c_1 \\cdot d$ +#. §4: $m = m_1 \\cdot d$ +#. §5: $a \\equiv b \\pmod{m_1}$ +#. §6: `IsGCD(a, b) d` +#. §7: `have` +#. §8: `IsGCD a b d` +#. §9: `gcd_div_coprime` +#. §10: `IsGCD(c_1, m_1) 1` +#. §11: $c = c_1 \\cdot d$ +#. §12: $m = m_1 \\cdot d$ +#. §13: $d$ +#. §14: `mul_left_cancel₀` +#. §15: `have h1' : (a * c1) ≡ (b * c1) (mod m1)` +#. §16: `ModEq` +#. §17: `mod_cancel_coprime` +#. §18: `have` +#. §19: `exact` +#: Game/Levels/GCD/L08_cancel_general.lean:9 +msgid "Time to combine the last two levels into the *fully general* cancellation law — no coprimality assumption required!\n" "\n" -"If §0, then §1." +"If §0 and §1 with §2, and we write §3, §4 (exactly as in Level 7), then §5.\n" +"\n" +"**Lean Syntax Tip:** The notation §6 is just syntactic sugar to make the goals easier to read. When writing your own code (for example, when defining a new hypothesis with §7), you need to use the standard Lean syntax without parentheses or commas: §8.\n" +"\n" +"**Strategy:** Assemble, don't reprove.\n" +"1. Apply §9 (Level 7) to get §10.\n" +"2. Unfold the congruence hypothesis, substitute §11 and §12, and cancel the shared factor §13 (using §14 again). This will leave you with a plain algebraic equation!\n" +"3. **Reassemble the congruence:** create the specific hypothesis you need using §15. Prove it by unfolding §16 and using the cancelled equation from step 2.\n" +"4. Feed both pieces into §17 (Level 6) to finish in one line!\n" +"\n" +"Build small intermediate facts with §18, then §19 the final theorem!" msgstr "" -#: Game -msgid "An interactive introduction to Number Theory and modular arithmetic." +#: Game/Levels/GCD/L08_cancel_general.lean:26 +msgid "The fully general cancellation law for congruences." msgstr "" -#: Game.Levels.GCD.L08_cancel_general -msgid "The General Cancellation Law" +#. §0: `«{a}» * «{c1}» - «{b}» * «{c1}» = «{m1}» * «{k}»` +#. §1: `mod_cancel_coprime` +#: Game/Levels/GCD/L08_cancel_general.lean:45 +msgid "You have a plain equation now, §0, but §1 needs an actual congruence, not a bare equation. Wrap it back up: state the congruence, unfold it, and it reduces to exactly the equation you already have." msgstr "" -#: Game.Levels.ModArith.L07_poly -msgid "Polynomial Congruences (Boss)" +#: Game/Levels/GCD/L08_cancel_general.lean:53 +msgid "Incredible! You just built the full cancellation law for modular congruences by gluing together two previous theorems and one careful algebraic cancellation. This is exactly how real number-theory results get assembled from smaller pieces." msgstr "" -#: Game.Levels.Divisors.L05_dvd_trans -msgid "Chain of Divisors" +#: Game/Levels/GCD/L09_gcd_shift.lean:7 +msgid "A Shift Doesn't Change the GCD (Boss)" msgstr "" #. §0: $m$ @@ -2580,838 +2820,769 @@ msgstr "" #. §43: `0 ≤ d2` #. §44: `d1 = d2` #. §45: `dvd_antisymm_int` -#: Game.Levels.GCD.L09_gcd_shift +#: Game/Levels/GCD/L09_gcd_shift.lean:9 msgid "Welcome to the final boss of the GCD world!\n" "\n" "We prove the fact that sits at the heart of the **Euclidean Algorithm**: shifting a number by a multiple of §0 does not change its greatest common divisor with §1.\n" "\n" "Formulation: if §2 is a (non-negative) gcd of §3 and §4, and §5 is a (non-negative) gcd of §6 and §7, then §8.\n" "\n" -"**Syntax Tip:** Before we start, a quick trick! Since §9 is a nested logical AND (§10), you can extract its pieces directly using **dot notation** without destroying the original hypothesis. For example, §11 gets the very first fact, and §12 gets the second. Because we will need to pass the intact hypotheses §13 and §14 to §15 later, using dot notation is safer here than using §16!\n" -"\n" -"**Strategy:** This one's long — take it one step at a time!\n" -"\n" -"1. Show §17 is also a common divisor of §18 and §19 (not just of §20): since §21, and §22 divides both §23 and §24, it divides §25 too. Now §26 is a common divisor of §27 and §28, and §29 is *the greatest one* (Level 2!), so §30.\n" -"2. Symmetrically, show §31 is also a common divisor of §32 and §33: since §34 divides both §35 and §36, it divides the combination §37 too. Applying Level 2 again (this time with §38 as \"the greatest\"), you get §39.\n" -"3. Finally, §40 and §41, together with §42 and §43, give §44 by the antisymmetry lemma (§45) that has just been added to your inventory!" -msgstr "" - -#. §0: `have` -#. §1: `h` -#. §2: `X = Y` -#. §3: `have` -#. §4: `a ≡ b (mod m)` -#. §5: `x ∣ y` -#. §6: `IsGCD(a, b) 1` -#. §7: `:=` -#. §8: `have h : a ≡ b (mod m)` -#. §9: `` -#: Game.Doc.Tactics -msgid "The §0 tactic allows you to prove intermediate steps. Once proven, a new hypothesis §1 is added to your context for the rest of the proof.\n" -"\n" -"You are not limited to basic equalities (§2). You can use §3 for any proposition, such as modular equivalences (§4), divisibility (§5), or predicates like §6.\n" -"\n" -"\n" -"**Important:** In this game, the assignment syntax (§7) is disabled. You must state the assumption and provide the proof on the following line.\n" -"\n" -"**Using a proof block:**\n" -"You can state the assumption and provide the proof on the following lines. This sets your intermediate assumption as the current goal:\n" -"§8\n" -"§9" -msgstr "" - -#. §0: `use` -#. §1: `∃ k, 12 = 3 * k` -#. §2: `use 4` -#. §3: `12 = 3 * 4` -#. §4: `∃ x y : ℤ, 2 * x + 3 * y = 1` -#. §5: `use -1, 1` -#: Game.Doc.Tactics -msgid "The §0 tactic is used to provide a \"witness\" to prove that something exists.\n" -"If your goal is §1, typing §2 changes the goal to §3.\n" -"\n" -"**Multiple arguments:**\n" -"If your goal has multiple existentials, for example §4, you can provide multiple witnesses separated by commas: §5." -msgstr "" - -#. §0: $6$ -#. §1: $x$ -#. §2: `h : 6 ∣ x` -#. §3: $3$ -#. §4: $x$ -#. §5: `h` -#. §6: `obtain ⟨k, hk⟩ := h` -#. §7: `hk : x = 6 * k` -#. §8: $6 \\cdot k = 3 \\cdot (2 \\cdot k)$ -#. §9: `use` -#. §10: `3 ∣ x` -#: Game.Levels.Divisors.L02_multiples_of_6 -msgid "Now let's combine unpacking a hypothesis with proving a new divisibility goal!\n" -"\n" -"Suppose §0 divides §1 (§2). Does §3 also divide §4?\n" -"Yes! Unpack §5 using §6 to get §7.\n" -"\n" -"Since §8, what witness should you §9 to prove §10?" -msgstr "" - -#. §0: `mul_left_cancel₀` -#. §1: `«{d}» * something = «{d}» * 1` -#: Game.Levels.GCD.L07_gcd_div_coprime -msgid "To use §0, you need to set up an equation of the exact form §1." -msgstr "" - -#: Game.Levels.Congruence.L04_mod_symm -msgid "Symmetry of Congruences" -msgstr "" - -#. §0: $d$ -#. §1: `IsGCD(a, b) d` -#. §2: $a$ -#. §3: $b$ -#. §4: $d$ -#. §5: `IsGCD(a, b) d` -#. §6: $c$ -#. §7: $a$ -#. §8: $b$ -#. §9: $c \\mid a$ -#. §10: $c \\mid b$ -#. §11: $c \\mid d$ -#. §12: $d = a \\cdot x + b \\cdot y$ -#. §13: $a$ -#. §14: $b$ -#. §15: `dvd_lin_comb_int` -#. §16: $a$ -#. §17: $b$ -#. §18: $a \\cdot x + b \\cdot y$ -#. §19: `unfold IsGCD at h` -#. §20: $x, y$ -#. §21: $a \\cdot x + b \\cdot y = d$ -#. §22: `obtain` -#. §23: `⟨⟨hda, hdb⟩, x, y, hxy⟩` -#. §24: $c \\mid d$ -#. §25: `rw [← hxy]` -#. §26: $c \\mid a \\cdot x + b \\cdot y$ -#. §27: `dvd_lin_comb_int` -#: Game.Levels.GCD.L02_gcd_greatest -msgid "Now for the payoff of our definition: let's show that any §0 satisfying §1 is truly a *greatest* common divisor — meaning every other common divisor of §2 and §3 also divides §4.\n" -"\n" -"Formulation: if §5 holds, and §6 is *any* common divisor of §7 and §8 (§9 and §10), then §11.\n" -"\n" -"Why is this so easy with our Bézout-style definition? Because §12 is a **linear combination** of §13 and §14 — and in the final boss of World 2 (§15), you already proved that any common divisor of §16 and §17 divides *every* linear combination §18!\n" -"\n" -"**Strategy:**\n" -"1. §19 to reveal the two divisibility facts and the Bézout witnesses §20 with §21. Since this is a nested conjunction-with-an-existential, §22 can peel apart all the layers at once with a pattern like §23.\n" -"2. Rewrite the goal §24 backwards using §25 to turn it into §26.\n" -"3. Close the goal in one line using §27 from World 2!" -msgstr "" - -#. §0: $a \\equiv 0 \\pmod m$ -#. §1: $m$ -#. §2: $a$ -#: Game.Levels.Congruence.L03_dvd_imp_mod_zero -msgid "Divisibility and congruence to zero are two sides of the same coin!\n" -"Whenever you see §0, you can immediately translate it in your head as \"§1 divides §2\"." -msgstr "" - -#. §0: $a \\equiv b \\pmod m$ -#. §1: $b \\equiv a \\pmod m$ -#. §2: `at` -#. §3: `unfold` -#. §4: `rw` -#. §5: `at` -#. §6: `unfold ModEq at h` -#. §7: `h` -#. §8: `unfold ModEq at *` -#. §9: `have` -#. §10: $a - b = m \\cdot k$ -#. §11: $b - a$ -#. §12: `have h_eq : b - a = -(a - b)` -#. §13: `ring` -#. §14: `h_eq` -#. §15: `rw [h_eq]` -#. §16: `rw` -#. §17: `rw [← h_eq]` -#. §18: `\\l` -#: Game.Levels.Congruence.L04_mod_symm -msgid "The second property of an equivalence relation is **symmetry**: if §0, then §1.\n" -"\n" -"Before we dive into the proof, let's learn two crucial Lean features:\n" -"\n" -"1. **The §2 keyword:** By default, tactics like §3 or §4 only affect your *goal*. To modify hypotheses, use §5:\n" -"* §6 unfolds the definition inside hypothesis §7.\n" -"* §8 unfolds it *everywhere* (in all hypotheses and the goal at once).\n" -"\n" -"2. **The §9 tactic:** Often, you need an intermediate algebraic fact before you can rewrite your goal. For example, here you know §10, but your goal contains §11.\n" -"If you type §12, Lean will pause and ask you to prove this equation first (using §13). Once proved, §14 is added to your assumptions so you can §15 to change the main goal!\n" +"**Syntax Tip:** Before we start, a quick trick! Since §9 is a nested logical AND (§10), you can extract its pieces directly using **dot notation** without destroying the original hypothesis. For example, §11 gets the very first fact, and §12 gets the second. Because we will need to pass the intact hypotheses §13 and §14 to §15 later, using dot notation is safer here than using §16!\n" "\n" -"*(Tip: Remember that §16 replaces the left side of an equation with the right side, unless you use a left arrow §17 via §18.)*" +"**Strategy:** This one's long — take it one step at a time!\n" +"\n" +"1. Show §17 is also a common divisor of §18 and §19 (not just of §20): since §21, and §22 divides both §23 and §24, it divides §25 too. Now §26 is a common divisor of §27 and §28, and §29 is *the greatest one* (Level 2!), so §30.\n" +"2. Symmetrically, show §31 is also a common divisor of §32 and §33: since §34 divides both §35 and §36, it divides the combination §37 too. Applying Level 2 again (this time with §38 as \"the greatest\"), you get §39.\n" +"3. Finally, §40 and §41, together with §42 and §43, give §44 by the antisymmetry lemma (§45) that has just been added to your inventory!" msgstr "" -#: Game.Levels.GCD.L02_gcd_greatest -msgid "Any gcd witness dominates every common divisor." +#: Game/Levels/GCD/L09_gcd_shift.lean:28 +msgid "Shifting by a multiple of m does not change the gcd with m." msgstr "" -#. §0: $a$ -#. §1: $m$ -#. §2: $a$ -#. §3: $m$ -#. §4: $0$ -#. §5: $a \\equiv 0 \\pmod m$ -#: Game.Levels.Congruence.L03_dvd_imp_mod_zero -msgid "Before continuing with equivalence relations, let's build a direct bridge between divisibility and congruences.\n" -"\n" -"What does it mean for a number §0 to be divisible by §1 in the language of congruences? It simply means that dividing §2 by §3 leaves a remainder of §4 — or in other words, §5." +#. §0: `«{h1}»` +#. §1: `«{h2}»` +#. §2: `have` +#: Game/Levels/GCD/L09_gcd_shift.lean:32 +msgid "Start by extracting the four divisibility facts from §0 and §1 using the dot notation explained in the introduction. Create new hypotheses for them using §2." msgstr "" -#: Game.Levels.GCD.L06_cancel_coprime -msgid "Cancelling a factor coprime to the modulus." +#. §0: `«{d1}»` +#. §1: `«{a}»` +#. §2: `«{a}»` +#. §3: `(«{a}» + «{m}» * «{k}») - «{m}» * «{k}»` +#: Game/Levels/GCD/L09_gcd_shift.lean:46 +msgid "First step: show that §0 divides §1. Think of §2 as §3." msgstr "" -#. §0: $10 \\cdot k + d$ -#. §1: $d$ -#. §2: $k$ -#. §3: $10 \\cdot k + d \\equiv d \\pmod{10}$ -#. §4: `mod_add_multiple` -#: Game.Levels.DivRules.L01_div10 -msgid "Let's start with the easiest rule: a number is divisible by 10 if and only if its last digit is 0.\n" +#. §0: `«{d1}» ∣ «{a}»` +#. §1: `«{d1}» ∣ «{m}»` +#. §2: `gcd_is_greatest` +#. §3: `«{h2}»` +#. §4: `«{d1}» ∣ «{d2}»` +#: Game/Levels/GCD/L09_gcd_shift.lean:59 +msgid "Now that you know §0 and §1, use the theorem §2 (from Level 2) on §3 to show that §4." +msgstr "" + +#. §0: `«{d2}» ∣ «{a}» + «{m}» * «{k}»` +#. §1: `«{d2}» ∣ «{a}»` +#. §2: `«{d2}» ∣ «{m}»` +#: Game/Levels/GCD/L09_gcd_shift.lean:64 +msgid "Symmetrically, show §0 using the fact that §1 and §2." +msgstr "" + +#. §0: `gcd_is_greatest` +#. §1: `«{h1}»` +#. §2: `«{d2}» ∣ «{d1}»` +#: Game/Levels/GCD/L09_gcd_shift.lean:73 +msgid "Almost there! Apply §0 on §1 to show §2." +msgstr "" + +#. §0: `«{d1}» ∣ «{d2}»` +#. §1: `«{d2}» ∣ «{d1}»` +#. §2: `dvd_antisymm_int` +#: Game/Levels/GCD/L09_gcd_shift.lean:77 +msgid "You have §0 and §1. Finish the boss by applying §2!" +msgstr "" + +#: Game/Levels/GCD/L09_gcd_shift.lean:82 +msgid "🎉 MAGNIFICENT! 🎉\n" "\n" -"How do we write \"the last digit\" in math? Think about how numbers are built. You can split any number into its last digit and \"everything else\" multiplied by 10. For example, **347 = 34 * 10 + 7**.\n" -"So, any integer can mathematically be written as §0, where §1 is the last digit and §2 is the rest of the number.\n" +"You have conquered the GCD world! You built a working theory of the greatest common divisor from a single Bézout-style definition, proved it truly deserves the name \"greatest\", derived the coprime and general cancellation laws, and finished by proving the very fact that powers the Euclidean Algorithm.\n" "\n" -"We want to prove that §3.\n" -"This is a direct consequence of §4 from the Congruence world! You just need to massage the equation slightly." +"To be continued in **Linear Congruences and CRT**, where all of this comes together to solve linear congruences and prove the Chinese Remainder Theorem!" msgstr "" -#: Game.Levels.Divisibility.L05_dvd_refl -msgid "Every integer divides itself." +#: Game/Levels/GCD.lean:12 +msgid "In Search of the GCD" msgstr "" -#. §0: $a \\mid b$ -#. §1: `use` -#. §2: `ring` -#. §3: `rw` -#: Game.Levels.Divisibility -msgid "Welcome to World 1: The Divisibility Club!\n" -"\n" -"In this first world, you will learn the basics of Lean 4, how to interact with the system, and how to write your very first formal proofs. Together, we will explore the fundamental concept of number theory: divisibility (§0).\n" +#. §0: $c$ +#. §1: $a \\cdot c \\equiv b \\cdot c \\pmod m$ +#: Game/Levels/GCD.lean:14 +msgid "Welcome to In Search of the GCD!\n" "\n" -"Starting from simple numerical examples, you will master essential proof tactics (§1, §2, and §3) and prove the first universal properties of divisibility.\n" +"Can we cancel a common factor §0 from both sides of a congruence §1? Not always! To safely cancel factors in modular arithmetic, we need to deeply understand the Greatest Common Divisor (GCD).\n" "\n" -"Take your time, read the explanations carefully, and have fun!" +"In this world, we will define the GCD using Bézout's identity, prove its properties, unlock the ultimate tool for number theory — the General Cancellation Law — and finish by proving the shift invariance that powers the Euclidean Algorithm. Let's find that GCD!" msgstr "" -#. §0: $c$ -#. §1: $m$ -#. §2: $1$ -#. §3: `IsGCD(c, m) 1` -#. §4: $x, y$ -#. §5: $c \\cdot x + m \\cdot y = 1$ -#. §6: $\\implies$ -#. §7: $\\impliedby$ -#. §8: `unfold IsGCD at h` -#. §9: `obtain` -#. §10: `use` -#. §11: $x$ -#. §12: $y$ -#. §13: `_` -#. §14: `obtain ⟨_, x, y, hxy⟩ := h` -#: Game.Levels.GCD.L03_coprime_forward -msgid "Two integers §0 and §1 are called **coprime** (or *relatively prime*) exactly when their greatest common divisor is §2: §3.\n" +#. §0: $\\text{IsGCD}(a, m) 1$ +#. §1: $x$ +#. §2: $a \\cdot x \\equiv 1 \\pmod m$ +#. §3: $a \\cdot x + m \\cdot y = 1$ +#. §4: $a \\cdot x = 1 - m \\cdot y$ +#. §5: $a \\cdot x$ +#. §6: $1$ +#. §7: $m$ +#. §8: $\\equiv 1 \\pmod m$ +#. §9: $\\gcd(3, 7) = 1$ +#. §10: $3 \\cdot (-2) + 7 \\cdot 1 = 1$ +#. §11: $x = -2$ +#. §12: $3 \\cdot (-2) = -6$ +#. §13: $-6 \\equiv 1 \\pmod 7$ +#. §14: $-6 - 1 = -7 = 7 \\cdot (-1)$ +#: Game/Doc/Theorems/LinCong.lean:4 +msgid "**Modular Inverse Existence**\n" "\n" -"By our definition, this immediately gives us a Bézout identity: there exist integers §4 with §5.\n" +"If §0, then there exists an integer §1 such that §2.\n" "\n" -"**Note:** an \"if and only if\" statement like this one is always split into two separate levels in this game — one per direction of the arrow. This level is the \"§6\" direction; the next one is \"§7\".\n" +"**Intuition:**\n" +"Coprimality gives §3, i.e. §4 — meaning §5 is exactly §6 *shifted by a multiple of §7*. That's precisely what \"§8\" means.\n" "\n" -"This direction is really just unpacking the definition: §8 to get access to the pieces, §9 to peel them apart, and hand the pieces straight back with §10.\n" +"For example: §9, and §10. So §11 works: §12, and indeed §13 (since §14)." +msgstr "" + +#. §0: $a \\cdot x \\equiv 1 \\pmod m$ +#. §1: $x$ +#. §2: $\\text{IsGCD}(a, m) 1$ +#: Game/Doc/Theorems/LinCong.lean:17 +msgid "**Reverse Inverse**\n" "\n" -"**Note:** Since we only need §11 and §12 and don't care about the divisibility facts, we can use an underscore §13 to discard that part of the pattern: §14." +"If §0 for some §1, then §2." msgstr "" -#. §0: $a$ -#. §1: $a \\mid b$ -#. §2: $a \\mid c$ -#. §3: $a$ -#. §4: $b + c$ -#. §5: `h1 : a ∣ b` -#. §6: `h2 : a ∣ c` -#. §7: `obtain` -#. §8: `obtain ⟨k1, hk1⟩ := h1` -#. §9: `obtain ⟨k2, hk2⟩ := h2` -#. §10: $b + c = a \\cdot k_1 + a \\cdot k_2 = a \\cdot (k_1 + k_2)$ -#. §11: `a ∣ b + c` -#: Game.Levels.Divisors.L04_dvd_add -msgid "What happens when we add two multiples of §0 together?\n" -"If §1 and §2, then §3 must also divide their sum §4.\n" +#. §0: $a \\cdot x \\equiv 1 \\pmod m$ +#. §1: $a \\cdot y \\equiv 1 \\pmod m$ +#. §2: $x \\equiv y \\pmod m$ +#: Game/Doc/Theorems/LinCong.lean:25 +msgid "**Uniqueness of Inverse**\n" "\n" -"This time you have **two** divisibility hypotheses: §5 and §6.\n" -"Unpack both of them using §7, making sure to give their witnesses different names:\n" -"- §8\n" -"- §9\n" +"If §0 and §1, then §2." +msgstr "" + +#. §0: $d = \\gcd(a, m)$ +#. §1: $a \\cdot x \\equiv b \\pmod m$ +#. §2: $d \\mid b$ +#: Game/Doc/Theorems/LinCong.lean:33 +msgid "**Solvability (Necessary Condition)**\n" "\n" -"Since §10, you can easily spot the witness for §11!" +"If §0 and §1 has a solution, then §2." msgstr "" -#. §0: `«{c}» * «{b}» ≡ «{d}» * «{b}»` -#. §1: `«{b}» * «{c}» ≡ «{b}» * «{d}»` -#: Game.Levels.ModArith.L05_mul -msgid "You know that §0. Because multiplication is commutative, this is equivalent to §1. Try proving this flipped version first, so you can smoothly chain everything together with transitivity." +#. §0: $d = \\gcd(a, m)$ +#. §1: $d \\mid b$ +#. §2: $\\exists x, a \\cdot x \\equiv b \\pmod m$ +#: Game/Doc/Theorems/LinCong.lean:41 +msgid "**Solvability (Sufficient Condition)**\n" +"\n" +"If §0 and §1, then §2." msgstr "" -#: Game.Levels.Divisibility.L07_rewriting -msgid "Rewriting" +#. §0: $m/d$ +#. §1: $a \\cdot x \\equiv b \\pmod m$ +#. §2: $m/d$ +#: Game/Doc/Theorems/LinCong.lean:49 +msgid "**Congruent Solutions modulo §0**\n" +"\n" +"All solutions to §1 are congruent modulo §2." msgstr "" -#. §0: `obtain` -#. §1: $\\exists$ -#. §2: $\\wedge$ -#. §3: `h : x ∣ y` -#. §4: `∃ k, y = x * k` -#. §5: `obtain ⟨k, hk⟩ := h` -#. §6: `k` -#. §7: `hk : y = x * k` -#. §8: `⟨` -#. §9: `⟩` -#. §10: `\\<` -#. §11: `\\>` -#. §12: `IsGCD(c, m) 1` -#. §13: `∧` -#. §14: `∃` -#. §15: `obtain ⟨_, x, y, hxy⟩ := h` -#. §16: `_` -#. §17: `x` -#. §18: `y` -#. §19: `hxy` -#. §20: `∧` -#. §21: `obtain` -#. §22: `h.1.1` -#. §23: `h.1.2` -#: Game.Doc.Tactics -msgid "The §0 tactic extracts a witness from a hypothesis that contains an \"exists\" (§1) or a logical AND (§2).\n" -"If you have a hypothesis §3 (which means §4), you can type\n" -"§5 to get the variable §6 and the equation §7.\n" -"*(To type §8 and §9, write §10 and §11, then press Space.)*\n" +#. §0: $m/d$ +#: Game/Doc/Theorems/LinCong.lean:57 +msgid "**Shifting the Solution**\n" "\n" -"**Nested and multiple arguments:**\n" -"For more complex hypotheses, such as §12 (which contains multiple nested §13 and §14), you can extract everything at once by providing up to 4 arguments.\n" -"For example: §15.\n" -"The underscore §16 is used to discard parts of the hypothesis you don't need (like the divisibility facts), while binding the Bézout witnesses to §17 and §18 and the equation to §19.\n" +"Any shift of a solution by a multiple of §0 yields another valid solution." +msgstr "" + +#. §0: $m \\mid (a \\cdot c)$ +#. §1: $c$ +#. §2: $m$ +#. §3: $m \\mid a$ +#: Game/Doc/Theorems/LinCong.lean:65 +msgid "**Euclid's Lemma**\n" +"\n" +"If §0 and §1 is coprime to §2, then §3." +msgstr "" + +#. §0: $\\gcd(m, n) = 1$ +#. §1: $x$ +#. §2: $x$ +#. §3: $u, v$ +#. §4: $m \\cdot u + n \\cdot v = 1$ +#. §5: $n \\cdot v$ +#. §6: $1$ +#. §7: $m$ +#. §8: $n$ +#. §9: $m \\cdot u$ +#. §10: $1$ +#. §11: $n$ +#. §12: $m$ +#. §13: $x = a \\cdot n \\cdot v + b \\cdot m \\cdot u$ +#. §14: $a$ +#. §15: $m$ +#. §16: $b$ +#. §17: $n$ +#. §18: $x \\equiv 2 \\pmod 3$ +#. §19: $x \\equiv 3 \\pmod 5$ +#. §20: $3 \\cdot 2 + 5 \\cdot (-1) = 1$ +#. §21: $u = 2, v = -1$ +#. §22: $x = 2 \\cdot 5 \\cdot (-1) + 3 \\cdot 3 \\cdot 2 = -10 + 18 = 8$ +#. §23: $8 \\equiv 2 \\pmod 3$ +#. §24: $8 \\equiv 3 \\pmod 5$ +#: Game/Doc/Theorems/LinCong.lean:73 +msgid "**CRT Existence**\n" +"\n" +"If §0, then there exists an §1 solving both congruences.\n" +"\n" +"**Intuition:**\n" +"Build §2 from two pieces using Bézout witnesses §3 with §4. The term §5 behaves like \"§6\" modulo §7 (and vanishes modulo §8), while §9 behaves like \"§10\" modulo §11 (and vanishes modulo §12). So §13 picks up §14's value mod §15 and §16's value mod §17 simultaneously.\n" "\n" -"**Dot notation alternative:**\n" -"If a hypothesis is just a nested logical AND (§20), you can extract its pieces directly using **dot notation** without destroying the original hypothesis via §21. For example, §22 gets the first fact, and §23 gets the second." +"**Example:** solving §18 and §19: here §20, so §21. This gives §22. Check: §23 ✓ and §24 ✓." msgstr "" -#. §0: $d$ -#. §1: $c$ -#. §2: $m$ -#. §3: $c$ +#. §0: $x \\equiv a \\pmod m$ +#. §1: $x \\equiv a \\pmod n$ +#. §2: $x \\equiv a \\pmod{m \\cdot n}$ +#. §3: $x - a$ #. §4: $m$ -#. §5: $d$ -#. §6: $c = c_1 \\cdot d$ -#. §7: $m = m_1 \\cdot d$ -#. §8: $c_1$ -#. §9: $m_1$ -#. §10: $d \\neq 0$ -#. §11: $d = 0$ -#. §12: $c = m = 0$ -#. §13: $d$ -#. §14: `unfold IsGCD at h` -#. §15: $c \\cdot x + m \\cdot y = d$ -#. §16: $c = c_1 \\cdot d$ -#. §17: $m = m_1 \\cdot d$ -#. §18: $c_1 \\cdot d \\cdot x + m_1 \\cdot d \\cdot y = d$ -#. §19: $d \\cdot (c_1 \\cdot x + m_1 \\cdot y) = d \\cdot 1$ -#. §20: $d \\neq 0$ -#. §21: `mul_left_cancel₀` -#. §22: $c_1, m_1$ -#. §23: $x, y$ -#: Game.Levels.GCD.L07_gcd_div_coprime -msgid "Here's a natural question: if §0 is a gcd of §1 and §2, and we divide both §3 and §4 by §5 (writing §6 and §7), are the quotients §8 and §9 coprime?\n" +#. §5: $n$ +#. §6: $m$ +#. §7: $n$ +#. §8: $m \\cdot n$ +#. §9: $m = n = 2$ +#. §10: $m \\cdot n = 4$ +#. §11: $x - a = 2$ +#. §12: $12$ +#. §13: $3$ +#. §14: $4$ +#. §15: $12$ +#. §16: $3 \\cdot 4 = 12$ +#: Game/Doc/Theorems/LinCong.lean:86 +msgid "**Glued Modulus**\n" "\n" -"Yes — and this is exactly what will let us reduce a *general* cancellation problem to the coprime case you just solved.\n" +"If §0 and §1 with coprime moduli, then §2.\n" "\n" -"We need §10 for this level. (If §11 then §12 too, and \"dividing by §13\" doesn't make sense — you'll see exactly where this hypothesis is used.)\n" +"**Intuition:**\n" +"§3 is a multiple of both §4 and §5 separately. If §6 and §7 share no common factor, the only way a number can be built from both is by being a multiple of their product §8 — nothing is double-counted. This is exactly why coprimality matters: if §9, a number could be a multiple of both without being a multiple of §10 (e.g. §11).\n" "\n" -"**Strategy:** §14 to get the Bézout identity §15. Substitute §16 and §17 to get §18, i.e. §19. Since §20, you can *cancel* it from both sides using the new theorem §21, leaving exactly the Bézout identity you need for §22 — with the very same §23!" +"**Example:** §12 is a multiple of both §13 and §14 (coprime!), and indeed §15 is a multiple of §16." msgstr "" -#. §0: `∧` -#. §1: `constructor` -#: Game.Levels.GCD.L01_gcd_def -msgid "The first goal is *also* an §0. Use §1 again!" +#: Game/Levels/LinCong/L01_inv_exists.lean:17 +msgid "Existence of the Inverse" msgstr "" -#. §0: `intro` -#. §1: $\\forall$ -#. §2: $\\implies$ -#. §3: `∀ a, P a` -#. §4: `intro a` -#. §5: `a` -#: Game.Doc.Tactics -msgid "The §0 tactic is used to introduce variables from a \"For all\" (§1) statement\n" -"or to assume the premise of an implication (§2).\n" -"For example, if the goal is §3, typing §4 moves §5 into your context." +#. §0: $a$ +#. §1: $m$ +#. §2: $\\gcd(a, m) = 1$ +#. §3: $x$ +#. §4: $a \\cdot x \\equiv 1 \\pmod m$ +#. §5: $a$ +#. §6: $m$ +#. §7: $a \\cdot x + m \\cdot y = 1$ +#. §8: $x$ +#. §9: `unfold IsGCD` +#: Game/Levels/LinCong/L01_inv_exists.lean:19 +msgid "First, let's explore **modular inverses**. If §0 and §1 are coprime (§2), does there exist an §3 such that §4?\n" +"\n" +"Yes! And Bézout's identity gives us exactly the proof. Since §5 and §6 are coprime, we know §7. The §8 from this identity is exactly the inverse we are looking for.\n" +"\n" +"Use §9 to extract Bézout's coefficients, and then use algebra!" msgstr "" -#. §0: `use` -#: Game.Levels.Divisibility.L01_first_proof -msgid "Congratulations! You have just written your first proof in Lean 4!\n" -"You used §0 to provide a witness, and Lean automatically closed the obvious equality." +#. §0: `«{m}» ∣ («{a}» * «{x}» - 1)` +#. §1: `«{hxy}»` +#. §2: `«{a}» * «{x}» - 1 = -«{m}» * «{y}»` +#. §3: `use -«{y}»` +#: Game/Levels/LinCong/L01_inv_exists.lean:33 +msgid "Your goal is §0. From §1 you know §2, so try §3." msgstr "" -#: Game.Levels.Divisors.L02_multiples_of_6 -msgid "Every multiple of 6 is also a multiple of 3." +#. §0: `«{a}» * «{x}» - 1` +#. §1: `«{hxy}»` +#. §2: `have h_eq : «{a}» * «{x}» - 1 = («{a}» * «{x}» + «{m}» * «{y}») - 1 - «{m}» * «{y}»` +#: Game/Levels/LinCong/L01_inv_exists.lean:35 +msgid "Rewrite §0 using §1 with §2." msgstr "" -#. §0: `«{m}»` -#. §1: `(«{a}» * «{n}» * «{v}» + «{b}» * «{m}» * «{u}») - «{a}»` -#. §2: `«{m}» * («{b}» * «{u}» - «{a}» * «{u}») + «{a}» * («{m}» * «{u}» + «{n}» * «{v}» - 1)` -#. §3: `«{huv}»` -#. §4: `«{m}» * «{u}» + «{n}» * «{v}»` -#. §5: `1` -#: Game.Levels.LinCong.L09_crt_exists -msgid "To prove this divisibility, you need to factor out §0. Notice that §1 can be algebraically rearranged into §2. If you introduce this equality, you can use §3 to replace §4 with §5, effectively cancelling out the second part." +#: Game/Levels/LinCong/L01_inv_exists.lean:44 +msgid "Perfect! You have proven that every number coprime to the modulus has a modular inverse." msgstr "" -#: Game.Levels.ModArith.L01_add -msgid "Excellent! You just proved your first arithmetic rule for congruences." +#: Game/Levels/LinCong/L02_inv_reverse.lean:7 +msgid "Inverse Implies Coprimality" msgstr "" -#. §0: $x \\equiv 2 \\pmod 5$ -#. §1: $x \\equiv 3 \\pmod 7$ -#. §2: $x^2 - 5x + 6 \\equiv 0 \\pmod{35}$ -#: Game.Levels.Problems.L07_quadratic -msgid "Let's evaluate a polynomial congruence based on multiple moduli.\n" +#. §0: $a$ +#. §1: $m$ +#. §2: $a$ +#. §3: $m$ +#. §4: $a \\cdot x \\equiv 1 \\pmod m$ +#. §5: $a \\cdot x - 1 = m \\cdot k$ +#. §6: $1$ +#. §7: `bezout_imp_coprime` +#: Game/Levels/LinCong/L02_inv_reverse.lean:9 +msgid "Does it work the other way? If §0 has a modular inverse modulo §1, must §2 and §3 be coprime?\n" "\n" -"If §0 and §1, can you prove that §2?" +"Absolutely. If §4, it means §5, which you can rearrange into a Bézout identity for §6. You proved in the GCD world (§7) that this forces the GCD to be 1!" msgstr "" -#: Game.Levels.LinCong.L03_inv_unique -msgid "The Inverse is Unique" +#. §0: `«{a}» * «{x}» - 1 = «{m}» * «{k}»` +#. §1: `«{a}» * «{x}» + «{m}» * (-«{k}») = 1` +#. §2: `«{x}»` +#. §3: `«{k}»` +#: Game/Levels/LinCong/L02_inv_reverse.lean:21 +msgid "You know §0. Rearranged, §1 — exactly a Bézout identity for 1, using the same §2 and the negation of §3." msgstr "" -#. §0: $a \\cdot x + b \\cdot y$ -#. §1: $a$ -#. §2: $b$ -#. §3: $d$ -#. §4: $a$ -#. §5: $b$ -#. §6: $d$ -#. §7: $a \\cdot x + b \\cdot y$ -#. §8: $d \\mid a \\implies d \\mid a \\cdot x$ -#. §9: $d \\mid u$ -#. §10: $d \\mid v \\implies d \\mid u + v$ -#. §11: `ha` -#. §12: `hb` -#. §13: `obtain` -#: Game.Levels.Divisors.L06_dvd_lin_comb -msgid "Welcome to the final boss of World 2!\n" -"\n" -"An expression of the form §0 is called a **linear combination** of §1 and §2.\n" -"Here you will prove one of the most important facts in all of number theory: if §3 divides both §4 and §5, then §6 divides **any** linear combination §7!\n" -"\n" -"This combines the scaling principle from Level 3 (§8) with the addition principle from Level 4 (§9 and §10) into a single proof.\n" -"\n" -"Unpack both §11 and §12 with §13, substitute them into the goal, and construct the combined witness!" +#. §0: `«{a}» * «{x}» + «{m}» * (-«{k}») = 1` +#. §1: `(«{a}» * «{x}» - 1) - «{m}» * «{k}» + 1` +#. §2: `«{a}» * «{x}» - 1 = «{m}» * «{k}»` +#: Game/Levels/LinCong/L02_inv_reverse.lean:25 +msgid "To verify §0, rewrite it as §1, then substitute §2. What remains is pure arithmetic." msgstr "" -#: Game.Levels.Divisors.L02_multiples_of_6 -msgid "Multiples of 6" +#: Game/Levels/LinCong/L02_inv_reverse.lean:35 +msgid "Great! Reversibility is confirmed. Having a modular inverse is *exactly equivalent* to being coprime to the modulus." msgstr "" -#. §0: `gcd_div_coprime` -#: Game.Levels.GCD.L07_gcd_div_coprime -msgid "Great! §0 is now saved — it's the missing piece that will let us cancel factors that aren't necessarily coprime to the modulus, in the very next level." +#: Game/Levels/LinCong/L03_inv_unique.lean:7 +msgid "The Inverse is Unique" msgstr "" -#. §0: `IsGCD(a, b) d` -#. §1: $c$ +#. §0: $x$ +#. §1: $y$ #. §2: $a$ -#. §3: $b$ -#. §4: $c \\mid a$ -#. §5: $c \\mid b$ -#. §6: $c \\mid d$ -#. §7: $2$ -#. §8: $3$ -#. §9: $12$ -#. §10: $18$ -#. §11: $2 \\mid 6$ -#. §12: $3 \\mid 6$ -#. §13: $6 = \\text{IsGCD}(12, 18)$ -#. §14: $d$ -#. §15: $a$ -#. §16: $b$ -#. §17: $a \\cdot x + b \\cdot y = d$ -#. §18: $a$ -#. §19: $b$ -#. §20: $d$ -#: Game.Doc.Theorems.GCD -msgid "**The Bézout Definition Really Gives the Greatest Common Divisor**\n" -"\n" -"If §0, and §1 is *any* common divisor of §2 and §3 (i.e. §4 and §5), then §6.\n" +#. §3: $m$ +#. §4: $a \\cdot x \\equiv 1 \\pmod m$ +#. §5: $a \\cdot y \\equiv 1 \\pmod m$ +#. §6: $a \\cdot x \\equiv a \\cdot y \\pmod m$ +#. §7: $a$ +#. §8: $a$ +#. §9: $m$ +#. §10: `mod_cancel_coprime` +#. §11: `inv_implies_coprime` +#. §12: `∃ k, a * k ≡ 1` +#. §13: $x$ +#. §14: $a \\cdot x \\equiv a \\cdot y \\pmod m$ +#. §15: `mod_cancel_coprime` +#. §16: $x \\cdot a \\equiv y \\cdot a$ +#: Game/Levels/LinCong/L03_inv_unique.lean:9 +msgid "If §0 and §1 are both inverses of §2 modulo §3, are they the same?\n" "\n" -"**Intuition:**\n" -"This is what actually justifies the name \"IsGCD\": our Bézout-style definition doesn't just hand you *a* common divisor, it hands you the *greatest* one — every other common divisor is forced to divide it too. For example, §7 and §8 both divide §9 and §10, and indeed §11 and §12, where §13's witness.\n" +"We know §4 and §5. This implies §6. Since §7 has an inverse, §8 and §9 are coprime. You can now use your ultimate weapon from the GCD world: §10!\n" "\n" -"The proof works because §14 is built from §15 and §16 via §17: anything that divides both §18 and §19 automatically divides this whole combination, and hence divides §20." +"**Strategy:**\n" +"1. **Prove coprimality:** The theorem §11 (from the previous level) requires a proof that *some* inverse exists (§12). You can provide §13 as the witness to build this existence proof, and then extract the coprimality fact.\n" +"2. **Equate the terms:** Use symmetry and transitivity to link your two main hypotheses into §14.\n" +"3. **Cancel the factor:** Prepare your congruence for §15. The theorem expects the common factor to be on the *right* side (§16), so you will need to swap the multiplication order before applying the cancellation law." msgstr "" -#. §0: $d = \\gcd(a, m)$ -#. §1: $d \\mid b$ -#. §2: $\\exists x, a \\cdot x \\equiv b \\pmod m$ -#: Game.Doc.Theorems.LinCong -msgid "**Solvability (Sufficient Condition)**\n" +#. §0: `«{x}»` +#. §1: `have h_exists : ∃ k, («{a}» * k) ≡ 1 (mod «{m}»)` +#: Game/Levels/LinCong/L03_inv_unique.lean:22 +msgid "Following step 1 of the strategy, create a proof that *some* inverse exists using §0 as the witness: §1." +msgstr "" + +#: Game/Levels/LinCong/L03_inv_unique.lean:48 +msgid "Exactly! Using the cancellation law on congruences works wonderfully here." +msgstr "" + +#: Game/Levels/LinCong/L04_sol_nec.lean:7 +msgid "Solvability: Necessary Condition" +msgstr "" + +#. §0: $a \\cdot x \\equiv b \\pmod m$ +#. §1: $d = \\gcd(a, m)$ +#. §2: $x$ +#. §3: $d$ +#. §4: $b$ +#. §5: `dvd_mul_of_dvd_left_int` +#: Game/Levels/LinCong/L04_sol_nec.lean:9 +msgid "We now move to general linear equations: §0.\n" +"When does this have a solution?\n" "\n" -"If §0 and §1, then §2." +"Let §1. If a solution §2 exists, it is strictly necessary that §3 divides §4.\n" +"Unfold the definitions, and apply §5 from World 2!" msgstr "" -#: Game.Levels.Congruence.L09_mod_split -msgid "Splitting the Modulus (Boss)" +#. §0: `«{a}» * «{x}» = «{d}» * «{k1}»` +#. §1: `«{m}» * «{k}» = «{d}» * «{k2}»` +#. §2: `«{b}» = «{a}» * «{x}» - «{m}» * «{k}»` +#. §3: `use «{k1}» - «{k2}»` +#: Game/Levels/LinCong/L04_sol_nec.lean:34 +msgid "You now know §0 and §1. Since §2, try §3." msgstr "" -#. §0: `have` -#. §1: `exact` -#: Game.Levels.ModArith.L03_add_const -msgid "You have mastered combining §0 and §1 to chain existing theorems together! This is how large mathematical libraries are constructed." +#. §0: $d \\mid b$ +#: Game/Levels/LinCong/L04_sol_nec.lean:44 +msgid "Nice! You successfully extracted the divisibility parts of the GCD to prove §0." +msgstr "" + +#: Game/Levels/LinCong/L05_sol_suff.lean:7 +msgid "Solvability: Sufficient Condition" +msgstr "" + +#. §0: $d \\mid b$ +#. §1: $x$ +#. §2: $a \\cdot x \\equiv b \\pmod m$ +#. §3: $d \\mid b$ +#. §4: $b = d \\cdot k$ +#. §5: $d = a \\cdot u + m \\cdot v$ +#. §6: $d$ +#. §7: $b = a \\cdot (u \\cdot k) + m \\cdot (v \\cdot k)$ +#. §8: $x$ +#: Game/Levels/LinCong/L05_sol_suff.lean:9 +msgid "Now the exciting part: if §0, there **must** exist a solution §1 to §2!\n" +"\n" +"This is a constructive proof. Since §3, we know §4.\n" +"From Bézout, §5.\n" +"Substituting §6, we get §7.\n" +"\n" +"Can you figure out what the solution §8 should be?" msgstr "" -#. §0: `«{d1}» ∣ «{d2}»` -#. §1: `«{d2}» ∣ «{d1}»` -#. §2: `dvd_antisymm_int` -#: Game.Levels.GCD.L09_gcd_shift -msgid "You have §0 and §1. Finish the boss by applying §2!" +#. §0: `x = «{u}» * «{k}»` +#. §1: `use «{u}» * «{k}»` +#: Game/Levels/LinCong/L05_sol_suff.lean:26 +msgid "As the introduction says, try §0. §1" msgstr "" -#. §0: `«{h1}»` -#. §1: `«{h2}»` -#. §2: `have` -#: Game.Levels.GCD.L09_gcd_shift -msgid "Start by extracting the four divisibility facts from §0 and §1 using the dot notation explained in the introduction. Create new hypotheses for them using §2." +#. §0: `«{m}» ∣ («{a}» * («{u}» * «{k}») - «{b}»)` +#. §1: `«{b}» = «{d}» * «{k}»` +#. §2: `use -«{v}» * «{k}»` +#: Game/Levels/LinCong/L05_sol_suff.lean:30 +msgid "Your goal is §0. Since §1, try §2" msgstr "" -#: Game.Levels.GCD.L09_gcd_shift -msgid "Shifting by a multiple of m does not change the gcd with m." +#. §0: `have h_eq : «{a}» * («{u}» * «{k}») - «{d}» * «{k}» = «{m}» * (-«{v}» * «{k}») + «{k}» * («{a}» * «{u}» + «{m}» * «{v}» - «{d}»)` +#. §1: `«{huv}»` +#: Game/Levels/LinCong/L05_sol_suff.lean:34 +msgid "Build the shift identity: §0. The last term vanishes once you plug in §1." msgstr "" -#: Game.Levels.DivRules.L06_div3 -msgid "The sum of digits rule for 3." +#. §0: $b/d$ +#. §1: $x$ +#: Game/Levels/LinCong/L05_sol_suff.lean:41 +msgid "Beautiful! You multiplied the Bézout coefficients by §0 to constructively find the solution §1." msgstr "" -#. §0: `constructor` -#. §1: $\\wedge$ -#. §2: `P ∧ Q` -#. §3: `P` -#. §4: `Q` -#: Game.Doc.Tactics -msgid "The §0 tactic is used to prove goals consisting of a logical AND (§1).\n" -"It splits the goal §2 into two separate goals: §3 and §4." +#: Game/Levels/LinCong/L06_sol_equiv.lean:7 +msgid "Congruent Solutions" msgstr "" -#. §0: `crt_exists` -#. §1: `crt_glue` -#: Game.Levels.LinCong.L10_crt_glue -msgid "🎉 YOU DEFEATED THE CRT BOSS! 🎉\n" -"\n" -"Together, §0 and §1 give you the full Chinese Remainder Theorem: a system of coprime congruences always has a solution, and that solution is unique modulo the product.\n" -"\n" -"Starting from a single Bézout-style definition of the GCD, you built cancellation laws, modular inverses, Euclid's Lemma, and now the CRT itself — one of the oldest and most celebrated theorems in number theory, formally verified, entirely by you.\n" +#. §0: $x_1$ +#. §1: $x_2$ +#. §2: $a \\cdot x \\equiv b \\pmod m$ +#. §3: $m$ +#. §4: $m_1 = m / d$ +#. §5: `mod_cancel_general` +#: Game/Levels/LinCong/L06_sol_equiv.lean:9 +msgid "If §0 and §1 are both solutions to §2, how are they related?\n" "\n" -"Once you have also completed the **Modular Arithmetic** and **Divisibility Rules** branch, the grand finale world — **Problems** — will unlock!" +"They are not necessarily congruent modulo §3, but they **are** congruent modulo §4.\n" +"This perfectly mirrors §5 from the GCD world. You can reuse it directly!" msgstr "" -#. §0: `use` -#. §1: $a = 1 \\cdot a$ -#. §2: `ring` -#. §3: `one_dvd_int` -#: Game.Levels.Divisibility.L04_one_dvd -msgid "Great job! Whenever §0 leaves you with an algebraic identity like §1, §2 cleans it right up. §3 is now added to your toolkit!" +#. §0: $m/d$ +#: Game/Levels/LinCong/L06_sol_equiv.lean:36 +msgid "Excellent! You have shown that any two solutions only differ by multiples of §0." msgstr "" -#. §0: `mod_cancel_coprime` -#: Game.Levels.Problems.L02_cancel -msgid "The theorem §0 expects the common factor on the *right* side of the multiplication. Create a new hypothesis to swap the order" +#: Game/Levels/LinCong/L07_sol_shift.lean:7 +msgid "Shifting the Solution" msgstr "" -#. §0: $14 \\cdot x \\equiv 14 \\cdot y \\pmod 9$ -#. §1: $x \\equiv y \\pmod 9$ -#. §2: `mod_cancel_coprime` -#. §3: `IsGCD(14, 9) 1` -#. §4: `have` -#. §5: `IsGCD 14 9 1` -#: Game.Levels.Problems.L02_cancel -msgid "Suppose we know that §0. Can we conclude that §1?\n" -"\n" -"In the GCD world, you proved §2, which says we can cancel a factor if it's coprime to the modulus.\n" -"To use it here, you first need to prove that 14 and 9 are coprime, meaning §3.\n" +#. §0: $x_0$ +#. §1: $m_1 = m / d$ +#. §2: $a(x_0 + t \\cdot m_1) \\equiv b \\pmod m$ +#. §3: $a = a_1 \\cdot d$ +#. §4: `IsGCD` +#. §5: $m$ +#. §6: `mod_add_multiple` +#: Game/Levels/LinCong/L07_sol_shift.lean:9 +msgid "Conversely, if we shift a valid solution §0 by any multiple of §1, we get another valid solution.\n" +"§2.\n" "\n" -"*(Remember the syntax tip: when writing your own code with §4, you need to use the standard Lean syntax without parentheses or commas, like §5)*" +"Use §3 (from §4) and the property of shifting modulo §5 (§6) to finish the job!" msgstr "" -#. §0: `mod_add_multiple` -#. §1: `mod_shrink` -#: Game.Levels.DivRules.L03_div5 -msgid "Done! Together with the last two levels, you now have the full \"last digit\" family for free: 10, 2, and 5 all fall directly out of §0 and §1." +#. §0: `«{a}» * («{x0}» + «{t}» * «{m1}») = «{a}» * «{x0}» + («{a1}» * «{t}») * «{m}»` +#. §1: `mod_add_multiple` +#. §2: `«{a}» = «{a1}» * «{d}»` +#. §3: `«{m}» = «{m1}» * «{d}»` +#: Game/Levels/LinCong/L07_sol_shift.lean:22 +msgid "You want to show §0, so that §1 applies directly. Substitute §2 and §3" msgstr "" -#: Game.Levels.DivRules.L07_div11 -msgid "The alternating sum of digits rule for 11." +#. §0: $m/d$ +#: Game/Levels/LinCong/L07_sol_shift.lean:34 +msgid "Great work! Together, Levels 6 and 7 give us the complete description of the set of solutions: an arithmetic progression with step §0." msgstr "" -#: Game.Levels.Divisibility.L01_first_proof -msgid "The exercise statement: 3 divides 12." +#: Game/Levels/LinCong/L08_euclid.lean:7 +msgid "Euclid's Lemma" msgstr "" -#. §0: $c$ -#. §1: $a \\equiv b \\pmod m$ -#. §2: $a \\cdot c \\equiv b \\cdot c \\pmod m$ -#: Game.Levels.ModArith.L04_mul_const -msgid "Now let's move from addition to multiplication. As a first step, let's show that we can scale both sides of a congruence by any integer §0:\n" -"If §1, then §2.\n" +#. §0: $m \\mid (a \\cdot c)$ +#. §1: $\\text{gcd}(c, m) = 1$ +#. §2: $m \\mid a$ +#. §3: $m \\mid (a \\cdot c)$ +#. §4: $a \\cdot c \\equiv 0 \\cdot c \\pmod m$ +#. §5: $c$ +#. §6: $m$ +#. §7: $c$ +#. §8: `mod_cancel_coprime` +#: Game/Levels/LinCong/L08_euclid.lean:9 +msgid "We are about to build the Chinese Remainder Theorem, but first, we need a legendary stepping stone: **Euclid's Lemma**.\n" "\n" -"This simple scaling rule will be our stepping stone to multiplying any two congruences together in the next level." +"If §0 and §1, then §2.\n" +"\n" +"Notice that §3 is exactly the same as saying §4.\n" +"Since §5 is coprime to §6, can we just cancel §7? Yes, you have §8!" msgstr "" -#. §0: `«{z}» = «{y}» * «{k2}»` -#. §1: `«{y}» = «{x}» * «{k1}»` -#. §2: `«{z}» = («{x}» * «{k1}») * «{k2}» = «{x}» * («{k1}» * «{k2}»)` -#. §3: `«{k1}»` -#. §4: `«{k2}»` -#. §5: `«{x}»` -#. §6: `«{z}»` -#: Game.Levels.Divisors.L05_dvd_trans -msgid "Think it through: §0, and §1, so §2. A single number built from §3 and §4 already turns §5 into §6 — that's the witness this goal wants." +#: Game/Levels/LinCong/L08_euclid.lean:40 +msgid "Incredible! A simple cancellation yields one of the oldest and most fundamental theorems in number theory." msgstr "" -#. §0: $a \\equiv b \\pmod m$ -#. §1: $c$ -#. §2: $$a + c \\equiv b + c \\pmod m$$ -#. §3: $a \\equiv b \\pmod m$ -#. §4: `h` -#. §5: $c \\equiv c \\pmod m$ -#. §6: `mod_refl` -#. §7: `mod_add` -#. §8: `have` -#. §9: `exact` -#. §10: `have h_refl : c ≡ c (mod m)` -#. §11: `exact mod_refl c m` -#. §12: `mod_add` -#. §13: `exact` -#: Game.Levels.ModArith.L03_add_const -msgid "If §0, adding the same integer §1 to both sides preserves the congruence:\n" -"§2\n" -"\n" -"We *could* unfold definitions and do the algebra again, but real mathematicians don't reinvent the wheel — they reuse what they've already proved!\n" -"\n" -"Notice that:\n" -"- We know §3 by hypothesis §4.\n" -"- We know §5 by §6 (from the Congruence world).\n" -"- We can combine these two facts using §7 (from Level 1)!\n" -"\n" -"You can combine §8 and §9 to build proofs step by step:\n" -"1. First, state the intermediate fact you need: §10.\n" -"2. Prove this new subgoal right away using §11.\n" -"3. Finally, close the main goal by feeding both congruences into §12 with §13!" +#: Game/Levels/LinCong/L09_crt_exists.lean:7 +msgid "Chinese Remainder Theorem: Existence" msgstr "" -#. §0: $10 \\cdot k + d \\equiv d \\pmod{10}$ -#: Game.Doc.Theorems.DivRules -msgid "**Divisibility by 10**\n" +#. §0: $x$ +#. §1: $x \\equiv a \\pmod m$ +#. §2: $x \\equiv b \\pmod n$ +#. §3: $x$ +#. §4: $m$ +#. §5: $n$ +#. §6: $m \\cdot u + n \\cdot v = 1$ +#. §7: $x = a \\cdot n \\cdot v + b \\cdot m \\cdot u$ +#: Game/Levels/LinCong/L09_crt_exists.lean:9 +msgid "If we want a number §0 to satisfy two separate congruences simultaneously:\n" +"§1 and §2\n" +"When does such an §3 exist?\n" "\n" -"The remainder of any number modulo 10 is exactly its last digit.\n" -"§0." +"The **Chinese Remainder Theorem (CRT)** guarantees a solution whenever §4 and §5 are coprime!\n" +"If §6, we can explicitly construct the solution:\n" +"§7.\n" +"\n" +"Try it! Use your algebra skills and the Bézout identity to prove this explicitly." msgstr "" -#: Game.Levels.GCD -msgid "In Search of the GCD" +#. §0: `x = «{a}» * «{n}» * «{v}» + «{b}» * «{m}» * «{u}»` +#. §1: `use` +#: Game/Levels/LinCong/L09_crt_exists.lean:26 +msgid "As explained in the introduction, the witness is §0. §1 it" msgstr "" -#. §0: `pow_succ` -#. §1: $a^{n+1} = a^n \\cdot a$ -#. §2: `rw [pow_succ]` -#: Game.Doc.Theorems.Congruence -msgid "§0 is a theorem from Mathlib that states §1.\n" -"Use §2 when dealing with powers in induction." +#. §0: `«{m}»` +#. §1: `(«{a}» * «{n}» * «{v}» + «{b}» * «{m}» * «{u}») - «{a}»` +#. §2: `«{m}» * («{b}» * «{u}» - «{a}» * «{u}») + «{a}» * («{m}» * «{u}» + «{n}» * «{v}» - 1)` +#. §3: `«{huv}»` +#. §4: `«{m}» * «{u}» + «{n}» * «{v}»` +#. §5: `1` +#: Game/Levels/LinCong/L09_crt_exists.lean:32 +msgid "To prove this divisibility, you need to factor out §0. Notice that §1 can be algebraically rearranged into §2. If you introduce this equality, you can use §3 to replace §4 with §5, effectively cancelling out the second part." msgstr "" -#. §0: `IsGCD(a, b) d` -#. §1: `IsGCD(b, a) d` -#: Game.Doc.Theorems.GCD -msgid "**Symmetry of the GCD**\n" -"\n" -"If §0, then §1." +#. §0: `«{n}»` +#: Game/Levels/LinCong/L09_crt_exists.lean:43 +msgid "Same trick, mirrored for §0." msgstr "" -#: Game.Levels.Problems.L01_large_powers -msgid "Beautiful! By using theorems instead of brute force, you reduced a massive calculation to simple logic." +#: Game/Levels/LinCong/L09_crt_exists.lean:54 +msgid "Magnificent! This explicit witness construction sits at the core of CRT." msgstr "" -#. §0: $m/d$ -#: Game.Levels.LinCong.L06_sol_equiv -msgid "Excellent! You have shown that any two solutions only differ by multiples of §0." +#: Game/Levels/LinCong/L10_crt_glue.lean:7 +msgid "Chinese Remainder Theorem: Glued (Boss)" msgstr "" #. §0: $m$ -#: Game -msgid "# Welcome to the Number Theory Game\n" -"#### An introduction to integer arithmetic and formal proofs.\n" -"\n" -"In this game, we will explore the fascinating world of Number Theory.\n" -"We will start from the basic definition of divisibility and build our way up\n" -"to modular arithmetic and congruences.\n" +#. §1: $n$ +#. §2: $m \\cdot n$ +#. §3: $m$ +#. §4: $n$ +#. §5: $x \\equiv a \\pmod m$ +#. §6: $x \\equiv a \\pmod n$ +#. §7: $m \\mid (x - a)$ +#. §8: $n \\mid (x - a)$ +#. §9: `euclids_lemma` +#. §10: `IsGCD(n, m) 1` +#. §11: `IsGCD(m, n) 1` +#. §12: `gcd_symm` +#. §13: $x - a$ +#. §14: $m \\mid (k_2 \\cdot n)$ +#. §15: `gcd_symm` +#. §16: `euclids_lemma` +#. §17: `IsGCD n m 1` +#. §18: $m$ +#. §19: $k_2$ +#. §20: `have` +#: Game/Levels/LinCong/L10_crt_glue.lean:9 +msgid "Welcome to the final boss of Linear Congruences and CRT!\n" "\n" -"Our ultimate goal is to understand how remainders work, how to safely manipulate\n" -"equations modulo §0, prove the classic divisibility rules, and prove strong\n" -"results like the Chinese Remainder Theorem. We will do this by solving levels\n" -"with Lean theorem prover.\n" +"Everything you've built in this branch — Bézout's identity, the cancellation laws, Euclid's Lemma, and CRT existence from the last level — comes together right here.\n" "\n" -"# Read this.\n" +"The second half of CRT: if two numbers share the same remainder modulo §0 and modulo §1 separately, they share the same remainder modulo §2 — provided §3 and §4 are coprime.\n" "\n" -"Learning how to use an interactive theorem prover takes time.\n" -"Tests show that the people who get the most out of this game are\n" -"those who read the help texts on the left side of the screen.\n" +"Formally: §5 and §6 means §7 and §8. Extract the witnesses, equate them, and reach for **Euclid's Lemma**.\n" "\n" -"To start, click on the **Divisibility Club**.\n" +"**One trap to watch for:** §9 expects coprimality as §10, but your hypothesis is §11 — arguments swapped! Fortunately, you already proved §12 in the GCD world for this exact moment.\n" "\n" -"## More\n" +"**Strategy:**\n" +"1. **Equate the witnesses:** Extract the witnesses for §13, set them equal, and deduce that §14.\n" +"2. **Swap the GCD:** Apply §15 to your coprimality hypothesis so it matches the argument order §16 expects (§17).\n" +"3. **Apply Euclid's Lemma:** Use the lemma to conclude that §18 must entirely divide §19.\n" +"4. **Finish the algebra:** Substitute this new divisibility witness back into your original equation.\n" "\n" -"Click on the three lines in the top right and select \"Game Info\" for resources,\n" -"links, solutions, and ways to interact with the Lean community." +"Take it one §20 at a time — you already have every tool you need." msgstr "" -#: Game.Levels.LinCong.L09_crt_exists -msgid "Magnificent! This explicit witness construction sits at the core of CRT." +#. §0: `x - a` +#. §1: `have h_eq : «{m}» * «{k1}» = «{n}» * «{k2}»` +#: Game/Levels/LinCong/L10_crt_glue.lean:36 +msgid "Following the strategy, start by creating an equation that sets your two expressions for §0 equal to each other: §1" msgstr "" -#: Game.Levels.GCD.L06_cancel_coprime -msgid "The Cancellation Law (Coprime Case)" +#. §0: `«{m}»` +#. §1: `«{k2}» * «{n}»` +#: Game/Levels/LinCong/L10_crt_glue.lean:40 +msgid "Now prove that §0 divides §1." msgstr "" -#: Game.Levels.Divisors -msgid "Algebra of Divisors" +#. §0: `gcd_symm` +#. §1: `«{h_coprime}»` +#. §2: `«{n}»` +#. §3: `«{m}»` +#: Game/Levels/LinCong/L10_crt_glue.lean:49 +msgid "Before applying Euclid's Lemma, apply §0 to §1 so it matches the expected order for §2 and §3." msgstr "" -#. §0: `rw [← h]` -#. §1: `a ∣ a * k` -#. §2: `use k` -#: Game.Levels.Divisibility.L08_rewriting_backwards -msgid "Nicely done! Rewriting backwards with §0 turned the goal into §1, where §2 could finish it in one step." +#. §0: `euclids_lemma` +#. §1: `«{m}» ∣ «{k2}»` +#: Game/Levels/LinCong/L10_crt_glue.lean:53 +msgid "Now apply §0 to extract a new witness showing that §1." msgstr "" -#. §0: `dvd_lin_comb_int` -#: Game.Levels.GCD.L02_gcd_greatest -msgid "Excellent! Because you already conquered linear combinations in World 2 (§0), proving that our Bézout-style GCD dominates every other common divisor took just four lines!" +#. §0: `crt_exists` +#. §1: `crt_glue` +#: Game/Levels/LinCong/L10_crt_glue.lean:61 +msgid "🎉 YOU DEFEATED THE CRT BOSS! 🎉\n" +"\n" +"Together, §0 and §1 give you the full Chinese Remainder Theorem: a system of coprime congruences always has a solution, and that solution is unique modulo the product.\n" +"\n" +"Starting from a single Bézout-style definition of the GCD, you built cancellation laws, modular inverses, Euclid's Lemma, and now the CRT itself — one of the oldest and most celebrated theorems in number theory, formally verified, entirely by you.\n" +"\n" +"Once you have also completed the **Modular Arithmetic** and **Divisibility Rules** branch, the grand finale world — **Problems** — will unlock!" msgstr "" -#: Game.Levels.GCD.L01_gcd_def -msgid "A first, concrete example: IsGCD(2, 3) 1." +#: Game/Levels/LinCong.lean:13 +msgid "Linear Congruences and CRT" msgstr "" -#. §0: $3x + 4y \\equiv 0 \\pmod{11}$ -#. §1: $4x - 3y \\equiv 0 \\pmod{11}$ -#. §2: $x \\equiv 0 \\pmod{11}$ -#. §3: $y$ -#. §4: `euclids_lemma` -#: Game.Levels.Problems.L08_system -msgid "Welcome to the final boss of the Problems world!\n" -"\n" -"In this battle, you are given a system of congruences:\n" -"§0\n" -"§1\n" +#. §0: $a \\cdot x \\equiv b \\pmod m$ +#: Game/Levels/LinCong.lean:15 +msgid "Welcome to Linear Congruences and CRT!\n" "\n" -"You must prove that §2.\n" +"Brace yourself — this is the deepest theoretical world in the game.\n" +"Here we bring our GCD toolkit and congruences together to solve equations of the form §0.\n" "\n" -"To win this battle, you only need two key ideas: figure out how to eliminate §3, and think about what you need to apply §4." +"We will discover when these equations have solutions, how to find modular inverses, prove the famous Euclid's Lemma, and finally face the ultimate theoretical boss: the Chinese Remainder Theorem!" msgstr "" -#. §0: $a$ -#. §1: $k$ -#. §2: $a = a \\cdot k$ -#: Game.Levels.Divisibility.L05_dvd_refl -msgid "Now let's practice what we just learned. Prove that any integer §0 divides itself.\n" -"Think about what §1 should be so that §2." +#: Game/Levels/Problems/L01_large_powers.lean:18 +msgid "Huge Powers" msgstr "" -#. §0: $a \\equiv b \\pmod m$ -#. §1: $P(a) \\equiv P(b) \\pmod m$ -#. §2: $P$ -#. §3: $m$ -#. §4: $m$ -#: Game.Doc.Theorems.Congruence -msgid "**Polynomial Congruences**\n" +#. §0: $17^{100} + 12^{100}$ +#. §1: $17^{100}$ +#. §2: $17 \\equiv 2 \\pmod 5$ +#. §3: $12 \\equiv 2 \\pmod 5$ +#. §4: `have` +#. §5: `mod_pow` +#. §6: `mod_add` +#: Game/Levels/Problems/L01_large_powers.lean:20 +msgid "Let's start with a classic competition problem: what is the remainder of §0 when divided by 5?\n" "\n" -"If §0, then §1 for any integer polynomial §2.\n" +"If you try to compute §1 directly, the universe will end before you finish. But you know that congruences preserve addition and powers! Since §2 and §3, you can use your abstract theorems to simplify the bases before applying the exponent.\n" "\n" -"**Intuition:**\n" -"This is the reason modular arithmetic is genuinely useful and not just a curiosity: congruence mod §3 is compatible with *every* polynomial operation, so you can reduce numbers mod §4 at any point in a calculation without changing the final remainder. It's what makes \"clock arithmetic\" behave like real arithmetic." +"**Strategy:**\n" +"Create intermediate facts using §4 for the base numbers, then raise them to the 100th power using §5, and finally add them together using §6." msgstr "" -#. §0: `gcd_symm` -#. §1: `«{h_coprime}»` -#. §2: `«{n}»` -#. §3: `«{m}»` -#: Game.Levels.LinCong.L10_crt_glue -msgid "Before applying Euclid's Lemma, apply §0 to §1 so it matches the expected order for §2 and §3." +#. §0: `have h1 : 17 ≡ 2 (mod 5)` +#: Game/Levels/Problems/L01_large_powers.lean:30 +msgid "Start by proving the base congruences. Create a hypothesis §0." msgstr "" -#: Game.Levels.DivRules.L02_div2 -msgid "The remainder modulo 2 depends only on the last digit." +#: Game/Levels/Problems/L01_large_powers.lean:49 +msgid "Beautiful! By using theorems instead of brute force, you reduced a massive calculation to simple logic." msgstr "" -#: Game.Levels.LinCong.L10_crt_glue -msgid "Chinese Remainder Theorem: Glued (Boss)" +#: Game/Levels/Problems/L02_cancel.lean:7 +msgid "Cancelling Constants" msgstr "" -#. §0: $m$ -#. §1: $m$ -#. §2: $$a + k \\cdot m \\equiv a \\pmod m$$ -#: Game.Levels.Congruence.L06_add_mul_mod -msgid "In modular arithmetic, the modulus §0 essentially acts like zero. That means adding or subtracting any multiple of §1 to a number doesn't change its remainder at all:\n" -"§2\n" +#. §0: $14 \\cdot x \\equiv 14 \\cdot y \\pmod 9$ +#. §1: $x \\equiv y \\pmod 9$ +#. §2: `mod_cancel_coprime` +#. §3: `IsGCD(14, 9) 1` +#. §4: `have` +#. §5: `IsGCD 14 9 1` +#: Game/Levels/Problems/L02_cancel.lean:9 +msgid "Suppose we know that §0. Can we conclude that §1?\n" "\n" -"Let's prove this fundamental shifting rule!" +"In the GCD world, you proved §2, which says we can cancel a factor if it's coprime to the modulus.\n" +"To use it here, you first need to prove that 14 and 9 are coprime, meaning §3.\n" +"\n" +"*(Remember the syntax tip: when writing your own code with §4, you need to use the standard Lean syntax without parentheses or commas, like §5)*" msgstr "" -#. §0: `«{a}» * «{x}» - 1` -#. §1: `«{hxy}»` -#. §2: `have h_eq : «{a}» * «{x}» - 1 = («{a}» * «{x}» + «{m}» * «{y}») - 1 - «{m}» * «{y}»` -#: Game.Levels.LinCong.L01_inv_exists -msgid "Rewrite §0 using §1 with §2." +#. §0: `mod_cancel_coprime` +#: Game/Levels/Problems/L02_cancel.lean:28 +msgid "The theorem §0 expects the common factor on the *right* side of the multiplication. Create a new hypothesis to swap the order" msgstr "" -#: Game.Levels.GCD.L09_gcd_shift -msgid "A Shift Doesn't Change the GCD (Boss)" +#. §0: `mod_cancel_coprime` +#. §1: `«{h_swap}»` +#. §2: `«{h_gcd}»` +#: Game/Levels/Problems/L02_cancel.lean:42 +msgid "Now you can finish the proof using §0 with your swapped hypothesis §1 and §2!" msgstr "" -#. §0: $a \\equiv b \\pmod m$ -#. §1: $b \\equiv c \\pmod m$ -#. §2: $a \\equiv c \\pmod m$ -#: Game.Levels.Congruence.L05_mod_trans -msgid "The final pillar of an equivalence relation is **transitivity**:\n" -"If §0 and §1, then §2.\n" +#: Game/Levels/Problems/L02_cancel.lean:46 +msgid "Excellent! You proved a concrete GCD on the fly to unlock the power of your cancellation theorem." +msgstr "" + +#: Game/Levels/Problems/L03_crt.lean:7 +msgid "The Oracle of CRT" +msgstr "" + +#. §0: $x$ +#. §1: $x \\equiv 7 \\pmod{10}$ +#. §2: $x \\equiv 2 \\pmod 3$ +#. §3: `crt_exists` +#. §4: `IsGCD(10, 3) 1` +#. §5: `IsGCD 10 3 1` +#. §6: `have` +#: Game/Levels/Problems/L03_crt.lean:9 +msgid "Is there a number that ends in 7 (modulo 10) but leaves a remainder of 2 when divided by 3?\n" +"In other words, does there exist an §0 such that §1 and §2?\n" "\n" -"This is the property that allows us to chain long sequences of congruences together, stepping from one expression to the next just like we do with standard equalities." +"Instead of guessing, we can use the §3 theorem you proved in the Linear Congruences world. It guarantees a solution exists as long as the moduli are coprime.\n" +"\n" +"All you need to do is prove §4 and feed it to the theorem!\n" +"*(Remember the syntax tip from the previous level: you need to use the standard Lean syntax §5 in your §6 block.)*" msgstr "" -#. §0: `mul_left_cancel₀` -#. §1: `a ≠ 0` -#. §2: `a * b = a * c` -#. §3: `b = c` -#: Game.Doc.Theorems.GCD -msgid "The §0 theorem lets you cancel a common non-zero factor from an equation:\n" -"if §1 and §2, then §3.\n" -"This works because the integers have no \"zero divisors\": the only way a product can vanish is if one of its factors does, so a non-zero factor can always be safely divided out of an equation." +#. §0: `crt_exists` +#. §1: `exact` +#: Game/Levels/Problems/L03_crt.lean:29 +msgid "Now let §0 do the heavy lifting! Look at its signature in the theorems list and apply it with §1." msgstr "" -#. §0: $a$ -#. §1: $0 = a \\cdot k$ -#. §2: $k$ -#: Game.Levels.Divisibility.L06_dvd_zero -msgid "A common misconception in standard school math is confusing \"dividing by zero\" (which is undefined) with \"dividing zero\".\n" -"Here, we want to prove that any number §0 *divides* zero.\n" -"By our definition, this just means §1 for some §2." +#. §0: $x = 17$ +#: Game/Levels/Problems/L03_crt.lean:32 +msgid "Excellent! You didn't even have to find the number yourself (though if you do the math, §0 works perfectly). Your abstract theorem did all the work.\n" +"\n" +"This is the true power of mathematics!" msgstr "" -#: GameServer.RpcHandlers -msgid "level completed! 🎉" +#: Game/Levels/Problems/L04_lincong.lean:7 +msgid "Solving Linear Congruences" msgstr "" #. §0: $5 \\cdot x \\equiv 3 \\pmod 7$ @@ -3424,7 +3595,7 @@ msgstr "" #. §7: `IsGCD(5, 7) 1` #. §8: `1 ∣ 3` #. §9: `lin_cong_suff` -#: Game.Levels.Problems.L04_lincong +#: Game/Levels/Problems/L04_lincong.lean:9 msgid "Can we always find a solution to §0?\n" "\n" "In the Linear Congruences world, you proved §1, which states that §2 has a solution as long as §3.\n" @@ -3434,266 +3605,174 @@ msgid "Can we always find a solution to §0?\n" "Build the GCD proof for §7, and the divisibility proof for §8. Then hand them to §9." msgstr "" -#. §0: `IsGCD(c, m) 1` -#: Game.Levels.GCD.L04_coprime_backward -msgid "Beautiful! Together, the last two levels show that §0 and \"a Bézout identity with 1 exists\" are two ways of saying exactly the same thing. From now on, feel free to think of *coprime* simply as \"Bézout equals 1\"." -msgstr "" - -#: Game.Levels.ModArith.L04_mul_const -msgid "Multiplying by a Common Factor" -msgstr "" - -#: Game.Levels.Divisors.L06_dvd_lin_comb -msgid "If d divides a and b, then d divides any linear combination a * x + b * y." -msgstr "" - -#. §0: `rw` -#. §1: `h : A = B` -#. §2: `rw [h]` -#. §3: `A` -#. §4: `B` -#. §5: `rw [h1, h2]` -#. §6: `rw` -#. §7: `←` -#. §8: `\\l` -#. §9: `rw [← h]` -#. §10: `rw` -#. §11: `h1` -#. §12: `at` -#. §13: `rw [h_eq] at h1` -#. §14: `at *` -#. §15: `rw [h_eq] at *` -#: Game.Doc.Tactics -msgid "The §0 (rewrite) tactic replaces a term with an equivalent term based on an equality you have.\n" -"If you have §1, typing §2 will replace §3 with §4 in your goal.\n" -"\n" -"**Multiple arguments:**\n" -"You can chain rewrites by putting multiple hypotheses in the brackets, separated by commas: §5. Lean will apply them sequentially.\n" -"\n" -"**Rewriting backwards:**\n" -"By default, §6 replaces the left side of an equality with the right side. To rewrite from right to left, use the §7 symbol (type §8 and Space): §9.\n" -"\n" -"**Targeting hypotheses:**\n" -"By default, §10 changes the goal. You can rewrite inside a hypothesis §11 by using §12: §13.\n" -"You can also rewrite everywhere (in all hypotheses and the goal at once) using §14: §15." -msgstr "" - -#: Game.Levels.GCD.L08_cancel_general -msgid "Incredible! You just built the full cancellation law for modular congruences by gluing together two previous theorems and one careful algebraic cancellation. This is exactly how real number-theory results get assembled from smaller pieces." -msgstr "" - -#. §0: `«{m}» ∣ («{a}» * («{u}» * «{k}») - «{b}»)` -#. §1: `«{b}» = «{d}» * «{k}»` -#. §2: `use -«{v}» * «{k}»` -#: Game.Levels.LinCong.L05_sol_suff -msgid "Your goal is §0. Since §1, try §2" -msgstr "" - -#: Game.Levels.Congruence.L08_mod_dvd -msgid "Decreasing the modulus to a divisor." -msgstr "" - -#. §0: `«{a}» * «{c1}» - «{b}» * «{c1}» = «{m1}» * «{k}»` -#. §1: `mod_cancel_coprime` -#: Game.Levels.GCD.L08_cancel_general -msgid "You have a plain equation now, §0, but §1 needs an actual congruence, not a bare equation. Wrap it back up: state the congruence, unfold it, and it reduces to exactly the equation you already have." +#. §0: `lin_cong_suff` +#: Game/Levels/Problems/L04_lincong.lean:33 +msgid "Apply your theorem! Look at the arguments for §0 in your theorems tab." msgstr "" -#. §0: $a \\cdot k = b$ -#. §1: $a \\mid b$ -#. §2: `h : a * k = b` -#. §3: `dvd_intro_int a b k h` -#. §4: `a ∣ b` -#. §5: $k$ -#: Game.Doc.Theorems.Divisibility -msgid "**Divisibility from Equality**\n" -"\n" -"If §0, then §1.\n" +#. §0: `lin_cong_suff` +#. §1: $x = u \\cdot (b/d) = 3 \\cdot 3 = 9$ +#. §2: $5 \\cdot 9 = 45 \\equiv 3 \\pmod 7$ +#: Game/Levels/Problems/L04_lincong.lean:36 +msgid "Excellent! The theorem constructed the solution under the hood.\n" "\n" -"**Intuition:**\n" -"If you already have an explicit equation §2 in your hypotheses, applying §3 proves §4 directly without needing to rewrite and supply the witness §5 manually." -msgstr "" - -#: Game.Levels.Problems.L02_cancel -msgid "Cancelling Constants" +"If you trace the algebra of §0, it gives §1, and indeed §2. Abstract theory gives concrete results!" msgstr "" -#: Game.Levels.LinCong.L08_euclid -msgid "Euclid's Lemma" +#: Game/Levels/Problems/L05_euclid.lean:7 +msgid "Euclid in Practice" msgstr "" -#. §0: $d \\mid b$ +#. §0: $x \\cdot 3$ #. §1: $x$ -#. §2: $a \\cdot x \\equiv b \\pmod m$ -#. §3: $d \\mid b$ -#. §4: $b = d \\cdot k$ -#. §5: $d = a \\cdot u + m \\cdot v$ -#. §6: $d$ -#. §7: $b = a \\cdot (u \\cdot k) + m \\cdot (v \\cdot k)$ -#. §8: $x$ -#: Game.Levels.LinCong.L05_sol_suff -msgid "Now the exciting part: if §0, there **must** exist a solution §1 to §2!\n" -"\n" -"This is a constructive proof. Since §3, we know §4.\n" -"From Bézout, §5.\n" -"Substituting §6, we get §7.\n" +#. §2: $x$ +#. §3: `euclids_lemma` +#. §4: $m \\mid (a \\cdot c)$ +#. §5: $\\gcd(c, m) = 1$ +#. §6: $m \\mid a$ +#. §7: $m = 10$ +#. §8: $a = x$ +#. §9: $c = 3$ +#: Game/Levels/Problems/L05_euclid.lean:9 +msgid "If a number is a multiple of 10, and we know it's written as §0, does 10 divide §1?\n" +"Yes! Because 3 and 10 share no common factors, the 10 must entirely divide the §2.\n" "\n" -"Can you figure out what the solution §8 should be?" +"This is exactly §3 from the Linear Congruences world: if §4 and §5, then §6.\n" +"\n" +"Let's prove this explicitly for §7, §8, and §9." msgstr "" -#. §0: `«{n}»` -#: Game.Levels.LinCong.L09_crt_exists -msgid "Same trick, mirrored for §0." +#: Game/Levels/Problems/L05_euclid.lean:30 +msgid "Spot on! Euclid's Lemma is an incredibly powerful tool for analyzing equations with integers, and now you know how to apply it to concrete numbers." msgstr "" -#: Game.Levels.LinCong.L07_sol_shift -msgid "Shifting the Solution" +#: Game/Levels/Problems/L06_shrink_shift.lean:8 +msgid "Shrinking and Shifting" msgstr "" -#. §0: $x, y$ -#. §1: $c \\cdot x + m \\cdot y = 1$ -#. §2: `IsGCD(c, m) 1` -#. §3: `one_dvd_int` -#. §4: $1$ -#. §5: `1 ∣ c` -#. §6: `1 ∣ m` -#: Game.Levels.GCD.L04_coprime_backward -msgid "Now the other direction: if there exist integers §0 with §1, does that mean §2?\n" +#. §0: $x \\equiv 23 \\pmod{100}$ +#. §1: $x$ +#. §2: `mod_shrink` +#. §3: $x \\equiv 23 \\pmod 4$ +#. §4: `mod_trans` +#. §5: `have` +#: Game/Levels/Problems/L06_shrink_shift.lean:10 +msgid "Let's combine multiple theorems into one elegant deduction.\n" +"If you know that §0, what is the remainder of §1 when divided by 4?\n" "\n" -"Yes — and to prove it, remember §3 from World 1: *every* integer is divisible by §4. So the \"common divisor\" half of the definition (§5 and §6) comes completely for free! All that's left is to hand back the Bézout identity you were already given." -msgstr "" - -#. §0: `have h_eq : «{a}» * («{u}» * «{k}») - «{d}» * «{k}» = «{m}» * (-«{v}» * «{k}») + «{k}» * («{a}» * «{u}» + «{m}» * «{v}» - «{d}»)` -#. §1: `«{huv}»` -#: Game.Levels.LinCong.L05_sol_suff -msgid "Build the shift identity: §0. The last term vanishes once you plug in §1." -msgstr "" - -#. §0: $a \\equiv b \\pmod m$ -#. §1: $a \\cdot c \\equiv b \\cdot c \\pmod{m \\cdot c}$ -#: Game.Doc.Theorems.Congruence -msgid "**Scaling the Modulus**\n" +"Since 4 divides 100, we can safely shrink the modulus using §2. This will give us §3.\n" +"But 23 is not a standard remainder! We need to step from 23 down to 3 modulo 4, using §4.\n" "\n" -"If §0, then §1." +"This level tests your ability to chain §5 statements and piece together different theorems." msgstr "" -#: Game.Levels.Congruence.L06_add_mul_mod -msgid "Shifting by the Modulus" +#: Game/Levels/Problems/L06_shrink_shift.lean:35 +msgid "Masterfully done! You used divisibility to shrink the modulus, manually computed a small remainder, and used transitivity to glue it all together.\n" +"\n" +"This is exactly how number theory problems are solved in practice." msgstr "" -#: Game.Levels.DivRules.L06_div3 -msgid "Divisibility by 3" +#: Game/Levels/Problems/L07_quadratic.lean:7 +msgid "Quadratic Congruence" msgstr "" -#: Game.Levels.Divisibility.L07_rewriting -msgid "Substituting known values with rw simplifies a monstrous divisibility goal." +#. §0: $x \\equiv 2 \\pmod 5$ +#. §1: $x \\equiv 3 \\pmod 7$ +#. §2: $x^2 - 5x + 6 \\equiv 0 \\pmod{35}$ +#: Game/Levels/Problems/L07_quadratic.lean:9 +msgid "Let's evaluate a polynomial congruence based on multiple moduli.\n" +"\n" +"If §0 and §1, can you prove that §2?" msgstr "" -#: Game.Doc.Theorems.DivRules -msgid "**Divisibility by 3**\n" -"\n" -"Since 3 divides 9, a number is congruent to the sum of its digits modulo 3, just like with 9." +#: Game/Levels/Problems/L07_quadratic.lean:16 +msgid "There are two paths to solve this: a short one and a long one. It is worth thinking a bit about algebraic transformations." msgstr "" -#. §0: $a \\cdot x \\equiv b \\pmod m$ -#: Game.Levels.LinCong -msgid "Welcome to Linear Congruences and CRT!\n" +#: Game/Levels/Problems/L07_quadratic.lean:28 +msgid "Brilliant!\n" "\n" -"Brace yourself — this is the deepest theoretical world in the game.\n" -"Here we bring our GCD toolkit and congruences together to solve equations of the form §0.\n" +"Whether you used clever algebra to factor the polynomial, or applied the heavy machinery of the Chinese Remainder Theorem, you proved you can handle complex congruences. Both paths are perfectly valid!\n" "\n" -"We will discover when these equations have solutions, how to find modular inverses, prove the famous Euclid's Lemma, and finally face the ultimate theoretical boss: the Chinese Remainder Theorem!" +"Now, take a deep breath. Only one challenge remains..." msgstr "" -#: Game.Levels.Problems.L06_shrink_shift -msgid "Shrinking and Shifting" +#: Game/Levels/Problems/L08_system.lean:8 +msgid "System of Congruences (Boss)" msgstr "" -#. §0: $a \\equiv b \\pmod m$ -#. §1: $a$ -#. §2: $b$ -#. §3: $m$ -#. §4: $(a - b)$ -#. §5: $m$ -#. §6: $m$ -#. §7: $(a - b)$ -#. §8: $$m \\mid (a - b)$$ -#. §9: $a$ -#. §10: $b$ -#. §11: $m$ -#. §12: $15 \\equiv 3 \\pmod{12}$ -#. §13: $17 \\equiv 5 \\pmod{12}$ -#. §14: $12 \\mid (17 - 5)$ -#. §15: $12 \\mid 12$ -#. §16: $23 \\equiv 2 \\pmod 7$ -#. §17: $7 \\mid (23 - 2)$ -#. §18: $7 \\mid 21$ -#. §19: $10 \\equiv 0 \\pmod 5$ -#. §20: $5 \\mid (10 - 0)$ -#. §21: $5 \\mid 10$ -#. §22: $a \\equiv b \\pmod m$ -#. §23: `ModEq` -#. §24: `unfold ModEq` -#. §25: `m ∣ a - b` -#. §26: `unfold ModEq` -#. §27: `≡` -#. §28: `\\==` -#: Game.Doc.Definitions -msgid "**Modular Congruence (§0)**\n" +#. §0: $3x + 4y \\equiv 0 \\pmod{11}$ +#. §1: $4x - 3y \\equiv 0 \\pmod{11}$ +#. §2: $x \\equiv 0 \\pmod{11}$ +#. §3: $y$ +#. §4: `euclids_lemma` +#: Game/Levels/Problems/L08_system.lean:10 +msgid "Welcome to the final boss of the Problems world!\n" "\n" -"We say that §1 is **congruent** to §2 modulo §3 if their difference §4 is a multiple of §5.\n" -"Formally, it means §6 divides §7:\n" -"§8\n" +"In this battle, you are given a system of congruences:\n" +"§0\n" +"§1\n" "\n" -"**Intuition:**\n" -"This is a mathematical way of saying that §9 and §10 leave the *same remainder* when divided by §11. Think of a clock: 15:00 and 3:00 point to the same place because §12.\n" +"You must prove that §2.\n" "\n" -"**Examples:**\n" -"* §13 because §14, which simplifies to §15.\n" -"* §16 because §17, which is §18.\n" -"* §19 because §20, which is §21.\n" +"To win this battle, you only need two key ideas: figure out how to eliminate §3, and think about what you need to apply §4." +msgstr "" + +#: Game/Levels/Problems/L08_system.lean:54 +msgid "🎉 CONGRATULATIONS ON COMPLETING THE NUMBER THEORY GAME! 🎉\n" "\n" -"**How it works in Lean:**\n" -"We created a custom notation §22 to represent a function called §23. When you see this notation in your goal or hypotheses, you can use the §24 tactic. This will strip away the formatting and reveal the underlying divisibility statement: §25.\n" +"You have defeated the final boss by elegantly solving a system of congruences and applying Euclid's Lemma!\n" "\n" -"To work with this definition, use: §26\n" +"You started from the simplest definition of divisibility and built a massive, formally verified mathematical theory. You conquered congruences, modular arithmetic, divisibility rules, the greatest common divisor, and the Chinese Remainder Theorem — and then used your abstract tools to crush real numerical problems.\n" "\n" -"*(To type the congruence symbol §27, type §28 and press Space)*" -msgstr "" - -#. §0: `dvd_refl_int` -#: Game.Levels.Divisibility.L05_dvd_refl -msgid "Nice! You are starting to recognize patterns — we call this property **reflexivity** (§0)." +"Thank you for playing!" msgstr "" -#: Game.Levels.ModArith.L01_add -msgid "Adding Congruences" +#: Game/Levels/Problems.lean:12 +msgid "Problems" msgstr "" -#. §0: `mod_mul` -#: Game.Levels.ModArith.L06_pow -msgid "Fantastic! You just performed your first proof by induction, effortlessly reducing powers to multiplication with §0.\n" +#: Game/Levels/Problems.lean:14 +msgid "Welcome to the Grand Finale: Problems!\n" "\n" -"Now, one last challenge stands between you and the end of Modular Arithmetic!" +"You've conquered both branches of the game and built a massive toolkit of abstract theorems — from modular arithmetic and divisibility rules to the GCD, Euclid's Lemma, and the Chinese Remainder Theorem.\n" +"\n" +"In this final world, we will use your theorems to crush concrete numerical problems that would be too massive to compute directly. Let's put your theory to the ultimate test!" msgstr "" -#. §0: `«{a}» * «{x}» = «{d}» * «{k1}»` -#. §1: `«{m}» * «{k}» = «{d}» * «{k2}»` -#. §2: `«{b}» = «{a}» * «{x}» - «{m}» * «{k}»` -#. §3: `use «{k1}» - «{k2}»` -#: Game.Levels.LinCong.L04_sol_nec -msgid "You now know §0 and §1. Since §2, try §3." +#: Game.lean:11 +msgid "Number Theory Game" msgstr "" -#. §0: $a$ -#. §1: $1 \\mid a$ -#: Game.Doc.Theorems.Divisibility -msgid "**One Divides Everything**\n" +#. §0: $m$ +#: Game.lean:13 +msgid "# Welcome to the Number Theory Game\n" +"#### An introduction to integer arithmetic and formal proofs.\n" "\n" -"For any integer §0: §1." +"In this game, we will explore the fascinating world of Number Theory.\n" +"We will start from the basic definition of divisibility and build our way up\n" +"to modular arithmetic and congruences.\n" +"\n" +"Our ultimate goal is to understand how remainders work, how to safely manipulate\n" +"equations modulo §0, prove the classic divisibility rules, and prove strong\n" +"results like the Chinese Remainder Theorem. We will do this by solving levels\n" +"with Lean theorem prover.\n" +"\n" +"# Read this.\n" +"\n" +"Learning how to use an interactive theorem prover takes time.\n" +"Tests show that the people who get the most out of this game are\n" +"those who read the help texts on the left side of the screen.\n" +"\n" +"To start, click on the **Divisibility Club**.\n" +"\n" +"## More\n" +"\n" +"Click on the three lines in the top right and select \"Game Info\" for resources,\n" +"links, solutions, and ways to interact with the Lean community." msgstr "" -#: Game +#: Game.lean:41 msgid "*Game version: 1.0*\n" "\n" "## About\n" @@ -3726,92 +3805,12 @@ msgid "*Game version: 1.0*\n" "[issue at the Number Theory Game repo](https://github.com/k88-b/NumberTheoryGame/issues)." msgstr "" -#. §0: $17 - 5 = 12 = 6 \\cdot 2$ -#: Game.Levels.Congruence.L01_concrete -msgid "Congratulations on proving your first congruence!\n" -"Because §0, 17 and 5 leave the exact same remainder when divided by 6.\n" -"Now let's leave specific numbers behind and build the general theory!" -msgstr "" - -#. §0: `ring` -#. §1: `x + y = y + x` -#. §2: `x * 1 = x` -#. §3: `ring` -#. §4: `+` -#. §5: `-` -#. §6: `*` -#. §7: `^` -#. §8: `ℤ` -#. §9: `ℚ` -#. §10: `ℝ` -#. §11: `/` -#. §12: `%` -#: Game.Doc.Tactics -msgid "The §0 tactic automatically proves algebraic equalities by expanding and rearranging expressions.\n" -"It is a powerful tool so you don't have to manually apply basic axioms like commutativity or distributivity (e.g., §1 or §2).\n" -"\n" -"**What it works with:**\n" -"§3 works on equations involving addition (§4), subtraction (§5), multiplication (§6), and natural number exponents (§7) within commutative rings (such as integers §8, rationals §9, or reals §10).\n" -"\n" -"**What it does NOT work with:**\n" -"It cannot handle division (§11), modulo arithmetic (§12) or non-commutative structures (like matrices)." -msgstr "" - -#: Game.Levels.Congruence.L09_mod_split -msgid "Splitting the modulus into a product." -msgstr "" - -#. §0: $m/d$ -#: Game.Levels.LinCong.L07_sol_shift -msgid "Great work! Together, Levels 6 and 7 give us the complete description of the set of solutions: an arithmetic progression with step §0." -msgstr "" - -#. §0: $a \\equiv b \\pmod{m \\cdot n}$ -#. §1: $a \\equiv b \\pmod m$ -#. §2: $a \\equiv b \\pmod n$ -#. §3: $(a - b)$ -#. §4: $15$ -#. §5: $3 \\cdot 5$ -#. §6: $3$ -#. §7: $5$ -#: Game.Doc.Theorems.Congruence -msgid "**Splitting the Modulus**\n" -"\n" -"If §0, then §1 and §2.\n" -"\n" -"**Intuition:**\n" -"If a difference §3 is a multiple of §4 (§5), it must logically be a multiple of §6 and a multiple of §7.\n" -"So if two numbers are congruent modulo 15, they are automatically congruent modulo 3 and modulo 5.\n" -"This is a crucial stepping stone towards the Chinese Remainder Theorem!" -msgstr "" - -#. §0: `«{m}»` -#. §1: `«{k2}» * «{n}»` -#: Game.Levels.LinCong.L10_crt_glue -msgid "Now prove that §0 divides §1." -msgstr "" - -#: Game.Levels.Congruence -msgid "Meet the Congruence" -msgstr "" - -#: Game.Levels.ModArith.L05_mul -msgid "If two pairs of numbers are congruent, their products are congruent." +#: Game.lean:86 +msgid "An interactive introduction to Number Theory and modular arithmetic." msgstr "" -#. §0: $0 \\le d_1$ -#. §1: $0 \\le d_2$ -#. §2: $d_1 \\mid d_2$ -#. §3: $d_2 \\mid d_1$ -#. §4: $d_1 = d_2$ -#. §5: $\\mathbb{Z}$ -#: Game.Doc.Theorems.GCD -msgid "**Antisymmetry of Divisibility (for non-negative integers)**\n" -"\n" -"If §0, §1, §2, and §3, then §4.\n" -"\n" -"**Why we need it:**\n" -"Divisibility on all of §5 only forms a *pre-order*: two different numbers can divide each other, as long as one is the negative of the other. Restricted to non-negative integers, though, divisibility becomes a genuine **partial order**: \"mutual divisibility\" really does collapse to equality.\n" -"\n" -"In this boss level, we will show two gcd-witnesses divide each other, and use exactly this theorem to conclude they must be the *same* number." +#: Game.lean:87 +msgid "In this game, you will learn the foundations of number theory.\n" +"Starting with basic divisibility, you will construct a full toolkit for\n" +"modular arithmetic (congruences) and prove theorems like a real mathematician." msgstr "" diff --git a/Game/Doc/Definitions.lean b/Game/Doc/Definitions.lean index d0c0e1a..93aeff2 100644 --- a/Game/Doc/Definitions.lean +++ b/Game/Doc/Definitions.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi /-- diff --git a/Game/Doc/Tactics.lean b/Game/Doc/Tactics.lean index 71c19f3..399bbc9 100644 --- a/Game/Doc/Tactics.lean +++ b/Game/Doc/Tactics.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi /-- The `use` tactic is used to provide a "witness" to prove that something exists. diff --git a/Game/Doc/Theorems/Congruence.lean b/Game/Doc/Theorems/Congruence.lean index 80bf4a2..0eebd25 100644 --- a/Game/Doc/Theorems/Congruence.lean +++ b/Game/Doc/Theorems/Congruence.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi /-- diff --git a/Game/Doc/Theorems/DivRules.lean b/Game/Doc/Theorems/DivRules.lean index 3231f81..75e7dc3 100644 --- a/Game/Doc/Theorems/DivRules.lean +++ b/Game/Doc/Theorems/DivRules.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi /-- diff --git a/Game/Doc/Theorems/Divisibility.lean b/Game/Doc/Theorems/Divisibility.lean index 8ccffd1..3507b5f 100644 --- a/Game/Doc/Theorems/Divisibility.lean +++ b/Game/Doc/Theorems/Divisibility.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi /-- diff --git a/Game/Doc/Theorems/GCD.lean b/Game/Doc/Theorems/GCD.lean index e2dfbb1..a5fce53 100644 --- a/Game/Doc/Theorems/GCD.lean +++ b/Game/Doc/Theorems/GCD.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi /-- diff --git a/Game/Doc/Theorems/LinCong.lean b/Game/Doc/Theorems/LinCong.lean index 6541668..d6d4d6d 100644 --- a/Game/Doc/Theorems/LinCong.lean +++ b/Game/Doc/Theorems/LinCong.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi /-- diff --git a/Game/Levels/Congruence/L01_concrete.lean b/Game/Levels/Congruence/L01_concrete.lean index 3984844..7f9858a 100644 --- a/Game/Levels/Congruence/L01_concrete.lean +++ b/Game/Levels/Congruence/L01_concrete.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Metadata import Game.Levels.Definitions diff --git a/Game/Levels/Congruence/L02_mod_refl.lean b/Game/Levels/Congruence/L02_mod_refl.lean index be3aec6..eb02ec0 100644 --- a/Game/Levels/Congruence/L02_mod_refl.lean +++ b/Game/Levels/Congruence/L02_mod_refl.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.Congruence.L01_concrete diff --git a/Game/Levels/Congruence/L03_dvd_imp_mod_zero.lean b/Game/Levels/Congruence/L03_dvd_imp_mod_zero.lean index ff08fff..9fc5fee 100644 --- a/Game/Levels/Congruence/L03_dvd_imp_mod_zero.lean +++ b/Game/Levels/Congruence/L03_dvd_imp_mod_zero.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.Congruence.L02_mod_refl diff --git a/Game/Levels/Congruence/L04_mod_symm.lean b/Game/Levels/Congruence/L04_mod_symm.lean index 46a6aad..dae2d9e 100644 --- a/Game/Levels/Congruence/L04_mod_symm.lean +++ b/Game/Levels/Congruence/L04_mod_symm.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.Congruence.L03_dvd_imp_mod_zero diff --git a/Game/Levels/Congruence/L05_mod_trans.lean b/Game/Levels/Congruence/L05_mod_trans.lean index 9b30830..de27f14 100644 --- a/Game/Levels/Congruence/L05_mod_trans.lean +++ b/Game/Levels/Congruence/L05_mod_trans.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.Congruence.L04_mod_symm diff --git a/Game/Levels/Congruence/L06_add_mul_mod.lean b/Game/Levels/Congruence/L06_add_mul_mod.lean index 3db28a0..9bdfd8d 100644 --- a/Game/Levels/Congruence/L06_add_mul_mod.lean +++ b/Game/Levels/Congruence/L06_add_mul_mod.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.Congruence.L05_mod_trans diff --git a/Game/Levels/Congruence/L07_mod_scale.lean b/Game/Levels/Congruence/L07_mod_scale.lean index 3ad7640..22a1883 100644 --- a/Game/Levels/Congruence/L07_mod_scale.lean +++ b/Game/Levels/Congruence/L07_mod_scale.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.Congruence.L06_add_mul_mod diff --git a/Game/Levels/Congruence/L08_mod_dvd.lean b/Game/Levels/Congruence/L08_mod_dvd.lean index 819b83f..68db1e6 100644 --- a/Game/Levels/Congruence/L08_mod_dvd.lean +++ b/Game/Levels/Congruence/L08_mod_dvd.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.Congruence.L07_mod_scale diff --git a/Game/Levels/Congruence/L09_mod_split.lean b/Game/Levels/Congruence/L09_mod_split.lean index 0eaad15..7238fd5 100644 --- a/Game/Levels/Congruence/L09_mod_split.lean +++ b/Game/Levels/Congruence/L09_mod_split.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.Congruence.L08_mod_dvd diff --git a/Game/Levels/Definitions.lean b/Game/Levels/Definitions.lean index ddd1962..15c9dcb 100644 --- a/Game/Levels/Definitions.lean +++ b/Game/Levels/Definitions.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic diff --git a/Game/Levels/DivRules/L01_div10.lean b/Game/Levels/DivRules/L01_div10.lean index 92c6fa2..9cabdcf 100644 --- a/Game/Levels/DivRules/L01_div10.lean +++ b/Game/Levels/DivRules/L01_div10.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Metadata import Game.Levels.Definitions diff --git a/Game/Levels/DivRules/L02_div2.lean b/Game/Levels/DivRules/L02_div2.lean index 3487f14..5791942 100644 --- a/Game/Levels/DivRules/L02_div2.lean +++ b/Game/Levels/DivRules/L02_div2.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.DivRules.L01_div10 diff --git a/Game/Levels/DivRules/L03_div5.lean b/Game/Levels/DivRules/L03_div5.lean index d1f9bd8..2a228b3 100644 --- a/Game/Levels/DivRules/L03_div5.lean +++ b/Game/Levels/DivRules/L03_div5.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.DivRules.L02_div2 diff --git a/Game/Levels/DivRules/L04_div4.lean b/Game/Levels/DivRules/L04_div4.lean index e77d343..66994ef 100644 --- a/Game/Levels/DivRules/L04_div4.lean +++ b/Game/Levels/DivRules/L04_div4.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.DivRules.L03_div5 diff --git a/Game/Levels/DivRules/L05_div9.lean b/Game/Levels/DivRules/L05_div9.lean index 906b0b1..7f6272c 100644 --- a/Game/Levels/DivRules/L05_div9.lean +++ b/Game/Levels/DivRules/L05_div9.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.DivRules.L04_div4 diff --git a/Game/Levels/DivRules/L06_div3.lean b/Game/Levels/DivRules/L06_div3.lean index 7868b80..372cb39 100644 --- a/Game/Levels/DivRules/L06_div3.lean +++ b/Game/Levels/DivRules/L06_div3.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.DivRules.L05_div9 diff --git a/Game/Levels/DivRules/L07_div11.lean b/Game/Levels/DivRules/L07_div11.lean index 1b955f6..e1172d2 100644 --- a/Game/Levels/DivRules/L07_div11.lean +++ b/Game/Levels/DivRules/L07_div11.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.DivRules.L06_div3 diff --git a/Game/Levels/Divisibility.lean b/Game/Levels/Divisibility.lean index 6fb8440..f8bce5b 100644 --- a/Game/Levels/Divisibility.lean +++ b/Game/Levels/Divisibility.lean @@ -1,5 +1,5 @@ import Game.Metadata -import GameServer +import GameApi import Game.Levels.Divisibility.L01_first_proof import Game.Levels.Divisibility.L02_negative_multiples diff --git a/Game/Levels/Divisibility/L01_first_proof.lean b/Game/Levels/Divisibility/L01_first_proof.lean index fff58c2..94b3c3f 100644 --- a/Game/Levels/Divisibility/L01_first_proof.lean +++ b/Game/Levels/Divisibility/L01_first_proof.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Metadata import Game.Levels.Definitions diff --git a/Game/Levels/Divisibility/L02_negative_multiples.lean b/Game/Levels/Divisibility/L02_negative_multiples.lean index 641a5ad..ebd02e4 100644 --- a/Game/Levels/Divisibility/L02_negative_multiples.lean +++ b/Game/Levels/Divisibility/L02_negative_multiples.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.Divisibility.L01_first_proof diff --git a/Game/Levels/Divisibility/L03_dvd_mul_right.lean b/Game/Levels/Divisibility/L03_dvd_mul_right.lean index 5232b6a..43fcef8 100644 --- a/Game/Levels/Divisibility/L03_dvd_mul_right.lean +++ b/Game/Levels/Divisibility/L03_dvd_mul_right.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.Divisibility.L02_negative_multiples diff --git a/Game/Levels/Divisibility/L04_one_dvd.lean b/Game/Levels/Divisibility/L04_one_dvd.lean index 0ee6153..3d77058 100644 --- a/Game/Levels/Divisibility/L04_one_dvd.lean +++ b/Game/Levels/Divisibility/L04_one_dvd.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.Divisibility.L03_dvd_mul_right diff --git a/Game/Levels/Divisibility/L05_dvd_refl.lean b/Game/Levels/Divisibility/L05_dvd_refl.lean index 8800aef..50d4113 100644 --- a/Game/Levels/Divisibility/L05_dvd_refl.lean +++ b/Game/Levels/Divisibility/L05_dvd_refl.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.Divisibility.L04_one_dvd diff --git a/Game/Levels/Divisibility/L06_dvd_zero.lean b/Game/Levels/Divisibility/L06_dvd_zero.lean index 078dd0e..8c20629 100644 --- a/Game/Levels/Divisibility/L06_dvd_zero.lean +++ b/Game/Levels/Divisibility/L06_dvd_zero.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.Divisibility.L05_dvd_refl diff --git a/Game/Levels/Divisibility/L07_rewriting.lean b/Game/Levels/Divisibility/L07_rewriting.lean index fa593a9..415cb92 100644 --- a/Game/Levels/Divisibility/L07_rewriting.lean +++ b/Game/Levels/Divisibility/L07_rewriting.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.Divisibility.L06_dvd_zero diff --git a/Game/Levels/Divisibility/L08_rewriting_backwards.lean b/Game/Levels/Divisibility/L08_rewriting_backwards.lean index 686ff13..dcaa7e8 100644 --- a/Game/Levels/Divisibility/L08_rewriting_backwards.lean +++ b/Game/Levels/Divisibility/L08_rewriting_backwards.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.Divisibility.L07_rewriting diff --git a/Game/Levels/Divisors/L01_eq_zero_of_zero_dvd.lean b/Game/Levels/Divisors/L01_eq_zero_of_zero_dvd.lean index 2085b83..5ade042 100644 --- a/Game/Levels/Divisors/L01_eq_zero_of_zero_dvd.lean +++ b/Game/Levels/Divisors/L01_eq_zero_of_zero_dvd.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.Divisibility diff --git a/Game/Levels/Divisors/L02_multiples_of_6.lean b/Game/Levels/Divisors/L02_multiples_of_6.lean index a0878e5..b3e1659 100644 --- a/Game/Levels/Divisors/L02_multiples_of_6.lean +++ b/Game/Levels/Divisors/L02_multiples_of_6.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.Divisors.L01_eq_zero_of_zero_dvd diff --git a/Game/Levels/Divisors/L03_dvd_mul.lean b/Game/Levels/Divisors/L03_dvd_mul.lean index 0f848d9..adb136d 100644 --- a/Game/Levels/Divisors/L03_dvd_mul.lean +++ b/Game/Levels/Divisors/L03_dvd_mul.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.Divisors.L02_multiples_of_6 diff --git a/Game/Levels/Divisors/L04_dvd_add.lean b/Game/Levels/Divisors/L04_dvd_add.lean index cd825df..5860964 100644 --- a/Game/Levels/Divisors/L04_dvd_add.lean +++ b/Game/Levels/Divisors/L04_dvd_add.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.Divisors.L03_dvd_mul diff --git a/Game/Levels/Divisors/L05_dvd_trans.lean b/Game/Levels/Divisors/L05_dvd_trans.lean index 555bb03..999176e 100644 --- a/Game/Levels/Divisors/L05_dvd_trans.lean +++ b/Game/Levels/Divisors/L05_dvd_trans.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.Divisors.L04_dvd_add diff --git a/Game/Levels/Divisors/L06_dvd_lin_comb.lean b/Game/Levels/Divisors/L06_dvd_lin_comb.lean index 7278417..fbb5045 100644 --- a/Game/Levels/Divisors/L06_dvd_lin_comb.lean +++ b/Game/Levels/Divisors/L06_dvd_lin_comb.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.Divisors.L05_dvd_trans diff --git a/Game/Levels/GCD/L01_gcd_def.lean b/Game/Levels/GCD/L01_gcd_def.lean index 611e79a..bc04272 100644 --- a/Game/Levels/GCD/L01_gcd_def.lean +++ b/Game/Levels/GCD/L01_gcd_def.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Metadata import Game.Levels.Definitions diff --git a/Game/Levels/GCD/L02_gcd_greatest.lean b/Game/Levels/GCD/L02_gcd_greatest.lean index 9d83f85..864ab88 100644 --- a/Game/Levels/GCD/L02_gcd_greatest.lean +++ b/Game/Levels/GCD/L02_gcd_greatest.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.GCD.L01_gcd_def diff --git a/Game/Levels/GCD/L03_coprime_forward.lean b/Game/Levels/GCD/L03_coprime_forward.lean index 2375e40..8dc61b2 100644 --- a/Game/Levels/GCD/L03_coprime_forward.lean +++ b/Game/Levels/GCD/L03_coprime_forward.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.GCD.L02_gcd_greatest diff --git a/Game/Levels/GCD/L04_coprime_backward.lean b/Game/Levels/GCD/L04_coprime_backward.lean index 0fa9c12..e77a053 100644 --- a/Game/Levels/GCD/L04_coprime_backward.lean +++ b/Game/Levels/GCD/L04_coprime_backward.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.GCD.L03_coprime_forward diff --git a/Game/Levels/GCD/L05_gcd_symm.lean b/Game/Levels/GCD/L05_gcd_symm.lean index 424677e..8cad3f2 100644 --- a/Game/Levels/GCD/L05_gcd_symm.lean +++ b/Game/Levels/GCD/L05_gcd_symm.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.GCD.L04_coprime_backward diff --git a/Game/Levels/GCD/L06_cancel_coprime.lean b/Game/Levels/GCD/L06_cancel_coprime.lean index e0a138a..0ad44de 100644 --- a/Game/Levels/GCD/L06_cancel_coprime.lean +++ b/Game/Levels/GCD/L06_cancel_coprime.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.GCD.L05_gcd_symm diff --git a/Game/Levels/GCD/L07_gcd_div_coprime.lean b/Game/Levels/GCD/L07_gcd_div_coprime.lean index 0ea1a6b..f777bb0 100644 --- a/Game/Levels/GCD/L07_gcd_div_coprime.lean +++ b/Game/Levels/GCD/L07_gcd_div_coprime.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.GCD.L06_cancel_coprime diff --git a/Game/Levels/GCD/L08_cancel_general.lean b/Game/Levels/GCD/L08_cancel_general.lean index 4a498e5..77ccde2 100644 --- a/Game/Levels/GCD/L08_cancel_general.lean +++ b/Game/Levels/GCD/L08_cancel_general.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.GCD.L07_gcd_div_coprime diff --git a/Game/Levels/GCD/L09_gcd_shift.lean b/Game/Levels/GCD/L09_gcd_shift.lean index 576033e..0881c94 100644 --- a/Game/Levels/GCD/L09_gcd_shift.lean +++ b/Game/Levels/GCD/L09_gcd_shift.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.GCD.L08_cancel_general diff --git a/Game/Levels/LinCong/L01_inv_exists.lean b/Game/Levels/LinCong/L01_inv_exists.lean index 53f7ca2..ddace8f 100644 --- a/Game/Levels/LinCong/L01_inv_exists.lean +++ b/Game/Levels/LinCong/L01_inv_exists.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Metadata import Game.Levels.Definitions diff --git a/Game/Levels/LinCong/L02_inv_reverse.lean b/Game/Levels/LinCong/L02_inv_reverse.lean index e8698c4..7f95cb8 100644 --- a/Game/Levels/LinCong/L02_inv_reverse.lean +++ b/Game/Levels/LinCong/L02_inv_reverse.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.LinCong.L01_inv_exists diff --git a/Game/Levels/LinCong/L03_inv_unique.lean b/Game/Levels/LinCong/L03_inv_unique.lean index 8813826..c2d9c4d 100644 --- a/Game/Levels/LinCong/L03_inv_unique.lean +++ b/Game/Levels/LinCong/L03_inv_unique.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.LinCong.L02_inv_reverse diff --git a/Game/Levels/LinCong/L04_sol_nec.lean b/Game/Levels/LinCong/L04_sol_nec.lean index bbfb8b8..0ff980b 100644 --- a/Game/Levels/LinCong/L04_sol_nec.lean +++ b/Game/Levels/LinCong/L04_sol_nec.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.LinCong.L03_inv_unique diff --git a/Game/Levels/LinCong/L05_sol_suff.lean b/Game/Levels/LinCong/L05_sol_suff.lean index 5c943ba..ad3a486 100644 --- a/Game/Levels/LinCong/L05_sol_suff.lean +++ b/Game/Levels/LinCong/L05_sol_suff.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.LinCong.L04_sol_nec diff --git a/Game/Levels/LinCong/L06_sol_equiv.lean b/Game/Levels/LinCong/L06_sol_equiv.lean index 92f8145..0c161b4 100644 --- a/Game/Levels/LinCong/L06_sol_equiv.lean +++ b/Game/Levels/LinCong/L06_sol_equiv.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.LinCong.L05_sol_suff diff --git a/Game/Levels/LinCong/L07_sol_shift.lean b/Game/Levels/LinCong/L07_sol_shift.lean index 005c89e..9f7e687 100644 --- a/Game/Levels/LinCong/L07_sol_shift.lean +++ b/Game/Levels/LinCong/L07_sol_shift.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.LinCong.L06_sol_equiv diff --git a/Game/Levels/LinCong/L08_euclid.lean b/Game/Levels/LinCong/L08_euclid.lean index cf412a9..0c57067 100644 --- a/Game/Levels/LinCong/L08_euclid.lean +++ b/Game/Levels/LinCong/L08_euclid.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.LinCong.L07_sol_shift diff --git a/Game/Levels/LinCong/L09_crt_exists.lean b/Game/Levels/LinCong/L09_crt_exists.lean index 0b1cbb2..11578f5 100644 --- a/Game/Levels/LinCong/L09_crt_exists.lean +++ b/Game/Levels/LinCong/L09_crt_exists.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.LinCong.L08_euclid diff --git a/Game/Levels/LinCong/L10_crt_glue.lean b/Game/Levels/LinCong/L10_crt_glue.lean index b42b832..1e7e771 100644 --- a/Game/Levels/LinCong/L10_crt_glue.lean +++ b/Game/Levels/LinCong/L10_crt_glue.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.LinCong.L09_crt_exists diff --git a/Game/Levels/ModArith/L01_add.lean b/Game/Levels/ModArith/L01_add.lean index b08d7aa..37e6d12 100644 --- a/Game/Levels/ModArith/L01_add.lean +++ b/Game/Levels/ModArith/L01_add.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Metadata import Game.Levels.Definitions diff --git a/Game/Levels/ModArith/L02_sub.lean b/Game/Levels/ModArith/L02_sub.lean index 27cda60..bd7e070 100644 --- a/Game/Levels/ModArith/L02_sub.lean +++ b/Game/Levels/ModArith/L02_sub.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.ModArith.L01_add diff --git a/Game/Levels/ModArith/L03_add_const.lean b/Game/Levels/ModArith/L03_add_const.lean index 2b94bc8..b41efb2 100644 --- a/Game/Levels/ModArith/L03_add_const.lean +++ b/Game/Levels/ModArith/L03_add_const.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.ModArith.L02_sub diff --git a/Game/Levels/ModArith/L04_mul_const.lean b/Game/Levels/ModArith/L04_mul_const.lean index 04736b5..1b5f592 100644 --- a/Game/Levels/ModArith/L04_mul_const.lean +++ b/Game/Levels/ModArith/L04_mul_const.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.ModArith.L03_add_const diff --git a/Game/Levels/ModArith/L05_mul.lean b/Game/Levels/ModArith/L05_mul.lean index 307c7f9..3875ef5 100644 --- a/Game/Levels/ModArith/L05_mul.lean +++ b/Game/Levels/ModArith/L05_mul.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.ModArith.L04_mul_const diff --git a/Game/Levels/ModArith/L06_pow.lean b/Game/Levels/ModArith/L06_pow.lean index e8a6738..a086757 100644 --- a/Game/Levels/ModArith/L06_pow.lean +++ b/Game/Levels/ModArith/L06_pow.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.ModArith.L05_mul diff --git a/Game/Levels/ModArith/L07_poly.lean b/Game/Levels/ModArith/L07_poly.lean index 4460b59..9a59429 100644 --- a/Game/Levels/ModArith/L07_poly.lean +++ b/Game/Levels/ModArith/L07_poly.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.ModArith.L06_pow diff --git a/Game/Levels/Problems/L01_large_powers.lean b/Game/Levels/Problems/L01_large_powers.lean index 08fff55..d5daea6 100644 --- a/Game/Levels/Problems/L01_large_powers.lean +++ b/Game/Levels/Problems/L01_large_powers.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Metadata import Game.Levels.Definitions diff --git a/Game/Levels/Problems/L02_cancel.lean b/Game/Levels/Problems/L02_cancel.lean index 4abea00..691106b 100644 --- a/Game/Levels/Problems/L02_cancel.lean +++ b/Game/Levels/Problems/L02_cancel.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.Problems.L01_large_powers diff --git a/Game/Levels/Problems/L03_crt.lean b/Game/Levels/Problems/L03_crt.lean index d86c5ef..cf909c9 100644 --- a/Game/Levels/Problems/L03_crt.lean +++ b/Game/Levels/Problems/L03_crt.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.Problems.L02_cancel diff --git a/Game/Levels/Problems/L04_lincong.lean b/Game/Levels/Problems/L04_lincong.lean index 41c2dd4..85919f1 100644 --- a/Game/Levels/Problems/L04_lincong.lean +++ b/Game/Levels/Problems/L04_lincong.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.Problems.L03_crt diff --git a/Game/Levels/Problems/L05_euclid.lean b/Game/Levels/Problems/L05_euclid.lean index 021a7a0..7c67a63 100644 --- a/Game/Levels/Problems/L05_euclid.lean +++ b/Game/Levels/Problems/L05_euclid.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.Problems.L04_lincong diff --git a/Game/Levels/Problems/L06_shrink_shift.lean b/Game/Levels/Problems/L06_shrink_shift.lean index 3c62343..361ff5d 100644 --- a/Game/Levels/Problems/L06_shrink_shift.lean +++ b/Game/Levels/Problems/L06_shrink_shift.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.Problems.L05_euclid diff --git a/Game/Levels/Problems/L07_quadratic.lean b/Game/Levels/Problems/L07_quadratic.lean index bb1f385..3e338c7 100644 --- a/Game/Levels/Problems/L07_quadratic.lean +++ b/Game/Levels/Problems/L07_quadratic.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.Problems.L06_shrink_shift diff --git a/Game/Levels/Problems/L08_system.lean b/Game/Levels/Problems/L08_system.lean index a80113a..e6a4fe8 100644 --- a/Game/Levels/Problems/L08_system.lean +++ b/Game/Levels/Problems/L08_system.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic import Game.Levels.Problems.L07_quadratic diff --git a/Game/Metadata.lean b/Game/Metadata.lean index 70368e7..48db17b 100644 --- a/Game/Metadata.lean +++ b/Game/Metadata.lean @@ -1,4 +1,4 @@ -import GameServer +import GameApi import Mathlib.Tactic /-! Use this file to add things that should be available in all levels. diff --git a/lake-manifest.json b/lake-manifest.json index 30531a0..56234a3 100644 --- a/lake-manifest.json +++ b/lake-manifest.json @@ -1,31 +1,31 @@ -{"version": "1.1.0", +{"version": "1.3.0", "packagesDir": ".lake/packages", "packages": [{"url": "https://github.com/leanprover-community/mathlib4", "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "37df177aaa770670452312393d4e84aaad56e7b6", + "rev": "fc4f59e577feb1a4956671bc04ac18aaaf8cd842", "name": "mathlib", "manifestFile": "lake-manifest.json", - "inputRev": "v4.23.0", + "inputRev": "v4.36.0", "inherited": false, "configFile": "lakefile.lean"}, - {"url": "https://github.com/leanprover-community/lean4game.git", + {"url": "https://github.com/hhu-adam/GameServer.git", "type": "git", - "subDir": "server", + "subDir": null, "scope": "hhu-adam", - "rev": "36aa0824532ba3a3788d6d2e7cf72905e891cf14", + "rev": "8d7bd73afb67c560c277570e3f513a4a354a00e4", "name": "GameServer", "manifestFile": "lake-manifest.json", - "inputRev": "v4.23.0", + "inputRev": "v4.36.0", "inherited": false, "configFile": "lakefile.lean"}, {"url": "https://github.com/leanprover-community/plausible", "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "a22e7c1fa7707fb7ea75f2f9fd6b14de2b7b87a9", + "rev": "054b228ce0ac61d767c6e71ba73a24728f191b72", "name": "plausible", "manifestFile": "lake-manifest.json", "inputRev": "main", @@ -35,7 +35,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "99657ad92e23804e279f77ea6dbdeebaa1317b98", + "rev": "4fb58e749ef3fc0395fe274f6cab70c2ea85f1c9", "name": "LeanSearchClient", "manifestFile": "lake-manifest.json", "inputRev": "main", @@ -45,7 +45,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "7fca1d4a190761bac0028848f73dc9a59fcb4957", + "rev": "8370c640afcd1cc3fb1cb9bf1560cc66eafee5e0", "name": "importGraph", "manifestFile": "lake-manifest.json", "inputRev": "main", @@ -55,17 +55,17 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "6e47cc88cfbf1601ab364e9a4de5f33f13401ff8", + "rev": "2f0f3520daeac2d9310ff25b7a877a0e5cdaa203", "name": "proofwidgets", "manifestFile": "lake-manifest.json", - "inputRev": "v0.0.71", + "inputRev": "main", "inherited": true, "configFile": "lakefile.lean"}, {"url": "https://github.com/leanprover-community/aesop", "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "247ff80701c76760523b5d7c180b27b7708faf38", + "rev": "66ff77cf0c4c898799e4b94d14db55f7a02d0c5a", "name": "aesop", "manifestFile": "lake-manifest.json", "inputRev": "master", @@ -75,7 +75,7 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "9b703a545097978aef0e7e243ab8b71c32a9ff65", + "rev": "ff055a2fcc835935e0ae607339b455a5f5896b4b", "name": "Qq", "manifestFile": "lake-manifest.json", "inputRev": "master", @@ -85,31 +85,32 @@ "type": "git", "subDir": null, "scope": "leanprover-community", - "rev": "d117e2c28cba42e974bc22568ac999492a34e812", + "rev": "b4b25a3886a16daacaf6615c2eea7170a6e8f458", "name": "batteries", "manifestFile": "lake-manifest.json", "inputRev": "main", "inherited": true, "configFile": "lakefile.toml"}, - {"url": "https://github.com/leanprover/lean4-cli", + {"url": "https://github.com/hhu-adam/lean-i18n", "type": "git", "subDir": null, - "scope": "leanprover", - "rev": "41c5d0b8814dec559e2e1441171db434fe2281cc", - "name": "Cli", + "scope": "hhu-adam", + "rev": "b932dae1f0872da19f53594ddb922fead0d7b793", + "name": "i18n", "manifestFile": "lake-manifest.json", - "inputRev": "main", + "inputRev": "v4.36.0", "inherited": true, - "configFile": "lakefile.toml"}, - {"url": "https://github.com/hhu-adam/lean-i18n", + "configFile": "lakefile.lean"}, + {"url": "https://github.com/leanprover/lean4-cli", "type": "git", "subDir": null, - "scope": "hhu-adam", - "rev": "c293094f25d8548435dcfa6bc58cc8ed52f15341", - "name": "i18n", + "scope": "leanprover", + "rev": "50810f72af7618bee62fe9800dc26e806c188703", + "name": "Cli", "manifestFile": "lake-manifest.json", - "inputRev": "v4.23.0", + "inputRev": "v4.36.0", "inherited": true, - "configFile": "lakefile.lean"}], + "configFile": "lakefile.toml"}], "name": "Game", - "lakeDir": ".lake"} + "lakeDir": ".lake", + "fixedToolchain": false} diff --git a/lakefile.lean b/lakefile.lean index 912adf6..1bf8533 100644 --- a/lakefile.lean +++ b/lakefile.lean @@ -5,14 +5,26 @@ open Lake DSL def leanVersion : String := s!"v{Lean.versionString}" /-- -Use the GameServer from a `lean4game` folder lying next to the game on your local computer. -Activated with `lake update -Klean4game.local`. +Use the GameServer from a `leangame` folder lying next to the game on your local computer. +Activated with `lake update -R -Kleangame.local --keep-toolchain`. -/ def LocalGameServer : Dependency := { name := `GameServer scope := "hhu-adam" - src? := DependencySrc.path "../lean4game/server" - version? := none + src? := DependencySrc.path "../leangame/server/lean" + version := .none + opts := ∅ +} + +/-- +For development of the game server itself, the GameServer dependency needs to come from within the repo. +Activated with `lake update -R -Kleangame.testgame --keep-toolchain`. +-/ +def TestGameServer : Dependency := { + name := `GameServer + scope := "hhu-adam" + src? := DependencySrc.path "../server/lean" + version := .none opts := ∅ } @@ -23,25 +35,54 @@ Deactivate local version with `lake update -R`. def RemoteGameServer : Dependency := { name := `GameServer scope := "hhu-adam" - src? := DependencySrc.git "https://github.com/leanprover-community/lean4game.git" leanVersion "server" - version? := s!"git#{leanVersion}" + src? := DependencySrc.git "https://github.com/hhu-adam/GameServer.git" leanVersion .none + version := .git leanVersion opts := ∅ } /- -Choose GameServer dependency depending on whether `-Klean4game.local` has been passed to `lake`. +Choose GameServer dependency depending on whether `-Kleangame.local` or `-Kleangame.testgame` has been passed to `lake`. -/ open Lean in #eval (do - let gameServerName := if get_config? lean4game.local |>.isSome then - ``LocalGameServer else ``RemoteGameServer + let gameServerName := if get_config? leangame.testgame |>.isSome then + ``TestGameServer + else if get_config? leangame.local |>.isSome then + ``LocalGameServer + else + ``RemoteGameServer modifyEnv (fun env => Lake.packageDepAttr.ext.addEntry env gameServerName) : Elab.Command.CommandElabM Unit) +/-! +# USER DEPENDENCIES + +Add any further dependencies of your game below. + +Note: If your package (like `mathlib` or `Std`) has tags of the form `v4.X.0` then +you can use + +``` +require "leanprover-community" / mathlib @ git leanVersion +``` + -/ + require "leanprover-community" / mathlib @ git leanVersion +/-! +# PACKAGE CONFIGURATION +Here you can set options used in your game. The player will use the same options as you'll +have set here. +NOTE: The `leanOptions` and `moreServerOptions` influence how the player preceives the game. +For example, it is important to have `linter.all` set to `false` to prevent any linter +warnings from showing up during playing. + +NOTE: We abuse the `trace.debug` option to toggle messages in VSCode on and +off when calling `lake build`. Ideally there would be a better way using `logInfo` and +an option like `leangame.verbose`. +-/ package Game where /- Used in all cases. -/ leanOptions := #[ @@ -53,12 +94,38 @@ package Game where ⟨`tactic.hygienic, false⟩] /- Used when calling `lake build`. -/ moreLeanArgs := #[ - -- TODO: replace with `lean4game.verbose` + -- TODO: replace with `leangame.verbose` "-Dtrace.debug=false"] /- Used when opening a file in VSCode or when playing the game. -/ moreServerOptions := #[ - -- TODO: replace with `lean4game.verbose` + -- TODO: replace with `leangame.verbose` ⟨`trace.debug, true⟩] +/-- Non-Lean build targets: if the content of `images/` or `.i18n/config.json` changed, +then we need to force `lake` to rebuild instead of replay. -/ +target makeGameInputs pkg : Unit := do + let imagesDir := pkg.dir / "images" + let imagesJob ← if ← imagesDir.isDir then + inputDir imagesDir (text := false) (fun _ => true) + else + pure (Job.pure #[]) + + let i18nConfig := pkg.dir / ".i18n" / "config.json" + let configJob ← if ← i18nConfig.pathExists then + inputTextFile i18nConfig + else + pure (Job.pure i18nConfig) + + return imagesJob.mix configJob + +/-- Note: changes to any target in `needs` cause the entire game to be rebuilt. -/ @[default_target] -lean_lib Game +lean_lib Game where + needs := #[ + /- The library `GameServer` is not imported by the game, but needed to run it. -/ + `@GameServer/GameServer, -- built the GameServer library, too + `@/makeGameInputs] -- ensure non-Lean inputs are up to date + +-- @[test_driver] +-- lean_lib test where +-- globs := #[.submodules `Test] diff --git a/lean-toolchain b/lean-toolchain index 14a4424..00f8483 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4:v4.23.0 \ No newline at end of file +leanprover/lean4:v4.36.0