announcements ics 6b
play

Announcements ICS 6B Final on Tuesday in class Comprehensive - PDF document

Announcements ICS 6B Final on Tuesday in class Comprehensive Boolean Algebra & Logic Similar to quizzes A little more focus on last lecture Let me know if anyone wants some suggested Lecture Notes for Summer Quarter, 2008


  1. Announcements ICS 6B � Final on Tuesday in class � Comprehensive Boolean Algebra & Logic ● Similar to quizzes ● A little more focus on last lecture � Let me know if anyone wants some suggested Lecture Notes for Summer Quarter, 2008 problems � Let me know if anyone wants to attend a final Michele Rousseau review on Monday ● I will announce if I am able to get a room Set 10 – Ch. 12.1, 12.2, 12.3 � Quiz #4 regrades due today (Some slides inspired and adapted from Alessandra Pantano) 2 Lecture Set 10 - Chpts 12.1, 12.2, 12.3 Today’s Lecture � Chapter 12�12.1, 12.2, 12.3� ● Languages and Grammars �12.1� Chapter 12: Section 12.1 ● Finite State Machines with Outputs �12.2� ● Finite State Machines with No Output �12.3� Languages and Grammars Lecture Set 10 - Chpts 12.1, 12.2, 12.3 3 Examples Preliminary Definitions: Example 1 � Vocabulary: a not empty finite set of symbols ● V��a,B,C,d� is a vocabulary ● Also called an “alphabet” ● aBaaC and dBaB are sentences ● The set �aBaaC, dBaB� is a language � Sentence: a finite string of symbols Example 2 ● Also called a “word” ● V��English words� � g � ● Any finite sequence of words is a sentence � Language: any collection of sentences ● The set �“The Blue The”, “sky is blue”, “goat two”� is a language Example 3 ● V��letters in the alphabet� A sentence can be the empty string of symbols. ● Any sequence of the letters is a sentence In this case the sentence is denoted by λ�lambda� ● The set �“blue”, “sky”, “the”� is a language Lecture Set 10 - Chpts 12.1, 12.2, 12.3 5 Lecture Set 10 - Chpts 12.1, 12.2, 12.3 6 1

  2. Grammar: Informal Definition Example � A grammar is a way to construct a language from a given � Consider the vocabulary V��a,B,C,d�. vocabulary � Say that B is the start element. Choose a special element S in the vocabulary to begin with 1. � Choose �a,d� to be the terminal elements, and �B,C� �S will be called the “start symbol”� to be the non‐terminal elements. Divide your set of symbols �i.e. your vocabulary� into two 2. categories: the “terminal” and the “non‐terminal” � Allow the following replacements: elements. l t add The non‐terminal elements are the ones that can be 3. ● B�aC �aBCd � aBBcd �… replaced by other symbols. Strings containing non‐ aaCCd �… terminal elements can be replaced by other strings. Assign a set of rules �called “productions”� to replace 4. certain strings by other stings Start from you “start element” S, and apply the rules 5. �“productions”� to create the sentences in the language. 7 8 Lecture Set 10 - Chpts 12.1, 12.2, 12.3 Lecture Set 10 - Chpts 12.1, 12.2, 12.3 Example 1 A more formal definition Consider the vocabulary V�T �N with A phrase structure grammar G��V,T,S,P� consists of: ● T��a, the, fat, rabbit, mathematician, hops, eats� � A vocabulary v ● N��sentence, article, adjective, noun, verb� ● i.e. a not empty set of symbols � Let “sentence” be the start element. � A subset T � V of terminal elements productions � Allow the following replacements ● �i.e. a subset of symbols that cannot be replaced by other symbols� 1. sentence � �article� �adjective� �noun� �verb� � A start element S 2. article � a 3. article � the ● To begin our construction 4. adjective � fat � A finite set of productions 5. noun � mathematician ● A finite set of rules that specify which strings of symbols 6. noun � rabbit can be replaced by other strings 7. verb � hops 8. verb � eats Lecture Set 10 - Chpts 12.1, 12.2, 12.3 9 10 Example 1 (2) Example 1 (3) If we start from S�sentence and apply a sequence of We obtained strings of the following form production �until no further production is S � �article� �adjective� �noun� �verb� applicable�, we produce the following valid � sentences: adjective �article� �fat� �noun� �verb� article verb noun The article can be replaced by “a” or “the” The article can be replaced by a or the ● a fat mathematician hops f h i i h The noun can be replaced by “rabbit” or “mathematician” ● the fat mathematician hops I am only The verb can be replaced by “eats” or “hops” interested ● a fat rabbit hops in the sentences Notice that we can’t produce the string ● the fat rabbit hops that contain “a mathematician eats the rabbit” ● a fat mathematician eats “terminal” symbols ● the fat mathematician eats By applying a sequence of productions? (those that can’t be ● a fat rabbit eats replaced) �� This is not a valid string ● the fat rabbit eats 11 Lecture Set 10 - Chpts 12.1, 12.2, 12.3 12 2

  3. Example 2 Derivations G��V,T,S,P� with � Let G��V,T,S,P� be a phrase‐structure grammar. � Let w 0 and w 1 be strings over V. ● V��a,b,A,B,S� � We say that w 1 is directly derivable from w 0 if w 1 can be ● T��a,b� obtained from w 0 by applying a single production ● S�the start symbol More precisely, we can write w 0 and w 1 as a concatenation of ● P��S �ABa, A �BB, B �ab, AB �b� w 0 � l, z 0 r, w 1 � l, z 1 r �1� �1� �2� �3� �4� �2� �3� �4� And there exists a production z 0 � z 1. Lets see what are all the valid sentences that we can If w 1 is directly derivable from w 0 , we write w 0 � w 1 produce �by applying a sequence of productions to S� � We say that w 1 is derivable from w 0 if w 1 can be obtained ba from w 0 by applying a sequence of productions. �4� �2� �3�, �3�, �3� More precisely, there exists strings u 1, u 2 , …, u k such that S �ABa � BBBa �1� � abababa w 0 � u 1 � u 2 � … � u k � w 1 �3�, �3� Aaba �BBaba * �3� In this case we write w 0 � w 1 �2� The sequence of steps w 0 � u 1 � u 2 � … � u k � w 1 is called a derivation. 13 14 Lecture Set 10 - Chpts 12.1, 12.2, 12.3 For example Language of a Grammar � In example 2, � Let G��V, T, S, P� be a grammar. The language of G ‐ denoted L�G� ‐ is the set of all sequences of ● Bbaba is derivable from Aba, and a derivation is: terminal elements that can be derived from P: Aaba � Aaba � BBaba �3� �2� L�G���w �T * : S � w� * � To construct the language of G, you start from S and ● Another derivation is ABa � BBBa � BBaba AB � BBB � BB b apply all possible derivations that lead to sentences l ll ibl d i ti th t l d t t �2� �3� which only contain the symbols in T. � In Example 1, L�G� consists of exactly 8 sentences. � In Example 2, L�G� consists of exactly 2 sentences ● �“ba” and “abababa”� Lecture Set 10 - Chpts 12.1, 12.2, 12.3 15 Lecture Set 10 - Chpts 12.1, 12.2, 12.3 16 Type 1: Construct the Lang of a Grammar 2 Main Types of Problems: Example 3 1 – Given a grammar G, find L�G� G ��V, T, S, P� with ● V��S, A, a, b� ● T��a, b� 2 – Given a language L, find a grammar G such ● S� the start element that L L�G� that L�L�G� ● P��S�aA S �b A�aa� ● P��S�aA, S �b, A�aa� Find L�G� S �aA �aaa � L(G) = {b, aaa} b Lecture Set 10 - Chpts 12.1, 12.2, 12.3 17 Lecture Set 10 - Chpts 12.1, 12.2, 12.3 18 3

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend