Presentation on theme: "CS 3240: Languages and Computation"— Presentation transcript:
1CS 3240: Languages and Computation Course Overview
2Course Staff Instructor: Prof. Alberto Apostolico TA: Akshay Wadia Office: KLAUS 1310Office Hours:Tue. & Thur. at 4-5pmOr by appointmentTA: Akshay WadiaOffice: KLAUS 2124Tue. & Thur. at am,
3Required TextbookIntroduction to Automata Theory, Languages, and Computation(3rd Edition) by John E. Hopcroft , Rajeev Motwani , Jeffrey D. Ullman Hardcover Addison Wesley; 3 edition (July 8, 2006) ISBN-10: ISBN-13:
4Required TextbookIntroduction to Automata Theory, Languages, and Computation(3rd Edition) by John E. Hopcroft , Rajeev Motwani , Jeffrey D. Ullman Hardcover Addison Wesley; 3 edition (July 8, 2006) ISBN-10: ISBN-13:This book is complemented by an online resource found atGo to this site, register using the student access code provided with your copy of the book, then login and enter the following class token at the prompt: 71E4F530PLEASE DO NOT DISTRIBUTE THIS TOKEN OUTSIDE THE CLASS
5Course Objectives Formal languages Theory of computation Understand definitions of regular and context-free languages and their corresponding “machines”Understand their computational powers and limitationsTheory of computationUnderstand Turing machinesUnderstand decidabilityApplications BasicsLexical Analysis & CompilerText searchingFinite state device design
6Outline Regular expressions, DFAs, NFAs and automata Limits on regular expressions, pumping lemmaPractical parsing and other applicationsContext-free languages, grammars, Chomsky HierarchyPushdown automata, deterministic vs. non-deterministicAttribute grammars, type inferencingContext-free vs. context-sensitive grammarsTuring machines, decidable vs. undecidable problems, reducibility
7Grading Homework: 20% Mini-project: 25% Tests: 30% Final: 25% Homework will try to exploit Gradiance resource with final version due in classNo late homework or assignments without prior approval of instructorHomework should be concise, complete, and preciseTests will be in class. Closed book, closed notes, but one-page cheat-sheet allowed.
8Collaboration PolicyStudents must write solutions to assignments completely independentlyGeneral discussions are allowed on assignments among students, but names of collaborators must be reported
9Resources Check often for announcements and schedule changes. Class webpageGRADIANCE webpageCheck often for announcements and schedule changes.
11Automata & Formal Languages Turing MachinesAutomata & GrammarsCompilersText & Web applications
12Compilers What is a compiler? Why compilers? A program that translates an executable program from source language into target languageUsually source language is high-level language, and target language is object (or machine) codeRelated to interpretersWhy compilers?Programming in machine (or assembly) language is tedious, error prone, and machine dependentHistorical note: In 1954, IBM started developing FORTRAN (FORmula TRANslation) language and its compiler
13How Does Compiler Work? Scanner Start Parser RequestTokenGetTokenStartParserFront End: Analysis of program syntax and semanticsSemanticActionSemanticErrorCheckingIntermediateRepresentation
14Parts of Compilers Focus of this class. 1. Lexical Analysis Front End 2. Syntax Analysis3. Semantic AnalysisSynthesisBackEnd4. Code Generation5. Optimization
15Basic ConceptsComputational problems can be posed ultimately as decision (yes-no) problemsYes-No problems can be posed ultimately as language recognition problemsA language is any set of strings over some alphabetDeciding a language means being able to discriminate the strings belonging to it against all othersThere are two basic ways to ‘’decide’’ a language: Automata & GrammarsAn Automaton discriminates whether a given input string is in the language or notA Grammar generates all and only the strings in the languageThere is a subtle correspondence between an automaton and a corresponding grammarSome languages are easy to decide, some are harder, some are ‘’impossible’’We can build a hierarchy of automata , and a corresponding one of grammars based on the complexity of the languages we wish to decide
16Limits of ComputationThree easy functions defined on the decimal development of Greek Pi p …The ratio of the circumference to the diagonal of the unit circlef(n) = 1, if 4 appears before the nth decimal digit of pf(n) = 0 otherwiseg(n) = 1, if 4 appears as the nth decimal digit of pg(n) = 0 otherwiseh(n) = 1, if 4 appears after the nth decimal digit of ph(n) = 0 otherwiseDo we have an algorithm for f? for g? for h?
17Computable, Undecidable, Untractable Questions of decidability revolve around whether there is an algorithm to solve a certain problemQuestions of untractability revolve around whether there is a practically viable algorithm to solve a certain problemMost of the algorithms we design and use are have low computational complexity
18Proofs Deductive proofs Inductive proofs If-and-only-if proofs Proofs by contradictionProofs by counterexampleEtc.
19Deductive ProofsA chain of statements implying each the next one, leading from the first one (hypothesis) to the last (thesis or conclusion)For integer x = 4 or higher 2x is not smaller than x2Try for few values of parameter x, e.g., x=4 or x=6What happens to the left side and right side when x becomes larger than 4?Left side doubles with unit increase,right side grows by not more than [(x+1)/x]2 , which is for x=4Exercise 1: generalize to non-integersExercise 2: give an inductive proof (see next)
20Inductive ProofsProve a basis statement and an inductive step providing a propagation ruleLet S(n) be a statement about integer nBasis: prove S(i) for some fixed value iInductive step: prove that for any m > i – 1, S(m) implies S(m+1)
21Inductive ProofsProve a basis statement and an inductive step providing a propagation ruleLet S(n) be a statement about integer nBasis: prove S(i) for some fixed value iInductive step: prove for m > i-1 S(m) implies S(m+1)E.g.1, prove that for any positive n the sum of the first n integers equals n(n+1)/2 (btw did you know how Pitagoras did it?)E.g. 2 Let a binary tree be defined as ‘a single node or a node with having two trees as its children . Prove that any binary tree with n leaves (nodes without children) has precisely n-1 internal nodes (nodes with children)
22The structure of Inductive Proofs Prove the basis statement : check the validity of the claim for initial values of the parameterProve inductive step :assume statement is true for all values of the parameter up to n-1 providing a propagation ruleTake instance associated with value nDecompose this instance into instances involving smaller values of the parameterForce inductive hypothesis on these instancesRe-assemble the instance for value nStrange things happen when we are not carefulE.g.: for any positive n, all horses in a group of n have the same mantel
23Additional Proofs Proofs by contradiction Assume the opposite of hypothesis, show thesis cannot followProofs by counterexampleAll primes are odd – Exhibit the even prime 2(are there also proofs ‘’by example’’?)If-then-else proofs
24Automata Finite Automata model many design and analysis tasks, e.g. Lexical analyzer in a compilerDigital cicuit designKeywork searching in texts or on the web.Software for verifying finite state systems,such as communication protocols.Etc.