Lecture Two: Formal Languages Formal Languages, Lecture 2, slide 1 Amjad Ali.

Slides:



Advertisements
Similar presentations
Chapter 2 Revision of Mathematical Notations and Techniques
Advertisements

YES-NO machines Finite State Automata as language recognizers.
Regular Languages Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 3 Comments, additions and modifications.
Strings and Languages Operations
Regular Languages Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 3 Comments, additions and modifications.
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
1 Regular Expressions/Languages Regular languages –Inductive definitions –Regular expressions syntax semantics Not covered in lecture.
Languages and Machines Unit two: Regular languages and Finite State Automata.
Theory Of Automata By Dr. MM Alam
Chapter 2 Languages.
Languages & Strings String Operations Language Definitions.
Lexical Analysis CSE 340 – Principles of Programming Languages Fall 2015 Adam Doupé Arizona State University
::ICS 804:: Theory of Computation - Ibrahim Otieno SCI/ICT Building Rm. G15.
1 Syntax Specification Regular Expressions. 2 Phases of Compilation.
CS/IT 138 THEORY OF COMPUTATION Chapter 1 Introduction to the Theory of Computation.
Module 2 How to design Computer Language Huma Ayub Software Construction Lecture 7 1.
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,
1 Chapter 1 Automata: the Methods & the Madness Angkor Wat, Cambodia.
Formal Methods in SE Theory of Automata Qasiar Javaid Assistant Professor Lecture # 06.
Introduction to Theory of Automata
CMSC 330: Organization of Programming Languages Theory of Regular Expressions.
Two examples English-Words English-Sentences alphabet S ={a,b,c,d,…}
1 Chapter 1 Introduction to the Theory of Computation.
Languages, Grammars, and Regular Expressions Chuck Cusack Based partly on Chapter 11 of “Discrete Mathematics and its Applications,” 5 th edition, by Kenneth.
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} =
COMP 3438 – Part II - Lecture 2: Lexical Analysis (I) Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ. 1.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 2 Mälardalen University 2006.
Module 2 How to design Computer Language Huma Ayub Software Construction Lecture 8.
L ECTURE 3 Chapter 4 Regular Expressions. I MPORTANT T ERMS Regular Expressions Regular Languages Finite Representations.
Introduction to Theory of Automata By: Wasim Ahmad Khan.
1 Module 14 Regular languages –Inductive definitions –Regular expressions syntax semantics.
Recursive Definitions & Regular Expressions (RE)
Lecture 5 Regular Expressions CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
Regular Expressions and Languages A regular expression is a notation to represent languages, i.e. a set of strings, where the set is either finite or contains.
Strings and Languages CS 130: Theory of Computation HMU textbook, Chapter 1 (Sec 1.5)
Overview of Previous Lesson(s) Over View  Symbol tables are data structures that are used by compilers to hold information about source-program constructs.
Lecture 02: Theory of Automata:08 Theory of Automata.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 2 Mälardalen University 2010.
CSC312 Automata Theory Lecture # 3 Languages-II. Formal Language A formal language is a set of words—that is, strings of symbols drawn from a common alphabet.
Recursive Definations Regular Expressions Ch # 4 by Cohen
UNIT - I Formal Language and Regular Expressions: Languages Definition regular expressions Regular sets identity rules. Finite Automata: DFA NFA NFA with.
Lecture # Book Introduction to Theory of Computation by Anil Maheshwari Michiel Smid, 2014 “Introduction to computer theory” by Daniel I.A. Cohen.
Theory of computation Introduction theory of computation: It comprises the fundamental mathematical properties of computer hardware, software,
Lecture # 4.
Lecture 2 Theory of AUTOMATA
Week 13 - Wednesday.  What did we talk about last time?  Exam 3  Before review:  Graphing functions  Rules for manipulating asymptotic bounds  Computing.
1 Strings and Languages Lecture 2-3 Ref. Handout p12-17.
Lecture 02: Theory of Automata:2014 Asif Nawaz Theory of Automata.
Lecture 03: Theory of Automata:2014 Asif Nawaz Theory of Automata.
Akram Salah ISSR Basic Concepts Languages Grammar Automata (Automaton)
By Dr.Hamed Alrjoub. 1. Introduction to Computer Theory, by Daniel I. Cohen, John Wiley and Sons, Inc., 1991, Second Edition 2. Introduction to Languages.
Chapter 2. Formal Languages Dept. of Computer Engineering, Hansung University, Sung-Dong Kim.
Lecture #2 Advanced Theory of Computation. Languages & Grammar Before discussing languages & grammar let us deal with some related issues. Alphabet: is.
Chapter 1 INTRODUCTION TO THE THEORY OF COMPUTATION.
Theory of Computation Lecture #
Lecture # 2.
Lecture 1 Theory of Automata
Languages Prof. Busch - LSU.
Languages Costas Busch - LSU.
Formal Language & Automata Theory
LANGUAGES Prepared by: Paridah Samsuri Dept. of Software Engineering
Introduction Reading: Sections 1.5 – 1.7.
Chapter 1 Introduction to the Theory of Computation
Formal Languages Context free languages provide a convenient notation for recursive description of languages. The original goal of formalizing the structure.
CSC312 Automata Theory Lecture # 2 Languages.
Languages Fall 2018.
Introduction and Chapter One: Fundamentals
Presentation transcript:

Lecture Two: Formal Languages Formal Languages, Lecture 2, slide 1 Amjad Ali

Formal Language It is an abstraction of the general characteristics of programming languages It consists of a set of symbols and some rules of formation of sentences Sentences are formed by grouping the symbols Formal Languages, Lecture 2, slide 2

Formal Language A formal language is the set of all strings permitted by the rules of formation Formal Languages, Lecture 2, slide 3

What is a language? A system for the expression of certain ideas, facts, or concepts, including a set of symbols and rules for their manipulation Formal Languages, Lecture 2, slide 4

Mathematical definition of a language This shall require us to understand the following concepts first Alphabets Strings Concatenation of strings etc. Formal Languages, Lecture 2, slide 5

Alphabet An ALPHABET is a nonempty set of symbols It is denoted by  Example:  {a,b} where a and b are symbols Formal Languages, Lecture 2, slide 6

Alphabets An alphabet is any finite set of symbols {0,1}: binary alphabet {0,1,2,3,4,5,6,7,8,9}: decimal alphabet ASCII, Unicode: machine-text alphabets Or just {a,b}: enough for many examples {}: a legal but not usually interesting alphabet We will usually use  as the name of the alphabet we’re considering, as in  = {a,b} Formal Languages, Lecture 2, slide 7

Strings Strings are constructed from the individual symbols Strings are finite sequences of symbols from the alphabet Example : aabba, ababaaa, abbbaaa, etc are the strings formed by t he symbols of the alphabet Formal Languages, Lecture 2, slide 8

Symbols And Variables Sometimes we will use variables that stand for strings: x = abbb In programming languages, syntax helps distinguish symbols from variables String x = "abbb"; In formal language, we rely on context and naming conventions to tell them apart We'll use the first letters, like a, b, and c, as symbols The last few, like x, y, and z, will be string variables Formal Languages, Lecture 2, slide 9

Assumptions Lower case letters a,b,c,… are used for elements of the alphabet Lower case letters u,v,w,… for string names eg w=aabbaba This indicates that w is a string having specific value aabbaba Formal Languages, Lecture 2, slide 10

Empty String The empty string is written as  Like "" in some programming languages |  | = 0 Don't confuse empty set and empty string: {}   {}  {  } Formal Languages, Lecture 2, slide 11

Concatenation The concatenation of two strings x and y is the string containing all the symbols of x in order, followed by all the symbols of y in order We show concatenation just by writing the strings next to each other If x = abc and y = def, then xy = abcdef For any x,  x = x  = x Formal Languages, Lecture 2, slide 12

Concatenation of the strings Two strings are concatenated by appending the symbols of one string to the end of the other string Example u=aaabbb v=abbabba Concatenated string uv=aaabbbabbabba Formal Languages, Lecture 2, slide 13

Length of the string The length of the string is the number of symbols in the string |w| = 5 if w = aabaa Empty String has no symbols and is denoted by  = 0 Automata Theory, Lecture 2, slide 14

Kleene Star The Kleene closure of an alphabet , written as  *, is the language of all strings over  {a}* is the set of all strings of zero or more as: { , a, aa, aaa, …} {a,b}* is the set of all strings of zero or more symbols, each of which is either a or b = { , a, b, aa, bb, ab, ba, aaa, …} x   * means x is a string over  Unless  = {},  * is infinite Formal Languages, Lecture 2, slide 15

Kleene Star Iterating a language L L ={ε} L =L L =L·L Kleene star: L*=U n ≥ 0 L Example: {a,b}* = {ε,a,b,aa,bb,ab,ba, aab, …} all finite sequences over {a,b}. Formal Languages, Lecture 2, slide 16

   and    is an alphabet   is the set of all strings obtained by concatenating zero or more symbols from    always contains  then      Formal Languages, Lecture 2, slide 17

Finiteness  is always finite   and   are always infinite Formal Languages, Lecture 2, slide 18

Numbers We use N to denote the set of natural numbers: N = {0, 1, …} Formal Languages, Lecture 2, slide 19

Exponents We use N to denote the set of natural numbers: N = {0, 1, …} Exponent n concatenates a string with itself n times If x = ab, then x 0 =  x 1 = x = ab x 2 = xx = abab, etc. We use parentheses for grouping exponentiations (assuming that  does not contain the parentheses) (ab) 7 = ababababababab Formal Languages, Lecture 2, slide 20

Languages A language is a set of strings over some fixed alphabet Not restricted to finite sets: in fact, finite sets are not usually interesting languages All our alphabets are finite, and all our strings are finite, but most of the languages we're interested in are infinite Formal Languages, Lecture 2, slide 21

Language A language L is defined very generally as a subset of  A  string in a language L will be called a sentence of L Formal Languages, Lecture 2, slide 22

Set Formers A set written with extra constraints or conditions limiting the elements of the set Not the rigorous definitions we're looking for, but a useful notation anyway: {x  {a, b}* | |x| ≤ 2} = { , a, b, aa, bb, ab, ba} {xy | x  {a, aa} and y  {b, bb}} = {ab, abb, aab, aabb} {x  {a, b}* | x contains one a and two bs} = {abb, bab, bba} {a n b n | n ≥ 1} = {ab, aabb, aaabbb, aaaabbbb,...} Formal Languages, Lecture 2, slide 23

Free Variables in Set Formers Unless otherwise constrained, exponents in a set former are assumed to range over all N Examples {(ab) n } = { , ab, abab, ababab, abababab,...} {a n b n } = { , ab, aabb, aaabbb, aaaabbbb,...} Formal Languages, Lecture 2, slide 24

The Quest Set formers are relatively informal They can be vague, ambiguous, or self- contradictory A big part of our quest in the study of formal language is to develop better tools for defining languages Formal Languages, Lecture 2, slide 25

Problem  a,b     a,b,aa,ab,ba,bb,aaa,aab,aba, abb, baa,bab,bba,bbb,aaaa,… ….} L = {a,aa,aab} is a language on  as L is a subset of   and is finite L = {a n b n :n>0} is also a subset of   but it is infinite Formal Languages, Lecture 2, slide 26

Concatenation of two Languages L 1 L 2 = {xy :x ε L 1 and y ε L 2 } Formal Languages, Lecture 2, slide 27