首页 > 编程语言 >COMP3610编程技巧几点看法

COMP3610编程技巧几点看法

时间:2023-09-01 19:44:06浏览次数:35  
标签:int leaves 编程 Question COMP3610 Marks 几点 fn E3


COMP3610/6361 Principles of Programming Languages
Assignment 1
ver 1.1
Submission Guidelines
Due time: Aug 31, 2023, 11am (Canberra Time)
Submit a pdf via Wattle.
Scans of hand-written text are fine, as long as they are readable and neat.
Please read and sign the declaration on the last page and attach a copy to your submission.
No late submission, deadline is strict
Exercise 1 (Type Preservation) (15 Marks)
In the lecture we discussed alternatives for the semantics rule for assignment and sequential composition.
Among others we looked at the following:
Does Type Preservation hold for the variant language with rules (assign1’) and (seq1’) instead of (as-
sign1) and (seq1)?
If not, give an example, and explain which changes to the typing rules would be needed to get the prop-
erty back; if yes, sketch a proof.
Exercise 2 (Structural Induction) (25 Marks)
A BTree is defined by the following grammar.
T ::= Id | One T | Two T T
That means that leaves are labelled ‘Id’, and inner nodes can have One or Two children.
Question 1 Define a function leaves that determines the number of leaves for a given tree.
Question 2 Define a function two succ that determines the number of nodes with two children.
Question 3 Derive an induction principle for BTree
Question 4 Prove that any tree B with n leaves has exactly n+1 nodes with two children:
leaves B= (two succ B)?1
2 COMP3610/6361
Exercise 3 (Functions) (25 Marks)
Question 5 Calculate the free variables of the following expressions:
1. x+(fn y : int? z)
2. (fn y : int? (fn y : int? (fn y : int? y)))
3. while !l0 ≥ y do l0 := x
Draw also their abstract syntax trees (up to alpha equivalence).
Question 6 Perform the following substitutions:
1. {y z/x}(fn x : int y x)
2. {z x/x}(fn y : int y x)
3. {z x/x}(fn z : int (fn x : int y x) x z)
Exercise 4 (Nested substitution) (25 Marks)
Question 7 For the language variant featuring while, if-statement and functions (no recursion), show
the following statement.
{E3/y}{E2/x}E1 = {({E3/y}E2)/x}{E3/y}E1
where x and y are variable with x = y, and E1, E2 and E3 expressions with x ∈ fv(E3). Clearly state your
proof strategy and mark the places where the assumptions are used.
Exercise 5 (Exception Handling) (10 Marks)
When using error handling in its simplest form (see lecture), the progress property does not hold.
Question 8 Explain why the property is broken and give an example.
Question 9 Fix the progress theorem in a way that it still captures the essence of progress. The theorem
should hold for languages with error handling. Other properties such as type preservation and type safety
should stay valid.
P. Ho¨fner 3
Academic Integrity
I declare that this work upholds the principles of academic integrity, as defined in the University Aca-
demic Misconduct Rule; is entirely my own work, with only the exceptions listed; is produced for the
purposes of this assessment task and has not been submitted for assessment in any other context, except
where authorised in writing by the course convener; gives appropriate acknowledgement of the ideas,
scholarship and intellectual property of others insofar as these have been used; in no part involves copy-
ing, cheating, collusion, fabrication, plagiarism or recycling.
Date Signature

 

标签:int,leaves,编程,Question,COMP3610,Marks,几点,fn,E3
From: https://www.cnblogs.com/goodnewss/p/17672733.html

相关文章

  • AI辅助编程测试2023.9.1
    今天考虑做一个需求WinForm程序中,将DevExpress中的SpreadsheetControl控件的[Ctrl+S]快捷键禁掉,避免用户自行将程序中提供的表格进行另存。我将下面这句话拿给各个AI工具,以及搜索工具关键词:DevExpress的SpreadsheetControl控件,如何能禁用ctrl+S这个快捷键  POE中的chatGPT3......
  • 编程中的参数
    一、参数的概念与作用参数是编程中的重要概念之一,用于向函数或方法传递输入值。在编程中,我们经常需要对不同的数据进行处理,而参数的引入使得函数能够根据不同的输入值产生不同的输出结果。参数可以帮助我们定义函数的行为,并且使得函数更加可复用和灵活。参数的作用主要有两个方......
  • 如何学习编程
    如何学习编程编程是当今世界最热门技能之一,而且它的重要性在不断增加。然而,对于初学者来说,编程策划可能看起来像是一片未知的领域。幸运的是,学习编程并不是一项艰难的任务。通过采取一些有效的学习方法和策略,任何人都可以掌握编程技能。在本文中,我们将介绍一些学习编程的建议和技......
  • Android并发编程高级面试题汇总(含详细解析 十五)
    Android并发编程高级面试题汇总最全最细面试题讲解持续更新中......
  • 纯干货!一文get昇腾Ascend C编程入门全部知识点
    本文分享自华为云社区《昇腾AscendC编程入门教程》,作者:昇腾CANN。2023年5月6日,在昇腾AI开发者峰会上,华为正式发布了面向算子开发场景的昇腾AscendC编程语言。AscendC原生支持C/C++编程规范,通过多层接口抽象、并行编程范式、孪生调试等技术,极大提高了算子的开发效率,帮助AI开发......
  • c++并发编程实战-第2章 线程管控-读书笔记
    线程的基本管控每个应用程序都至少拥有一个线程,即运行main函数的线程,称为主线程,它由c++运行时系统启动。我们可以在软件运行中产生其他线程,它们以指定的函数作为入口函数。当main函数返回后,程序会退出;同样,当入口函数返回后,与之对应的线程结束。发起线程线程是通过构造std::thre......
  • Java是一种广泛使用的面向对象编程语言
    Java是一种广泛使用的面向对象编程语言,具有以下特性:平台无关性:Java语言编写的程序可以在不同的操作系统和硬件平台上运行,因为Java语言通过Java虚拟机(JVM)实现了平台无关性。面向对象:Java是一种完全面向对象的编程语言,支持封装、继承和多态等面向对象的基本特性。强类型语言:Java是一......
  • Python下载_Python免费版下载「编程工具」中文版介绍
    Python具有脚本语言中最丰富和强大的类库,足以支持绝大多数日常应用。Python的名字来源于一个喜剧,也许最初设计Python这种语言的人并没有想到今天它会在工业和科研上获得如此广泛的使用。著名的自由软件作者EricRaymond在他的文章《如何成为一名黑客》中,将Python列为黑客应当学习的......
  • Java并发编程:volatile关键字解析
    Java并发编程:volatile关键字解析volatile这个关键字可能很多朋友都听说过,或许也都用过。在Java5之前,它是一个备受争议的关键字,因为在程序中使用它往往会导致出人意料的结果。在Java5之后,volatile关键字才得以重获生机。volatile关键字虽然从字面上理解起来比较简单,但是......
  • 编程语言的分类
    最早的时候,0和1就是编程语言.......机器语言优点:执行代码效率非常快缺点:开发效率低汇编语言然后通过写英文字符的形式代替了写0和1,但是他还是直接和硬件交互(了解)优点(相对于机器语言):开发效率高缺点(相对于机器语言):执行效率低高级语言printf("helloworld")翻译001010011010......