Languages, prefixes, sets, cardinality, functions

Slides:



Advertisements
Similar presentations
CS3012 Formal Languages and Compilers Frank Guerin Room 227 Lectures Monday11:00MT3 Tuesday9:00105 St. Marys Tutorials Thursday13:00 Thursday 14:00definitely.
Advertisements

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.
Properties of Regular Languages
Sets Definition of a Set: NAME = {list of elements or description of elements} i.e. B = {1,2,3} or C = {x  Z + | -4 < x < 4} Axiom of Extension: A set.
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.
Costas Busch - RPI1 Mathematical Preliminaries. Costas Busch - RPI2 Mathematical Preliminaries Sets Functions Relations Graphs Proof Techniques.
Courtesy Costas Busch - RPI1 Mathematical Preliminaries.
Theoretical Computer Science COMP 335 Fall 2004
Fall 2006Costas Busch - RPI1 Languages. Fall 2006Costas Busch - RPI2 Language: a set of strings String: a sequence of symbols from some alphabet Example:
1 Regular Expressions/Languages Regular languages –Inductive definitions –Regular expressions syntax semantics Not covered in lecture.
Regular Languages A language is regular over  if it can be built from ;, {  }, and { a } for every a 2 , using operators union ( [ ), concatenation.
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,
Mathematical Preliminaries Strings and Languages Preliminaries 1.
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} =
Mathematical Preliminaries. Sets Functions Relations Graphs Proof Techniques.
1 Languages. 2 A language is a set of strings String: A sequence of letters Examples: “cat”, “dog”, “house”, … Defined over an alphabet:
1 Exercise: Prove that the set S = { π : π is a permutation of {1, 2, 3, …, n} for some integer n ≥ 1 } is countable.
1 Module 14 Regular languages –Inductive definitions –Regular expressions syntax semantics.
MA/CSSE 474 Theory of Computation Regular Expressions Intro.
Language: Set of Strings
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)
Discrete Mathematics R. Johnsonbaugh
Why Study the Theory of Computation? Implementations come and go. Chapter 1.
COMPSCI 102 Introduction to Discrete Mathematics.
Mathematical Preliminaries
Great Theoretical Ideas in Computer Science.
CS 203: Introduction to Formal Languages and Automata
MA/CSSE 474 Theory of Computation Minimizing DFSMs.
Languages and Strings Chapter 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.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
1 Let S = { π : π is a permutation of {1, 2, 3, …, n} for some integer n ≥ 1 }. (a) List the elements of S for n= 1, 2, and 3. (b) Prove that the set S.
MA/CSSE 474 Theory of Computation How many regular/non-regular languages are there? Closure properties of Regular Languages (if there is time) Pumping.
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.
MA/CSSE 474 Theory of Computation Regular Expressions Intro.
Introduction to Set Theory (§1.6) A set is a new type of structure, representing an unordered collection (group, plurality) of zero or more distinct (different)
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. –{
Language Theory Module 03.1 COP4020 – Programming Language Concepts Dr. Manuel E. Bermudez.
Languages Prof. Busch - LSU.
Languages Costas Busch - LSU.
More on showing L non-regular
Formal Language & Automata Theory
Properties of Regular Languages
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 2 Sets Slides are adopted from “Discrete.
MA/CSSE 474 Decision Problems about Regular Languages
COP4620 – Programming Language Translators Dr. Manuel E. Bermudez
Assume that p, q, and r are in
Closure Properties of Regular Languages
Mathematical Preliminaries Strings and Languages
MA/CSSE 474 Theory of Computation
Closure Properties of Regular Languages
Languages, prefixes, sets, cardinality, functions
MA/CSSE 474 Theory of Computation Computation FSM Intro.
More on showing L non-regular
Chapter 1 Introduction to the Theory of Computation
CSE 105 theory of computation
Equivalence Relations
Minimize # states in a DFSM
More About Nondeterminism
MA/CSSE 474 Theory of Computation
Languages Fall 2018.
Computation Chapter 4.
CSE 105 theory of computation
Presentation transcript:

Languages, prefixes, sets, cardinality, functions MA/CSSE 474 Theory of Computation Languages, prefixes, sets, cardinality, functions

Your Questions? Must not be a FSM Syllabus Tuesday's discussion Reading Assignments HW1 or HW2 Anything else Must not be a FSM

More about Languages and Strings Mostly very quick. Some should be review of previous courses, and some others you should have gotten for Reading Quiz 2. Ask questions if there are things I list here that you are not sure about.

Relations on Strings: Substring, proper substring Every string is a substring of itself. is a substring of every string. prefix, proper prefix Every string is a prefix of itself.  is a prefix of every string. s is a suffix, proper suffix, self, 

Defining a Language A language is a (finite or infinite) set of strings over a finite alphabet . Examples for  = {a, b} 1. L = {x  {a, b}* : all a’s precede all b’s} , a, aa, aabbb, and bb are in L. aba, ba, and abc are not in L. 2. L = {x : u  {a, b}* : x = ua} Simple English description: 3. L = {x#y: x, y  {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}* and, when x and y are viewed as the decimal representations of natural numbers, square(x) = y}. Examples (in L or not?): 3#9, 12#144, 3#8, 12, 12#12#12, # L = {an : n  0} uses replication, simpler description of L? AnBn = {akbk : k 0 } L = Ø = { } L = {ε} Note that the last two languages are not the same. You saw in Reading Quiz 2 that the last two examples are different languages

Natural Languages are Tricky L = {w: w is a sentence in English}. Examples: Kerry hit the ball. Colorless green ideas sleep furiously. The window needs fixed. Ball the Stacy hit blue.

A Halting Problem Language L = {w: w is a Java program that, when given any finite input string, is guaranteed to halt}. Is this language well specified? Can we decide which strings L contains?

Languages and Prefixes What are the following languages? L = {w  {a, b}*: no prefix of w contains b} L = {w  {a, b}*: no prefix of w starts with a} L = {w  {a, b}*: every prefix of w starts with a} Ask what each language is (describe in symbols only): {a}* {}  { bx : x  {a, b}*} 

Concatenation of Languages If L1 and L2 are languages over : L1L2 = {w  * : s  L1 (t  L2 (w = st))} Example: L1 = {a, aa} L2 = {a, c,ε} L1 L2 = Alternate definition: L1L2 = { st : s  L1 ∧ t  L2 } Simpler than the first definition, but the first one conveys the idea more precisely. {aa, aaa, ac, aac, a}

Concatenation of Languages L1L2 LR L3 Is this the same as {w3 : w  L } L0 Lk L* L+ Note that L3 is not the same as {w3 : wL}

Formally: Kleene Star and + of a Language   L+ = L L* L+ = L* - {} iff   L L+ is the closure of L under concatenation. C

Concatenation and Reverse of Languages Theorem: (L1 L2)R = L2R L1R. Proof: x (y ((xy)R = yRxR)) Theorem 2.1 we proved last time (L1 L2)R = {(xy)R : x  L1 and y  L2} Definition of concatenation of languages = {yRxR : x  L1 and y  L2} Thm 2.1 = L2R L1R Definition of Hidden. Try to Fit it in earlier next time.

Sets and Relations

Sets of Sets The power set of S is the set of all subsets of S. Let S = {1, 2, 3}. Then: P(S) = {, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}}.   P(S) is a partition of a set S iff: Every element of  is nonempty, Every pair of elements of  is disjoint , and the union of all the elements of  equals S. Six different partitions Some partitions of = {1, 2, 3}: {{1}, {2, 3}} or {{1, 3}, {2}} or {{1, 2, 3}}. How many different partitions of S?

Closure A set S is closed under binary operation op iff x,yS ( x op y  S) , closed under unary function f iff xS (f(x)  S) Examples ℕ+ (the set of all positive integers) is closed under addition and multiplication but not negation, subtraction, or division. What is the closure of ℕ+ under subtraction? Under division? The set of all finite sets is closed under union and intersection. Closed under infinite union? If S is not closed under unary function f, a closure of S is a set S' such that S is a subset of S' S' is closed under f No proper subset of S' contains S and is closed under f When we say "closed under union", we mean union of two things. Which can be repeated to get union of a finite number of things. But infinite union ifs different.

Equivalence Relations A relation on a set A is any set of ordered pairs of elements of A. A relation R  A  A is an equivalence relation iff it is: reflexive, symmetric, and transitive. Examples of equivalence relations: Equality Lives-at-Same-Address-As Same-Length-As Contains the same number of a's as Show that ≡₃ is an equivalence relation

Cardinality of a set. The cardinality of every set we will consider is one of the following : a specific natural number (if S is finite), “countably infinite” (if S has the same number of elements as there are integers), or “uncountably infinite” (if S has more elements than there are integers).

Functions on Languages Functions whose domains and ranges are languages maxstring(L) = {w  L: z  * (z    wz  L)}. Examples: • maxstring( AnBn ) • maxstring( {a}* ) Let INF be the set of infinite languages. Let FIN be the set of finite languages. Are the language classes FIN and INF closed under maxstring? Exercise for later: What language is maxstring({bna: n≥0}) ? maxstring(AnBn) = AnBn - { } maxstring(a*) =  FIN, yes, because every subset of a finite set is finite. INF, no, see {a}* example Exercise for later (on notes sheet): maxstring({bna: n≥0}) = the same language.

Functions on Languages chop(L) = {w : xL (x = x1cx2, x1  L*, x2  L*, c  L, |x1| = |x2|, and w = x1x2)}. What is chop(AnBn)? What is chop(AnBnCn)? Are FIN and INF closed under chop? Empty set {a2n+1b2nc2n+1} Yes (FIN) No (INF)

Functions on Languages firstchars(L) = {w : yL (y = cx  c  L  x  L*  w  {c}*)}. . What is firstchars(AnBn)? What is firstchars({a, b}*)? Are FIN and INF closed under firstchars? firstchars(AnBn) = {a}* firstchars({a, b}*) = {a}*  {b}* FIN, no. firstchars({a}) = {a}* INF, yes.