首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
代做program、代写c++,Python程序
项目预算:
开发周期:
发布时间:
要求地区:
Foundations1 assignment 2023
Submit by Monday of week 8 (30 October 2023)
by the deadline hour relevant to your campus.
Worth 15%
Submit only typed material
No handwritten material
NO EMAIL SUBMISSIONS
EACH CAMPUS WILL INFORM YOU WHERE
& HOW TO SUBMIT
WRITE YOUR FAMILYNAME+NAME+STUDENT ID (in this order) HERE
1
Background
• The syntax of the classical λ-calculus is given by M ::= V | (λV.M) | (MM).
We assume the usual notational conventions in M and use the reduction rule:
(λv.P)Q →β P[v := Q].
• The syntax of the λ-calculus in item notation is given by M0
::= V |[V]M0
| hM0
iM0
.
We use the reduction rule: hQ0
i[v]P
0 →β0 [v := Q0
]P
0
where [v := Q0
]P
0
is defined in a similar way to P[v := Q].
• In M, (P Q) stands for the application of function P to argument Q.
In M0
, hQ0
iP
0
stands for the application of function P
0
to argument Q0
(note the
reverse order).
For example:
(λx.x)y in M becomes hyi[x]x in M0
.
(λx.(λy.xy)z)(λz0
.z0
) in M becomes h[z
0
]z
0
i[x]hzi[y]hyix in M0
.
• The syntax of the classical λ-calculus with de Bruijn indices is given by
Λ ::= N | (λΛ) | (ΛΛ).
For example: (λ1) is a term (it is equivalent to λx.x and λy.y, etc).
Also (λ(λ1 2)) is also a term. It stands as you will see for λxy.yx.
Also, (λ(λ2 1)) is also a term. It stands as you will see for λxy.xy.
We will use similar parenthesis convention for Λ as in M, so ABC stands for ((AB)C),
but we cannot combine many λs into one. So, λλA cannot be written as λA, but we
know that λv.λv0
.A can be written as λvv0
.A.
• For [x1, · · · , xn] a list (not a set) of variables, we define ω[x1,··· ,xn]
: M 7→ Λ by:
1. ω[x1,··· ,xn]
(vi) = min{j : vi ≡ xj}
2. ω[x1,··· ,xn]
(AB) = ω[x1,··· ,xn]
(A)ω[x1,··· ,xn]
(B)
3. ω[x1,··· ,xn]
(λx.A) = λω[x,x1,··· ,xn]
(A)
Hence
– ω[x,y,x,y,z]
(x) = 1
– ω[x,y,x,y,z]
(y) = 2
– ω[x,y,x,y,z]
(z) = 5.
– Also ω[x,y,x,y,z]
(xyz) = 1 2 5.
– Also ω[x,y,x,y,z]
(λxy.xz) = λλ2 7.
• Translation from M to Λ: If our variables are ordered as v1, v2, v3, · · · , then we
define ω : M 7→ Λ by
0. ω(A) = ω[v1,··· ,vn]
(A) where F V (A) ⊆ {v1, · · · , vn}.
2
So for example, if our variables are ordered as
x, y, z, x0
, y0
, z0
, · · ·
then the translation of ω(λxyx0
.xzx0
) from M to Λ gives the term λλλ3 6 1. This
can be seen as follows:
ω(λxyx0
.xzx0
) =0
ω[x,y,z]
(λxyx0
.xzx0
) =3
λω[x,x,y,z]
(λyx0
.xzx0
) =3
λλω[y,x,x,y,z]
(λx0
.xzx0
) =3
λλλω[x0
,y,x,x,y,z]
(xzx0
) =2
λλλω[x0
,y,x,x,y,z]
(xz)ω[x0
,y,x,x,y,z]
(x
0
) =2
λλλω[x0
,y,x,x,y,z]
(x)ω[x0
,y,x,x,y,z]
(z)ω[x0
,y,x,x,y,z]
(x
0
) =1
λλλ3 ω[x0
,y,x,x,y,z]
(z)ω[x0
,y,x,x,y,z]
(x
0
) =1
λλλ3 6 ω[x0
,y,x,x,y,z]
(x
0
) =1
λλλ3 6 1.
• – We define v :: L as the consing of v to L as for example in v :: [2, 3, y] = [v, 2, 3, y].
– Assume an ordered list of variables
listorder = [x, y, z, x0
, y0
, z0
, x1, y1, z1, x2, y2, z2, . . . ].
– Let L = [a1, a2, · · · , an, · · · ] be a list whose number of elements is denoted as
|L|.
For example, |listorder| = ∞, |[x, y, z]| = 3, |[2, 3, 4, 5]| = 4, |[ ]| = 0.
Assume j ≤ |L|. We define:
∗ lel(j, L) = [a1, a2, · · · , aj ].
∗ el(j, L) = aj .
– Let S be a set of positive natural numbers. We define max(S) to be the largest
number ai
in S. I.e., max(S) = aj such that for every ai ∈ S we have ai ≤ aj .
– We define lams(n) = 0
lams(AB) = lams(A) + lams(B)
lams(λA) = 1 + lams(A).
– We define ω1 : Λ 7→ M as follows:
0. ω1(A) = ω
0
1
(n + 1, lel(n, listorder), A)
where n = max(F V (A)).
1. ω0
1
(n, l, m) = el(m, l)
2. ω0
1
(n, l, λA) = λv.ω0
1
(n + 1, v :: l, A) where v = el(n, listorder).
3. ω0
1
(n, l, AB) = ω
0
1
(n, l, A)ω
0
1
(n + lams(A), l, B)
3
For example, F V (λ1 2) = {1} and max(F V (λ1 2)) = 1. Hence
ω1(λ1 2) =0
ω
0
1
(2, lel(1, listorder), λ1 2) =
ω
0
1
(2, [x], λ1 2) =2
λy.ω0
1
(3, [y, x], 1 2) =3
λy.ω0
1
(3, [y, x], 1)ω
0
1
(3 + lams(1), [y, x], 2) =
λy.ω0
1
(3, [y, x], 1)ω
0
1
(3, [y, x], 2) =1
λy.el(1, [y, x])ω
0
1
(3, [y, x], 2) =1
λy.el(1, [y, x])el(2, [y, x]) =
λy.yel(2, [y, x]) =
λy.yx.
• Assume the following SML datatypes which implement M, Λ and M0
respectively
(here, if e1 implements A0
1
and e2 implements A0
2
, then IAPP(e1,e2) implements
hA0
1
iA0
2 which stands for the function A0
2
applied to argumentA0
1
):
datatype LEXP =
APP of LEXP * LEXP | LAM of string * LEXP | ID of string;
datatype BEXP =
BAPP of BEXP * BEXP | BLAM of BEXP | BID of int;
datatype IEXP =
IAPP of IEXP * IEXP | ILAM of string * IEXP | IID of string;
Recall the printing function on LEXP:
(*Prints a term in classical lambda calculus*)
fun printLEXP (ID v) =
print v
| printLEXP (LAM (v,e)) =
(print "(\\";
print v;
print ".";
printLEXP e;
print ")")
| printLEXP (APP(e1,e2)) =
(print "(";
printLEXP e1;
print " ";
4
printLEXP e2;
print ")");
• For each of BEXP and IEXP we can also write a printing function printBEXP (respectively printIEXP) that prints its elements nicely just like we wrote printLEXP
which prints nicely the elements of LEXP.
(*Prints a term in item lambda calculus*)
fun printIEXP (IID v) =
print v
| printIEXP (ILAM (v,e)) =
(print "[";
print v;
print "]";
printIEXP e
)
| printIEXP (IAPP(e1,e2)) =
(print "<";
printIEXP e1;
print ">";
printIEXP e2
);
(*Prints a term in classical lambda calculus with de Bruijn indices*)
fun printBEXP (BID n) =
print (Int.toString n)
| printBEXP (BLAM (e)) =
(print "(\\";
printBEXP e;
print ")")
| printBEXP (BAPP(e1,e2)) =
(print "(";
printBEXP e1;
print " ";
printBEXP e2;
print ")");
• At http://www.macs.hw.ac.uk/~fairouz/foundations-2023/slides/assign23-help.
sml, you find an implementation in SML of the set of terms M, M0
, and Λ including
printing their terms printLEXP, printIEXP and printBEXP, and many operations on
M like substitution and free variables etc. You can use all of these in your assignment.
Anything you use from here or elsewhere has to be well cited/referenced.
5
Questions
1. For each term A of the terms below, give its translation ω(A) from M to Λ showing
all the steps, their number and underlining all the parts you are working on, just like
we did in the above example:
(a) (λxy.x). (1)
ω(λxy.x) =0
.
.
.
(b) (λxyz.xz(yz)). (1)
ω(λxyz.xz(yz)) =0
.
.
.
(c) xz(λxy.z(λz.zy)x). (1.5)
ω(xz(λxy.z(λz.zy)x)) =0
.
.
.
2. Assume the following translation function f from M to M0
that will translate terms
in M to terms in M0
:
0. f(v) = v
1. f(λv.A) = [v]f(A)
2. f(AB) = hf(B)if(A)
So for example:
f((λx.x)y) =2
hf(y)if(λx.x) =0
hyif(λx.x) =1
hyi[x]f(x) =0
hyi[x]x.
Similarly you can show that: f((λx.(λy.xy)z)(λz0
.z0
)) = h[z
0
]z
0
i[x]hzi[y]hyix.
Use this translation function f to translate all the terms in Question 1 above into
terms of M0
. That is, give f(λxy.x) and f(λxyz.xz(yz)) and f(xz(λxy.z(λz.zy)x))
showing all the steps and underlining all the parts you are working on. (3.5)
• f(λxy.x) =1
.
.
.
6
• f(λxyz.xz(yz)) =1
.
.
.
• f(xz(λxy.z(λz.zy)x)) =2
.
.
.
3. Calculate ω1(λ1(λ21)3) showing, numbering and underlining all the steps you carry
out in the calculations. (4)
F V (λ1(λ2 1)3) = {2} and max(F V (λ1(λ2 1)3)) = 2.
Hence ω1(λ1(λ2 1)3) =0
.
.
.
4. In the SML files, you were given the following LEXP terms (which implement terms
of M):
val vx = (ID "x");
val vy = (ID "y");
val vz = (ID "z");
val t1 = (LAM("x",vx));
val t2 = (LAM("y",vx));
val t3 = (APP(APP(t1,t2),vz));
val t4 = (APP(t1,vz));
val t5 = (APP(t3,t3));
val t6 = (LAM("x",(LAM("y",(LAM("z",
(APP(APP(vx,vz),(APP(vy,vz))))))))));
val t7 = (APP(APP(t6,t1),t1));
val t8 = (LAM("z", (APP(vz,(APP(t1,vz))))));
val t9 = (APP(t8,t3));
For example vx implements the variable x. The SML term t1 implements the M
term λx.x.
Give the full term of M implemented by the SML LEXP term t9. (0.5)
The SML term t9 implements the M term · · ·
5. Give the term It8 of IEXP that correspond to t8 of LEXP. (0.5)
val It8 = ...
6. Give the term Bt2 of BEXP that corresponds to t2 of LEXP. (0.5)
7
val Bt2 = ....
7. Remote login to your university account (or do whatever you usually do to get to the
university machines, or if you have SML on your own computer then do the work on
your own computer).
On university machines, in the same directory in which you have the files assign21-
help.sml, type the following line (and hit return):
poly
You will get the prompt
>
Type at the prompt the following:
>use "assign21-help.sml";
If you want, read and understand the messages you get, but don’t bother if you don’t
want to, or you think you don’t udnerstand.
Then, test the commands below (in poly) and write the output of the following: (1)
subs vy "x" t2;
subs vx "y" t2;
>subs vy "x" t2;
val it ...
>subs vx "y" t2;
val it ...
8. Give (λy.x)[x := y] and compare with subs vy ”x” t2 above. (1.5)
.
.
.
8
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
urba6006代写、java/c++编程语...
2024-12-26
代做program、代写python编程语...
2024-12-26
代写dts207tc、sql编程语言代做
2024-12-25
cs209a代做、java程序设计代写
2024-12-25
cs305程序代做、代写python程序...
2024-12-25
代写csc1001、代做python设计程...
2024-12-24
代写practice test preparatio...
2024-12-24
代写bre2031 – environmental...
2024-12-24
代写ece5550: applied kalman ...
2024-12-24
代做conmgnt 7049 – measurem...
2024-12-24
代写ece3700j introduction to...
2024-12-24
代做adad9311 designing the e...
2024-12-24
代做comp5618 - applied cyber...
2024-12-24
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!