mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
math wiki example
This commit is contained in:
39
examples/math/Math.gf
Normal file
39
examples/math/Math.gf
Normal file
@@ -0,0 +1,39 @@
|
||||
abstract Math = {
|
||||
|
||||
flags startcat = Section ;
|
||||
|
||||
cat
|
||||
Section ; Label ; Context ; Typ ; Obj ; Prop ; Proof ; Var ;
|
||||
|
||||
fun
|
||||
SDefObj : Label -> Context -> Obj -> Typ -> Obj -> Section ;
|
||||
SDefProp : Label -> Context -> Prop -> Prop -> Section ;
|
||||
SAxiom : Label -> Context -> Prop -> Section ;
|
||||
STheorem : Label -> Context -> Prop -> Proof -> Section ;
|
||||
|
||||
CEmpty : Context ;
|
||||
CObj : Var -> Typ -> Context -> Context ;
|
||||
CProp : Prop -> Context -> Context ;
|
||||
|
||||
OVar : Var -> Obj ;
|
||||
|
||||
LNone : Label ;
|
||||
LString : String -> Label ;
|
||||
VString : String -> Var ;
|
||||
|
||||
PLink : Proof ;
|
||||
|
||||
-- lexicon
|
||||
|
||||
Set : Typ ;
|
||||
Nat : Typ ;
|
||||
Zero : Obj ;
|
||||
Succ : Obj -> Obj ;
|
||||
One : Obj ;
|
||||
Two : Obj ;
|
||||
Even : Obj -> Prop ;
|
||||
Odd : Obj -> Prop ;
|
||||
Prime : Obj -> Prop ;
|
||||
Divisible : Obj -> Obj -> Prop ;
|
||||
|
||||
}
|
||||
43
examples/math/MathEnz.gf
Normal file
43
examples/math/MathEnz.gf
Normal file
@@ -0,0 +1,43 @@
|
||||
--# -path=.:prelude
|
||||
|
||||
concrete MathEnz of Math = open Prelude in {
|
||||
|
||||
flags lexer = textlit ; unlexer = textlit ;
|
||||
|
||||
-- lincat Section ; Label ; Context ; Typ ; Obj ; Prop ; Proof ; Var ;
|
||||
|
||||
lin
|
||||
SDefObj lab cont obj typ df =
|
||||
ss ("Definition" ++ lab.s ++ "." ++ cont.s ++
|
||||
obj.s ++ "is" ++ "a" ++ typ.s ++ "," ++ "defined" ++ "as" ++ df.s ++ ".") ;
|
||||
SDefProp lab cont prop df =
|
||||
ss ("Definition" ++ lab.s ++ "." ++ cont.s ++ "we" ++ "say" ++
|
||||
"that" ++ prop.s ++ "to" ++ "mean" ++ "that" ++ df.s ++ ".") ;
|
||||
SAxiom lab cont prop =
|
||||
ss ("Axiom" ++ lab.s ++ "." ++ cont.s ++ prop.s ++ ".") ;
|
||||
STheorem lab cont prop proof =
|
||||
ss ("Theorem" ++ lab.s ++ "." ++ cont.s ++ prop.s ++ "." ++ proof.s ++ ".") ;
|
||||
|
||||
CEmpty = ss [] ;
|
||||
CObj vr typ co = ss ("let" ++ vr.s ++ "be" ++ "a" ++ typ.s ++ "." ++ co.s) ;
|
||||
CProp prop co = ss ("assume" ++ prop.s ++ "." ++ co.s) ;
|
||||
|
||||
OVar v = v ;
|
||||
LNone = ss [] ;
|
||||
LString s = s ;
|
||||
VString s = s ;
|
||||
|
||||
-- lexicon
|
||||
|
||||
Set = ss "set" ;
|
||||
Nat = ss ["natural number"] ;
|
||||
Zero = ss "zero" ;
|
||||
Succ = prefixSS ["the successor of"] ;
|
||||
One = ss "one" ;
|
||||
Two = ss "two" ;
|
||||
Even = postfixSS ["is even"] ;
|
||||
Odd = postfixSS ["is odd"] ;
|
||||
Prime = postfixSS ["is prime"] ;
|
||||
Divisible = infixSS ["is divisible by"] ;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user