Lecture #2 Advanced Theory of Computation. Languages & Grammar Before discussing languages & grammar let us deal with some related issues. Alphabet: is.

Slides:



Advertisements
Similar presentations
Theory Of Automata By Dr. MM Alam
Advertisements

Natural Language Processing - Formal Language - (formal) Language (formal) Grammar.
Chapter Chapter Summary Languages and Grammars Finite-State Machines with Output Finite-State Machines with No Output Language Recognition Turing.
Regular Languages Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 3 Comments, additions and modifications.
Regular Languages Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 3 Comments, additions and modifications.
CS5371 Theory of Computation Lecture 1: Mathematics Review I (Basic Terminology)
79 Regular Expression Regular expressions over an alphabet  are defined recursively as follows. (1) Ø, which denotes the empty set, is a regular expression.
Topics Automata Theory Grammars and Languages Complexities
Syntactic Pattern Recognition Statistical PR:Find a feature vector x Train a system using a set of labeled patterns Classify unknown patterns Ignores relational.
Finite State Machines Data Structures and Algorithms for Information Processing 1.
Languages and Grammars MSU CSE 260. Outline Introduction: E xample Phrase-Structure Grammars: Terminology, Definition, Derivation, Language of a Grammar,
Languages & Strings String Operations Language Definitions.
Introduction Syntax: form of a sentence (is it valid) Semantics: meaning of a sentence Valid: the frog writes neatly Invalid: swims quickly mathematics.
Finite-State Machines with No Output
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.
Lecture Two: Formal Languages Formal Languages, Lecture 2, slide 1 Amjad Ali.
1 Regular Expressions. 2 Regular expressions describe regular languages Example: describes the language.
Languages, Grammars, and Regular Expressions Chuck Cusack Based partly on Chapter 11 of “Discrete Mathematics and its Applications,” 5 th edition, by Kenneth.
Grammars CPSC 5135.
Chapter 9. Section 9.1 Binary Relations Definition: A binary relation R from a set A to a set B is a subset R ⊆ A × B. Example: Let A = { 0, 1,2 } and.
1 Computability Five lectures. Slides available from my web page There is some formality, but it is gentle,
Introduction to Language Theory
Computabilty Computability Finite State Machine. Regular Languages. Homework: Finish Craps. Next Week: On your own: videos +
Discrete Mathematical Structures 4 th Edition Kolman, Busby, Ross © 2000 by Prentice-Hall, Inc. ISBN
Overview of Previous Lesson(s) Over View  Symbol tables are data structures that are used by compilers to hold information about source-program constructs.
CSC312 Automata Theory Lecture # 26 Chapter # 12 by Cohen Context Free Grammars.
UNIT - I Formal Language and Regular Expressions: Languages Definition regular expressions Regular sets identity rules. Finite Automata: DFA NFA NFA with.
Theory of computation Introduction theory of computation: It comprises the fundamental mathematical properties of computer hardware, software,
Mathematical Foundations of Computer Science Chapter 3: Regular Languages and Regular Grammars.
Transparency No. 2-1 Formal Language and Automata Theory Homework 2.
CS 154 Formal Languages and Computability February 11 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron.
Akram Salah ISSR Basic Concepts Languages Grammar Automata (Automaton)
Chapter 2. Formal Languages Dept. of Computer Engineering, Hansung University, Sung-Dong Kim.
  An alphabet is any finite set of symbols.  Examples: ASCII, Unicode, {0,1} ( binary alphabet ), {a,b,c}. Alphabets.
Chapter 1 INTRODUCTION TO THE THEORY OF COMPUTATION.
Topic 3: Automata Theory 1. OutlineOutline Finite state machine, Regular expressions, DFA, NDFA, and their equivalence, Grammars and Chomsky hierarchy.
Theory of Languages and Automata By: Mojtaba Khezrian.
Modeling Arithmetic, Computation, and Languages Mathematical Structures for Computer Science Chapter 8 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesAlgebraic.
CS314 – Section 5 Recitation 2
Theory of Computation Lecture #
BCT 2083 DISCRETE STRUCTURE AND APPLICATIONS
Generalized Transition Graphs
Context-Free Grammars: an overview
Lecture 1 Theory of Automata
CIS Automata and Formal Languages – Pei Wang
Complexity and Computability Theory I
Natural Language Processing - Formal Language -
Mathematical Notions and Terminology
Formal Language Theory
Lecture 9 Theory of AUTOMATA
[Week#03,04] (b) - Finite Automata
Context-Free Languages
REGULAR LANGUAGES AND REGULAR GRAMMARS
Regular Grammar.
Chapter 7 Regular Grammars
Review: Compiler Phases:
COSC 3340: Introduction to Theory of Computation
Intro to Data Structures
Finite Automata.
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Compiler Construction
Language Recognition (12.4)
CSC312 Automata Theory Transition Graphs Lecture # 9
CSE 105 theory of computation
RECAP Lecture 7 FA of EVEN EVEN, FA corresponding to finite languages(using both methods), Transition graphs.
CSC312 Automata Theory Lecture # 2 Languages.
LECTURE # 07.
CSE 105 theory of computation
Presentation transcript:

Lecture #2 Advanced Theory of Computation

Languages & Grammar Before discussing languages & grammar let us deal with some related issues. Alphabet: is defined as a nonempty finite set of symbols or letters such as {a 1, a 2, …, a k }. Particularly the alphabet for theory of computation is mostly the binary alphabet {0, 1}. Set of alphabet represented by

Languages & Grammar A string (word or sentence): is defied as a finite sequence of symbols over the set of alphabet (∑), e.g. aaabbbabbb is string over ∑ = {a, b}. A string might be represent by w. A string may have no symbol at all, in this case it is called the empty string / null string and denoted by

Note: Some times string (word/sentence) can be represented as function. e.g. A string x = x 0 x 1 x 2 x 3 … x n, which can be viewed as function as: x : [n] | x(k) = x k. where n is the length of the string x, which denoted by |x|, e.g. |aabbaab| = 7

Operations on strings For an alphabet Σ, given any two strings u: [m] → Σ and v: [n] → Σ, the concatenation u ・ v (also written as uv) of u and v is the string uv: [m + n] → Σ, defined such that: In particular

Formal Languages Formal vs. Natural Languages Natural Languages: used by human to communicate. e.g. Arabic, English, … syntax is very complicated not completely specified

Formal Languages Formal vs. Natural Languages Formal Language: specified by a well-defined sets of grammatical rules e.g. programming languages syntax completely defined by given grammar.

Why study Formal Languages? Programming languages are formal. very useful for pattern matching. Important for research in natural language processing (NLP) with computers. Closely tied to study of abstract machines.

Formal Languages Let be any finite set of symbols (possibly none), called an alphabet. A word (string) over is any fine sequence of letters from. A formal language is simply a set of strings

Formal Languages defined as the set of all possible words over, including the empty word (denoted by ). Example Let, then

A language over is defined as strings over i.e. a subset of Examples: ∑ = {a, b}

Example Let Then The language is a finite language on. Note: Language can be infinite, and the most interesting languages are infinite.

New language can be constructed using any of the set operations. As an example the union of tow languages over, is also a language over. Having {as, so} and {if, soon, possible} as tow languages over the concatenation of the tow languages give another language over as follows. {as, so} {if, soon, possible} = {asif, assoon, aspossible, soif, sosoon, sopossible}.

Regular Expression & Language Definition: A regular expression over, that corresponding to a language, can be defined as follows. is a regular expression, corresponding to the empty language.

Regular Expression & Language For each symbol a is a regular expression corresponding to the language {a}. is a regular expression, corresponding to the empty language., ε and a are called primitive regular expressions.

corresponding to L r L s corresponding to A language over is a regular language if there is some regular expression over corresponding to it. For any regular expression r and s over, corresponding to the languages L r and L s, respectively, each of the following are regular expression over, corresponding to the language indicated.

Examples of regular expression over All words over MeaningExpression All words over beginning with 0 followed only by 1’s. All words over containing exactly two 0’s. All words over containing two consecutive 0’s or two consecutive 1s.

Meaning Expression All words over containing an even number of 0’s an even number of 1’s. All words over in which every 1 immediately followed by at least tow 0’s.

Meaning Expression All strings containing only 0’s, 1’s, that begin with b and ending with a 2. All strings that starting with any number of 1’s followed by 001, followed by any number of 0’s.

Formal Grammar Formal definition where, A generative grammar, which firstly proposed by Noam Chomsky in 1950s, considered as a grammar G that defined as a quadruple.

is a finite set of objects called variables. is a finite set of objects called terminal symbols. is a special symbol called start variable. is a finite set of productions. It is assumed that and are nonempty and disjoint

Definition (L(G)) Let be a grammar. Then the set is the language generated by.

Example Consider a grammar G that defined as where, V = {S, B}T = {a, b, c} P consists of the following production rule S aBSc S abc Ba aBBb bb

L(G) may be derived to be consisted of the following strings: L(G) = {abc, aabbcc, aaabbbccc, …} Therefore L(G) can be represented as L(G) = {a n b n c n | n>0} L(G) = {w {a, b, c} * | n a (w) = n b (w) = n c (w)}

Example Consider a grammar G that defined as where, V = {S, A, B}T = {0, 1} P consists of the following production rule S A|B A 0A1|εB 0B1|ε L(G) = L(A) U L(B) = {0 n 1 n : n ≥ 0} U {1 n 0 n : n ≥ 0}

Example Consider a grammar G that defined as where, V = {S, X}T = {0, 1} P consists of the following production rule S 0S|0X X 0X1|ε L(G) = {0 m 1 n :m > n}

Representation of Language using Graphs Transition Graph over is a finite directed graph in which every arrow (edge) is labeled by some word (possibly the empty word ( )). There is a least one vertex, labeled by a ( ) sign (such vertices are called initial vertices), and a (possibly empty set) of vertices, labeled by a ( ) sign (called the final vertices). A vertex can be both initial and final.

Example Consider the following transition graphs over

All words over beginning with a followed by All words over containing two consecutive ( ) or two consecutive ( )

All words over containing an even number of ( ) and even number of ( ) All words over either starting with ( ) or containing ( ).