Presentation laddar. Vänta.

Presentation laddar. Vänta.

Formal Languages, Automata and Models of Computation

Liknande presentationer


En presentation över ämnet: "Formal Languages, Automata and Models of Computation"— Presentationens avskrift:

1 Formal Languages, Automata and Models of Computation
CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 1 - Intro School of Innovation, Design and Engineering Mälardalen University 2012

2 Content Adminstrivia Mathematical Preliminaries
Countable Sets (Uppräkneliga mängder) Uncountable sets (Överuppräkneliga mängder)

3 Lecturer & Examiner Gordana Dodig-Crnkovic

4 visit home page regularly!
Course Home Page visit home page regularly!

5 20 hours a week for this type of course (norm)
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!

6 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.

7 Why Theory of Computation?
5. Robustness of a general computational model. 6. The Church-Turing thesis: "everything algorithmically computable is computable by a Turing machine." 7. Study of non-determinism: languages can be described by the existence or no-nexistence of computational paths. 8. Understanding unsolvability: for some computational problems there is no corresponding algorithm that will unerringly solve them.

8 Practical Applications
Efficient compilation of computer languages String search Investigation of the limits of computation, recognizing difficult/unsolvable 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 (modelling by grammars)

9 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 reasoning as calculus - "Characteristica Universalis" aiming at: "a general method in which all truths of the reason would be reduced to a kind of calculation. At the same time this would be a sort of universal language or script, but infinitely different from all those projected hitherto; for the symbols and even the words in it would direct reason; and errors, except those of fact, would be mere mistakes in calculation.“ de Morgan, Boole, Frege, Russell, Whitehead: Mathematics as a branch of symbolic logic!

10 1900 Hilberts program for axiomatization of mathematics, redefined "proof" to become a completely rigorous notion, totally different from the psycho/sociological "A proof is something that convinces other mathematicians.“ He confirms the prediction Leibniz made, that "the symbols would direct reason" first programming languages 1931 Gödels incompleteness theorems 1936 Turing maschine (showed to be equivalent with recursive functions). Commonly accepted: TM as ultimate computer 1950 automata 1956 language/automata hierarchy

11 Formalization of Mathematics
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 Gödel's two incompleteness theorems of mathematical logic show limitations of all but the most trivial axiomatic systems. The theorems are widely interpreted as showing that Hilbert's program to find a complete and consistent set of axioms for all of mathematics is impossible, thus giving a negative answer to Hilbert's second problem.

12 Statement of Hilbert’s program
The main goal of Hilbert's program was to provide secure foundations for all mathematics. In particular this should include: A formalization of all mathematics; in other words all mathematical statements should be written in a precise formal language, and manipulated according to well defined rules. Completeness: a proof that all true mathematical statements can be proved in the formalism. Consistency: a proof that no contradiction can be obtained in the formalism of mathematics. This consistency proof should preferably use only "finitistic" reasoning about finite mathematical objects. Decidability: there should be an algorithm for deciding the truth or falsity of any mathematical statement.

13 Statement of Hilbert’s program
Gödel showed that most of the goals of Hilbert's program were impossible to achieve. His second incompleteness theorem stated that any consistent theory powerful enough to encode addition and multiplication of integers cannot prove its own consistency. This wipes out most of Hilbert's program as follows: It is not possible to formalize all of mathematics, as any attempt at such a formalism will omit some true mathematical statements. The most interesting mathematical theories are not complete. A theory such as Peano arithmetic cannot even prove its own consistency.

14 Turing’s Contribution
Turing used a Universal Turing machine (UTM) to prove an incompleteness theorem even more powerful than Gödel’s 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.

15 Mathematical Preliminaries
Based on C Busch, RPI, Models of Computation

16 Sets Functions Relations Proof Techniques Set Cardinality and Infinities Uncomputability

17 SETS A set is a collection of elements We write

18 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

19 A = { 1, 2, 3, 4, 5 } Universal Set: All possible elements U = { 1 , … , 10 } 1 2 3 4 5 A U 6 7 8 9 10

20 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 } U A B A-B

21 A A Complement Universal set = {1, …, 7}
4 A A 6 3 1 2 5 7 A = A

22 { even integers } = { odd integers }
2 4 6 1 3 5 7 even odd Integers

23 DeMorgan’s Laws A U B = A B U A B = A U B

24 Empty, Null Set: = { } S U = S S = S = S - S = U = Universal Set

25 Subset A = { 1, 2, 3} B = { 1, 2, 3, 4, 5 } A B U Proper Subset: A B

26 Disjoint Sets A = { 1, 2, 3 } B = { 5, 6} A B = U A B

27 Set Cardinality For finite sets A = { 2, 5, 7 } |A| = 3

28 Powersets A powerset is a set of sets S = { a, b, c }
Powerset of S = the set of all the subsets of S S = { a, b, c } 2S = { , {a}, {b}, {c}, {a, b}, {a, c}, {b, c}, {a, b, c} } Observation: | 2S | = 2|S| ( 8 = 23 )

29 Generalizes to more than two sets
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

30 PROOF TECHNIQUES Proof by construction Proof by induction
Proof by contradiction

31 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. 2 3 2 1 1 4 5 3 n = 6 n = 4

32 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 Proof by Construction END OF PROOF

33 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

34 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

35 Example Theorem A binary tree of height n has at most 2n leaves. Proof
let L(i) be the number of leaves at level i L(0) = 1 L(3) = 8

36 We want to show: L(i)  2i Inductive basis L(0) = (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

37 Induction Step hypothesis: L(n)  2n Level n n+1

38 Induction Step Level n hypothesis: L(n)  2n n+1
L(n+1)  2 * L(n)  2 * 2n = 2n+1 Induction Step END OF PROOF

39 Proof by induction: Cardinality of a power set
Let S be a finite set with N elements. Then the powerset of S (that is the set of all subsets of S ) contains 2^N elements. In other words, S has 2^N subsets. This statement can be proved by induction. It's true for N=0,1,2,3 as can be shown by examination. The notation 2^N means 2 to the power N, i.e., the product of N factors all of which equal 2. 2^0 is defined to be 1

40 The size of a finite power set
For the induction step suppose that the statement is true for a set with N-1 elements, and let S be a set with N elements. Remove on element x from S to obtain a set T with N-1 elements. There are two types of subsets of S: those that contain x and those that do not contain x. The latter are subsets of T, of which there are 2^ N-1. Every subset P of S that does contain x can be obtained from a subset Q of T by adding x. The set Q is simply the set P with x removed. Clearly there is a unique and distinct set Q for each set P and every subset Q of T gives rise to a unique and distinct subset P of S. There are thus also 2^ (N-1) subsets of S that contain x, for a total of 2^ (N-1) + 2^ (N-1) = 2^ N subsets of S.

41 Inductionsbevis: Potensmängdens kardinalitet
Påstående: En mängd med n element har 2n delmängder Kontroll Tomma mängden {} (med noll element) har bara en delmängd: {}. Mängden {a} (med ett element) har två delmängder: {} och {a}

42 Påstående: En mängd med n element har 2n delmängder
Kontroll (forts.) Mängden {a, b} (med två element) har fyra delmängder: {}, {a}, {b} och {a,b} Mängden {a, b, c} (med tre element) har åtta delmängder: {}, {a}, {b}, {c} och {a,b}, {a,c}, {b,c}, {a,b,c} Påstående stämmer så här långt.

43 Bassteg Enklaste fallet är en mängd med noll element (det finns bara en sådan), som har 20 = 1 delmängder.

44 Induktionssteg Antag att påståendet gäller för alla mängder med k element, dvs antag att varje mängd med k element har 2k delmängder. Visa att påståendet i så fall också gäller för alla mängder med k+1 element, dvs visa att varje mängd med k+1 element har 2k+1 delmängder.

45 Vi betraktar en godtycklig mängd med k+1 element
Vi betraktar en godtycklig mängd med k+1 element. Delmängderna till mängden kan delas upp i två sorter: Delmängder som inte innehåller element nr k+1: En sådan delmängd är en delmängd till mängden med de k första elementen, och delmängder till en mängd med k element finns det (enligt antagandet) 2k stycken.

46 Delmängder som innehåller element nr k+1: En sådan delmängd kan man skapa genom att ta en delmängd som inte innehåller element nr k+1 och lägga till detta element. Eftersom det finns 2k delmängder utan element nr k+1 kan man även skapa 2k delmängder med detta element. Totalt har man 2k + 2k = 2. 2k= 2k+1 delmängder till den betraktade mängden. END OF PROOF

47 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

48 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

49 Thus, m and n have common factor 2 Contradiction! = n/m 2 m2 = n2
Therefore, n2 is even n is even n = 2 k 2 m2 = 4k2 m2 = 2k2 m is even m = 2 p Thus, m and n have common factor 2 Contradiction! = n/m m2 = n2 END OF PROOF

50 Countable Sets

51 Infinite sets are either
Countable or Uncountable

52 Countable set There is a one to one correspondence between elements of the set and natural numbers

53 We started with the natural numbers, then
add infinitely many negative whole numbers to get the integers, then add infinitely many rational fractions to get the rationals, Each infinite addition seem to increase cardinality: |N| < |Z| < |Q| But is this true? NO!

54 Example The set of integers is countable Integers: Correspondence: Natural numbers:

55 Example The set of rational numbers is countable Positive Rational numbers:

56 Naive Idea Rational numbers: Correspondence: Natural numbers: Doesn’t work! we will never count numbers with nominator 2:

57 Better Approach ... ... ... ... Rows: constant numerator (täljare)
Columns: constant denominator ...

58 ... ... ... ...

59 We proved: the set of rational numbers is countable by describing an enumeration procedure

60 Definitions A language is a set of strings. A string is a sequence of symbols defined over an alphabet: An alphabet is a set of symbols.

61 Definition An enumeration procedure for is an algorithm that generates all elements of one by one. Let be a set.

62 Observation A set is countable if there is an enumeration procedure for it.

63 Example The set of all finite strings of symbols is countable. Proof We will describe the enumeration procedure.

64 Naive procedure: Produce the strings in lexicographic order: Doesn’t work! Strings starting with will never be produced.

65 Better procedure Proper Order 1. Produce all strings of length 1 2. Produce all strings of length 2 3. Produce all strings of length 3 4. Produce all strings of length 4

66 length 1 Produce strings in Proper Order length 2 length 3

67 Theorem The set of all finite strings is countable. Proof Find an enumeration procedure for the set of finite strings. Any finite string can be encoded with a binary string of 0’s and 1’s.

68 Produce strings in Proper Order
length 2 length 3 length 1 1 00 01 10 11 000 001 …. 2 3 4 5 6 7 String = program Natural number

69 PROGRAM = STRING (syntactic way)
PROGRAM = FUNCTION  (semantic way) PROGRAM string PROGRAM natural number n

70 Uncountable Sets

71 Definition A set is uncountable if it is not countable.

72 Theorem The set of all infinite strings is uncountable. Proof (by contradiction) We assume we have an enumeration procedure for the set of infinite strings.

73 Cantor’s diagonal argument
Encoding Infinite string = ... = = ... ... ... ... ...

74 Cantor’s diagonal argument
We can construct a new string that is missing in our enumeration! Conclusion The set of all infinite strings is uncountable!

75 Conclusion There are some integer functions that
An infinite string can be seen as FUNCTION  (n:th output is n:th bit in the string) Conclusion There are some integer functions that that cannot be described by finite strings (programs/algorithms).

76 Example of uncountable infinite sets
Theorem Let be an infinite countable set. The powerset of is uncountable.

77 Proof Since is countable, we can write

78 Elements of the powerset have the form:
……

79 We encode each element of the power set
with a binary string of 0’s and 1’s Encoding Powerset element ... ... ... ...

80 Let’s assume (by contradiction)
that the powerset is countable. Then: we can enumerate the elements of the powerset

81 Powerset element Encoding ... ... ... ... ...

82 Take the powerset element
whose bits are the complements in the diagonal

83 ... ... ... ... New element: (binary complement of diagonal)

84 The new element must be some
of the powerset However, that’s impossible: from definition of the i-th bit of must be the complement of itself Contradiction!

85 Since we have a contradiction:
The powerset of is uncountable END OF PROOF

86 uncountable infinite An Application: Languages Example Alphabet :
The set of all finite strings: infinite and countable The powerset of contains all languages: uncountable infinite

87 Finite strings (algorithms): countable
Languages (power set of strings): uncountable There are infinitely many more languages than finite strings.

88 Conclusion There are some languages that cannot be described by finite strings (algorithms).

89 Cardinality - Kardinaltal
Kardinaltal är mått på storleken av mängder. Kardinaltalet för en ändlig mängd är helt enkelt antalet element i mängden. Två mängder är lika mäktiga om man kan para ihop elementen i den ena mängden med elementen i den andra på ett uttömmande sätt, dvs det finns en bijektion mellan dem.

90 Real Numbers

91 Cardinality - Kardinaltal
Kardinaltal kan generaliseras till oändliga mängder. Till exempel är mängden av positiva heltal och mängden av heltal lika mäktiga (har samma kardinaltal). Däremot kan man inte para ihop alla reella tal med heltalen på detta sätt. Mängden av reella tal har större mäktighet än mängden av heltal.

92 Cardinality - Kardinaltal
Man kan införa kardinaltal på ett sådant sätt att två mängder har samma kardinaltal om och endast om de har samma mäktighet. T ex kallas kardinaltalet som hör till de hela talen för 0 (alef 0, alef är den första bokstaven i det hebreiska alfabetet). Dessa oändliga kardinaltal kallas transfinita kardinaltal.

93 Mer om oändligheter… More about Infinty
Georg Cantor utvecklade i slutet av 1800-talet matematikens logiska grund, mängdläran. Den enklaste, "minsta", oändligheten kallade han 0. Det är den uppräkningsbara oändliga mängdens (exempelvis mängden av alla heltal) kardinaltalet. Kardinaltalet av mängden punkter på en linje, och även punkterna på ett plan och i en kropp, kallade Cantor 1. Fanns det större oändligheter?

94 Ja! Cantor kunde visa att antalet funktioner på en linje var ”ännu oändligare” än punkterna på linjen, och han kallade den mängden 2. Cantor fann att det gick att räkna med kardinaltalen precis som med vanliga tal, men räknereglerna blev något enahanda.. 0 + 1= 0 0 + 0 = 0 0 · 0 = 0.

95 Men vid exponering hände det något: 0 0 (0 upphöjt till 0) = 1.
Mer generellt visade det sig att 2 n (2 upphöjt till n) = n+1 Det innebar att det fanns oändligt många oändligheter, den ena mäktigare än den andra!

96 Men var det verkligen säkert att det inte fanns någon oändlighet mellan den uppräkningsbara och punkterna på linjen? Cantor försökte bevisa den så kallade kontinuumhypotesen. Cantor: two different infinities 0 and 1 Continuum Hypothesis: 0 < 1 = 2 0 Se även:

97 Course materials based on
Peter Linz, An Introduction to Formal Languages and Automata Models of Computation, C Busch Lenart Salling, Formella språk, automater och beräkningar Mathematical Foundations of Computer Science; Susan H. Rodger; Duke University Rich Elaine, Automata, Computability and Complexity: Theory and Applications, Prentice Hall


Ladda ner ppt "Formal Languages, Automata and Models of Computation"

Liknande presentationer


Google-annonser