Skip to content
Snippets Groups Projects
Commit e464484e authored by Richard Eisenberg's avatar Richard Eisenberg
Browse files

Change polytypes from sg to s

parent f71a732a
No related branches found
No related tags found
No related merge requests found
...@@ -22,7 +22,7 @@ grammar ...@@ -22,7 +22,7 @@ grammar
prog :: 'Prog_' ::= {{ com Programs }} prog :: 'Prog_' ::= {{ com Programs }}
| empty :: :: Empty {{ com Empty }} | empty :: :: Empty {{ com Empty }}
| f = e , prog :: :: Bind {{ com Inferred binding }} | f = e , prog :: :: Bind {{ com Inferred binding }}
| f '::' sg '=' e , prog :: :: TypedBind {{ com Ascribed binding }} | f '::' s '=' e , prog :: :: TypedBind {{ com Ascribed binding }}
CL :: 'ConLike_' ::= {{ com ConLikes }} CL :: 'ConLike_' ::= {{ com ConLikes }}
| K :: :: RealDataCon {{ com Data constructor }} | K :: :: RealDataCon {{ com Data constructor }}
...@@ -40,8 +40,8 @@ e :: 'Expr_' ::= {{ com Expressions }} ...@@ -40,8 +40,8 @@ e :: 'Expr_' ::= {{ com Expressions }}
| e1 e2 :: :: App {{ com Application }} | e1 e2 :: :: App {{ com Application }}
| case e of { alts } :: :: Case {{ com Pattern-match }} | case e of { alts } :: :: Case {{ com Pattern-match }}
| ( e ) :: :: Parens {{ com Grouping }} | ( e ) :: :: Parens {{ com Grouping }}
| let x '::' sg = e1 in e2 :: :: Let {{ com Ascribed let }} | let x '::' s = e1 in e2 :: :: Let {{ com Ascribed let }}
{{ tex \keyword{let}\ [[x]] [[::]] [[sg]] = [[e1]]\ \keyword{in}\ [[e2]] }} {{ tex \keyword{let}\ [[x]] [[::]] [[s]] = [[e1]]\ \keyword{in}\ [[e2]] }}
alts {{ tex \overline{\ottnt{p} \to \ottnt{e} } }} :: 'Alts_' ::= {{ com Case alternatives }} alts {{ tex \overline{\ottnt{p} \to \ottnt{e} } }} :: 'Alts_' ::= {{ com Case alternatives }}
| </ pi -> ei // i /> :: :: Patterns | </ pi -> ei // i /> :: :: Patterns
...@@ -49,7 +49,7 @@ alts {{ tex \overline{\ottnt{p} \to \ottnt{e} } }} :: 'Alts_' ::= {{ com Case al ...@@ -49,7 +49,7 @@ alts {{ tex \overline{\ottnt{p} \to \ottnt{e} } }} :: 'Alts_' ::= {{ com Case al
p :: 'Pat_' ::= {{ com Patterns }} p :: 'Pat_' ::= {{ com Patterns }}
| _ :: :: Underscore {{ com Wildcard }} | _ :: :: Underscore {{ com Wildcard }}
| x :: :: Var {{ com Variable }} | x :: :: Var {{ com Variable }}
| p '::' sg :: :: Sig {{ com Pattern signature }} | p '::' s :: :: Sig {{ com Pattern signature }}
| CL ps :: :: Con {{ com Constructor }} | CL ps :: :: Con {{ com Constructor }}
| CL atts ps :: :: ConTys {{ com Constructor with type arguments }} | CL atts ps :: :: ConTys {{ com Constructor with type arguments }}
| ( p ) :: :: Parens {{ com Grouping }} | ( p ) :: :: Parens {{ com Grouping }}
...@@ -60,14 +60,14 @@ ps {{ tex \overline{\ottnt{p} } }} :: 'Pats_' ::= {{ com Lists of patterns }} ...@@ -60,14 +60,14 @@ ps {{ tex \overline{\ottnt{p} } }} :: 'Pats_' ::= {{ com Lists of patterns }}
atts {{ tex \overline{\at \tau} }} :: 'AtTypes_' ::= {{ com Lists of visible type patterns }} atts {{ tex \overline{\at \tau} }} :: 'AtTypes_' ::= {{ com Lists of visible type patterns }}
| @ t1 ... @ ti :: :: List | @ t1 ... @ ti :: :: List
sg {{ tex \sigma }} :: 'SigTy_' ::= {{ com Type schemes }} s {{ tex \sigma }} :: 'SigTy_' ::= {{ com Type schemes }}
| Q => sg :: :: ForallQTy {{ com Qualified type }} | Q => s :: :: ForallQTy {{ com Qualified type }}
{{ tex [[Q]] [[=>]] [[sg]] }} {{ tex [[Q]] [[=>]] [[s]] }}
| forall as . sg :: :: ForallTy {{ com Quantified type }} | forall as . s :: :: ForallTy {{ com Quantified type }}
{{ tex [[forall]] [[as]].\,[[sg]] }} {{ tex [[forall]] [[as]].\,[[s]] }}
| t :: :: MonoTy {{ com Monotype }} | t :: :: MonoTy {{ com Monotype }}
| [ </ ai |-> ti // i /> ] sg :: M :: Subst | [ </ ai |-> ti // i /> ] s :: M :: Subst
| theta ( sg ) :: M :: SubstVar | theta ( s ) :: M :: SubstVar
tvs {{ tex \overline{\ottnt{tv} } }}, as {{ tex \overline{\ottmv{a} } }}, bs {{ tex \overline{\ottmv{b} } }}, cs {{ tex \overline{\ottmv{c} } }} :: 'Vars_' ::= {{ com Lists of variables }} tvs {{ tex \overline{\ottnt{tv} } }}, as {{ tex \overline{\ottmv{a} } }}, bs {{ tex \overline{\ottmv{b} } }}, cs {{ tex \overline{\ottmv{c} } }} :: 'Vars_' ::= {{ com Lists of variables }}
| </ ai // i /> :: :: List | </ ai // i /> :: :: List
...@@ -98,8 +98,8 @@ theta {{ tex \theta }} :: 'Subst_' ::= {{ com Type substitutions }} ...@@ -98,8 +98,8 @@ theta {{ tex \theta }} :: 'Subst_' ::= {{ com Type substitutions }}
t {{ tex \tau }}, u {{ tex \upsilon }} :: 'Ty_' ::= {{ com Monotypes }} t {{ tex \tau }}, u {{ tex \upsilon }} :: 'Ty_' ::= {{ com Monotypes }}
| a :: :: IVar {{ com Internal variable }} | a :: :: IVar {{ com Internal variable }}
| c :: :: UVar {{ com External variable }} | c :: :: UVar {{ com External variable }}
| sg -> t :: :: Fun {{ com Function }} | s -> t :: :: Fun {{ com Function }}
| sgs -> t :: M :: Funs | ss -> t :: M :: Funs
| T ts :: :: ConApp {{ com Constructor application }} | T ts :: :: ConApp {{ com Constructor application }}
| theta t :: M :: Subst | theta t :: M :: Subst
{{ tex [[theta]] [[t]] }} {{ tex [[theta]] [[t]] }}
...@@ -111,14 +111,14 @@ ts {{ tex \overline{\tau} }} :: 'Tys_' ::= {{ com Lists of monotypes }} ...@@ -111,14 +111,14 @@ ts {{ tex \overline{\tau} }} :: 'Tys_' ::= {{ com Lists of monotypes }}
| </ ti // i /> :: :: List | </ ti // i /> :: :: List
| as :: :: Vars | as :: :: Vars
sgs {{ tex \overline{\sigma} }} :: 'Sigmas_' ::= {{ com Lists of polytypes }} ss {{ tex \overline{\sigma} }} :: 'Sigmas_' ::= {{ com Lists of polytypes }}
| </ sgi // , // i /> :: :: List | </ si // , // i /> :: :: List
G {{ tex \Gamma }}, Gt {{ tex \Gamma_t }} :: 'TyEnv_' ::= {{ com Type environments }} G {{ tex \Gamma }}, Gt {{ tex \Gamma_t }} :: 'TyEnv_' ::= {{ com Type environments }}
| empty :: :: Empty {{ com Empty }} | empty :: :: Empty {{ com Empty }}
| G1 , ... , Gn :: :: List {{ com Concatentation }} | G1 , ... , Gn :: :: List {{ com Concatentation }}
| v : sg :: :: Var {{ com Variable binding }} | v : s :: :: Var {{ com Variable binding }}
| CL : sg :: :: PatSyn {{ com ConLike binding }} | CL : s :: :: PatSyn {{ com ConLike binding }}
| Q :: :: Constraint {{ com Given constraint }} | Q :: :: Constraint {{ com Given constraint }}
| tv : type :: :: TyVar {{ com Type variable binding }} | tv : type :: :: TyVar {{ com Type variable binding }}
| < tv : type > :: M :: TyVars | < tv : type > :: M :: TyVars
...@@ -128,7 +128,7 @@ G {{ tex \Gamma }}, Gt {{ tex \Gamma_t }} :: 'TyEnv_' ::= {{ com Type environmen ...@@ -128,7 +128,7 @@ G {{ tex \Gamma }}, Gt {{ tex \Gamma_t }} :: 'TyEnv_' ::= {{ com Type environmen
| Giminus_one :: M :: GIHack | Giminus_one :: M :: GIHack
obj :: 'SynObj' ::= {{ com Syntactic object }} obj :: 'SynObj' ::= {{ com Syntactic object }}
| sgs :: :: TypeScheme | ss :: :: TypeScheme
| Q :: :: Constraint | Q :: :: Constraint
| G :: :: Context | G :: :: Context
...@@ -186,8 +186,8 @@ terminals :: 'terminals_' ::= ...@@ -186,8 +186,8 @@ terminals :: 'terminals_' ::=
formula :: formula_ ::= formula :: formula_ ::=
| judgement :: :: judgement | judgement :: :: judgement
| formula1 '//' .. '//' formulan :: :: dots | formula1 '//' .. '//' formulan :: :: dots
| ( v : sg ) in G :: :: ctxtlookup | ( v : s ) in G :: :: ctxtlookup
| ( P : sg ) in G :: :: patsynlookup | ( P : s ) in G :: :: patsynlookup
| theta1 = theta2 :: :: substdef | theta1 = theta2 :: :: substdef
| G = G' :: :: ctxtdef | G = G' :: :: ctxtdef
| tvrel :: :: tvrel | tvrel :: :: tvrel
......
...@@ -30,16 +30,16 @@ ...@@ -30,16 +30,16 @@
\section{Grammar} \section{Grammar}
\nonterms{prog,CL,v,e,p,sg,Q,tv,theta,t,G} \nonterms{prog,CL,v,e,p,s,Q,tv,theta,t,G}
\section{Typing rules} \section{Typing rules}
\drules[E]{$[[G |- e : t]]$}{Expressions}{VarCon,Eq,App,Abs,Case,Let} \drules[E]{$[[G |- e : t]]$}{Expressions}{VarCon,Eq,App,Abs,Case,Let}
Abstract judgments $[[G ||- Q]]$ denotes entailment and $[[G ||- sg1 <= sg2]]$ denotes Abstract judgments $[[G ||- Q]]$ denotes entailment and $[[G ||- s1 <= s2]]$ denotes
subtyping ($[[sg1]]$ is more general than $[[sg2]]$). subtyping ($[[s1]]$ is more general than $[[s2]]$).
\drules[P]{$[[G |-p p : sg => G']]$}{Patterns}{Var,Con,Syn,Sig} \drules[P]{$[[G |-p p : s => G']]$}{Patterns}{Var,Con,Syn,Sig}
\drules[Ps]{$[[G |-p* </ pi : sgi // i /> => G']]$}{Pattern sequences}{PatSeq} \drules[Ps]{$[[G |-p* </ pi : si // i /> => G']]$}{Pattern sequences}{PatSeq}
\end{document} \end{document}
...@@ -43,30 +43,30 @@ ftv(t) (= dom(G) ...@@ -43,30 +43,30 @@ ftv(t) (= dom(G)
--------------------------------- :: Case --------------------------------- :: Case
G |- case e of {</ pi -> ei // i />} : t G |- case e of {</ pi -> ei // i />} : t
sg = forall cs. Q => u s = forall cs. Q => u
ftv(sg) (= dom(G) ftv(s) (= dom(G)
G, <c : type>, Q |- e : u G, <c : type>, Q |- e : u
G, x : sg |- e2 : t G, x : s |- e2 : t
----------------------------- :: Let ----------------------------- :: Let
G |- let x :: sg = e in e2 : t G |- let x :: s = e in e2 : t
defn defn
G ||- Q' :: :: ConImpl :: 'ConImpl_' {{ com Constraint implication }} G ||- Q' :: :: ConImpl :: 'ConImpl_' {{ com Constraint implication }}
by by
defn defn
G ||- sg <= sg' :: :: Subtype :: 'SubType_' {{ com Subtyping relation}} G ||- s <= s' :: :: Subtype :: 'SubType_' {{ com Subtyping relation}}
by by
defn defn
G |-p p : sg => G' :: :: Pat :: 'P_' {{ com Pattern typing }} G |-p p : s => G' :: :: Pat :: 'P_' {{ com Pattern typing }}
by by
-------------------------------- :: Var -------------------------------- :: Var
G |-p x : sg => G, (x : sg) G |-p x : s => G, (x : s)
(P : forall </ ai // i />. Qr => forall </ bj // j />. Qp => </ sgk // k /> -> u) in G (P : forall </ ai // i />. Qr => forall </ bj // j />. Qp => </ sk // k /> -> u) in G
G' = G, (</ ai : type // i />), (</ ai ~ u'i // i />) G' = G, (</ ai : type // i />), (</ ai ~ u'i // i />)
</ ai // i /> # dom(G) </ ai // i /> # dom(G)
G' ||- (u ~ t) /\ Qr G' ||- (u ~ t) /\ Qr
...@@ -75,45 +75,45 @@ G' ||- (u ~ t) /\ Qr ...@@ -75,45 +75,45 @@ G' ||- (u ~ t) /\ Qr
G'' = G',(</ bj : type // j />),(</ cl : type // l />),(</ cl ~ b'l // l />),Qp G'' = G',(</ bj : type // j />),(</ cl : type // l />),(</ cl ~ b'l // l />),Qp
</ G'' ||- t'i ~ ai // i /> </ G'' ||- t'i ~ ai // i />
</ G'' ||- t''j ~ bj // j /> </ G'' ||- t''j ~ bj // j />
G'' |-p* </ pk : theta(sgk) // k /> => G''' G'' |-p* </ pk : theta(sk) // k /> => G'''
-------------------------------- :: Syn -------------------------------- :: Syn
G |-p P </ @ t'i // i /> </ @ t''j // j /> </ pk // k /> : t => G''' G |-p P </ @ t'i // i /> </ @ t''j // j /> </ pk // k /> : t => G'''
(K : forall </ aj // j /> . Q => </ sgk // k /> -> T </ ui // i />) in G (K : forall </ aj // j /> . Q => </ sk // k /> -> T </ ui // i />) in G
</ cl // l /> = ftv(</ t'j // j />) \ dom(G) </ cl // l /> = ftv(</ t'j // j />) \ dom(G)
</ aj // j /> # dom(G) </ aj // j /> # dom(G)
G' = G,(</ aj : type // j />),(</ cl : type // l />),(</ cl ~ t''l // l />),(</ ui ~ ti // i />),Q G' = G,(</ aj : type // j />),(</ cl : type // l />),(</ cl ~ t''l // l />),(</ ui ~ ti // i />),Q
</ G' ||- t'j ~ aj // j /> </ G' ||- t'j ~ aj // j />
G' |-p* </ pk : sgk // k /> => G'' G' |-p* </ pk : sk // k /> => G''
-------------------------------- :: Con -------------------------------- :: Con
G |-p K </ @ t'j // j /> </ pk // k /> : T </ ti // i /> => G'' G |-p K </ @ t'j // j /> </ pk // k /> : T </ ti // i /> => G''
cs = ftv(sg') \ dom(G) cs = ftv(s') \ dom(G)
G' = G, <c : type>, < c ~ t > G' = G, <c : type>, < c ~ t >
G' ||- sg <= sg' G' ||- s <= s'
G' |-p p : sg' => G'' G' |-p p : s' => G''
-------------------------------- :: Sig -------------------------------- :: Sig
G |-p (p :: sg') : sg => G'' G |-p (p :: s') : s => G''
defn defn
G |-p* </ pi : sgi // i /> => G' :: :: PatSeq :: 'Ps_' {{ com Pattern squence typing }} G |-p* </ pi : si // i /> => G' :: :: PatSeq :: 'Ps_' {{ com Pattern squence typing }}
by by
% help, how do I typeset that with G_{i-1} % help, how do I typeset that with G_{i-1}
</ Giminus_one |-p pi : sgi => Gi // i IN 1 .. n /> </ Giminus_one |-p pi : si => Gi // i IN 1 .. n />
----------------------------- :: PatSeq ----------------------------- :: PatSeq
G0 |-p* </ pi : sgi // i IN 1 .. n /> => Gn G0 |-p* </ pi : si // i IN 1 .. n /> => Gn
% defn % defn
% G |-sb* e <= sg :: :: Check :: '' {{ com Checking against specified polytypes }} % G |-sb* e <= s :: :: Check :: '' {{ com Checking against specified polytypes }}
% {{ tex [[G]] [[|-sb*]] [[e]] \Leftarrow [[sg]] }} % {{ tex [[G]] [[|-sb*]] [[e]] \Leftarrow [[s]] }}
% by % by
% G, c : type |-sb* e <= [a |-> c]sg % G, c : type |-sb* e <= [a |-> c]s
% --------------------------------- :: SB_DTyAbs % --------------------------------- :: SB_DTyAbs
% G |-sb* \ @c . e <= forall a. sg % G |-sb* \ @c . e <= forall a. s
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment