910 likes | 1.09k Views
CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 1 - Intro Mälardalen University 2010. Content Adminstrivia Mathematical Preliminaries Countable Sets (Uppräkneliga mängder) Uncountable sets (Överuppräkneliga mängder). E xami ner Gordana Dodig-Crnkovic
E N D
CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 1 - Intro Mälardalen University 2010
Content • Adminstrivia • Mathematical Preliminaries • Countable Sets (Uppräkneliga mängder) • Uncountable sets (Överuppräkneliga mängder)
Examiner • Gordana Dodig-Crnkovic • Lecturer • Stefan Bygde
Course Home Page http://www.idt.mdh.se/kurser/cd5560/11_10 visit home page regularly!
How Much Work? 20 hours a week for this type of course (norm) 4 hours lectures 2 hours exercises 14 hours own work a week!
Why Theory of Computation? • A real computer can be modelled by a mathematical object: a theoretical computer. • A formal language is a set of strings, and can represent a computational problem. • A formal language can be described in many different ways that ultimately prove to be identical. • Simulation: the relative power of computing models can be based on the ease with which one model can simulate another.
5. Robustness of a computational model. • 6. The Church-Turing thesis: anything that can be computed can be computed by a Turing machine. • 7. Nondeterminism: languages can be described by the existence or nonexistence of computational paths. • 8. Unsolvability: for some computational problems there is no corresponding algorithm that will unerringly solve them.
Practical Applications • Efficient compilation of computer languages • String searching • Identifying the limits; Recognizing difficult problems • Applications to other areas: • circuit verification • economics and game theory (finite automata as strategy models in decision-making); • theoretical biology (L-systems as models of organism growth) • computer graphics (L-systems) • linguistics (modeling by grammars)
History • Euclid's attempt to axiomatize geometry • (Archimedes realized, during his own efforts to define the area of a planar figure, that Euclid's attempt had failed and that additional postulates were needed.) • Leibniz's dream of a symbolic logic • de Morgan, Boole, Frege, Russell, Whitehead: • Mathematics as branch of symbolic logic!
1900 Hilberts program 1880 -1936 first programming languages 1931 Gödels incompleteness theorem 1936 Turing machine (showed to be equivalent with recursive functions). Commonly accepted: TM as ultimate computer 1950 automata 1956 language/automata hierarchy
Every mathematical truth expressed in a formal language is consisting of • a fixed alphabet of admissible symbols, and • explicit rules of syntax for combining those symbols • into meaningful words and sentences
Turing used a Universal Turing machine (UTM) to prove an even more powerful incompleteness theorem because it destroyed not one but two of Hilbert's dreams: • Finding a finite list of axioms from which all mathematical truths can be deduced • Solving the entscheidungsproblem, ("decision problem“) by producing a "fully automatic procedure" for deciding whether a given proposition (sentence) is true or false.
Examination • Three midterms • Regular Languages • Context Free Languages • Restriction Free Languages • OR: • Final Exam in three parts • If you have finished the midterm of one time of language you don’t have to do corresponding part of the final exam
Form and Resources • Lectures • Exercises • Labs (optional) • Midterms • Webpage (many links, news etc) • Literature: • Swe: Lennart Salling. Formella språk, automater och beräkningar • Eng: Linz, An Introduction to Formal Languages and Automata
Sets • Functions • Relations • Proof Techniques • Languages, Alphabets and Strings • Strings & String Operations • Languages & Language Operations
SETS A set is a collection of elements We write
Set Representations • C = { a, b, c, d, e, f, g, h, i, j, k } • C = { a, b, …, k } • S = { 2, 4, 6, … } • S = { j : j > 0, and j = 2k for some k>0 } • S = { j : j is nonnegative and even } finite set infinite set
A = { 1, 2, 3, 4, 5 } U A 6 8 2 3 1 7 4 5 9 10 • Universal Set: All possible elements • U = { 1 , … , 10 }
Set Operations • A = { 1, 2, 3 } B = { 2, 3, 4, 5} • Union • A U B = { 1, 2, 3, 4, 5 } • Intersection • A B = { 2, 3 } • Difference • A - B = { 1 } • B - A = { 4, 5 } B A U A-B
Complement • Universal set = {1, …, 7} • A = { 1, 2, 3 } A = { 4, 5, 6, 7} 4 A A 6 3 1 2 5 7 A = A
{ even integers } = { odd integers } Integers 1 odd 0 5 even 6 2 4 3 7
DeMorgan’s Laws A U B = A B U A B = A U B U
Empty, Null Set: = { } S U = S S = S - = S - S = U = Universal Set
Subset A = { 1, 2, 3} B = { 1, 2, 3, 4, 5 } U A B Proper Subset: B U A B A
Disjoint Sets A = { 1, 2, 3 } B = { 5, 6} A B = U A B
Set Cardinality For finite sets A = { 2, 5, 7 } |A| = 3
Powersets A powerset is a set of sets S = { a, b, c } Powerset of S = the set of all the subsets of S 2S = { , {a}, {b}, {c}, {a, b}, {a, c}, {b, c}, {a, b, c} } Observation: | 2S | = 2|S| ( 8 = 23 )
Cartesian Product A = { 2, 4 } B = { 2, 3, 5 } A X B = { (2, 2), (2, 3), (2, 5), ( 4, 2), (4, 3), (4, 5) } |A X B| = |A| |B| Generalizes to more than two sets A X B X … X Z
PROOF TECHNIQUES • Proof by construction • Proof by induction • Proof by contradiction
2 2 3 1 1 4 0 0 5 3 Proof by Construction We define a graph to be k-regular if every node in the graph has degree k. Theorem. For each even number n > 2 there exists 3-regular graph with n nodes. n = 6 n = 4
Proof by Construction Construct a graph G = (V, E) with n > 2 nodes. V= { 0, 1, …, n-1 } E = { {i, i+1} for 0 i n-2} {{n-1,0}} (*) {{i, i+n/2 for 0 i n/2 –1} (**) The nodes of this graph can be written consecutively around the circle. (*) edges between adjacent pairs of nodes (**) edges between nodes on opposite sides END OF PROOF
Inductive Proof We have statements P1, P2, P3, … • If we know • for some k that P1, P2, …, Pk are true • for any n k that • P1, P2, …, Pn imply Pn+1 • Then • Every Pi is true
Proof by Induction • Inductive basis • Find P1, P2, …, Pk which are true • Inductive hypothesis • Let’s assume P1, P2, …, Pn are true, • for any n k • Inductive step • Show that Pn+1 is true
L(0) = 1 L(3) = 8 Example TheoremA binary tree of height n has at most 2n leaves. Proof let L(i) be the number of leaves at level i
We want to show: L(i) 2i • Inductive basis • L(0) = 1 (the root node) • Inductive hypothesis • Let’s assume L(i) 2i for all i = 0, 1, …, n • Induction step • we need to show that L(n + 1) 2n+1
Induction Step Level hypothesis: L(n) 2n n n+1
Induction Step Level hypothesis: L(n) 2n n n+1 L(n+1) 2 * L(n) 2 * 2n = 2n+1 END OF PROOF
Proof of induction: The cardinality of the powerset Claim:A set of n elements has 2n subsets • Check: • The empty set {} has only one subset: {}. • The set {a} (a set with exactly one element) has two subsets: {} och {a}
Påstående:En mängd med n element har 2n delmängder • Check (cont.) • The set of two elements {a, b} has four subsets: {}, {a}, {b} and {a,b} • The set {a, b, c} has eight subsets: {}, {a}, {b}, {c} och {a,b}, {a,c}, {b,c}, {a,b,c} • The claim holds for these basic cases.
Base Case • The simplest case is a set with no elements (there is just one such set), which has 20 = 1 subsets.
Induction step • Suppose that the claim holds for all sets with k elements, i.e., suppose that every set with k elements has 2k subsets. • Show that the claim in this case holds also for all sets with k+1 elements, i.e., show that every set with k+1 elements has 2k+1 subsets.
Consider an arbitrary set with k+1 elements. The subsets of this set can be divided into two groups: • Subsets which does not contain the k+1:th element:Such a subset is a subset to the set of the k original elements, and the cardinality of subsets to a set of k elements is (according to the inductive hypothesis) 2k.
Subsets containing the k+1:th element:Such a subset can be constructed by taking any set not containing the k+1th element and add the k+1th element. Since there are 2k subsets without the k+1th element (by hypothesis), it is also possible to create 2k subsets including this element. • In total there are 2k +2k = 2. 2k= 2k+1 subsets to the considered set. • END OF PROOF • (Exemple taken from the book: Diskret matematik och diskreta modeller, K Eriksson, H. Gavel)
Proof by Contradiction • We want to prove that a statement P is true • we assume that P is false • then we arrive at a conclusion that contradicts our assumptions • therefore, statement P must be true
Example • Theorem is not rational • Proof • Assume by contradiction that it is rational • = n/m • n and m have no common factors • We will show that this is impossible
= n/m 2 m2 = n2 n is even n = 2 k Therefore, n2 is even m is even m = 2 p 2 m2 = 4k2 m2 = 2k2 Thus, m and n have common factor 2 Contradiction! END OF PROOF
Infinite sets are either Countable or Uncountable
Countable set There is a one to one correspondence between elements of the set and natural numbers