G52LAC Languages and Computation Lecture 1

Similar documents
Language properties and Grammar of Parallel and Series Parallel Languages

A Version Space Approach to Learning Context-free Grammars

Informatics 2A: Language Complexity and the. Inf2A: Chomsky Hierarchy

A General Class of Noncontext Free Grammars Generating Context Free Languages

A R "! I,,, !~ii ii! A ow ' r.-ii ' i ' JA' V5, 9. MiN, ;

Syntax Parsing 1. Grammars and parsing 2. Top-down and bottom-up parsing 3. Chart parsers 4. Bottom-up chart parsing 5. The Earley Algorithm

Grammars & Parsing, Part 1:

Erkki Mäkinen State change languages as homomorphic images of Szilard languages

COMPUTATIONAL COMPLEXITY OF LEFT-ASSOCIATIVE GRAMMAR

MOODLE 2.0 GLOSSARY TUTORIALS

Self Study Report Computer Science

Proof Theory for Syntacticians

Getting Started with Deliberate Practice

Diagnostic Test. Middle School Mathematics

Statewide Framework Document for:

RANKING AND UNRANKING LEFT SZILARD LANGUAGES. Erkki Mäkinen DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF TAMPERE REPORT A ER E P S I M S

Enumeration of Context-Free Languages and Related Structures

CS177 Python Programming

Backwards Numbers: A Study of Place Value. Catherine Perez

The Strong Minimalist Thesis and Bounded Optimality

Natural Language Processing. George Konidaris

CS 101 Computer Science I Fall Instructor Muller. Syllabus

IT Students Workshop within Strategic Partnership of Leibniz University and Peter the Great St. Petersburg Polytechnic University

arxiv: v1 [math.at] 10 Jan 2016

A Grammar for Battle Management Language

Telekooperation Seminar

OCR for Arabic using SIFT Descriptors With Online Failure Prediction

School of Innovative Technologies and Engineering

Grade 6: Correlated to AGS Basic Math Skills

Lecture 10: Reinforcement Learning

Foothill College Summer 2016

CS 1103 Computer Science I Honors. Fall Instructor Muller. Syllabus

Computer Organization I (Tietokoneen toiminta)

Navigating the PhD Options in CMS

Parsing of part-of-speech tagged Assamese Texts

PRODUCT PLATFORM DESIGN: A GRAPH GRAMMAR APPROACH

We are strong in research and particularly noted in software engineering, information security and privacy, and humane gaming.

MASTER OF SCIENCE (M.S.) MAJOR IN COMPUTER SCIENCE

Chinese Language Parsing with Maximum-Entropy-Inspired Parser

MTH 141 Calculus 1 Syllabus Spring 2017

On the Polynomial Degree of Minterm-Cyclic Functions

CS4491/CS 7265 BIG DATA ANALYTICS INTRODUCTION TO THE COURSE. Mingon Kang, PhD Computer Science, Kennesaw State University

Probability and Game Theory Course Syllabus

Mathematics. Mathematics

Empiricism as Unifying Theme in the Standards for Mathematical Practice. Glenn Stevens Department of Mathematics Boston University

FONDAMENTI DI INFORMATICA

NAME: East Carolina University PSYC Developmental Psychology Dr. Eppler & Dr. Ironsmith

11/29/2010. Statistical Parsing. Statistical Parsing. Simple PCFG for ATIS English. Syntactic Disambiguation

CS 100: Principles of Computing

Detecting English-French Cognates Using Orthographic Edit Distance

a) analyse sentences, so you know what s going on and how to use that information to help you find the answer.

Module 12. Machine Learning. Version 2 CSE IIT, Kharagpur

Android App Development for Beginners

Spring 2016 Stony Brook University Instructor: Dr. Paul Fodor

Characterizing Mathematical Digital Literacy: A Preliminary Investigation. Todd Abel Appalachian State University

The open source development model has unique characteristics that make it in some

Lecture 1: Machine Learning Basics

Course Content Concepts

THE UNIVERSITY OF SYDNEY Semester 2, Information Sheet for MATH2068/2988 Number Theory and Cryptography

Basic Parsing with Context-Free Grammars. Some slides adapted from Julia Hirschberg and Dan Jurafsky 1

Computer Science is more important than Calculus: The challenge of living up to our potential

CS 598 Natural Language Processing

B. How to write a research paper

Data Structures and Algorithms

Developing a TT-MCTAG for German with an RCG-based Parser

PH.D. IN COMPUTER SCIENCE PROGRAM (POST M.S.)

IAT 888: Metacreation Machines endowed with creative behavior. Philippe Pasquier Office 565 (floor 14)

A Case Study: News Classification Based on Term Frequency

Notes on The Sciences of the Artificial Adapted from a shorter document written for course (Deciding What to Design) 1

Business Analytics and Information Tech COURSE NUMBER: 33:136:494 COURSE TITLE: Data Mining and Business Intelligence

OPTIMIZATINON OF TRAINING SETS FOR HEBBIAN-LEARNING- BASED CLASSIFIERS

CUSTOMER EXPERIENCE ASSESSMENT SALES (CEA-S) TEST GUIDE

Graduate Handbook Linguistics Program For Students Admitted Prior to Academic Year Academic year Last Revised March 16, 2015

Software Maintenance

Context Free Grammars. Many slides from Michael Collins

Learning to Think Mathematically With the Rekenrek

Welcome to the Purdue OWL. Where do I begin? General Strategies. Personalizing Proofreading

MBA 5652, Research Methods Course Syllabus. Course Description. Course Material(s) Course Learning Outcomes. Credits.

Course outline. Code: LFS303 Title: Pathophysiology

DEVM F105 Intermediate Algebra DEVM F105 UY2*2779*

systems have been developed that are well-suited to phenomena in but is properly contained in the indexed languages. We give a

University of Groningen. Systemen, planning, netwerken Bosman, Aart

AQUA: An Ontology-Driven Question Answering System

Aviation English Training: How long Does it Take?

GRADUATE PROGRAM Department of Materials Science and Engineering, Drexel University Graduate Advisor: Prof. Caroline Schauer, Ph.D.

Evolution of Collective Commitment during Teamwork

ENGBG1 ENGBL1 Campus Linguistics. Meeting 2. Chapter 7 (Morphology) and chapter 9 (Syntax) Pia Sundqvist

PREP S SPEAKER LISTENER TECHNIQUE COACHING MANUAL

How to set up gradebook categories in Moodle 2.

DMA CLUSTER CALCULATIONS POLICY

TU-E2090 Research Assignment in Operations Management and Services

"f TOPIC =T COMP COMP... OBJ

Lecture 1: Basic Concepts of Machine Learning

Multimedia Application Effective Support of Education

CAN PICTORIAL REPRESENTATIONS SUPPORT PROPORTIONAL REASONING? THE CASE OF A MIXING PAINT PROBLEM

CX 105/205/305 Greek Language 2017/18

Timeline. Recommendations

OFFICE SUPPORT SPECIALIST Technical Diploma

Short vs. Extended Answer Questions in Computer Science Exams

Graduate Program in Education

Transcription:

G52LAC Languages and Computation Lecture 1 Administrative Details and Introduction Venanzio Capretta and Henrik Nilsson University of Nottingham G52LACLanguages and ComputationLecture 1 p.1/35

Finding People and Information Venanzio Capretta Room B83 Henrik Nilsson Room A08 Moodle Main module web page: www.cs.nott.ac.uk/~nhn/g52lac Moodle forum! G52LACLanguages and ComputationLecture 1 p.2/35

Aims of the Course G52LACLanguages and ComputationLecture 1 p.3/35

Aims of the Course To familiarize you with key Computer Science concepts in central areas: - Automata Theory - Formal Languages - Models of Computation - Complexity Theory G52LACLanguages and ComputationLecture 1 p.3/35

Aims of the Course To familiarize you with key Computer Science concepts in central areas: - Automata Theory - Formal Languages - Models of Computation - Complexity Theory To equip you with tools with wide applicability in the fields of CS and IT. G52LACLanguages and ComputationLecture 1 p.3/35

Aims of the Course To familiarize you with key Computer Science concepts in central areas: - Automata Theory - Formal Languages - Models of Computation - Complexity Theory To equip you with tools with wide applicability in the fields of CS and IT. Draws from: G51MCS Feeds into: G53CMP, G53COM, G54FOP G52LACLanguages and ComputationLecture 1 p.3/35

Organization (1) Lectures: - Two 1 h lectures per week. - Detailed but provisional schedule available on the module web page. G52LACLanguages and ComputationLecture 1 p.4/35

Organization (1) Lectures: - Two 1 h lectures per week. - Detailed but provisional schedule available on the module web page. Coursework: - 4 problem sets. - Made available via the module web page. - Best 3 counts. - Deadlines: 21/2, 21/3, 26/4, 9/5. - Released a week prior to submission deadline. G52LACLanguages and ComputationLecture 1 p.4/35

Organization (2) Assessment: - Coursework, 25 % - 2 hour written examination, 75 % G52LACLanguages and ComputationLecture 1 p.5/35

Organization (2) Assessment: - Coursework, 25 % - 2 hour written examination, 75 % However, resits are by 100 % written examination (standard School policy) G52LACLanguages and ComputationLecture 1 p.5/35

Literature (1) Main reference: John E. Hopcroft, Rajeev Motwani, & Jeffrey D. Ullman. Introduction to Automata Theory, Languages, and Computation, 3rd edition, Pearson, 2007. G52LACLanguages and ComputationLecture 1 p.6/35

Literature (1) Main reference: John E. Hopcroft, Rajeev Motwani, & Jeffrey D. Ullman. Introduction to Automata Theory, Languages, and Computation, 3rd edition, Pearson, 2007. Alternative/complement: Linz. An Introduction to Formal Languages and Automata, 6th edition, Jones & Bartlett Publishers, 2017. G52LACLanguages and ComputationLecture 1 p.6/35

Literature (1) Main reference: John E. Hopcroft, Rajeev Motwani, & Jeffrey D. Ullman. Introduction to Automata Theory, Languages, and Computation, 3rd edition, Pearson, 2007. Alternative/complement: Linz. An Introduction to Formal Languages and Automata, 6th edition, Jones & Bartlett Publishers, 2017. The lecture notes by Altenkirch, Nilsson, Capretta, 30 Jan. 2018 Available via the G52LAC module page. G52LACLanguages and ComputationLecture 1 p.6/35

Literature (2) Supplementary material; e.g., slides, sample program code. (Available via the G52LAC module page.) G52LACLanguages and ComputationLecture 1 p.7/35

Literature (2) Supplementary material; e.g., slides, sample program code. (Available via the G52LAC module page.) Your own notes from the lectures! G52LACLanguages and ComputationLecture 1 p.7/35

Literature (2) Supplementary material; e.g., slides, sample program code. (Available via the G52LAC module page.) Your own notes from the lectures! The lecture schedule contains detailed lecture-by-lecture references to the literature. G52LACLanguages and ComputationLecture 1 p.7/35

Literature (3) G52LACLanguages and ComputationLecture 1 p.8/35

The Lecture Notes G52LACLanguages and ComputationLecture 1 p.9/35

The Lecture Notes Comprehensive, typeset lecture notes. (At present 156 pages.) G52LACLanguages and ComputationLecture 1 p.9/35

The Lecture Notes Comprehensive, typeset lecture notes. (At present 156 pages.) Carefully aligned with the lectures. G52LACLanguages and ComputationLecture 1 p.9/35

The Lecture Notes Comprehensive, typeset lecture notes. (At present 156 pages.) Carefully aligned with the lectures. Covers everything said in the lectures (and more). G52LACLanguages and ComputationLecture 1 p.9/35

The Lecture Notes Comprehensive, typeset lecture notes. (At present 156 pages.) Carefully aligned with the lectures. Covers everything said in the lectures (and more). New for this year: Exercises with detailed model solutions. (In response to student feedback.) G52LACLanguages and ComputationLecture 1 p.9/35

The Lecture Notes Comprehensive, typeset lecture notes. (At present 156 pages.) Carefully aligned with the lectures. Covers everything said in the lectures (and more). New for this year: Exercises with detailed model solutions. (In response to student feedback.) The exercises are quite similar to typical coursework problems. G52LACLanguages and ComputationLecture 1 p.9/35

Your Own Notes You are strongly encourage to take your own notes as well during lectures because: G52LACLanguages and ComputationLecture 1 p.10/35

Your Own Notes You are strongly encourage to take your own notes as well during lectures because: Lectures may provide an alternative perspective, use different examples, etc. G52LACLanguages and ComputationLecture 1 p.10/35

Your Own Notes You are strongly encourage to take your own notes as well during lectures because: Lectures may provide an alternative perspective, use different examples, etc. Research shows that note taking significantly aids learning. G52LACLanguages and ComputationLecture 1 p.10/35

Your Own Notes You are strongly encourage to take your own notes as well during lectures because: Lectures may provide an alternative perspective, use different examples, etc. Research shows that note taking significantly aids learning. Taking relevant notes is a lot easier if you familiarise yourself with the relevant parts of the typeset lecture notes prior to each lecture! G52LACLanguages and ComputationLecture 1 p.10/35

Content (1) G52LACLanguages and ComputationLecture 1 p.11/35

Content (1) The notion of a formal language G52LACLanguages and ComputationLecture 1 p.11/35

Content (1) The notion of a formal language Description of different classes of languages: - Regular expressions - Grammars G52LACLanguages and ComputationLecture 1 p.11/35

Content (1) The notion of a formal language Description of different classes of languages: - Regular expressions - Grammars Recognition of different classes of languages: - Finite Automata - Push Down Automata G52LACLanguages and ComputationLecture 1 p.11/35

Content (1) The notion of a formal language Description of different classes of languages: - Regular expressions - Grammars Recognition of different classes of languages: - Finite Automata - Push Down Automata Applications: Scanning and Parsing G52LACLanguages and ComputationLecture 1 p.11/35

Content (2) Leading to: G52LACLanguages and ComputationLecture 1 p.12/35

Content (2) Leading to: General notions of computation: - Turing machines - Lambda calculus G52LACLanguages and ComputationLecture 1 p.12/35

Content (2) Leading to: General notions of computation: - Turing machines - Lambda calculus Fundamental questions such as - What can be computed at all? - What can be computed efficiently? G52LACLanguages and ComputationLecture 1 p.12/35

Example: Languages and Grammars (1) Consider the following Java fragment: class Foo { int n; void printnsqrd() { System.out.println(n * n); } } G52LACLanguages and ComputationLecture 1 p.13/35

Example: Languages and Grammars (1) Consider the following Java fragment: class Foo { int n; void printnsqrd() { System.out.println(n * n); } } Fundamentally a string of characters. G52LACLanguages and ComputationLecture 1 p.13/35

Example: Languages and Grammars (1) Consider the following Java fragment: class Foo { int n; void printnsqrd() { System.out.println(n * n); } } Fundamentally a string of characters. But lots of structure to valid Java code, e.g.: - Keywords, identifiers, operators - Nesting; e.g. method inside class G52LACLanguages and ComputationLecture 1 p.13/35

Example: Languages and Grammars (2) How to describe the set of strings that are valid Java? G52LACLanguages and ComputationLecture 1 p.14/35

Example: Languages and Grammars (2) How to describe the set of strings that are valid Java? Given a string, how to determine if it is a valid Java program or not? G52LACLanguages and ComputationLecture 1 p.14/35

Example: Languages and Grammars (2) How to describe the set of strings that are valid Java? Given a string, how to determine if it is a valid Java program or not? How to recover the structure of a Java program from a flat string? G52LACLanguages and ComputationLecture 1 p.14/35

Example: Languages and Grammars (2) How to describe the set of strings that are valid Java? Given a string, how to determine if it is a valid Java program or not? How to recover the structure of a Java program from a flat string? We will study: G52LACLanguages and ComputationLecture 1 p.14/35

Example: Languages and Grammars (2) How to describe the set of strings that are valid Java? Given a string, how to determine if it is a valid Java program or not? How to recover the structure of a Java program from a flat string? We will study: Regular expressions and grammars: precise descriptions of languages. G52LACLanguages and ComputationLecture 1 p.14/35

Example: Languages and Grammars (2) How to describe the set of strings that are valid Java? Given a string, how to determine if it is a valid Java program or not? How to recover the structure of a Java program from a flat string? We will study: Regular expressions and grammars: precise descriptions of languages. Various kinds of automata: decide if a string belongs to a language or not. G52LACLanguages and ComputationLecture 1 p.14/35

Noam Chomsky (1) Noam Chomsky (1928 ): G52LACLanguages and ComputationLecture 1 p.15/35

Noam Chomsky (1) Noam Chomsky (1928 ): American linguist who introduced Context Free Grammars in an attempt to describe natural languages formally. G52LACLanguages and ComputationLecture 1 p.15/35

Noam Chomsky (1) Noam Chomsky (1928 ): American linguist who introduced Context Free Grammars in an attempt to describe natural languages formally. Also introduced the Chomsky Hierarchy which classifies grammars and languages and their descriptive power. G52LACLanguages and ComputationLecture 1 p.15/35

Noam Chomsky (2) G52LACLanguages and ComputationLecture 1 p.16/35

The Chomsky Hierarchy All languages Type 0 or recursively enumerable languages Decidable languages Turing machines Type 1 or context sensitive languages Type 2 or context free languages pushdown automata Type 3 or regular languages finite automata G52LACLanguages and ComputationLecture 1 p.17/35

Example: The Halting Problem (1) Consider the following program. Does it terminate for all values ofn 1? while (n > 1) { if even(n) { n = n / 2; } else { n = n * 3 + 1; } } G52LACLanguages and ComputationLecture 1 p.18/35

Example: The Halting Problem (2) Not as easy to answer as it might first seem. G52LACLanguages and ComputationLecture 1 p.19/35

Example: The Halting Problem (2) Not as easy to answer as it might first seem. Say we start withn=7, for example: 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1 G52LACLanguages and ComputationLecture 1 p.19/35

Example: The Halting Problem (2) Not as easy to answer as it might first seem. Say we start withn=7, for example: 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1 The sequence involved is known as the hailstone sequence and Collatz conjecture says that the number 1 will always be reached. G52LACLanguages and ComputationLecture 1 p.19/35

Example: The Halting Problem (2) Not as easy to answer as it might first seem. Say we start withn=7, for example: 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1 The sequence involved is known as the hailstone sequence and Collatz conjecture says that the number 1 will always be reached. In fact, for all numbers that have been tried (up to 2 60!), it does terminate... G52LACLanguages and ComputationLecture 1 p.19/35

Example: The Halting Problem (2) Not as easy to answer as it might first seem. Say we start withn=7, for example: 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1 The sequence involved is known as the hailstone sequence and Collatz conjecture says that the number 1 will always be reached. In fact, for all numbers that have been tried (up to 2 60!), it does terminate...... but so far, no proof! (See e.g. Wikipedia.) G52LACLanguages and ComputationLecture 1 p.19/35

Example: The Halting Problem (3) The following important decidability result should then perhaps not come as a total surprise: G52LACLanguages and ComputationLecture 1 p.20/35

Example: The Halting Problem (3) The following important decidability result should then perhaps not come as a total surprise: It is impossible to write a program that decides if another, arbitrary, program terminates (halts) or not. G52LACLanguages and ComputationLecture 1 p.20/35

Example: The Halting Problem (3) The following important decidability result should then perhaps not come as a total surprise: It is impossible to write a program that decides if another, arbitrary, program terminates (halts) or not. This was first proved by the British mathematician Alan Turing using Turing Machines. G52LACLanguages and ComputationLecture 1 p.20/35

Alan Turing (1) Alan Turing (1912 1954): G52LACLanguages and ComputationLecture 1 p.21/35

Alan Turing (1) Alan Turing (1912 1954): Introduced an abstract model of computation, Turing Machines (1936), to give a precice definition of what problems are effectively calculable (can be solved mechanically). G52LACLanguages and ComputationLecture 1 p.21/35

Alan Turing (1) Alan Turing (1912 1954): Introduced an abstract model of computation, Turing Machines (1936), to give a precice definition of what problems are effectively calculable (can be solved mechanically). Instrumental in the success of British code breaking efforts during WWII. G52LACLanguages and ComputationLecture 1 p.21/35

Alan Turing (1) Alan Turing (1912 1954): Introduced an abstract model of computation, Turing Machines (1936), to give a precice definition of what problems are effectively calculable (can be solved mechanically). Instrumental in the success of British code breaking efforts during WWII. PhD student of Alonzo Church G52LACLanguages and ComputationLecture 1 p.21/35

Alan Turing (2) G52LACLanguages and ComputationLecture 1 p.22/35

Example: theλ-calculus λ-calculus is a theory of pure functions: (λx.x)(λy.y) G52LACLanguages and ComputationLecture 1 p.23/35

Example: theλ-calculus λ-calculus is a theory of pure functions: (λx.x)(λy.y) Functional programming languages like Haskell implements the λ-calculus. G52LACLanguages and ComputationLecture 1 p.23/35

Example: theλ-calculus λ-calculus is a theory of pure functions: (λx.x)(λy.y) Functional programming languages like Haskell implements the λ-calculus. Both the Turing machine and the λ-calculus are universal models of computation: equivalent in capabilities. G52LACLanguages and ComputationLecture 1 p.23/35

Alonzo Church (1) Alonzo Church (1903 1995): Alan Turing s PhD advisor G52LACLanguages and ComputationLecture 1 p.24/35

Alonzo Church (1) Alonzo Church (1903 1995): Alan Turing s PhD advisor Introduced the λ-calculus (1936) to give a precise definition of what problems are effectively calculable. G52LACLanguages and ComputationLecture 1 p.24/35

Alonzo Church (1) Alonzo Church (1903 1995): Alan Turing s PhD advisor Introduced the λ-calculus (1936) to give a precise definition of what problems are effectively calculable. Church-Turing thesis: What is effectively calculable is exactly what can be computed by a Turing machine. G52LACLanguages and ComputationLecture 1 p.24/35

Alonzo Church (2) G52LACLanguages and ComputationLecture 1 p.25/35

Example: P versus NP (1) Can every problem whose solution can be checked quickly by a computer also be solved quickly by a computer? G52LACLanguages and ComputationLecture 1 p.26/35

Example: P versus NP (1) Can every problem whose solution can be checked quickly by a computer also be solved quickly by a computer? Likely the most famous open problem in computer science, dating back to the 1950s. G52LACLanguages and ComputationLecture 1 p.26/35

Example: P versus NP (1) Can every problem whose solution can be checked quickly by a computer also be solved quickly by a computer? Likely the most famous open problem in computer science, dating back to the 1950s. Quickly here means in time proportional to a polynomial in the size of the problem. G52LACLanguages and ComputationLecture 1 p.26/35

Example: P versus NP (1) Can every problem whose solution can be checked quickly by a computer also be solved quickly by a computer? Likely the most famous open problem in computer science, dating back to the 1950s. Quickly here means in time proportional to a polynomial in the size of the problem. There is an abundance of important problems where solutions can be checked quickly, but where the best known algorithm for finding a solution is exponential in the size of the problem. G52LACLanguages and ComputationLecture 1 p.26/35

Example: P versus NP (2) Subset sum problem: Does some non-empty subset of given set of integers sum to zero? G52LACLanguages and ComputationLecture 1 p.27/35

Example: P versus NP (2) Subset sum problem: Does some non-empty subset of given set of integers sum to zero? E.g. given {3, 2, 8, 5, 4, 9}, the non-empty subset { 5, 2, 3, 4} sums to 0. G52LACLanguages and ComputationLecture 1 p.27/35

Example: P versus NP (2) Subset sum problem: Does some non-empty subset of given set of integers sum to zero? E.g. given {3, 2, 8, 5, 4, 9}, the non-empty subset { 5, 2, 3, 4} sums to 0. Easy to check proposed solution: just add all numbers. G52LACLanguages and ComputationLecture 1 p.27/35

Example: P versus NP (2) Subset sum problem: Does some non-empty subset of given set of integers sum to zero? E.g. given {3, 2, 8, 5, 4, 9}, the non-empty subset { 5, 2, 3, 4} sums to 0. Easy to check proposed solution: just add all numbers. (How long would it take for set of size n?) G52LACLanguages and ComputationLecture 1 p.27/35

Example: P versus NP (2) Subset sum problem: Does some non-empty subset of given set of integers sum to zero? E.g. given {3, 2, 8, 5, 4, 9}, the non-empty subset { 5, 2, 3, 4} sums to 0. Easy to check proposed solution: just add all numbers. (How long would it take for set of size n?) But for finding a solution, no better way known than essentially trying each possible subset in turn. G52LACLanguages and ComputationLecture 1 p.27/35

Example: P versus NP (2) Subset sum problem: Does some non-empty subset of given set of integers sum to zero? E.g. given {3, 2, 8, 5, 4, 9}, the non-empty subset { 5, 2, 3, 4} sums to 0. Easy to check proposed solution: just add all numbers. (How long would it take for set of size n?) But for finding a solution, no better way known than essentially trying each possible subset in turn. (How long would it take for set of size n? How many subsets are there?) G52LACLanguages and ComputationLecture 1 p.27/35

Introduction to Languages The terms language and word are used in a strict technical sense in this course: G52LACLanguages and ComputationLecture 1 p.28/35

Introduction to Languages The terms language and word are used in a strict technical sense in this course: A language is a (possibly infinite) set of words. G52LACLanguages and ComputationLecture 1 p.28/35

Introduction to Languages The terms language and word are used in a strict technical sense in this course: A language is a (possibly infinite) set of words. A word is a finite sequence (or string) of symbols. G52LACLanguages and ComputationLecture 1 p.28/35

Introduction to Languages The terms language and word are used in a strict technical sense in this course: A language is a (possibly infinite) set of words. A word is a finite sequence (or string) of symbols. ǫ denotes the empty word, the sequence of zero symbols. G52LACLanguages and ComputationLecture 1 p.28/35

Introduction to Languages The terms language and word are used in a strict technical sense in this course: A language is a (possibly infinite) set of words. A word is a finite sequence (or string) of symbols. ǫ denotes the empty word, the sequence of zero symbols. The term string is often used interchangeably with the term word. G52LACLanguages and ComputationLecture 1 p.28/35

Symbols and Alphabets What is a symbol, then? G52LACLanguages and ComputationLecture 1 p.29/35

Symbols and Alphabets What is a symbol, then? Anything, but it has to come from an alphabet Σ which is a finite set. G52LACLanguages and ComputationLecture 1 p.29/35

Symbols and Alphabets What is a symbol, then? Anything, but it has to come from an alphabet Σ which is a finite set. A common (and important) instance is Σ = {0,1}. G52LACLanguages and ComputationLecture 1 p.29/35

Symbols and Alphabets What is a symbol, then? Anything, but it has to come from an alphabet Σ which is a finite set. A common (and important) instance is Σ = {0,1}. ǫ, the empty word, is never a symbol of an alphabet. G52LACLanguages and ComputationLecture 1 p.29/35

Languages: Examples alphabet Σ = {a,b} words? G52LACLanguages and ComputationLecture 1 p.30/35

Languages: Examples alphabet words Σ = {a,b} ǫ,a,b,aa,ab,ba,bb, G52LACLanguages and ComputationLecture 1 p.30/35

Languages: Examples alphabet words Σ = {a,b} ǫ,a,b,aa,ab,ba,bb, aaa,aab,aba,abb,baa,bab,... G52LACLanguages and ComputationLecture 1 p.30/35

Languages: Examples alphabet Σ = {a,b} words ǫ,a,b,aa,ab,ba,bb, aaa,aab,aba,abb,baa,bab,... languages? G52LACLanguages and ComputationLecture 1 p.30/35

Languages: Examples alphabet words languages Σ = {a,b} ǫ,a,b,aa,ab,ba,bb, aaa,aab,aba,abb,baa,bab,...,{ǫ},{a},{b},{a,aa}, G52LACLanguages and ComputationLecture 1 p.30/35

Languages: Examples alphabet words languages Σ = {a,b} ǫ,a,b,aa,ab,ba,bb, aaa,aab,aba,abb,baa,bab,...,{ǫ},{a},{b},{a,aa}, {ǫ,a,aa,aaa}, G52LACLanguages and ComputationLecture 1 p.30/35

Languages: Examples alphabet words languages Σ = {a,b} ǫ,a,b,aa,ab,ba,bb, aaa,aab,aba,abb,baa,bab,...,{ǫ},{a},{b},{a,aa}, {ǫ,a,aa,aaa}, {a n n 0}, G52LACLanguages and ComputationLecture 1 p.30/35

Languages: Examples alphabet words languages Σ = {a,b} ǫ,a,b,aa,ab,ba,bb, aaa,aab,aba,abb,baa,bab,...,{ǫ},{a},{b},{a,aa}, {ǫ,a,aa,aaa}, {a n n 0}, {a n b n n 0,neven} G52LACLanguages and ComputationLecture 1 p.30/35

Languages: Examples alphabet words languages Σ = {a,b} ǫ,a,b,aa,ab,ba,bb, aaa,aab,aba,abb,baa,bab,...,{ǫ},{a},{b},{a,aa}, {ǫ,a,aa,aaa}, {a n n 0}, {a n b n n 0,neven} Note the distinction between ǫ,, and {ǫ}! G52LACLanguages and ComputationLecture 1 p.30/35

All Words Over an Alphabet (1) Given an alphabet Σ we define the set Σ as set of words (or sequences) over Σ: The empty word ǫ Σ. given a symbol x Σ and a word w Σ, xw Σ. These are all elements in Σ. This is called an inductive definition. G52LACLanguages and ComputationLecture 1 p.31/35

All Words Over an Alphabet (1) Given an alphabet Σ we define the set Σ as set of words (or sequences) over Σ: The empty word ǫ Σ. given a symbol x Σ and a word w Σ, xw Σ. These are all elements in Σ. This is called an inductive definition. Is Σ always non-empty? G52LACLanguages and ComputationLecture 1 p.31/35

All Words Over an Alphabet (1) Given an alphabet Σ we define the set Σ as set of words (or sequences) over Σ: The empty word ǫ Σ. given a symbol x Σ and a word w Σ, xw Σ. These are all elements in Σ. This is called an inductive definition. Is Σ always non-empty? Always infinite? G52LACLanguages and ComputationLecture 1 p.31/35

All Words over an Alphabet (2) Example: Given Σ = {0,1}, some elements of Σ are ǫ (the empty word) 0, 1 00, 10, 01, 11 000, 100, 010, 110, 001, 101, 011, 111... G52LACLanguages and ComputationLecture 1 p.32/35

All Words over an Alphabet (2) Example: Given Σ = {0,1}, some elements of Σ are ǫ (the empty word) 0, 1 00, 10, 01, 11 000, 100, 010, 110, 001, 101, 011, 111... We are just applying the inductive definition. G52LACLanguages and ComputationLecture 1 p.32/35

All Words over an Alphabet (2) Example: Given Σ = {0,1}, some elements of Σ are ǫ (the empty word) 0, 1 00, 10, 01, 11 000, 100, 010, 110, 001, 101, 011, 111... We are just applying the inductive definition. Note: although there are infinitely many words in Σ (when Σ ), each word has a finite length! G52LACLanguages and ComputationLecture 1 p.32/35

Examples of Languages (1) Some examples of languages: G52LACLanguages and ComputationLecture 1 p.33/35

Examples of Languages (1) Some examples of languages: The set {0010,00000000,ǫ} is a language over Σ = {0,1}. G52LACLanguages and ComputationLecture 1 p.33/35

Examples of Languages (1) Some examples of languages: The set {0010,00000000,ǫ} is a language over Σ = {0,1}. This is an example of a finite language. G52LACLanguages and ComputationLecture 1 p.33/35

Examples of Languages (1) Some examples of languages: The set {0010,00000000,ǫ} is a language over Σ = {0,1}. This is an example of a finite language. The set of words with odd length over Σ = {1}. (Finite or infinite?) G52LACLanguages and ComputationLecture 1 p.33/35

Examples of Languages (1) Some examples of languages: The set {0010,00000000,ǫ} is a language over Σ = {0,1}. This is an example of a finite language. The set of words with odd length over Σ = {1}. (Finite or infinite?) The set of words that contain the same number of 0s and 1s is a language over Σ = {0,1}. (Finite or infinite?) G52LACLanguages and ComputationLecture 1 p.33/35

Examples of Languages (2) The set of palindromes (words that read the same forwards and backwards, likeabba) is a language for any alphabet. G52LACLanguages and ComputationLecture 1 p.34/35

Examples of Languages (2) The set of palindromes (words that read the same forwards and backwards, likeabba) is a language for any alphabet. The set of correct Java programs. This is a language over the set of UNICODE characters. G52LACLanguages and ComputationLecture 1 p.34/35

Examples of Languages (2) The set of palindromes (words that read the same forwards and backwards, likeabba) is a language for any alphabet. The set of correct Java programs. This is a language over the set of UNICODE characters. The set of programs that, if executed successfully on a Windows machine, prints the text Hello World! in a window. This is a language over Σ = {0,1}. G52LACLanguages and ComputationLecture 1 p.34/35

Language Membership Fundamental question for a language L: w L? G52LACLanguages and ComputationLecture 1 p.35/35

Language Membership Fundamental question for a language L: w L? L finite: G52LACLanguages and ComputationLecture 1 p.35/35

Language Membership Fundamental question for a language L: w L? L finite:? G52LACLanguages and ComputationLecture 1 p.35/35

Language Membership Fundamental question for a language L: w L? L finite: Easy! (Enumerate L and check) G52LACLanguages and ComputationLecture 1 p.35/35

Language Membership Fundamental question for a language L: w L? L finite: Easy! (Enumerate L and check) L infinite: G52LACLanguages and ComputationLecture 1 p.35/35

Language Membership Fundamental question for a language L: w L? L finite: Easy! (Enumerate L and check) L infinite:? G52LACLanguages and ComputationLecture 1 p.35/35

Language Membership Fundamental question for a language L: w L? L finite: Easy! (Enumerate L and check) L infinite:? We need: A finite (and preferably concise) formal description of L. G52LACLanguages and ComputationLecture 1 p.35/35

Language Membership Fundamental question for a language L: w L? L finite: Easy! (Enumerate L and check) L infinite:? We need: A finite (and preferably concise) formal description of L. An algorithmic method to decide if w L given a suitable description. G52LACLanguages and ComputationLecture 1 p.35/35

Language Membership Fundamental question for a language L: w L? L finite: Easy! (Enumerate L and check) L infinite:? We need: A finite (and preferably concise) formal description of L. An algorithmic method to decide if w L given a suitable description. Various approaches to achieve this will be key a theme throughout the module. G52LACLanguages and ComputationLecture 1 p.35/35