GithubHelp home page GithubHelp logo

leanprover-community / lean4game Goto Github PK

View Code? Open in Web Editor NEW
160.0 9.0 26.0 32.7 MB

Server to host lean games.

Home Page: https://adam.math.hhu.de

License: GNU General Public License v3.0

HTML 0.30% JavaScript 3.96% CSS 5.82% Lean 38.35% TypeScript 51.24% Shell 0.34%
lean4 react

lean4game's Introduction

Lean 4 Game

This is the source code for a Lean game platform hosted at adam.math.hhu.de.

Creating a Game

Please follow the tutorial Creating a Game. In particular, the following steps might be of interest:

Documentation

The documentation is very much work in progress but the linked documentation here should be up-to-date:

Game creation API

Frontend API

Backend

not fully written yet.

  • Server: describes the server part (i.e. the content of server/ und relay/).

Contributing

Contributions to lean4game are always welcome!

Translation

The interface can be translated to various languages. For adding a translation, one needs to do the following:

  1. In client/src/config.json, add your new language. The "iso" key is the ISO language code, i.e. it should be accepted by "i18next" and "GNU gettext"; the "flag" key is once accepted by react-country-flag.
  2. Run npm run translate. This should create a new file client/public/locales/{language}/translation.json. (alternatively you can copy-paste client/public/locales/en/translation.json)
  3. Add all translations.
  4. Commit the changes you made to config.json together with the new translation.json.

For translating games, see Translating a game.

Security

Providing the use access to a Lean instance running on the server is a severe security risk. That is why we start the Lean server with bubblewrap.

Credits

The project has primarily been developed by Alexander Bentkamp and Jon Eugster.

It is based on ideas from the Lean Game Maker and the Natural Number Game (NNG) by Kevin Buzzard and Mohammad Pedramfar, and on Patrick Massot's prototype: NNG4.

lean4game's People

Contributors

abentkamp avatar alexjbest avatar geoc2022 avatar hydrogenbear avatar jadabouhawili avatar joneugster avatar kbuzzard avatar lnay avatar miguelmarco avatar noamraph avatar pitmonticone avatar rexwzh avatar semorrison avatar tentativeconvert avatar wzixiao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lean4game's Issues

Available/visible Tactics

  • Make it possible to block certain tactics in a level. E.g. see levels for suffices & have.
  • In the toolbox, display tactics that are not yet introduced as locked entries.

`NewLemma` does not work properly with namespaces

See level "Endliche Summe, 2". rw [Finset.sum_add_distrib] raises

You have not unlocked the lemma/definition 'Finset.sum_add_distrib' yet!

albeit having NewLemmas Finset.sum_add_distrib defined.

Server panic in MyServer_FileWorker_compileProof

[server] Lean Server Server: PANIC at Option.get! Init.Data.Option.BasicAux:16:14: value is none
[server] Lean Server Server: 
[server] backtrace:
[server] Lean Server Server: ./gameserver(lean_panic_fn+0x9e)[0x557037a5d00e]
[server] 
[server] Lean Server Server: ./gameserver(l_MyServer_FileWorker_compileProof+0x8ef)[0x5570350a08af]
[server] 
[server] Lean Server Server: ./gameserver(l___private_GameServer_FileWorker_0__MyServer_FileWorker_nextSnap___lambda__1+0x21a)[0x5570350a454a]
[server] 
[server] Lean Server Server: ./gameserver(l___private_GameServer_FileWorker_0__MyServer_FileWorker_nextSnap+0x6bc)[0x5570350a57ec]
[server] 
[server] Lean Server Server: ./gameserver(lean_apply_2+0x5f0)[0x557037a68190]
[server] 
[server] Lean Server Server: ./gameserver(l_IO_AsyncList_unfoldAsync_step___rarg+0x3b)[0x55703569f4bb]
[server] 
[server] Lean Server Server: ./gameserver(lean_apply_1+0x455)[0x557037a673c5]
[server] 
[server] Lean Server Server: ./gameserver(l_EIO_toBaseIO___rarg+0x10)[0x5570379de890]
[server] 
[server] Lean Server Server: ./gameserver(lean_apply_1+0x420)[0x557037a67390]
[server] 
[server] Lean Server Server: ./gameserver(+0x34734ae)[0x557037a7a4ae]
[server] 
[server] Lean Server Server: ./gameserver(lean_apply_1+0x420)[0x557037a67390]
[server] 
[server] Lean Server Server: ./gameserver(+0x345eb7b)[0x557037a65b7b]
[server] 
[server] Lean Server Server: ./gameserver(+0x345fc21)[0x557037a66c21]
[server] 
[server] Lean Server Server: ./gameserver(+0x341a605)[0x557037a21605]
[server] 
[server] Lean Server Server: /lib/x86_64-linux-gnu/libc.so.6(+0x94b43)[0x7f92d5294b43]
[server] 
[server] Lean Server Server: /lib/x86_64-linux-gnu/libc.so.6(+0x126a00)[0x7f92d5326a00]

Server crashes on nontrivial `rw`

Our custom Lean server crashes when running rw on nontrivial goals, with the error

cannot evaluate [init] declaration X in the same module

This error message is triggered because the server cannot find the compiled executable code of the tactics defined in Mathlib. The text of the error message is misleading. For some reason I don't understand, adding Mathlib as a dependency to the Lean Server project helped, but this issue needs to be investigated further.

Lemma Library

We would need to sections of the Lemma library:

  1. Selected lemmas relevant for this level.
  2. Overview of all lemmas ever learned.

feat: DefEq in `Hint`

The current Hint matches expressions exactly, which allows for detailed instructions about unfold or change.
However, it would be handy to have an option Hint (defeq := true) "some text" to relax this, so that a hint is shown even if the goal is only defEq to the Hint's goal.

Also think about defeq in the assumptions. Currently hints might not be shown if the user unfolds a definition more/less than the sample solution did, for example in the level about Function.Bijective.

Investigate lazy loading of JavaScript

Currently, npm run build shows a warning that assets are too large:

WARNING in asset size limit: The following asset(s) exceed the recommended size limit 

Should we lazy-load some of the JavaScript?

`DisabledTactic` disables beyond level.

DisabledTactic [tactic] causes the tactic to be disabled in all subsequent levels as well. See for example tactic revert in "Aussagelogik 2, level 4".

Expected behaviour: DisabledTactic should only count for the level it is defined for.

Autogenerate LemmaDoc

Add an Option to LemmaDoc (and DefinitionDoc) to automatically generate Information about a lemma that is in Mathlib. The automatically generated information could comprise:

  • The lemma statement
  • mathlib docs link.
  • Full namespace
  • Is it a simp-lemma

Information that needs to be added manually:

  • The name the lemma appears under in the game.
  • A supplementary short description (to explain the usage inside the game)

Lemmas that are not from Mathlib should also be marked as such somehow.

Lemmas kopierbar

Lemmas (und Taktiken?) in der Leiste links sollten kopierbar sein.

cursor focus

When loading a new level, the cursor should directly go to the input field.

Currently you have to select the input field with two Tab.
Enter causes to load the next level and Backslash goes to the previous level. I find that counterintuitive, and would expect that I could directly start typing a tactic and enter calls Execute

Additionally, when level completed, the focus should be on the Next button below, so that Enter loads the next level.

Unsolved Goals Message

In cda4e5b, I hide the "unsolved goals" message on the client side. But the red underline in the editor remains. Is this good or not?

Worlds names

Worlds sollten Namen bekommen, die man im TestGame.lean definieren kann.

Inaccessible variables

Implement a feature that gives a message on tactics that induce implicit variables. i.e. intro should have a message (blue/info) saying "consider naming your variables using intro x."

or rcases h could display "consider using rcases h with ⟨x, hx⟩" but that might be trickier providing the correct syntax.

Make local commands in the game source file apply to the game

Currently, any local commands in the source file of a game do not have an effect in the game because technically the game file is only imported by the server. It would be much more intuitive for authors if the server would literally take the source file and replace the proof.

This refactoring is not super-urgent. For now we can probably live with a custom command that allows us to open namespaces.

Technical implementation: We probably cannot use the olean files for this. We'll have to read in the original .lean source file and parse the contained commands. We search for the "Statement" command and substitute the player's proof.

`let` in Objekte

let n := 3 wird bei den Objekten einfach als n : ℕ angezeigt, sollte irgendwie n : ℕ := 3 sein.

Names

Are there better words than game, world, level?

Übersichtstabelle

Wir brauchen eine automatisch erstellte Übersichtstabelle pro World:

Aussagenlogik Level Name Notation neue Taktiken alte Taktiken neue Lemmas alte Lemmas Beschreibung
1 Rfl ∧, ∨ rfl not_not Ein beispiellevel
2 Rw rw rfl not_not nichts gelernt.
3 ... ... ... ... ... ... ...

"neue Taktiken", "neue Lemmas" und "Beschreibung" sollten Felder wie "Tactics" im Level-File werden.

links in Hints and Introduction/Conclusion

It would be useful to be able to have linking options in all the text:

  1. Linking to a tactics/lemma/definition documentation. Should open the correct one on the right.
  2. (maybe?) Link to other levels within the game

Not sure (2.) is useful and certainly very low priority.

Autoergänzung

Autoergänzung zeigt jede Menge schwachsinn an. Entweder reduzieren oder entfernen.

loading symbol when reaching unexpected end of input.

Reconstruction: Go to level "Teilbarkeit nr. 1" and enter rcases h with.

There is an error message unexpected end of input but the remaining behaviour is a bit unpredictable:

  • sometimes it shows "Loading goal..." and just keeps shoing the loading icon
  • sometimes it shows nothing
  • sometimes it shows the hint from before or after.

Hints

Where should the hints be displayed?

feat: strict hint

Add a new variant of Hint (e.g. StrictHint, StrictHiddenHint) that only applies if all assumptions are mentioned in the Hint statement.

(dumb) example:

example : True := by
  -- Point 1
  have h : True
  trivial
  -- Point 2
  assumption

There should be an option to have two hints

Hint : True =>  -- StrictHint
"Create an assumption `have h : True`"

Hint (h : True) : True =>
"Now use {h} in `exact {h}`." 

Currently both Hints are displayed at Point 2 instead of only the second.

Error Message of `NewTactics`

NewTactics (and relatives) does not anymore give an error if the correponding TacticDoc does not exist. The old Tactics used to do that.

Construct instances

One way to construct algebraic structures (in Tactic-mode) could be the following:

Statement
"Zeige, dass $\\mathbb{R}$ ein $\\mathbb{Q}$-Modul ist."
    : Module ℚ ℝ := by
  refine {
    smul := fun a r => ↑a * r
    smul_zero := ?smul_zero
    zero_smul := ?zero_smul
    one_smul := ?one_smul
    smul_add := ?smul_add
    add_smul := ?add_smul
    mul_smul := ?mul_smul }
  
  -- Now there are 6 goals which can be proved
  sorry

We should figure way/notation to make that first step easier.

rcases tooltip does not show

Reconstruct: open level "Teilbarkeit, level 1", go to editor mode and type rcases h. Hover over rcases. It does not show a tooltip or only h : m ∣ n. Entering rcases h with ⟨x, hx⟩ causes the tooltip to show correctly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.