Formal Languages Languages: English, Spanish,... PASCAL, C,... Problem: How do we define a language? i.e. what sentences belong to a language? e.g.Large.

Slides:



Advertisements
Similar presentations
Recognising Languages We will tackle the problem of defining languages by considering how we could recognise them. Problem: Is there a method of recognising.
Advertisements

CS3012 Formal Languages and Compilers Frank Guerin Room 227 Lectures Monday11:00MT3 Tuesday9:00105 St. Marys Tutorials Thursday13:00 Thursday 14:00definitely.
Why empty strings? A bit like zero –you may think you can do without –but it makes definitions & calculations easier Definitions: –An alphabeth is a finite.
Recognising Languages We will tackle the problem of defining languages by considering how we could recognise them. Problem: Is there a method of recognising.
Properties of Regular Languages
Natural Language Processing - Formal Language - (formal) Language (formal) Grammar.
Deterministic Finite Automata (DFA)
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 3 School of Innovation, Design and Engineering Mälardalen University 2012.
COMP-421 Compiler Design Presented by Dr Ioanna Dionysiou.
YES-NO machines Finite State Automata as language recognizers.
1 Languages. 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet: Languages.
Finite Automata Great Theoretical Ideas In Computer Science Anupam Gupta Danny Sleator CS Fall 2010 Lecture 20Oct 28, 2010Carnegie Mellon University.
Lexical Analysis III Recognizing Tokens Lecture 4 CS 4318/5331 Apan Qasem Texas State University Spring 2015.
1 Lecture 4: Formal Definition of Solvability Analysis of decision problems –Two types of inputs:yes inputs and no inputs –Language recognition problem.
1 CSCI-2400 Models of Computation. 2 Computation CPU memory.
Regular Languages Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 3 Comments, additions and modifications.
CS 310 – Fall 2006 Pacific University CS310 Strings, String Operators, and Languages Sections: August 30, 2006.
Regular Languages Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 3 Comments, additions and modifications.
1 Languages and Finite Automata or how to talk to machines...
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
1 Module 4: Formal Definition of Solvability Analysis of decision problems –Two types of inputs:yes inputs and no inputs –Language recognition problem.
CS 3240 – Chuck Allison.  A model of computation  A very simple, manual computer (we draw pictures!)  Our machines: automata  1) Finite automata (“finite-state.
Topics Automata Theory Grammars and Languages Complexities
Fall 2006Costas Busch - RPI1 Languages. Fall 2006Costas Busch - RPI2 Language: a set of strings String: a sequence of symbols from some alphabet Example:
Lecture 1 String and Language. String string is a finite sequence of symbols. For example, string ( s, t, r, i, n, g) CS4384 ( C, S, 4, 3, 8) (1,
Great Theoretical Ideas in Computer Science.
Regular Languages A language is regular over  if it can be built from ;, {  }, and { a } for every a 2 , using operators union ( [ ), concatenation.
Chapter 2 Languages.
CS490 Presentation: Automata & Language Theory Thong Lam Ran Shi.
CS/IT 138 THEORY OF COMPUTATION Chapter 1 Introduction to the Theory of Computation.
CSC312 Automata Theory Lecture # 2 Languages.
CSC312 Automata Theory Lecture # 2 Languages.
Costas Busch - LSU1 Languages. Costas Busch - LSU2 Language: a set of strings String: a sequence of symbols from some alphabet Example: Strings: cat,
Lecture Two: Formal Languages Formal Languages, Lecture 2, slide 1 Amjad Ali.
Introduction to Theory of Automata
1 Strings and Languages. 2 Review Sets and sequences Functions and relations Graphs Boolean logic:      Proof techniques: – Construction, Contradiction,
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
MA/CSSE 474 Theory of Computation Functions, Closure, Decision Problems.
1 Chapter 1 Introduction to the Theory of Computation.
Mathematical Preliminaries (Hein 1.1 and 1.2) Sets are collections in which order of elements and duplication of elements do not matter. – {1,a,1,1} =
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 2 Mälardalen University 2006.
Great Theoretical Ideas in Computer Science.
1 Languages. 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet:
Strings and Languages CS 130: Theory of Computation HMU textbook, Chapter 1 (Sec 1.5)
CS 203: Introduction to Formal Languages and Automata
Recognising Languages We will tackle the problem of defining languages by considering how we could recognise them. Problem: Is there a method of recognising.
Deterministic Finite Automata COMPSCI 102 Lecture 2.
Strings and Languages Denning, Section 2.7. Alphabet An alphabet V is a finite nonempty set of symbols. Each symbol is a non- divisible or atomic object.
Theory of computation Introduction theory of computation: It comprises the fundamental mathematical properties of computer hardware, software,
Great Theoretical Ideas in Computer Science for Some.
Introduction Why do we study Theory of Computation ?
Finite Automata Great Theoretical Ideas In Computer Science Victor Adamchik Danny Sleator CS Spring 2010 Lecture 20Mar 30, 2010Carnegie Mellon.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
Set, Alphabets, Strings, and Languages. The regular languages. Clouser properties of regular sets. Finite State Automata. Types of Finite State Automata.
Akram Salah ISSR Basic Concepts Languages Grammar Automata (Automaton)
MA/CSSE 474 Theory of Computation Languages, prefixes, sets, cardinality, functions.
Languages and Strings Chapter 2. (1) Lexical analysis: Scan the program and break it up into variable names, numbers, etc. (2) Parsing: Create a tree.
Alphabet, String, Language. 2 Alphabet and Strings An alphabet is a finite, non-empty set of symbols. –Denoted by  –{ 0, 1 } is a binary alphabet. –{
Languages.
Lecture 1 Theory of Automata
CIS Automata and Formal Languages – Pei Wang
Languages Prof. Busch - LSU.
Languages Costas Busch - LSU.
Natural Language Processing - Formal Language -
Languages, prefixes, sets, cardinality, functions
Languages, prefixes, sets, cardinality, functions
Chapter 1 Introduction to the Theory of Computation
CSC312 Automata Theory Lecture # 2 Languages.
Languages Fall 2018.
What is it? The term "Automata" is derived from the Greek word "αὐτόματα" which means "self-acting". An automaton (Automata in plural) is an abstract self-propelled.
Presentation transcript:

Formal Languages Languages: English, Spanish,... PASCAL, C,... Problem: How do we define a language? i.e. what sentences belong to a language? e.g.Large red cars go quickly. Colourless green ideas sleep furiously. Cars red large go quickly. Coches rojos grandes marchan rapidamente. Formal languages: Languages with a well-defined membership, usually based solely on the form of the sentences.

Alphabets and Strings: Definitions A symbol is a basic unit. g, 5, 1 and $ can be used as symbols A string over an alphabet T is a finite sequence of symbols from T. Also called T-string, or simply string. aZb, 45637, , aabababba The empty string is the string with no symbols, denoted by. An alphabet is a finite set of symbols. {a, b, c, d, e,..., z, A, B,..., Z} {0,1,2,3,4,5,6,7,8,9} {0,1} {a,b}

Definitions (cont.) The length of a string, w, is the number of symbols in the sequence, denoted |w|. |4732| = 4, |abbca| = 5 Two strings, w and v are equal if they have exactly the same sequence of symbols. The concatenation of two strings, w and v, is the sequence of symbols in w followed by the sequence of symbols in v. Denoted wv. w = abb, v = bab, wv = abbbab. w = w. Note: concatenation is not commutative: wv need not equal vw. Concatenation is associative: w(vu) = (wv)u.

Definitions (cont.) A string u is a substring of w if there exist other strings x and y s.t. w = xuy. ab is a substring of babba. Note:  is a substring of every string. If u is a substring of w, and x above is, then u is a prefix of w. If u  w, then u is a proper prefix. ba is a prefix of babba. If u is a substring of w, and y above is, then u is a suffix of w. If u  w, then u is a proper suffix. bba is a suffix of babba.

Definitions (cont.) If T is an alphabet, then T* is the set of all strings over T. T + is T* without T = {a,b}, T* = {,a, b, aa, ab, bb, ba, aaa,...} If a is a symbol, then a n is the string of n a's a 3 = aaa a* = {, a, aa, aaa,...} a + = {a, aa, aaa,...} Note: a n a m = a n+m. A language over an alphabet T is a set of strings over T. Also called a T-language, or simply a language. T = {a,b}, then {, ab, babba, bbbbbbb} is a T-language Note: L is a T-language iff L  T*

Language Operations A+B is the set union of A and B A  B is the set intersection of A and B A' is the complement of A - i.e. all strings in T* but not in A. AB is the concatenation of A and B - i.e. all strings uv where u  A and v  B Note: associative, but not commutative. Let A and B be languages over T. A n is the concatenation of A with itself n times. Note: A 0 = { }.

Some simple theorems A* = A 0 + A 1 + A (A*)* = A* A + = A 1 + A A* is called the Kleene Closure of A.

Orderings Let T be an alphabet with a given ordering on its symbols. Say T = {a, b, c, d,...}. Strings over T can be ordered in two ways: Dictionary Order All strings beginning a are ordered before all strings beginning b, and b before c, etc. Within groups of strings beginning with the same symbol, strings are ordered by their second symbol, and so on. is always the first string. Lexical Order Strings are ordered by their length, with the shortest first. Within groups of strings of the same length, strings are ordered in dictionary order. is always the first string.

Specifying Languages L 1 = {x n : n = 1, 2, 3,...} What elements are in L 1 ? L 2 = {x n : n = 1, 4, 9, 16,...} What elements are in L 2 ? L 3 = {x n : n = 1,4, 9, 48,...} What elements are in L 3 ? Problem: Devise a clear and precise method for defining infinite languages.

Languages and Machines Languages represent problems Machines find solutions Given a Question: How to Find the Answer?  Yes/no – decision problem E.g., “Is this a prime number?”  Function problems, E.g., “What is the square of this number?” Given a Problem: How to Work Out the Solution?  E.g., the best move in a chess game Given a Task: How to Achieve it?  How to get out of a maze  How to drive a car through an obstacle course  How to carry on a conversation?

Languages and Machines Some of these problems are very hard... Languages are as useful as numbers – It appears that a language can describe any problem (though this cannot be proved). A class of languages is a useful abstraction for a class of problems. Maths is all about abstraction (e.g. a number is an abstraction) If you think about problems abstractly you can see solutions you might otherwise miss, you can see equivalent/related problems

Recognising Languages We will tackle the problem of defining languages by considering how we could recognise them. Problem: Is there a method of recognising infinite languages? i.e. given a language description and a string, is there an algorithm which will answer yes or no correctly? We will define an abstract machine which takes a candidate string and produces the answer yes or no. The abstract machine will be the specification of the language.

Finite State Automata A finite state automaton is an abstract model of a simple machine (or computer). The machine can be in a finite number of states. It receives symbols as input, and the result of receiving a particular input in a particular state moves the machine to a specified new state. Certain states are finishing states, and if the machine is in one of those states when the input ends, it has ended successfully (or has accepted the input). Example: A a b b b a a a,b