Introduction to Languages, Machines and Logic

Similar documents
Guide to Teaching Computer Science

A R "! I,,, !~ii ii! A ow ' r.-ii ' i ' JA' V5, 9. MiN, ;

Proof Theory for Syntacticians

Objectives. Chapter 2: The Representation of Knowledge. Expert Systems: Principles and Programming, Fourth Edition

Language properties and Grammar of Parallel and Series Parallel Languages

GACE Computer Science Assessment Test at a Glance

A General Class of Noncontext Free Grammars Generating Context Free Languages

Compositional Semantics

RANKING AND UNRANKING LEFT SZILARD LANGUAGES. Erkki Mäkinen DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF TAMPERE REPORT A ER E P S I M S

Mathematics subject curriculum

Informatics 2A: Language Complexity and the. Inf2A: Chomsky Hierarchy

Lecture Notes on Mathematical Olympiad Courses

THE PROMOTION OF SOCIAL AWARENESS

Radius STEM Readiness TM

University of Groningen. Systemen, planning, netwerken Bosman, Aart

A Version Space Approach to Learning Context-free Grammars

AQUA: An Ontology-Driven Question Answering System

Syntax Parsing 1. Grammars and parsing 2. Top-down and bottom-up parsing 3. Chart parsers 4. Bottom-up chart parsing 5. The Earley Algorithm

Grammars & Parsing, Part 1:

COMPUTATIONAL COMPLEXITY OF LEFT-ASSOCIATIVE GRAMMAR

Introduction to HPSG. Introduction. Historical Overview. The HPSG architecture. Signature. Linguistic Objects. Descriptions.

Statewide Framework Document for:

An Interactive Intelligent Language Tutor Over The Internet

Module 12. Machine Learning. Version 2 CSE IIT, Kharagpur

Math 098 Intermediate Algebra Spring 2018

Context Free Grammars. Many slides from Michael Collins

On the Polynomial Degree of Minterm-Cyclic Functions

Knowledge-Based - Systems

Enumeration of Context-Free Languages and Related Structures

CS 598 Natural Language Processing

Some Principles of Automated Natural Language Information Extraction

GUIDE TO THE CUNY ASSESSMENT TESTS

Pre-Processing MRSes

Advanced Grammar in Use

Perspectives of Information Systems

Parsing of part-of-speech tagged Assamese Texts

CS4491/CS 7265 BIG DATA ANALYTICS INTRODUCTION TO THE COURSE. Mingon Kang, PhD Computer Science, Kennesaw State University

Mathematics. Mathematics

WSU Five-Year Program Review Self-Study Cover Page

Lecture 2: Quantifiers and Approximation

Document number: 2013/ Programs Committee 6/2014 (July) Agenda Item 42.0 Bachelor of Engineering with Honours in Software Engineering

Physics 270: Experimental Physics

Lecture 1: Machine Learning Basics

OFFICE SUPPORT SPECIALIST Technical Diploma

South Carolina English Language Arts

Probability and Game Theory Course Syllabus

Ontological spine, localization and multilingual access

Page 1 of 11. Curriculum Map: Grade 4 Math Course: Math 4 Sub-topic: General. Grade(s): None specified

AGS THE GREAT REVIEW GAME FOR PRE-ALGEBRA (CD) CORRELATED TO CALIFORNIA CONTENT STANDARDS

Practical Research Planning and Design Paul D. Leedy Jeanne Ellis Ormrod Tenth Edition

MASTER OF SCIENCE (M.S.) MAJOR IN COMPUTER SCIENCE

Version Space. Term 2012/2013 LSI - FIB. Javier Béjar cbea (LSI - FIB) Version Space Term 2012/ / 18

Mathematics Assessment Plan

PH.D. IN COMPUTER SCIENCE PROGRAM (POST M.S.)

Excel Formulas & Functions

Mixed Up Multiplication Grid

International Series in Operations Research & Management Science

Computerized Adaptive Psychological Testing A Personalisation Perspective

Learning to Schedule Straight-Line Code

STA 225: Introductory Statistics (CT)

Abstractions and the Brain

Rule-based Expert Systems

Visual CP Representation of Knowledge

Basic Parsing with Context-Free Grammars. Some slides adapted from Julia Hirschberg and Dan Jurafsky 1

Maximizing Learning Through Course Alignment and Experience with Different Types of Knowledge

"f TOPIC =T COMP COMP... OBJ

Erkki Mäkinen State change languages as homomorphic images of Szilard languages

Chapter 4: Valence & Agreement CSLI Publications

Developing a TT-MCTAG for German with an RCG-based Parser

Course Syllabus for Math

THE UNIVERSITY OF SYDNEY Semester 2, Information Sheet for MATH2068/2988 Number Theory and Cryptography

Evolution of Collective Commitment during Teamwork

Controlled vocabulary

MARE Publication Series

Probability and Statistics Curriculum Pacing Guide

South Carolina College- and Career-Ready Standards for Mathematics. Standards Unpacking Documents Grade 5

Parallel Evaluation in Stratal OT * Adam Baker University of Arizona

Conducting the Reference Interview:

THE UNITED REPUBLIC OF TANZANIA MINISTRY OF EDUCATION, SCIENCE, TECHNOLOGY AND VOCATIONAL TRAINING CURRICULUM FOR BASIC EDUCATION STANDARD I AND II

Syllabus ENGR 190 Introductory Calculus (QR)

The 9 th International Scientific Conference elearning and software for Education Bucharest, April 25-26, / X

BPS Information and Digital Literacy Goals

Inleiding Taalkunde. Docent: Paola Monachesi. Blok 4, 2001/ Syntax 2. 2 Phrases and constituent structure 2. 3 A minigrammar of Italian 3

Bittinger, M. L., Ellenbogen, D. J., & Johnson, B. L. (2012). Prealgebra (6th ed.). Boston, MA: Addison-Wesley.

Numeracy Medium term plan: Summer Term Level 2C/2B Year 2 Level 2A/3C

arxiv: v1 [cs.cv] 10 May 2017

CX 105/205/305 Greek Language 2017/18

Refining the Design of a Contracting Finite-State Dependency Parser

Loughton School s curriculum evening. 28 th February 2017

An Introduction to the Minimalist Program

Blinky Bill. Handwriting and. Alphabet Copy Book. Sample file. From Homeschooling Downunder. Manuscript Print Ball and Stick Font

Spring 2016 Stony Brook University Instructor: Dr. Paul Fodor

Developing Grammar in Context

CS/SE 3341 Spring 2012

K 1 2 K 1 2. Iron Mountain Public Schools Standards (modified METS) Checklist by Grade Level Page 1 of 11

Math 181, Calculus I

Specification and Evaluation of Machine Translation Toy Systems - Criteria for laboratory assignments

This scope and sequence assumes 160 days for instruction, divided among 15 units.

Learning Microsoft Publisher , (Weixel et al)

MGMT3403 Leadership Second Semester

Transcription:

Introduction to Languages, Machines and Logic

Springer-Verlag London Ltd.

Alan P. Parkes Introduction to Languages, Machines and Logic Computable Languages, Abstract Machines and Formal Logic Springer

Alan P. Parkes, BSc, PhD Distributed Multimedia Research Group, Computing Department, Lancaster University, Lancaster, LAI 4YR British Library Cataloguing in Publication Data Parkes, Alan Introduction to languages, machines and logic: computable languages, abstract machines and formal logic 1. Machine theory I. Title 511.3 ISBN 978-1-85233-464-2 Library of Congress Cataloging-in-Publication Data Parkes, Alan Introduction to languages, machines and logic: computable languages, abstract machines and formal logic/ Alan P. Parkes. p.cm. Includes index. ISBN 978-1-85233-464-2 ISBN 978-1-4471-0143-7 (ebook) DOI 10.1007/978-1-4471-0143-7 1. Formallanguages 2. Machine theory. I. Title. QA267.3.P372001 511.3-dc21 2001054282 Apart from any fair dealing for the purposes of research or private study, or criticism or review, as permitted under the Copyright, Designs and Patents Act 1988, this publication may only be reproduced, stored or transmitted, in any form or by any means, with the prior permission in writing of the publishers, or in the case of reprographic reproduction in accordance with the terms of licences issued by the Copyright Licensing Agency. Enquiries concerning reproduction outside those terms should be sent to the publishers. ISBN 978-1-85233-464-2 http://www.springer.co.uk Springer-Verlag London Limited 2002 Originally published by Springer-Verlag London in 2002 The use of registered names, trademarks etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant laws and regulations and therefore free for general use. The publisher makes no representation, express or implied, with regard to the accuracy of the information contained in this book and cannot accept any legal responsibility or liability for any errors or omissions that may be made. Typesetting: Gray Publishing, Tunbridge Wells, Kent 34/3830-54321 Printed on acid-free paper SPIN 10935873

Contents 1 Introduction............................. 1 Overview... 1 What This Book Is About...................... 1 What This Book Tries to Do... 5 What This Book Tries Notto Do... 6 The Exercises............................. 7 Further Reading... 7 Some Advice... 7 Part 1 Languages and Machines 2 Elements of Formal Languages.................. 11 Overview... 11 Alphabets... 11 Strings................................ 12 Functions that Apply to Strings................. 12 Useful Notation for Describing Strings... 13 Formal Languages... 14 Methods for Defining Formal Languages... 15 Set Definitions of Languages... 15 Decision Programs for Languages... 17 Rules for Generating Languages... 19 Formal Grammars... 22 Grammars, Derivations, and Languages............ 22 The Relationship Between Grammars and Languages... 26 Phrase Structure Grammars and the Chomsky Hierarchy... 26 Formal Definition of PSGs... 26 Derivations, Sentential Forms, Sentences, and "L( G)"... 27 The Chomsky Hierarchy... 30 A Type 0 Grammar: Computation as Symbol Manipulation " 33 Exercises............................... 35 v

vi Contents 3 Syntax, Semantics, and Ambiguity... 37 Overview.................. 37 Syntax Vs. Semantics............... 37 Derivation Trees................. 38 Parsing........................... 39 Ambiguity.............................. 42 Exercises............................... 45 4 Regular Languages and Finite State Recognisers... 49 Overview... 49 Regular Grammars................... 49 Some Problems with Grammars... 51 Finite State Recognisers and Finite State Generators 51 Creating an FSR... 51 The Behaviour of the FSR.................... 51 The FSR as Equivalent to the Regular Grammar... 56 Non-determinism in FSRs................. 59 Constructing Deterministic FSRs... 61 The DFSR as Equivalent to the Non-DFSR 63 A Simple Deterministic Decision Program..... 68 Minimal FSRs................... 68 Constructing a Minimal FSR... 70 Why Minimisation Works................... 73 The General Equivalence of Regular Languages and FSRs.. 76 Observations on Regular Grammars and Languages... 77 Exercises......................... 78 5 Context Free Languages and ~shdown Recognisers...... 81 Overview... 81 Context Free Grammars and Context Free Languages 81 Changing G Without Changing L( G)... 82 The Empty String (8)... 82 Chomsky Normal Form.................. 85 Pushdown Recognisers...................... 89 The Stack............................ 90 Constructing a Non-deterministic PDR........... 92 Example NPDRs, M3 and MlO..... 93 Deterministic PDRs... 96 M~, a Deterministic Version of M3.. 97 More DPDRs... 99 Deterministic and Non-deterministic CFLs... 99 Every Regular Language Is a Deterministic CFL.. 100 The Non-deterministic CFLs... 101 A Refinement to the Chomsky Hierarchy in the Case of CFLs... 103 The Equivalence of the CFLs and the PDRs 103

Contents vii Observations on CFGs and CFLs 104 Exercises.............. 105 6 Important Features of Regular and Context Free Languages... 107 Overview.............................. 107 Closure Properties of Languages... 107 Closure Properties of the Regular Languages...... 108 Complement......... 108 Union......... 109 Intersection........................... 110 Concatenation... 112 Closure Properties of the Context Free Languages....... 112 Union... 113 Concatenation Intersection........................... Complement.... Chomsky's Hierarchy Is Indeed a Proper Hierarchy...... The "Repeat State Theorem".................. A Language that Is Context Free but Not Regular...... The" uvwxy" Theorem for CFLs.... {aibici: i ;;:" I} Is Not Context Free.... The "Multiplication Language" Is Not Context Free... Preliminary Observations on the Scope of the Chomsky Hierarchy................ Exercises.... 7 Phrase Structure Languages and Thring Machines.... Overview.... The Architecture of the Turing Machine.... "Tapes" and the "Read/Write Head".... Blank Squares..................... TM "Instructions".... TMs Defined....... The Behaviour of a TM..... 115 116 117 118 118 120 122 128 129 130 131 133 133 133 133 134 135 136 136 TMs as Language Recognisers................ 139 Regular Languages................. 139 Context Free Languages... 140 TMs Are More Powerful than PDRs........... 143 Introduction to (TM) Computable Languages... 145 The TM as the Recogniser for the Context Sensitive Languages... 146 Constructing a Non-deterministic TM for Reduction Parsing of a Context Sensitive Language........... 146 The Generality of the Construction.............. 150 The TM as the Recogniser for the Type 0 Languages... 152

viii Contents Amending the Reduction Parsing TM to Deal with Type 0 Productions................. 152 Dealing with the Empty String... 153 The TM as the Recogniser for All Types in the Chomsky Hierarchy... 155 Decidability: A Preliminary Discussion............. 155 Deciding a Language...................... 155 Accepting a Language... 157 End of Part 1............................ 158 Exercises.............................. 159 Part 2 Machines and (omputation 8 Finite State Transducers... 163 Overview.............................. 163 Finite State Transducers... 163 FSTs and Language Recognition................. 164 FSTs and Memory......................... 164 FSTs and Computation... 167 Simple Multiplication... 167 Addition and Subtraction... 168 Simple Division and Modular Arithmetic... 171 The Limitations of the FST.................... 172 Restricted FST Multiplication................. 173 FSTs and Unlimited Multiplication... 176 FSTs as Unsuitable Models for Real Computers... 176 Exercises.............................. 178 9 Thring Machines as Computers... 179 Overview.............................. 179 Thring Machines and Computation... 179 TMs and Arbitrary Binary Multiplication............ 180 Some Basic TM Operations... 180 The''ADD''TM... 181 The"MULT"TM... 185 TMs and Arbitrary Integer Division............... 190 The"SUBTRACT"TM... 191 The "DIY" TM... 193 Logical Operations... 194 TMs and the Simulation of Computer Operations....... 196 Exercises.............................. 199 10 Turing's Thesis and the Universality of the Thring Machine... 203 Overview........................ 203

Contents ix Turing's Thesis.................. 203 Coding a TM and Its Tape as a Binary Number 205 Coding Any TM... 206 Coding the Tape....... 208 The Universal Turing Machine 208 UTMs Tapes......... 209 The Operation of UTM..... 211 Some Implications of UTM... 211 Non-deterministic TMs... 213 Converting a Non-deterministic TM into a 4-tape Deterministic TM... 214 The Four Tapes ofthe Deterministic Machine, D 214 The Systematic Generation of the Strings of Quintuple Labels... 216 The Operation of D.............. 222 The Equivalence of Non-deterministic and Four-tape Deterministic TMs... 222 Converting a Multi-tape TM into a Single-tape TM 222 Example: Representing Three Tapes as One 223 The Operation of the Single-tape Machine, S. 226 The Equivalence of Deterministic Multi-tape and Deterministic Single-tape TMs... 227 The Linguistic Implications of the Equivalence of Non-deterministic and Deterministic TMs 228 Exercises... 228 11 Computability, Solvability, and the Halting Problem 231 Overview... 231 The Relationship Between Functions, Problems, Solvability, and Decidability 231 Functions and Computability... 231 Problems and Solvability....... 232 Decision Problems and Decidability.. 234 The Halting Problem... 234 UTM H Partially Solves the Halting Problem. 235 Reductio ad Absurdum Applied to the Halting Problem... 235 The Halting Problem Shown to Be Unsolvable 239 Some Implications of the Unsolvability of the Halting Problem................. 240 Computable Languages... 242 An Unacceptable (Non-computable) Language 243 An Acceptable, but Undecidable, Language. 245 Languages and Machines....... 245 Exercises... 247

x Contents 12 Dimensions of Computation............... 249 Overview...................... 249 Aspects of Computation: Space, Time, and Complexity... 249 Non-deterministic TMs Viewed as Parallel Processors 251 Parallel Computations and Time............. 252 A Brief Look at an Unsolved Problem of Complexity 254 A Beginner's Guide to the "Big 0"... 254 Predicting the Running Time of Algorithms. 255 Linear Time... 256 Logarithmic Time 257 Polynomial Time 260 Exponential Time 267 The Implications of Exponential Time Processes 268 Is P Equal to NP?.................. 269 Observations on the Efficiency of Algorithms 270 End of Part 2 271 Exercises... 271 Part 3 Computation and Logic 13 Boolean Logic and Propositional Logic Overview.... Boolean Logic.... Boolean Logic Operators....... Boolean Logic for Problem Solving. Boolean Logic and Computing Propositional Logic.... Propositions.... Implication and Equivalence Rules of Inference...... 275 275 275 275 276 278 281 281 282 284 Problem Solving and Reasoning in Propositional Logic. 285 Using Truth Tables to Prove Things in PropositionalLogic................ 286 Observations on Propositional Logic 288 Exercises... 289 14 First Order Predicate Logic. 291 Overview... 291 Predicate Logic.. 291 Predicates 292 Functions 293 "Sentences" Revisited: Well-formed Formulae. 294 The "First Orderness" of First Order Logic... 295

Contents xi Quantifiers... 296 The Existential Quantifier... 296 The Universal Quantifier................... 298 A "Blocks World" Example of FOPL Representation... 299 The Semantics of FOPL: Interpretation... 300 Problem Solving and Inference in FOPL............ 301 Rules ofinference for FOPL... 301 Solving Problems by Classical FOPL Reasoning... 303 The Nature of FOPL....................... 304 Conclusions 305 Exercises... 305 15 Logic and Computation..................... 307 Overview... 307 A Computational Form of FOPL................ 307 Getting Rid of V........................ 308 Getting Rid of 3........................ 309 Conjunctive Normal Form Databases............ 312 Resolution... 314 The Role of Unification in Resolution............ 314 How to Do Resolution... 316 The Efficiency of Resolution................. 322 Why Resolution Works... 322 Logic in Action.......................... 323 Languages, Machines, and Logic... 325 Exercises... 326 Solutions to Selected Exercises... 327 Chapter 2............................... 327 Chapter 3............................... 329 Chapter 4............................... 329 Chapter 5............................... 331 Chapter 6............................... 333 Chapter 7............................... 333 Chapter 8............................... 333 Chapter 9............................... 334 Chapter 10... 334 Chapter 11... 334 Chapter 12... 335 Chapter 13... 337 Chapter 14... 338 Chapter 15... 338 Further Reading 341 Index... 343