Merge branch 'main' into addition-revision
This commit is contained in:
@@ -22,4 +22,10 @@ RUN git clone https://github.com/leanprover-community/lean4game.git
|
||||
WORKDIR /lean4game
|
||||
RUN npm install
|
||||
|
||||
# For some reason `node:node` results in 1000:1000, but user `node` has UID 30000...??
|
||||
# TODO: This alone takes 2min for me. can we refactor this so that `npm install` is already
|
||||
# run as the `node` user
|
||||
WORKDIR /
|
||||
RUN chown -R 30000:30003 /lean4game
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
@@ -3,6 +3,16 @@
|
||||
"service": "game",
|
||||
"workspaceFolder": "/game",
|
||||
"forwardPorts": [3000],
|
||||
// These settings make sure that the created files (lake-packages etc.) are owned
|
||||
// by the user and not `root`.
|
||||
// see also https://containers.dev/implementors/json_reference/
|
||||
// // and https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user
|
||||
"remoteUser": "node",
|
||||
"overrideCommand": true,
|
||||
"updateRemoteUserUID": true,
|
||||
// TODO: A problem with this setup is that the cache file is downloaded newly every time
|
||||
// can we use the global cache storage? or already download it when creating the docker image?
|
||||
"postAttachCommand": "(cd /game && lake update && lake exe cache get && lake build) && (cd /lean4game && npm start)",
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"settings": {
|
||||
|
||||
@@ -2,10 +2,10 @@ version: "3.9"
|
||||
|
||||
services:
|
||||
game:
|
||||
user: root
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
command: bash -c "(cd /game && lake update && lake build) && npm start"
|
||||
volumes:
|
||||
- ..:/game
|
||||
ports:
|
||||
|
||||
@@ -16,7 +16,7 @@ Introduction
|
||||
"
|
||||
# Natural Number Game
|
||||
|
||||
##### version 3.0.2
|
||||
##### version 4.0.1
|
||||
|
||||
*(note that this ported version of the NNG is still a bit rough around the edges
|
||||
and will experience some more love soon.)*
|
||||
|
||||
@@ -53,5 +53,8 @@ $ (a + b) + c = a + (b + c). $"
|
||||
rw [hc]
|
||||
rfl
|
||||
|
||||
-- Adding this instance to make `ac_rfl` work.
|
||||
instance : Lean.IsAssociative (α := ℕ) (·+·) := ⟨MyNat.add_assoc⟩
|
||||
|
||||
NewLemma MyNat.zero_add
|
||||
LemmaTab "Add"
|
||||
|
||||
@@ -39,6 +39,9 @@ $a + b = b + a$."
|
||||
rw [succ_add]
|
||||
rfl
|
||||
|
||||
-- Adding this instance to make `ac_rfl` work.
|
||||
instance : Lean.IsCommutative (α := ℕ) (·+·) := ⟨MyNat.add_comm⟩
|
||||
|
||||
LemmaTab "Add"
|
||||
|
||||
Conclusion
|
||||
|
||||
@@ -56,6 +56,8 @@ $a + b + c = a + c + b$."
|
||||
additions like this: `rw [add_comm a]` will swap around
|
||||
additions of the form `a + _`, and `rw [add_comm a b]` will only
|
||||
swap additions of the form `a + b`."
|
||||
Branch
|
||||
ac_rfl
|
||||
Branch
|
||||
rw [add_comm]
|
||||
Hint "`rw [add_comm]` just rewrites to first instance of `_ + _` it finds, which
|
||||
|
||||
@@ -10,6 +10,7 @@ import Mathlib.Tactic
|
||||
import Game.Tactic.Induction
|
||||
import Game.Tactic.Rfl
|
||||
import Game.Tactic.Rw
|
||||
import Game.Tactic.Apply
|
||||
-- import Std.Tactic.RCases
|
||||
-- import Game.Tactic.Have
|
||||
-- import Game.Tactic.LeftRight
|
||||
|
||||
@@ -12,7 +12,7 @@ instance instAdd : Add MyNat where
|
||||
add := MyNat.add
|
||||
|
||||
/--
|
||||
`add_zero a` is a proof of `a + 0 = a`.
|
||||
If `a` is a natural number, then `add_zero a` is the proof that `a + 0 = a`.
|
||||
|
||||
`add_zero` is a `simp` lemma, because if you see `a + 0`
|
||||
you usually want to simplify it to `a`.
|
||||
@@ -20,6 +20,7 @@ you usually want to simplify it to `a`.
|
||||
@[simp] theorem add_zero (a : MyNat) : a + 0 = a := by rfl
|
||||
|
||||
/--
|
||||
This theorem proves that (a + (d + 1)) = ((a + d) + 1) for a,d in MyNat.
|
||||
If `a` and `d` are natural numbers, then `add_succ a d` is the proof that
|
||||
`a + succ d = succ (a + d)`.
|
||||
-/
|
||||
theorem add_succ (a d : MyNat) : a + (succ d) = succ (a + d) := by rfl
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/-- Our copy of the natural numbers called `MyNat`. -/
|
||||
/-- Our copy of the natural numbers called `MyNat`, with notation `ℕ`. -/
|
||||
inductive MyNat where
|
||||
| zero : MyNat
|
||||
| succ : MyNat → MyNat
|
||||
|
||||
16
Game/Tactic/ACRfl.lean
Normal file
16
Game/Tactic/ACRfl.lean
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
import Lean
|
||||
|
||||
-- Note: to get `ac_rfl` working (which is in core), we just
|
||||
-- need the two instances below in the files where
|
||||
-- `add_assoc` and `add_comm` are proven.
|
||||
-- This file is only for demonstration purpose.
|
||||
|
||||
import Game.Levels.Addition.Level_2 -- defines `MyNat.add_assoc`
|
||||
import Game.Levels.Addition.Level_4 -- defines `MyNat.add_comm`
|
||||
|
||||
instance : Lean.IsAssociative (α := ℕ) (·+·) := ⟨MyNat.add_assoc⟩
|
||||
instance : Lean.IsCommutative (α := ℕ) (·+·) := ⟨MyNat.add_comm⟩
|
||||
|
||||
example (a b c : ℕ) : c + (b + a) = (a + b) + c := by
|
||||
ac_rfl
|
||||
21
Game/Tactic/Apply.lean
Normal file
21
Game/Tactic/Apply.lean
Normal file
@@ -0,0 +1,21 @@
|
||||
import Mathlib.Tactic.Replace
|
||||
|
||||
open Lean Elab Tactic
|
||||
|
||||
/--
|
||||
If `(h : A)` is a proof of `A` and `f : A → B` an implication then
|
||||
`apply f to h` turns `h` into a proof of `B`.
|
||||
|
||||
This is a game specific implementation. It is equivalent to the
|
||||
tactic `replace h := f h`.
|
||||
-/
|
||||
syntax (name := applyTo) "apply" ident " to " ident : tactic
|
||||
|
||||
elab_rules : tactic | `(tactic| apply $thm to $hyp) => do
|
||||
evalTactic (← `(tactic| replace $hyp := $thm $hyp))
|
||||
|
||||
-- Test
|
||||
example (A B C : Prop) (ha : A) (f : A → B) (g : B → C) : C := by
|
||||
apply g
|
||||
apply f to ha
|
||||
assumption
|
||||
@@ -16,7 +16,7 @@ open Lean Meta Elab Tactic
|
||||
|
||||
`rfl` closes goals of the form `A = A`.
|
||||
|
||||
Note that teh version for this game is somewhat weaker than the real one. -/
|
||||
Note that the version for this game is somewhat weaker than the real one. -/
|
||||
syntax (name := rfl) "rfl" : tactic
|
||||
|
||||
@[tactic MyNat.rfl] def evalRfl : Tactic := fun _ =>
|
||||
|
||||
@@ -18,8 +18,9 @@ In order to create a new game, click "use this template" above to create your o
|
||||
|
||||
### Installation
|
||||
|
||||
Note that the setup is currently still in development and will likely see changes
|
||||
and improvements in the next few months.
|
||||
The full instructions are at [Running games locally](https://github.com/leanprover-community/lean4game/blob/main/DOCUMENTATION.md#running-games-locally).
|
||||
In particular, the recommended setup is to have `docker` installed on your computer
|
||||
and then click on the pop-up "Reopen in Container" which is shown when
|
||||
opening this project in VSCode.
|
||||
|
||||
To run a local version of the game on your `localhost`, follow the
|
||||
instructions "[Running games locally](https://github.com/leanprover-community/lean4game/blob/main/DOCUMENTATION.md#running-games-locally)".
|
||||
The game is then accessible at [localhost:3000/#/g/local/game](http://localhost:3000/#/g/local/game).
|
||||
|
||||
Reference in New Issue
Block a user