add definitions

pull/43/head
Alexander Bentkamp 2 years ago
parent 2be1a348ee
commit a44efef7de

@ -6,9 +6,10 @@ import { faLock, faLockOpen, faBook, faHammer, faBan } from '@fortawesome/free-s
import Markdown from './Markdown'; import Markdown from './Markdown';
import { useLoadDocQuery } from '../state/api'; import { useLoadDocQuery } from '../state/api';
function Inventory({ tactics, lemmas } : function Inventory({ tactics, lemmas, definitions } :
{lemmas: {name: string, locked: boolean, disabled: boolean}[], {lemmas: {name: string, locked: boolean, disabled: boolean}[],
tactics: {name: string, locked: boolean, disabled: boolean}[]}) { tactics: {name: string, locked: boolean, disabled: boolean}[],
definitions: {name: string, locked: boolean, disabled: boolean}[]}) {
const [docName, setDocName] = useState(null) const [docName, setDocName] = useState(null)
const [docType, setDocType] = useState(null) const [docType, setDocType] = useState(null)
@ -25,6 +26,13 @@ function Inventory({ tactics, lemmas } :
TODO: click on paste icon -> paste into command line */} TODO: click on paste icon -> paste into command line */}
</div> </div>
<h2>Definitions</h2>
<div className="inventory-list">
{ definitions.map(def =>
<InventoryItem key={def.name} showDoc={() => {setDocName(def.name); setDocType("Definition")}}
name={def.name} locked={def.locked} disabled={def.disabled} />) }
</div>
<h2>Lemmas</h2> <h2>Lemmas</h2>
<div className="inventory-list"> <div className="inventory-list">
{ lemmas.map(lem => { lemmas.map(lem =>

@ -181,7 +181,7 @@ function Level() {
</EditorContext.Provider> </EditorContext.Provider>
</div> </div>
<div className="doc-panel"> <div className="doc-panel">
{!level.isLoading && <Inventory tactics={level?.data?.tactics} lemmas={level?.data?.lemmas} />} {!level.isLoading && <Inventory tactics={level?.data?.tactics} lemmas={level?.data?.lemmas} definitions={level?.data?.definitions} />}
</div> </div>
</Split> </Split>
</> </>

@ -16,6 +16,7 @@ interface LevelInfo {
index: number, index: number,
tactics: {name: string, disabled: boolean, locked: boolean}[], tactics: {name: string, disabled: boolean, locked: boolean}[],
lemmas: {name: string, disabled: boolean, locked: boolean}[], lemmas: {name: string, disabled: boolean, locked: boolean}[],
definitions: {name: string, disabled: boolean, locked: boolean}[],
descrText: null|string, descrText: null|string,
descrFormat: null|string, descrFormat: null|string,
} }

@ -91,13 +91,14 @@ partial def findForbiddenTactics (inputCtx : Parser.InputContext) (levelParams :
for n in ns do for n in ns do
let some (.thmInfo ..) := (← getEnv).find? n let some (.thmInfo ..) := (← getEnv).find? n
| return () -- not a theroem -> ignore | return () -- not a theroem -> ignore
match levelParams.lemmas.find? (fun l => l.name.toString == n) with let lemmasAndDefs := levelParams.lemmas ++ levelParams.definitions
| none => addErrorMessage info s!"You have not unlocked the lemma '{n}' yet!" match lemmasAndDefs.find? (fun l => l.name.toString == n) with
| none => addErrorMessage info s!"You have not unlocked the lemma/definition '{n}' yet!"
| some lem => | some lem =>
if lem.locked then if lem.locked then
addErrorMessage info s!"You have not unlocked the lemma '{n}' yet!" addErrorMessage info s!"You have not unlocked the lemma/definition '{n}' yet!"
else if lem.disabled then else if lem.disabled then
addErrorMessage info s!"The lemma '{n}' is disabled in this level!" addErrorMessage info s!"The lemma/definition '{n}' is disabled in this level!"
where addErrorMessage (info : SourceInfo) (s : MessageData) := where addErrorMessage (info : SourceInfo) (s : MessageData) :=
modify fun st => { st with modify fun st => { st with
messages := st.messages.add { messages := st.messages.add {

@ -42,8 +42,9 @@ Fields:
structure LevelInfo where structure LevelInfo where
index : Nat index : Nat
title : String title : String
tactics: Array Availability tactics : Array Availability
lemmas: Array Availability lemmas : Array Availability
definitions : Array Availability
introduction : String introduction : String
descrText : String := "" descrText : String := ""
descrFormat : String := "" descrFormat : String := ""
@ -57,8 +58,9 @@ structure LoadLevelParams where
structure DidOpenLevelParams where structure DidOpenLevelParams where
uri : String uri : String
levelModule : Name levelModule : Name
tactics: Array Availability tactics : Array Availability
lemmas: Array Availability lemmas : Array Availability
definitions : Array Availability
deriving ToJson, FromJson deriving ToJson, FromJson
structure Doc where structure Doc where
@ -91,6 +93,7 @@ def handleDidOpenLevel (params : Json) : GameServerM Unit := do
levelModule := lvl.module levelModule := lvl.module
tactics := lvl.tactics.computed tactics := lvl.tactics.computed
lemmas := lvl.lemmas.computed lemmas := lvl.lemmas.computed
definitions := lvl.definitions.computed
: DidOpenLevelParams : DidOpenLevelParams
} }
} }
@ -119,6 +122,7 @@ partial def handleServerEvent (ev : ServerEvent) : GameServerM Bool := do
title := lvl.title, title := lvl.title,
tactics := lvl.tactics.computed, tactics := lvl.tactics.computed,
lemmas := lvl.lemmas.computed, lemmas := lvl.lemmas.computed,
definitions := lvl.definitions.computed,
descrText := lvl.descrText, descrText := lvl.descrText,
descrFormat := lvl.descrFormat --toExpr <| format (lvl.goal.raw) --toString <| Syntax.formatStx (lvl.goal.raw) --Syntax.formatStx (lvl.goal.raw) , -- TODO descrFormat := lvl.descrFormat --toExpr <| format (lvl.goal.raw) --toString <| Syntax.formatStx (lvl.goal.raw) --Syntax.formatStx (lvl.goal.raw) , -- TODO
introduction := lvl.introduction } introduction := lvl.introduction }

@ -61,13 +61,13 @@ LemmaDoc not_forall as not_forall in "Logic"
LemmaDoc not_exists as not_exists in "Logic" LemmaDoc not_exists as not_exists in "Logic"
"`∀ (A : Prop), ¬(∃ x, A) ↔ ∀x, (¬A)`." "`∀ (A : Prop), ¬(∃ x, A) ↔ ∀x, (¬A)`."
LemmaDoc Even as Even in "Nat" DefinitionDoc Even
" "
`even n` ist definiert als `∃ r, a = 2 * r`. `even n` ist definiert als `∃ r, a = 2 * r`.
Die Definition kann man mit `unfold even at *` einsetzen. Die Definition kann man mit `unfold even at *` einsetzen.
" "
LemmaDoc Odd as Odd in "Nat" DefinitionDoc Odd
" "
`odd n` ist definiert als `∃ r, a = 2 * r + 1`. `odd n` ist definiert als `∃ r, a = 2 * r + 1`.
Die Definition kann man mit `unfold odd at *` einsetzen. Die Definition kann man mit `unfold odd at *` einsetzen.

@ -66,4 +66,5 @@ Conclusion ""
NewTactics «have» NewTactics «have»
DisabledTactics «suffices» DisabledTactics «suffices»
NewLemmas Even Odd not_even not_odd NewDefinitions Even Odd
NewLemmas not_even not_odd

@ -62,5 +62,5 @@ Conclusion ""
NewTactics «suffices» NewTactics «suffices»
DisabledTactics «have» DisabledTactics «have»
NewDefinitions Even Odd
NewLemmas Even Odd not_even not_odd NewLemmas not_even not_odd

@ -62,4 +62,5 @@ Hint (n : ) : Even n → Even (n ^ 2) =>
"Diese Aussage hast du bereits als Lemma bewiesen, schau mal in der Bibliothek." "Diese Aussage hast du bereits als Lemma bewiesen, schau mal in der Bibliothek."
NewTactics contrapose rw apply NewTactics contrapose rw apply
NewLemmas Even Odd not_even not_odd even_square NewDefinitions Even Odd
NewLemmas not_even not_odd even_square

@ -72,5 +72,5 @@ HiddenHint (n: ) (h : Odd (n ^ 2)) (g : Even n) : Even (n ^ 2) =>
NewTactics contradiction by_contra rw apply assumption -- TODO: suffices, have NewTactics contradiction by_contra rw apply assumption -- TODO: suffices, have
NewDefinitions Even Odd
NewLemmas Odd Even not_odd not_even even_square NewLemmas not_odd not_even even_square

@ -68,4 +68,4 @@ Hint (n : ) (x : ) (hx : n = x + x) : (x + x) ^ 2 = 2 * x ^ 2 + 2 * x ^ 2
"Die Taktik `ring` löst solche Gleichungen." "Die Taktik `ring` löst solche Gleichungen."
NewTactics unfold rcases use rw ring NewTactics unfold rcases use rw ring
NewLemmas Even Odd NewDefinitions Even Odd

@ -63,5 +63,5 @@ Hint (n : ) : n + n = 2 * n => "Recap: `ring` löst Gleichungen in ``."
Conclusion "" Conclusion ""
NewTactics push_neg intro use rw unfold ring NewTactics push_neg intro use rw unfold ring
NewDefinitions Even Odd
NewLemmas Even Odd not_even not_odd not_exists not_forall NewLemmas not_even not_odd not_exists not_forall

@ -51,5 +51,5 @@ Statement
Conclusion "" Conclusion ""
NewTactics push_neg intro use rw unfold ring NewTactics push_neg intro use rw unfold ring
NewDefinitions Even Odd
NewLemmas Even Odd not_even not_odd not_exists not_forall NewLemmas not_even not_odd not_exists not_forall

Loading…
Cancel
Save