Formal Languages and Logics Jacobs University Bremen Herbert Jaeger Course Number 320211 Lecture Notes Version from Oct 18, 2017 1 1. Introduction 1.1 What these lecture notes are and aren't This lecture covers material that is relatively simple, extremely useful, superbly described in a number of textbooks, and taught in almost precisely the same way in hundreds of university courses. It would not make much sense to re-invent the wheel and re-design this lecture to make it different from the standards. Thus I will follow closely the classical textbook of Hopcroft, Motwani, and Ullman for the first part (automata and formal languages) and, somewhat more freely, the book of Schoening in the second half (logics). Both books are available at the IRC. These books are not required reading; the lecture notes that I prepare are a fully self-sustained reference for the course. However, I would recommend to purchase a personal copy of these books all the same for additional and backup reading because these are highly standard reference books that a computer scientist is likely to need again later in her/his professional life, and they are more detailed than this lecture or these lecture notes. There are several sets of course slides and lecture notes available on the Web which are derived from the Hopcroft/Motwani/Ullman book. At http://www- db.stanford.edu/~ullman/ialc/win00/win00.html, you will find lecture notes prepared by Jeffrey Ullman himself. Given the highly standardized nature of the material and the availablity of so many good textbooks and online lecture notes, these lecture notes of mine do not claim originality. In fact, many of the examples I use are taken from the Hopcroft/Motwani/Ullman book, and I will not explicitly mention this in the text. I also occasionally copy from the ACS1 lecture notes written by Andreas Jacoby in Spring 2002, without giving the reference. The main purpose of these (fully self-contained) lecture notes is to make the purchase of a textbook unnecessary and to establish a reference of what contents will be asked for in the exams. 1.2 What automata and formal languages are and are good for The first part of this lecture will be concerned with formal languages. One of the most convenient and most widely used ways to specify a formal language is through automata. In this first introduction, we will give an informal sketch of the most simple type of an automaton, which will in turn give you a first idea of what a formal language is. What are "automata"? They are mathematical formalisms that can be interpreted intuitively as simple computational machines. What do they "do"? Typically they process "words", that is, finite symbol sequences. Example: The simplest kind of automaton is a finite automaton (FA). Physically, think of a FA as a device that can switch between a finite number of different states (they might be realised electronically or mechanically), with the switching events being triggered by symbols that are read in into the FA. More abstractly, such a FA can be represented by a directed graph, whose nodes ("vertices") correspond to the states. They are connected by arrows which are labelled by the symbols that the FA can process. Fig. 1.1 gives a simple example (from the Hopcroft book): 2 Fig. 1.1:A graph representation of a finite automaton. It has 4 states q0, q1, q2, q3, of which q0 is both the starting state (indicated by "start" arrow) and the final accepting state (indicated by double circle). The FA from Fig. 1.1 starts in the starting state q0. It now reads in a word made from symbols {0,1}, for instance the word "0110". The symbols are read in one by one. Each newly read-in symbol induces a state transition according to the transition arrows' labels. Thus, the word 0110 takes the FA through the state sequence q0, q2, q3, q2, q0. Because the last state in this sequence is q0, the accepting state, the FA accepts the input 0110. It would reject any input word that does not drive it through a state sequence ending in the accepting state. For instance, the word 10 would bring the FA to q3, which is not an accepting state, the word 10 would be rejected. The set of words accepted by this FA is the language of this automaton. (Can you describe this language in intuitive terms?) This is just an informal first contact to give an idea of the "flavour" of automata. We will later re-introduce FAs rigorously, and learn about more complicated (and more powerful) automata types. Here are some characteristic features of the theory of automata and languages: • The task of automata is to accept/reject input words. • Thus, an automaton defines a formal language, that is, the set of accepted words. • Finite automata are the most simple automata. • More complicated automata can be derived from FA by adding further mechanisms, for instance a stack memory (then you get "pushdown automata") or a tape memory (then you get "Turing machines"), or one can associate output actions with states (then one gets input-output-devices), or one can introduce randomness (then one gets non- deterministic or probabilistic automata) • The basic use of automata is as algorithms that "decide" languages, that is, for any query word carry out a computation (run the automaton on that word) whose result is a yes – no answer (via accept – reject) whether the query word belongs to the language. • The theory of automata and formal languages investigates how certain classes of formal languages correspond to certain types of automata. Applications of the theory of automata and formal languages: • Computer science: o Syntax checking of computer programs, lexical analysis of computer programs o Software for scanning large bodies of text (e.g., web page collections) for key words or key patterns 3 • Mechanical and electrical engineering: Design and implement control devices in mechano-electrical machines, from laundering machines to cellphones to nuclear power plants (control chips often implement tens to hundreds to thousands of FAs – note that the basic forking of labelled arrows leaving a FA state has the logical structure of a case distinction) • Chemistry, biochemistry: Models of chemical reaction chains, folding states of enzymes. • Information theory, theoretical physics: measuring the complexity of measurement series • Cognitive science, robotics: modeling and implementing decision-making ("action selection") sequences All in all, automata models and formal languages provide one of the most basic and most widely useful tools that computer science and mathematics offers, comparable to elementary calculus or elementary linear algebra. 1.3 What a logic is and is good for What is a "logic"? A mathematical language that can describe non-mathematical and mathematical facts in mathematical "propositions". What can you "do" with a logic? You can formally derive ("deduce") new propositions from ones that you already have, thereby answering interesting questions about the reality you are describing. You already know a simple kind of logic, Boolean logic. Boolean logic is quite restricted in its descriptive possibilities, you can only point to complete real-life facts and claim that they are false or true. In this lecture we will be concerned with another logic, first order logic (FOL). FOL can describe the internal structure of real-life facts; FOL can name individual things, actions, properties. A famous example, which is in fact as old as it appears, is illustrated in Fig. 1.2. Important points: • FOL can point to objects (Socrates), properties (human, mortal), actions (not in this example) • Using FOL, one can describe almost anything one wants; FOL is a very expressive logic. For instance, FOL is powerful enough to capture all of mathematics (within a certain set- theoretic framework) – in contrast, with Boolean logic you could not express mathematical statements as simple as "1 + 1 = 2". • Within the world of logics, one can derive new propositions (the conclusions, here: mortal Socrates) from given ones (the premises, here: "x (human x ® mortal x) and human Socrates). Such derivations are mathematical proofs. (the ß in Fig. 1.2.). • If a logic is correct, the conclusions one can prove are true (= hold in the real world) whenever the premises are true. This is a miraculous fact – think about it! 4 World of Logics Real World ∀ x (human x → mortal x) it's true! ∧ human Socrates it's true! ⇓ mortal Socrates it must be true -- it's true! it's proven! Fig. 1.2: The miracle of logics: Purely formal derivations are true in the real world! Applications of Boolean logic: • In basic EE & CS: for all binary switching systems, -- that is, for pretty much all of digital electronics from simple logical gate arrays to DSP chips to complete computers. • In Artificial Intelligence (AI): some real-world planning problems can be cast in Boolean logic and solved mechanically by the rules of Boolean logic. In the advanced lecture on Computation and Complexity (in your third year) you will learn that in fact, Boolean logic is in a sense universal: every computational problem that can be solved out by "trying out solutions" (technically, every problem that lies in class NP) can be translated into an equivalent Boolean logic problem. Applications of FOL: • In basic CS: program verification • In Artificial Intelligence: FOL is the basis of most AI systems, like expert systems, high-level robot control systems, intelligent user interfaces, speech understanding systems, etc. • In database systems: deductive databases 5 1. 4 Basic textbooks (for additional and backup reading, not required): Hopcroft, John E., Motwani, Rajeev, Ullman, Jeffrey D.: Introduction to Automata Theory, Languages, and Computation (2nd Edition), 2 (Addison Wesley) IRC: QA267 .H56 2003 Schoening, Uwe: Logic for Computer Scientists (Progress in Computer Science and Applied Logic, Vol 8), (Birkhauser) IRC: QA9 .S363 1989 Michal Walicki: Introduction to Logic.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages111 Page
-
File Size-