1 Strings and Languages Lecture 2-3 Ref. Handout p12-17.

Slides:



Advertisements
Similar presentations
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.
Advertisements

Properties of Regular Languages
YES-NO machines Finite State Automata as language recognizers.
Strings and Languages Operations
Languages, grammars, and regular expressions
Regular Languages Sequential Machine Theory Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 3 Comments, additions and modifications.
Fall 2005 CSE 467/567 1 Formal languages regular expressions regular languages finite state machines.
CS 3240 – Chuck Allison.  A model of computation  A very simple, manual computer (we draw pictures!)  Our machines: automata  1) Finite automata (“finite-state.
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,
Regular Languages A language is regular over  if it can be built from ;, {  }, and { a } for every a 2 , using operators union ( [ ), concatenation.
Theory Of Automata By Dr. MM Alam
CMSC 330 Exercise: Write a Ruby function that takes an array of names in “Last, First Middle” format and returns the same list in “First Middle Last” format.
1 Finite Automata (Finite State Machine) Lecture 4-5 Ref. Handout p18-24.
Lexical Analysis CSE 340 – Principles of Programming Languages Fall 2015 Adam Doupé Arizona State University
Theory of Automata.
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.
Formal Methods in SE Theory of Automata Qasiar Javaid Assistant Professor Lecture # 06.
Lecture Two: Formal Languages Formal Languages, Lecture 2, slide 1 Amjad Ali.
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,…}
Whole numbers and numeration Math 123 September 17-19, 2008.
1 Language Definitions Lecture # 2. Defining Languages The languages can be defined in different ways, such as Descriptive definition, Recursive definition,
1 Chapter 1 Introduction to the Theory of Computation.
Lecture # 3 Regular Expressions 1. Introduction In computing, a regular expression provides a concise and flexible means to "match" (specify and recognize)
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} =
Introduction to Language Theory
Module 2 How to design Computer Language Huma Ayub Software Construction Lecture 8.
Lecture-2 Recap Lecture-1
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.
Counting CSC-2259 Discrete Structures Konstantin Busch - LSU1.
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.
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.
Strings and Languages CS 130: Theory of Computation HMU textbook, Chapter 1 (Sec 1.5)
1 Lecture 3.3: Recursion CS 250, Discrete Structures, Fall 2012 Nitesh Saxena Adopted from previous lectures by Cinda Heeren, Zeph Grunschlag.
Discrete Mathematical Structures 4 th Edition Kolman, Busby, Ross © 2000 by Prentice-Hall, Inc. ISBN
Rosen 1.6, 1.7. Basic Definitions Set - Collection of objects, usually denoted by capital letter Member, element - Object in a set, usually denoted by.
(CSC 102) Lecture 13 Discrete Structures. Previous Lectures Summary  Direct Proof  Indirect Proof  Proof by Contradiction  Proof by Contra positive.
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
Formal Languages and Grammars
Lecture # Book Introduction to Theory of Computation by Anil Maheshwari Michiel Smid, 2014 “Introduction to computer theory” by Daniel I.A. Cohen.
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.
Lecture 2 Theory of AUTOMATA
MATH 2311 Section 2.2. Sets and Venn Diagrams A set is a collection of objects. Two sets are equal if they contain the same elements. Set A is a subset.
Lecture 02: Theory of Automata:2014 Asif Nawaz Theory of Automata.
Set, Alphabets, Strings, and Languages. The regular languages. Clouser properties of regular sets. Finite State Automata. Types of Finite State Automata.
Lecture 03: Theory of Automata:2014 Asif Nawaz Theory of Automata.
L ANGUAGE C ONCEPTS : F ORMAL M ODEL FOR L ANGUAGES Theory of Computer Akram Salah.
CHAPTER TWO LANGUAGES By Dr Zalmiyah Zakaria.
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.
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.
Section 6.1 Set and Set Operations. Set: A set is a collection of objects/elements. Ex. A = {w, a, r, d} Sets are often named with capital letters. Order.
Theory of Computation Lecture #
Lecture # 2.
Language Theory Module 03.1 COP4020 – Programming Language Concepts Dr. Manuel E. Bermudez.
Regular Languages, Regular Operations, Closure
CSC-2259 Discrete Structures
Lexical Analysis CSE 340 – Principles of Programming Languages
Lecture 1 Theory of Automata
LANGUAGES Prepared by: Paridah Samsuri Dept. of Software Engineering
COP4620 – Programming Language Translators Dr. Manuel E. Bermudez
Introduction to Programming in C
Recap lecture 29 Example of prefixes of a language, Theorem: pref(Q in R) is regular, proof, example, Decidablity, deciding whether two languages are equivalent.
CS 250, Discrete Structures, Fall 2015 Nitesh Saxena
Chapter 1 Introduction to the Theory of Computation
CSC312 Automata Theory Lecture # 2 Languages.
Presentation transcript:

1 Strings and Languages Lecture 2-3 Ref. Handout p12-17

2 Strings Examples abcdef Җ □ فقلΛφψωΫ√ Finite alphabet = a set of symbols Definition A string is a sequence of discrete symbols from a known finite alphabet

3 The Empty String – Λ (lambda)

4 Notation for Strings if x = abcd (use x to stand for “abcd”) and y = dba (use y to stand for “dba”) x R = dcba (reversing the symbols in x) |x| = |abcd| = 4 (the number of symbols in x) x.y = abcddba (the result of joining x and y) concatnation x 2 = x.x = abcdabcd x 3 = abcdabcdabcd x 1 = abcdx 0 = Λ (x.y is normally written as xy)

5 Languages A language is a set of strings

6 Sets Sets – A set is a collection of objects (informal) For example, S = {0,1,2,3,4,5,6,7,8,9} all digits S = { } ( an empty set, also written as Φ ) S = {1,2,3,4, …} all positive integers x ∈ S means that x is an element in S

7 Sets Two special properties about sets: No particular order of elements i.e. { a, b } = { b, a } No redundant elements i.e. { a, a } = { a } Recall the definition for string Strings “as” and “sa” are different strings, i.e. as ≠ sa But for sets, {a, s} = {s, a}

8 Some Simple Examples of Languages {yes, no, come-here, sit, run, good-boy} this is a finite language { a, aa, aaa, aaaa, …… } this is an infinite language { } { Λ }

9 Natural Languages English: alphabet = { a,b,c, …,z,., ;, !, :, etc } String: a valid sequence of English symbols = a valid English sentence English Language = a set of valid English sentences

10 A Programming Language class abc { public start(int x) { …… } Alphabet: class public, private if, while, = {, }, +, -, *., /, (, ), numbers, identifiers, ……

11 Use Set Notation to Define a Language { a, aa, aaa, aaaa, … } what does … mean? = { a n | n > 0 } it read as – the set of a n where n > 0 In set notation, S = { x | x has property P or the conditions for x }

12 Examples { ab n c | n >= 0 } = { xx R | x ∈ {cat, dog} } = { a m b n c k | m+n > k, 0<k, k<4 } = { } = { 00, 01, 10, 11 } { } = {Λ, 0, 1, 00, 01, 10, 11}

13 Memo for In-class test 2 [ /5] questionsmy answers correct answers comments

14 New Languages from Old A U Ball strings in either A or B the union of A and B A ∩ Ball strings in both A and B the intersection of A and B A. Bevery combination of one string from A followed by one from B the product of A and B

15 Examples A = { a, b, c } B = { b, c, d } What is: A ∩ B = A U B = A.B = |A| =|B| = |A| x |B| = |A.B| =

16 More Examples A = { the } B = { big, red }C = { car, bus } What is: A ∩ B = B U C = B.C = A.B.B.C = A.( B U {Λ} ).C = (A U { a }).B.(C ∩ { car }) =

17 More Operations on Sets The difference between two sets A and B: A \ B = { x | x ∈ A and x ∉ B } e.g. A = { a, b, c }, B = { b, c, d } A \ B = { a },B \ A = { d } The complement of A A’ = { x | x ∉ A } all strings not in A using the same alphabet as A Let U denote ‘the universe’, i.e. all possible string using same alphabet as A, then the complement of A can be also expressed as A’ = U \ A

18 Examples A = {Λ, a, aa, aaa } ( alphabet = {a} ) The universe set = {Λ, a, aa, aaa, aaaa, … } = { a n | n >= 0 } A’ = {aaaa, aaaaa, aaaaaa, … } = { a n | n > 3 }

19 Venn Diagrams – illustrating the set operations: 1. Union A = B = a b cc d e A U B = a b c d e = { a, b, c, d, e}

20 Venn Diagrams – illustrating the set operations: 2. Intersection A = B = a b cc d e A ∩ B = a b c d e = { c }

21 Venn Diagrams – illustrating the set operations: 3. difference A = B = a b cc d e A \ B = a b c d e = { a, b } B \ A = = { d, e } a b c d e

22 Venn Diagrams – illustrating the set operations: 4. complement A = Universe U = a b c Λ a b c aa ab ac ba bb bc ca cb cc aaa aab aac baa bab bac bba bbb bbc caa cab cac cba cbb cbc cca ccb ccc aaaa A’ = U \ A = Λ aa ab ac ba bb bc ca cb cc aaa aab aac baa bab bac bba bbb bbc caa cab cac cba cbb cbc cca ccb ccc aaaa a b c

23 Closure A 0 = { Λ },A 1 = A, A 2 = A.A etc A* = A 0 U A 1 U A 2 U …… (Kleene star of A ) (the closure of A) A + = A 1 U A 2 U A 3 U ……

24 Examples A = { a, b }, B = { Λ, a, b } What is: A* = B* = A + = B + =

25 Memo for In-class test 3 [ /5] questionsmy answers correct answers comments