Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 397 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
397
Dung lượng
20,96 MB
Nội dung
b d An Introductionto FormalLanguages andAutomata Third Edition PeterLinz Universityof Californiaat Davis 6l;l rf;ti etig* dtry'l-,tlti,tFI, hgfryfl6a t' o filru;;;: ';;'ut: \ n qf I" A\ ,r'f7 lA ,obi IONES AND BARTLETT P,UBLISHERS BOSTON Stdlnry, Massnclrrsrtr TORONT'O LONDON SINGAPORE Workl Headquerters Iones and Bartlett Puhlishers 40 Tall PineDrive MA 01776 Sudbury, 978-443-5000 info@jbpub.corn www.jbpub.com Jonesand Bartlett Publishers Canada 2406 Nikanna Road Mississauga,ON L5C 2W6 CANADA Jonesand BarJlettPublishers International Barb House,Barb Mews London W6 7PA UK Copyright O 2001 by Jonesand Bartlett Publishers,Inc All rights reserved.No part of the materialprotectedby this copyrightnotice may be reproducedor utilized in any fonn, elcctronicor mechanical,including photocopying,recording,or any infotmation storageor retrievalsy$tem,without written permissionf'romthe copyright owner G' Library of Congress Cataloging-in-Puhtication Data Linz, Peter An introductionto formal languagesand automata/ PeterLinz' 3'd cd p cm and index Includesbi hliographicalref'erences rsBN0-7637-1422-4 26+,3 L5 LooI l Formal languages Machine theory l Title QA267.3.Ls6 2000 | 1.3 dc2l A 00-062546 Chief ExecutiveOfficer: Clayton Jones Chief OperatingOfficer: Don W Jones,Jr ExecutiveVicc Presidentand Publisher: Tom Manning V.P., ManagingEditor: Judith H Hauck V.P Collese Editorial Director: Brian L McKean V.P;, Dcsigir'and"Prodgction: \ Anne $pencer V P., Salcs anit*ffrarket+rg-i.FauI Shefiardson V P., Man uf aeturingjandilnhrr'trrry dpntrol : ThereseBriiucr SeniorAgquisitionsEditor; Michacl $tranz f)evelopment and Product Managcr: f,lny Rose Markcting Director: Jennifer.Iacobson Production CoordinationI Tri{ litrm -Pt'oject M anagcment Cover Design; Night & Day Design Composition:NortheastCompositors Printing and Binding: Courier Westford Cover printing: John Pow Cotnpany,Inc ; #F*F*., Covel Imasc O Jim Wehtie This book was typesetin Texturcs2 I on a MacintoshG4 The fbnt families usedwere Computer Modern, Optima, and F'utura.The first printing was printed on 50 lb Decision94 Opaque Printedin the UnitedStatesof Arnerica _ -'_ 04030201 lo987654321 I lchL I ,r./1,il.t!\ his book is designed for an introductory course orr forrnir,l larrguages, autornatir, txlmputability, and rclated matters These topics form a major part of whnt is known as tht: theory of cornputation A course on this strbitx:t rnatter is now stir,nda,rdin the comprrter science curriculurn ancl is oftrlrr ta,ught fairly early irr the prograrn Hence, the Jrrospective audience for this book consists prirnrr,rily of sophomores and juniors rnirjrlring in computer scicntxlor computer errgirrwring Prerequisites for the material in this book are a knowledge of sorne higher-level prograrnrning la,nguage (cornmonly C, C++, or Iava) and fatrrilinritv with ihe furrdarn lul For example, AB-C r:anhe repla,cedby A.B +CI) D - \ Thtl equivaklrr(jc irrgunro\nt is straightfrlrwarrl Section 11.3 (c) Working with context-sensitive grammars is not always easy fhe idea of a messenger,introduced in Example 11.2, is often usefirl In this problern, the first stcp is to crtlatt: thc scrrttlrrtial fclrrn o.nBt:nD The variables -B and D will act as rrrarktlrs irrrcl urcsscrrgcrsto assrrrc that the correct nurnber clf b's and dts are r:reaterl irr the riglrt places The first part is achievtxl casily with the produr:tiorrs S + aAcDlaBcD A + a.AclaBc Irr the rtext sttlll, thc: B travcls to thc right to nxret the D, bv Bc +cB Bh +hB When that happens, we can create one d and a return messengerthat will put the b in the right place a,rrdstop BD - Erl, cE-Ec bE-Eb aE - ub Sol.urroNs alo HrNrs ron Snrlcrrr Exnncrsls 399 Alternatively, we create a,d plus a,marker D, with a diff'erent messenger thatcr.*t.sa b,but**" tT;:T;;*, tF + Fr b.F - I-b aF - ubB 'l'he easiest argument is from an lba Suppose that a language is 'I'hen context-sensitive there exists an Iba M that acceots it Given ?u, we first rewrite it as tuft, then apply M to it Because LR : ( LR 'I'he rnachine {w : wR € L}, M accepts trrn if and only if w tha,t reversesa string and applies M is a,nlba Therefore -Lft is contextsensitive Wc (:arr rlrglle frorn a.n lba Clearlv, there is an lha tha,t can recognize arty strirrg of thc ftrrtr u.r'url Just stirrt irt oppositt: enrl$ a,nrl cr)rrrpiirc syrnbols rrrrtil yorr grtt ir mat