summaryrefslogtreecommitdiff
path: root/examples/math/MathAgd.gf
blob: 9b723c26e8d0a764d5c436445be10edb21a75265 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
--# -path=.:prelude

concrete MathAgd of Mathw = open Prelude in {

flags lexer = codelit ; unlexer = codelit ;

-- lincat Section ; Context ; Typ ; 
 lincat Obj, Prop = {s,name : Str} ;
-- Proof ; Var ;

lin
  SDefObj cont obj typ df = 
    ss (obj.name ++ "::" ++ cont.s ++ typ.s ++ 
        "=" ++ df.s ++ ";") ;  
  SDefProp cont prop df = 
    ss (prop.name ++ "::" ++ cont.s ++ "Prop" ++ 
        "=" ++ df.s ++ ";") ;  
  SAxiom cont prop = 
    ss ("ax" ++ "::" ++ cont.s ++ prop.s ++ ";") ;
  STheorem cont prop proof = 
    ss ("thm" ++ "::" ++ cont.s ++ prop.s ++ 
        "=" ++ proof.s ++ ";") ;  

  CEmpty = ss [] ;
  CObj vr typ co = ss ("(" ++ vr.s ++ "::" ++ typ.s ++ ")" ++ co.s) ;
  CProp prop co = ss ("(" ++ "_" ++ "::" ++ prop.s ++ ")" ++ co.s) ;

  OVar v = obj v.s [] ;

  V_x = ss "x" ;
  V_y = ss "y" ;
  V_z = ss "z" ;

oper
  obj : Str -> Str -> {s,name : Str} = \f,xs -> {
    s = f ++ xs ;
    name = f
  } ;

-- lexicon
lin
  Set  = ss "set" ;
  Nat  = ss ["Nat"] ;
  Zero = obj "Zero" [] ;
  Succ x = obj "Succ" x.s ;
  One  = obj "one" [] ;
  Two  = obj "two" [] ;
  Even x = obj "Even" x.s ;
  Odd x = obj "Odd" x.s ;
  Prime x = obj "Prime" x.s ;
  Divisible x y = obj "Div" (x.s ++ y.s) ;
  
}