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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
|
metavar ident , x ::=
{{ isa string }} {{ coq nat }} {{ hol string }} {{ ocaml string }} {{ lex [A-Z]+ }} {{ coq-equality }}
grammar
exp , e :: Exp_ ::=
| x :: :: ident
| () :: :: unit
| ( exp , exp' ) :: :: pair
| function x : type -> exp :: :: 'fun'
| exp exp' :: :: app
% | :: :: empty
type , t :: Typ_ ::=
| unit :: :: unit
| type * type' :: :: pair
| type -> type' :: :: 'fun'
E :: E_ ::= {{ isa (ident*type) list }} {{ coq list (ident*type) }} {{ hol (ident#type) list }}
| empty :: :: empty
{{ isa [] }}
{{ coq nil }}
{{ hol [] }}
| E , x : t :: :: ident
{{ isa (([[x]],[[t]])#[[E]]) }}
{{ coq (cons ([[x]],[[t]]) [[E]]) }}
{{ hol (([[x]],[[t]])::[[E]]) }}
| E , x : t , E' :: :: ident2
{{ isa ([[E']] @ ([[x]],[[t]])#[[E]]) }}
{{ coq (app [[E']] (cons ([[x]],[[t]]) [[E]])) }}
{{ hol ( [[E']] ++ ([[x]],[[t]])::[[E]] )}}
formula :: formula_ ::=
| judgement :: :: judgement
| not ( formula ) :: :: not
{{ isa ~( [[formula]] ) }}
{{ coq not([[formula]]) }}
{{ hol ~( [[formula]] ) }}
{{ ocaml not([[formula]]) }}
| x in dom ( E ) :: M :: indom
{{ isa list_ex ( \<lambda>(x',y'). [[x]]=x') [[E]] }}
{{ ocaml List.exists (fun (x',y') -> [[x]]=x') [[E]] }}
{{ coq (indom [[x]] [[E]]) }}
{{ hol (EXISTS ( \(x',y'). [[x]]=x') [[E]]) }} % TODO
terminals :: 'terminals_' ::=
| \ :: :: lambda {{ tex \lambda }}
| --> :: :: red {{ tex \longrightarrow }}
| -> :: :: arrow {{ tex \rightarrow }}
| |- :: :: turnstile {{ tex \vdash }}
| in :: :: in {{ tex \in }}
embed
{{ coq
Fixpoint indom (x:ident) (e:E) { struct e } : Prop :=
match e with
| nil => False
| cons (x',y') tl => if eq_ident x x' then True else indom x tl
end. }}
{{ isa
primrec
order :: "type => nat"
where
"order [[unit]] = 0"
| "order [[t*t']] = max (order [[t]]) (order [[t']])"
| "order [[t->t']] = max (1+order [[t]]) (order [[t']])"
}}
{{ tex
A test of some filtered embedded latex:
$Foo( [[ E,x:t |- ok ]] )$
}}
% defns
% Jin :: '' ::=
% defn
% x in dom ( E ) :: :: xinE :: xinE_ by
%
% -------------------- :: 1
% x in dom ( E )
%
% x in dom(E)
% -------------------- :: 2
% x in dom(E,x':t)
% this type system doesn't allow any shadowing
defns
Jtype :: '' ::=
defn
E |- ok :: :: Eok :: Eok_ by
----------- :: empty
empty |- ok
E |- ok
not (x in dom(E))
-------------- :: ident
E,x:t |- ok
defn
E |- e : t :: :: Eet :: Eet_ by
E,x:t,E' |- ok
--------------- :: ident
E,x:t,E' |- x:t
E |- ok
---------------- :: unit
E |- () : unit
E |- e1:t1
E |- e2:t2
------------------- :: pair
E |- (e1,e2):t1*t2
E,x:t1 |- e :t2
---------------------- :: 'fun'
E |- function x:t1 -> e : t1->t2
E |- e : t1->t2
E |- e': t1
------------------ :: app
E |- e e' : t2
>>
| let pat = exp in exp' :: :: let
pat , p :: Pat_ ::=
x :: :: ident
| _ :: :: wildcard
| () :: :: unit
| ( pat , pat' ) :: :: pair
<<
>>
|- p : t gives E'
E |- e : t
E,E' |- e' : t'
------------------------ :: let
E |- let p=e in e' : t'
defn
|- p : t gives E' :: :: Ept :: Ept_ by
----------------------- :: ident
|- x:t gives empty,x:t
----------------------- :: wildcard
|- _:t gives empty
------------------------ :: unit
|- () : unit gives empty
|- p1:t1 gives E1
|- p2:t2 gives E2
-------------------------- :: pair
|- (p1,p2):t1*t2 gives E1,E2
<<
|