gf-book web page index and toc

This commit is contained in:
aarne
2011-01-11 15:46:43 +00:00
parent fa54c29616
commit 9c3e74ee4a
110 changed files with 492 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
abstract Calculator = {
flags startcat = Exp ;
cat Exp ;
fun
EPlus, EMinus, ETimes, EDiv : Exp -> Exp -> Exp ;
EInt : Int -> Exp ;
}

View File

@@ -0,0 +1,10 @@
concrete CalculatorC of Calculator = open Formal, Prelude in {
lincat
Exp = TermPrec ;
lin
EPlus = infixl 0 "+" ;
EMinus = infixl 0 "-" ;
ETimes = infixl 1 "*" ;
EDiv = infixl 1 "/" ;
EInt i = constant i.s ;
}

View File

@@ -0,0 +1,13 @@
concrete CalculatorJ of Calculator = open Prelude in {
lincat
Exp = SS ;
lin
EPlus = postfix "iadd" ;
EMinus = postfix "isub" ;
ETimes = postfix "imul" ;
EDiv = postfix "idiv" ;
EInt i = ss ("ldc" ++ i.s) ;
oper
postfix : Str -> SS -> SS -> SS = \op,x,y ->
ss (x.s ++ ";" ++ y.s ++ ";" ++ op) ;
}

View File

@@ -0,0 +1,14 @@
concrete CalculatorP of Calculator = open Prelude in {
lincat
Exp = SS ;
lin
EPlus = infix "+" ;
EMinus = infix "-" ;
ETimes = infix "*" ;
EDiv = infix "/" ;
EInt i = i ;
oper
infix : Str -> SS -> SS -> SS = \f,x,y ->
ss ("(" ++ x.s ++ f ++ y.s ++ ")") ;
}

View File

@@ -0,0 +1,11 @@
concrete CalculatorS of Calculator = open Prelude in {
lin
EPlus = infix "plus" ;
EMinus = infix "minus" ;
ETimes = infix "times" ;
EDiv = infix ["divided by"] ;
EInt i = i ;
oper
infix : Str -> SS -> SS -> SS = \op,x,y ->
ss (x.s ++ op ++ y.s ++ "PAUSE") ;
}

View File

@@ -0,0 +1,7 @@
abstract Geometry = Logic ** {
fun
Line, Point, Circle : Dom ;
Intersect, Parallel : Ind -> Ind -> Atom ;
Vertical : Ind -> Atom ;
Centre : Ind -> Ind ;
}

View File

@@ -0,0 +1,13 @@
--# -path=.:present
concrete GeometryEng of Geometry = LogicEng **
open SyntaxEng, ParadigmsEng in {
lin
Line = mkCN (mkN "line") ;
Point = mkCN (mkN "point") ;
Circle = mkCN (mkN "circle") ;
Intersect = pred (mkV2 "intersect") ;
Parallel = pred (mkA2 (mkA "parallel") (mkPrep "to")) ;
Vertical = pred (mkA "vertical") ;
Centre = app (mkN2 (mkN "centre") (mkPrep "of")) ;
}

View File

@@ -0,0 +1,11 @@
concrete GeometryEng of Geometry = LogicEng **
open SyntaxEng, ParadigmsEng in {
lin
Line = mkN "line" ;
Point = mkN "point" ;
Circle = mkN "circle" ;
Intersect = pred (mkV2 "intersect") ;
Parallel = pred (mkA2 (mkA "parallel") (mkPrep "to")) ;
Vertical = pred (mkA "vertical") ;
Centre = app (mkN2 (mkN "centre") (mkPrep "of")) ;
}

View File

@@ -0,0 +1,7 @@
abstract Geometry = Logic ** {
fun
Line, Point, Circle : Dom ;
Intersect, Parallel : Ind -> Ind -> Prop ;
Vertical : Ind -> Prop ;
Centre : Ind -> Ind ;
}

View File

@@ -0,0 +1,7 @@
-- (c) Krasimir Angelov 2009
abstract Graftal = {
cat N; S;
fun z : N ;
s : N -> N ;
c : N -> S ;
}

View File

@@ -0,0 +1,21 @@
abstract Logic = {
flags startcat = Stm ;
cat
Stm ; -- top-level statement
Prop ; -- proposition
Atom ; -- atomic formula
Ind ; -- individual term
Dom ; -- domain expression
Var ; -- variable
[Prop] {2} ; -- list of propositions, 2 or more
[Var] {1} ; -- list of variables, 1 or more
fun
SProp : Prop -> Stm ;
And, Or : [Prop] -> Prop ;
If : Prop -> Prop -> Prop ;
Not : Prop -> Prop ;
PAtom : Atom -> Prop ;
All, Exist : [Var] -> Dom -> Prop -> Prop ;
IVar : Var -> Ind ;
VString : String -> Var ;
}

View File

@@ -0,0 +1,38 @@
concrete LogicEng of Logic = open
SyntaxEng, (P = ParadigmsEng), SymbolicEng, Prelude in {
lincat
Stm = Text ;
Prop = S ;
Atom = Cl ;
Ind = NP ;
Dom = CN ;
Var = NP ;
[Prop] = [S] ;
[Var] = NP ;
lin
SProp = mkText ;
And = mkS and_Conj ; -- A, B ... and C
Or = mkS or_Conj ; -- A, B ... or C
If A B = -- if A B
mkS (mkAdv if_Subj A) B ;
Not A = -- it is not the case that A
mkS negativePol (mkCl
(mkVP (mkNP the_Quant
(mkCN case_CN A)))) ;
All xs A B = -- for all A's xs, B
mkS (mkAdv for_Prep
(mkNP all_Predet (mkNP a_Quant
plNum (mkCN A xs)))) B ;
Exist xs A B = -- for some A's xs, B
mkS (mkAdv for_Prep
(mkNP somePl_Det (mkCN A xs))) B ;
PAtom = mkS ;
IVar x = x ;
VString s = symb s ;
BaseProp A B = mkListS A B ;
ConsProp A As = mkListS A As ;
BaseVar x = x ;
ConsVar x xs = mkNP and_Conj (mkListNP x xs) ;
oper
case_CN : CN = mkCN (P.mkN "case") ;
}

View File

@@ -0,0 +1,39 @@
concrete LogicEng of Logic = open
SyntaxEng, (P = ParadigmsEng), SymbolicEng, Prelude in {
lincat
Stm = Text ;
Prop = {pos,neg : S ; isAtom : Bool} ;
Atom = Cl ;
Ind = NP ;
Dom = CN ;
Var = NP ;
[Prop] = ListS ;
[Var] = NP ;
lin
SProp p = mkText p.pos ;
And ps = complexProp (mkS and_Conj ps) ;
Or ps = complexProp (mkS or_Conj ps) ;
If A B = complexProp (mkS if_then_Conj (mkListS A.pos B.pos)) ;
Not A = complexProp A.neg ;
All xs A B = complexProp (mkS (mkAdv for_Prep
(mkNP all_Predet (mkNP a_Quant plNum (mkCN A xs)))) B.pos) ;
Exist xs A B = complexProp (mkS (mkAdv for_Prep
(mkNP somePl_Det (mkCN A xs))) B.pos) ;
PAtom p =
{pos = mkS p ; neg = mkS negativePol p ; isAtom = True} ;
IVar x = x ;
VString s = symb s ;
BaseProp A B = mkListS A.pos B.pos ;
ConsProp A As = mkListS A.pos As ;
BaseVar x = x ;
ConsVar x xs = mkNP and_Conj (mkListNP x xs) ;
oper
complexProp : S -> {pos,neg : S ; isAtom : Bool} = \s -> {
pos = s ;
neg = negS s ;
isAtom = False
} ;
negS : S -> S = \s -> mkS negativePol (mkCl (mkNP it_Pron)
(mkNP the_Quant (mkCN (mkCN (P.mkN "case")) s))) ;
if_Then_Conj : Conj = P.mkConj "if" "then" ;
}

View File

@@ -0,0 +1,11 @@
abstract Logic = {
cat
Prop ; Ind ; Dom ; Var ; [Prop] {2} ; [Var] {1} ;
fun
And, Or : [Prop] -> Prop ;
If : Prop -> Prop -> Prop ;
Not : Prop -> Prop ;
All, Exist : [Var] -> Dom -> Prop -> Prop ;
IVar : Var -> Ind ;
VString : String -> Var ;
}

View File

@@ -0,0 +1,16 @@
concrete Sierpinski of Graftal = {
lincat N = {a : Str; b : Str} ;
lincat S = {s : Str} ;
lin z = {a = A; b = B} ;
lin s x = {
a = x.b ++ R ++ x.a ++ R ++ x.b ;
b = x.a ++ L ++ x.b ++ L ++ x.a
} ;
lin c x = {s = "newpath 300 550 moveto" ++ x.a ++ "stroke showpage"} ;
oper A : Str = "0 2 rlineto" ;
oper B : Str = "0 2 rlineto" ;
oper L : Str = "+60 rotate" ;
oper R : Str = "-60 rotate" ;
}