Concepts in Programming Languages.pdf
Concepts in Programming Languages by John Mitchell.一本国外经典教材,看了之后对编程语言更加理解。费了很多劲才找到的。Concepts in Programming LanguagesThis textbook for undergraduate and beginning graduate students explains and examines the central concepts used in modern programminglanguages, such as functions, types, memory management, and controlThe book is unique in its comprehensive presentation and comparisonof major object-oriented programming languages. Separate chapters ex-amine the history of objects, Simula and Smalltalk, and the prominentanguages c++ and JavaThe author presents foundational topics, such as lambda calculus anddenotational semantics, in an easy-to-read, informal style, focusing on themain insights provided by these theories. Advanced topics include concurrency and concurrent object-oriented programming. A chapter on logicprogramming illustrates the importance of specialized programming meth-ods for certain kinds of problemsThis book will give the reader a better understanding of the issuesand trade-offs that arise in programming language design and a betterappreciation of the advantages and pitfalls of the programming languagesthey useJohn C. mitchell is Professor of Computer Science at Stanford University,where he has been a popular teacher for more than a decade. Many of hisformer students are successful in research and private industry. He received his ph D. from mit in 1984 and was a member of technical staff atat&T Bell Laboratories before joining the faculty at Stanford. Over thepast twenty years, Mitchell has been a featured speaker at internationalconferences; has led research projects on a variety of topics, includingprogramming language design and analysis, computer security, and applications of mathematical logic to computer science; and has written morethan 100 research articles. His previous textbook, Foundations for Pro-gramming Languages(MIT Press, 1996), covers lambda calculus, typesystems, logic for program verification, and mathematical semantics ofprogramming languages. Professor Mitchell was a member of the programming language subcommittee of the ACM/ieEE Curriculum 2001standardization effort and the 2002 Program Chair of the aCm principlesof programming languages conferenceCONCEPTS NPROGRAMMINGLANGUAGESJohn c. mitchellStanford UniversityCAMBRIDGEUNIVERSITY PRESSPUBLISHED BY THE PRESS SYNDICATE OF THE UNIVERSITY OF CAMBRIDGEThe Pitt Building, Trumpington Street, Cambridge, United KingdomCAMBRIDGE UNIVERSITY PRESSThe Edinburgh Building, Cambridge CB2 2RU, UK40 West 20th Street, New York, NY 10011-4211 USA477 Williamstown Road, Port Melbourne vic 3207, AustraliaRuiz de alarcon 13, 28014 Madrid, spainDock House, The Waterfront, Cape Town 8001, South Africahttp://www.cambridge.orgo Cambridge university press 2004First published in printed format 2002isBN 0-511-03492-X eBook(adobe readerISBN 0-521-78098-5 hardbackContentsPrefacepage IxPart 1 functions and foundations1 Introduction1.1 Programming Languages1.2 Goals1.3 Programming Language History3561.4 Organization: Concepts and Languages2 Computability2. 1 Partial Functions and computability102.2 Chapter SummaryExercises163 Lisp: Functions, Recursion, and Lists3.1 Lisp History183.2 Good Language design203. 3 Brief Language overview223.4 Innovations in the Design of Lisp253.5 Chapter Summary: Contributions of LispExercises404 Fundamentals484.1 Compilers and syntax484.2 Lambda calculus4.3 Denotational semantics4.4 Functional and Imperative Languages4.5 Chapter SummaryExercisesContentsPart 2 Procedures, Types, Memory Management, and Control5 The algol Family and ML5.1 The Algol Family of Programming Languages5.2 The Development of C5.3 The LCF System and ml5.4 The Ml Programming Language1035.5 Chapter summary121Exercises1226 Type Systems and Type Inference1296.1 Types in Programming1296.2 Type Safety and Type Checking1326.3 Type Inference1356.4 Polymorphism and Overloadin1456.5 Type Declarations and Type Equality1516.6 Chapter Summary155Exercises1567 Scope, Functions, and storage Management1627.1 Block-Structured Languages1627.2 In-Line blocks1657.3 Functions and procedures1707.4 Higher-Order functions1827.5 Chapter summary190Exercises1918 Control in Sequential Languages2048.1 Structured control2048.2 Exceptions2078.3 Continuations2188.4 Functions and evaluation order2238.5 Chapter summary227Exercises8Part 3 Modularity, Abstraction, and object-Oriented Programming9 Data Abstraction and Modularity2359.1 Structured Programming2359.2 Language Support for Abstraction2429.3 Modules9.4 Generic Abstractions2599.5 Chapter Summary269Exercises27110 Concepts in Object-Oriented Languages27710.1 Object-Oriented design27710.2 Four Basic concepts in object-Oriented languages278Contents10.3 Program Structure28810.4 Design Patterns29010.5 Chapter summary29210.6 Looking Forward: Simula, SmalltalkC++Java293Exercises29411 History of objects: Simula and smalltalk30011.1 Origin of Objects in Simula30011.2 Objects in Simula30311.3 Subclasses and Subtypes in Simula30811.4 Development of smalltalk31011.5 Smalltalk Language features31211.6 Smalltalk flexibilit31811.7 Relationship between Subtyping andInheritance2211.8 Chapter SummaryExercises32712 objects and Run-Time Efficiency: C++33712.1 Design goals and Constraints33712.2 Overview of c++34012.3 Classes. Inheritance and Virtual functions34612.4 Subtyping35512.5 Multiple inheritance12.6 Chapter summary366Exercises36713 Portability and Safety: Java38413.1 Java language overview38613.2 Java Classes and Inheritance38913.3 Java Types and Subtyping39613.4 Java System architecture40413.5 Security Features41213.6 Java summary417Exercises420Part 4 Concurrency and Logic Programming14 Concurrent and Distributed Programming43114.1 Basic Concepts in Concurrency43314.2 The actor model44114.3 Concurrent ML14.4 Java concurrency45414.5 Chapter Summary466Exercises469Contents15 The Logic Programming Paradigm and Prolog47515. 1 History of logic Programming15.2 Brief Overview of the logic Programming Paradigm4715. 3 Equations solved by Unification as Atomic Actions15.4 Clauses as Parts of procedure declarations48215.5 Prologs Approach to Programming48615.6 Arithmetic in Prolog49215.7 Control, Ambivalent Syntax, and Meta-Variables49615.8 Assessment of Prolog50515.9 Bibliographic remarks50715.10 Chapter Summary507Appendix a Additional Program Examples509A 1 Procedural and Object-Oriented organization509Glossary521Index525
- 2020-12-09下载
- 积分:1
浙江大学计算理论复习总结
计算理论复习总结,但是考试快要结束了,估计大家也没有什么需要了。28.文法是CFG的推广,任何CFG都是文法。G=(V,∑,R,S)29.语言被文法生成ⅲ它是re的。30.所有数值函数都是原始递归的31.原始递归函数集是递归可枚举的。32.特殊语言/问题H={"M"w":M在w上停机}lH={"M"w":M是一台在"w"上不停机的TM}H1={"M":M在“M”上停机}H1={w:要么w不是一台TM的编码,要么w是M的编码,M是一台在"M"上不停机的TM}H:re.;H1:re.;-H,-H1:非r.e.;2-SAT∈P;SAT∈NPThe world as We Dont Know itreAsumming P≠APCo『eHrecursiveSATSATCO-A伊II Asumming P=Npr, eCo-r.erecursiveNP= cO-Np= p33没有算法的问题称作不可判定的or不可解的,如TM的停机问题34.证明不可判定通用图灵机U通过递归函数归约到L如果L是递归的则U是递归的ic若L1非递归,并存在L1到L2的归约,则L2也非递归。递归函数是 Turing Computable的35.语言是图灵可枚举的,证存在枚举它的图灵机。(M通过空格代开始,周期性的经过特殊状态q来枚举L,任意顺序且可重复)6.不可判定语言与递归语言互为补集,与rc语言有交集。37语言是re.,if它是图灵可枚举的;语言是递归的,i它是以字典序 turing可枚举的。8.P在并交连接和补运算下封闭NP在并、连接运算下封闭。若NP在补下封闭则NP=P39.H={M"wM在最多2w步后停机}唾P40.所有正则语言和所有CFL都属于P41.NPA.机器角度去定义:被多项式界限非确定型图灵机判定的所有语言的类。B.基于 verifier的定义:NP问题上建立的非确定机包含两步1)非确定地猜一个解2〕用一个确定的算法判定该解是否为可行解判定一个给定猜测值是否满足该问题(可满足性)的算法称作 verifier,一个问题称作NP问题当且仅当存在一个多项式时间的 verifier这两个定义是不矛盾的,因为如果一台非确定TM在多项式时间内可以判定一个非确定选择的翰入是否满足,就是基于 verifier的定义。P和NP的区别a problem is in P if we can decide them in polynomial time. It is in NP if we candecide them in polynomial time, if we are given the right certificate42.若存在计算函数f的多项式界限的图灵机M,则f称为多项式时间可计算的43.若τ1是L1->l2的多项式归约,τ2是L2->I3的多项式归约,则τ1τ2是L1->l3的多项式归约44.证明NP完全法一、按定义:LΣ*,若(a)L∈NP,且(b)对每个语言L∈NP,存在从L到L的多项式归约则L称为NP完全的。法二、归约,对于语言L,(a)若L∈NP(b)一个NP完全问题可以在多项式时间规约到L,ie. SAT 0 is context-free but not regular49.L=L1L2,L是CFL,则L1一定是CFL(x50. Regular-CFL不一定是CFL,如a*b*c*-anbn包含 anben51. 2-way PDalie PDa whose input heads can move both left and right] are more powerfulthan 1-way pda52. Given a PDa M1 and an fa M2, the problem l(M1)cl(M2)is decidable53.DFA/NFA识别的是 exactly正则语言54.Re.只在补和差下不封闭,CFL在交下也不封闭55.非正则语言的可能是正则语言。比如A:[W=w}及所有回文,A=*,为正则语言56.典型非正则:w=wR57.正则语言的子集可能非正则,如 anben是a*b*c*的子集;又如Σ*是正则语言,H≌Σ*58.归约:X到Y的归约可以理解为X到Y问题的映射, reduction可以解释为 at least asdifficult as….比如ⅹ可以被Y的算法解决,则 X is no more difficult than yⅩ可以约到Y,记X≤Y。e.gx2可以归约到任意两数的乘积。若有A≤B,A是不可判定问题>B不可判定A不递归->B不递归B可判定>A可判定B是递归的->A是递归的59.若X多项式时间归约到Y,Y多项式时间可解,则X多项式时间可解若X多项式时间归约到Y,Ⅹ多项式时间不可解,则Y多项式时间不可解60.X多项式时间归约到Y,Y多项式时间归约到Z,则X多项式时间归约到Z61.PRME( COMPOSITE)多项式时间归约到 Factor,但是 Factor多项式时间不能归约到PRIME COMPOSITE )o62.若A≤PB,B∈NP,则A∈NP。证明A≤PB→存在确定图灵机X,可将A归约到B。B∈NP→存在一个非确定图灵机N可判定B。我们希望构造一个新的TM(ⅹN)是的ⅹ*N非确定多项式时间求解A,则A∈NPRunning time of X*N≤1+p(mB>+qp(m)(B多项式时间非确定判定是多项式时间所以A∈NP63若AsPB,B∈P,则A∈P64.若X是NPC的,则X在多项式时间内可解ifP=NP65.SAT多项式时间归约到3SA(3AT是NPC的)66.证明语言L是R/Re, Non rea) Intuitively想想有没有半判定(判定)的TM,有则Rc、(R)。若非R执行下一步。b)用能否由Re.( Non re.)语言归约到该语言,能则Re而非R( Non re)严格用归约函数定义f:A≤B,r1∈A当且仅当r1∈Beg1∈H,M∈L证明Recg2∈非H,iM∈L证明 Non rc注意方向:是从A的实例经过递归函数推向B的实例。详细介绍http://www.cs.rice.edu/nakhleh/comp481/finalreviewsp06sol.pdf67.递归与μ递归等价68.PDA中,若每一个格局至多有一个格局接在它后面,则为确定型的。确定型CF在补下封闭69.M半判定L:w∈L,ifM在w上停机,注意半判定图灵机中不存在“拒绝”状态。只要不接受w,就不停机。70. Chomsky hierarchyElements of the Chomsky HierarchyRecursively enumerable languagesRecursive languageContext sensitive languagesContext ee languageseterministccontext free languagesRegularanguages71.俩证明7.6证明P在并、交、 Kleene*连接和补运算下封闭(1)并:对任意L,LEP,遴n时间图灵机M1和nb时间图灵机M2判定它们且c=max{ab}对L1L2构造判定器MM=“对于输入字符串w1)在W上运行M1,在w上运行M22)若有一个接受则接受,否则拒绝。时间复杂度:设M1为0(n)M2为0(m)。令c=max{ab}第一步用时0(n+n),因此总时间为Oma+n)=0(n9所以L1L2属于P类,即P在并的运算下封闭。(2)连接对任意L1,L2属于P类,设有n时间图灵机M1和m时间图灵机M2判定它们,且c=max{ab}。对L1l2构造判定器MM=“对于输入字符串w=w2灬,Wn对k=0,1,21…,n重复下列步骤。在wW2…wk上运行M1,在wk1wk+2…n上运行M若都接受,则接受。否则继续。若对所有分法都不接受则拒绝。时间复杂度:(n+1x0(n+0m-0(m+4)+0(nb+4=0(nc+),F以L1oL2属于P类,即P在连接的运算下封闭。对任意L属于P类,设有时间0(n)判定器M判定它,对构造判定器MM=“对于输入字符串〔1)在w上运行M12)若M1接受则拒绝,若M1拒绝则接受。时间复杂度为:0(m)。所以属于P类,即P在补的运算下封闭。77证明NP在并和连接运算下封闭。1)并对任意L1,L2∈NP,设分别有n时间非确定图灵机M1和n时间非确定图灵机M2判定它们,且c=max{a,b}。构造判定LL2的非确定图灵机M:M=“对于输入字符串w1)在W上运行M1,在w上运行M2。2)若有一个接受则接受,否则拒绝。对于每一个非确定计算分支,第一步用时为O(n-)+O(n),因此总时间为On+n)=0(n。所以LLz∈NP,即NP在并的运算下封闭2)连接对任意L,L2∈NP设分别有na时间非确定图灵机M1和m时间非确定图灵机M2判定它们,且c=max{ab}。构造判定L1oL2的非确定图灵机M:M=“对于输入字符串w:1〕非确定地将分成两段xy,使得w=xy。2)在x上运行M1,在y上运行M23)若都接受则接受,否则拒绝。对于每一个非确定计算分支,第一步用时O(n,第二步用时为0(n)+0(m),因此总时间为o(n+m)=0(n。所以L1oL2∈NP,即NP在连接运算下封闭。专题一一图灵机可判定性问题判定以下问题是否可判定:声明:思路—想证明B问题不可解,1.从一个不可解问题A入手(如停机问题)2.创建B的—个实例,从中推出如果能解决B,A也就可以解决了3.所以B是不可解的1.一个图灵机有至少481个状态。我们可以给出这样一个TMN进行cnc(M)a)数M中状态数,直到481b)如果达到了481,N就接受,否则拒绝2.给定图灵机在空串上走了481步还没停机。构造2带图灵机N,a)2a带:写481个0b)1s带在空串上模拟M,每走一步,第2带就删掉一个0c)如果M在所有0都删掉之后停机,则N接受,否则不接受给定图灵机,判定它是否在一些输入上经过481步还没停机?a)按字典序找出所有 length
- 2020-12-01下载
- 积分:1