types a. b 2 i b
Post on 18-Jun-2022
2 Views
Preview:
TRANSCRIPT
Simply#peda-cai.us
WE ( xx . xx) N-
- cow
types A. B '
i. = 2 I A- → B [ Ax B / I]
Terry M ,N : := x / ( xx :A. M) / MN
( M.nl I it.M Ita Nl *
Valves ii. = Xx : A. M
( M ,N) ← ebn
( V , W) ← cbv
H) ← cbnlcbv
"
stuck"
IT, ( xx : A. x) -17HI 4*4*7 -17
CX x : z.X) : 2 -72
-
IT,IM
,N) →bn M¥cmm→j 'THE
The type system-
Contexts T " = . I T,
x : A
T, ,T,
to"
append" T
.,
Tz
dom (T) = { x ) x : A appears in T}⇐ i. A) E T to mean x: A appears in T
> donk?) n domed = 0
Typing : /PtM: judgment
( var)- ( x :A ET)Mt x : A
T,x : A t M : B
labs)- ( x # dome))P t Xx :Aim : A → B
Tt M : A → B Tt N : A(app)-
Tt MN : B
Q : does there ex is a typing derivation
for
+
It Caxias . xx) : B- ?[ AIs : No ?
there is→Hype
.
T such that
Ti- M : A Ti- N :B-
Tt SM,N) : AXB
Tt M : AXB Tt M : AXB- -
T t IT,M : A T '- Iz M : B-
Tt Ca ) : I
-
7x:A3xC *"
wrong"
T t It,(Xx : A.x) : B or
-
"
stuck"
-
Type Safety : If • I- M : A and- ( M -7mm
' /brr
n
then. th
'
: A.
Milner 's"
well - typed programs don't
go wrong"
Wright a Tellefsen 1994 Syntactic Typesafety
• (R ) (Xx :A. M) N →p MENK]
(3) M -70M'
-7nA.M→p Xx :A.M'
-
Lemmy Subject Reduction
[If T th : A and M -7ns M'
then Tt M': A
.
Proof-
By induction on the structure of M .
• case M - X then x -17ps ✓
• case M= Xx : B. M '
o Fx :B TM ':c
o M' -7M
" by-
Pt Xx :B.
M'
:B-7Cin
=A
Thx : Bt M"
:c ( by I. H)
by abs Mt Xx :B . M"
:B -7C ✓-
=A
• Ease µ , Mz) a) B M,= Xx :B
.
M,
'
n' I M.
'
[ Mix]
④ m
'? 7in a conga ]
•Lemmy Substitution
If T,x : A
,Th t M : B and
T,t N : A
thenp
, , Pa t M [Nlx] :B .
Proof : By induction on the structure of M.
• case M=y .
P,x : A
,Th t y : B
-
- (x : Ae. .)
-
x=y I? x : A, Th t x : B
- A -- B
x CN = N
to show : 17,17 t N : A -
- B V
FYI weakening if I , t M : A=
and I , Th is well formed
then 17,17 I- M : A"I ''Fasten:X xiH⇒⇒×.
Rest by-
* case x # yM[NIX] = y ENID = y
17,x : A
, they :B IT,,PztY:BJ toshow
(Einsteins Efa In "B
then T., Th t M :B
Proof By induction on th.
1-• case M= Xy :C .
M'
have 17,x : A
,Rt Ty : C.M
': CTD
by inversion T. ,x : A , Tz , y :C
t M'
:D
and x# y .
Hy :c .M
' ) CNH] = Xy :C .( MININ)
By IH .
with th : - th, y :C and B :-D
we hare n, th
, y :c1-MIND :D
use abs . M,
tht Ay :c .CM'
B)i. GD
ngV
• Case M= M, Mz
by .
IH . twice,we have
17,17 + M,[ NAT :C -713
I? ,RtMzCNlx3 :c-
l?,tht (M . Ma) (Nld :B V
-
-• Preservation . TM : A and M -7
,
M'
-
other . I- M'
: A
[ ''
"
iii.ar.
E there exists M 's. E
.
M → M !
Corollary : ifA then Mis-
not stuck ,
Mh→
top related