Decision, Computation and Language

Similar documents
Language properties and Grammar of Parallel and Series Parallel Languages

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

Grammars & Parsing, Part 1:

A General Class of Noncontext Free Grammars Generating Context Free Languages

COMPUTATIONAL COMPLEXITY OF LEFT-ASSOCIATIVE GRAMMAR

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

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

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

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

Context Free Grammars. Many slides from Michael Collins

A Version Space Approach to Learning Context-free Grammars

Natural Language Processing. George Konidaris

CS 598 Natural Language Processing

Enumeration of Context-Free Languages and Related Structures

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

Parsing of part-of-speech tagged Assamese Texts

GRAMMAR IN CONTEXT 2 PDF

A Grammar for Battle Management Language

"f TOPIC =T COMP COMP... OBJ

IT Students Workshop within Strategic Partnership of Leibniz University and Peter the Great St. Petersburg Polytechnic University

The Strong Minimalist Thesis and Bounded Optimality

Proof Theory for Syntacticians

11/29/2010. Statistical Parsing. Statistical Parsing. Simple PCFG for ATIS English. Syntactic Disambiguation

Refining the Design of a Contracting Finite-State Dependency Parser

ENGBG1 ENGBL1 Campus Linguistics. Meeting 2. Chapter 7 (Morphology) and chapter 9 (Syntax) Pia Sundqvist

Grade 6: Correlated to AGS Basic Math Skills

(Sub)Gradient Descent

Morphotactics as Tier-Based Strictly Local Dependencies

Grade 5 + DIGITAL. EL Strategies. DOK 1-4 RTI Tiers 1-3. Flexible Supplemental K-8 ELA & Math Online & Print

Parsing natural language

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

A Neural Network GUI Tested on Text-To-Phoneme Mapping

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

Sample Problems for MATH 5001, University of Georgia

Improving Fairness in Memory Scheduling

Compositional Semantics

Multiple case assignment and the English pseudo-passive *

GACE Computer Science Assessment Test at a Glance

Learning to Think Mathematically With the Rekenrek

Towards a MWE-driven A* parsing with LTAGs [WG2,WG3]

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

Discriminative Learning of Beam-Search Heuristics for Planning

PRODUCT PLATFORM DESIGN: A GRAPH GRAMMAR APPROACH

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

WSU Five-Year Program Review Self-Study Cover Page

Hyperedge Replacement and Nonprojective Dependency Structures

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

Analysis of Probabilistic Parsing in NLP

ARNE - A tool for Namend Entity Recognition from Arabic Text

The New York City Department of Education. Grade 5 Mathematics Benchmark Assessment. Teacher Guide Spring 2013

Specifying Logic Programs in Controlled Natural Language

Self Study Report Computer Science

Ch VI- SENTENCE PATTERNS.

BANGLA TO ENGLISH TEXT CONVERSION USING OPENNLP TOOLS

Montana Content Standards for Mathematics Grade 3. Montana Content Standards for Mathematical Practices and Mathematics Content Adopted November 2011

FractionWorks Correlation to Georgia Performance Standards

systems have been developed that are well-suited to phenomena in but is properly contained in the indexed languages. We give a

Chinese Language Parsing with Maximum-Entropy-Inspired Parser

Some Principles of Automated Natural Language Information Extraction

Type Theory and Universal Grammar

Hans-Ulrich Block, Hans Haugeneder Siemens AG, MOnchen ZT ZTI INF W. Germany. (2) [S' [NP who][s does he try to find [NP e]]s IS' $=~

AP Calculus AB. Nevada Academic Standards that are assessable at the local level only.

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

UNIVERSITY OF OSLO Department of Informatics. Dialog Act Recognition using Dependency Features. Master s thesis. Sindre Wetjen

CS Machine Learning

Are You Ready? Simplify Fractions

Abstractions and the Brain

Detecting English-French Cognates Using Orthographic Edit Distance

Machine Learning from Garden Path Sentences: The Application of Computational Linguistics

The presence of interpretable but ungrammatical sentences corresponds to mismatches between interpretive and productive parsing.

Chapter 4: Valence & Agreement CSLI Publications

Parsing with Treebank Grammars: Empirical Bounds, Theoretical Models, and the Structure of the Penn Treebank

Liquid Narrative Group Technical Report Number

Efficient Normal-Form Parsing for Combinatory Categorial Grammar

Radius STEM Readiness TM

Standard 1: Number and Computation

On the Polynomial Degree of Minterm-Cyclic Functions

ReinForest: Multi-Domain Dialogue Management Using Hierarchical Policies and Knowledge Ontology

2/15/13. POS Tagging Problem. Part-of-Speech Tagging. Example English Part-of-Speech Tagsets. More Details of the Problem. Typical Problem Cases

LNGT0101 Introduction to Linguistics

CAAP. Content Analysis Report. Sample College. Institution Code: 9011 Institution Type: 4-Year Subgroup: none Test Date: Spring 2011

Computer Organization I (Tietokoneen toiminta)

Derivational and Inflectional Morphemes in Pak-Pak Language

Guide to the Uniform mark scale (UMS) Uniform marks in A-level and GCSE exams

Language Evolution, Metasyntactically. First International Workshop on Bidirectional Transformations (BX 2012)

An Introduction to the Minimalist Program

Hindi Aspectual Verb Complexes

CS 1103 Computer Science I Honors. Fall Instructor Muller. Syllabus

Lecture 1: Basic Concepts of Machine Learning

How Does Physical Space Influence the Novices' and Experts' Algebraic Reasoning?

have to be modeled) or isolated words. Output of the system is a grapheme-tophoneme conversion system which takes as its input the spelling of words,

Enhancing Unlexicalized Parsing Performance using a Wide Coverage Lexicon, Fuzzy Tag-set Mapping, and EM-HMM-based Lexical Probabilities

We are strong in research and particularly noted in software engineering, information security and privacy, and humane gaming.

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

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

CS 101 Computer Science I Fall Instructor Muller. Syllabus

Learning to Schedule Straight-Line Code

Parallel Evaluation in Stratal OT * Adam Baker University of Arizona

School of Innovative Technologies and Engineering

An Interactive Intelligent Language Tutor Over The Internet

Transcription:

Decision, Computation and Language Context-free Grammar (CFG) Dr. Muhammad S Khan (mskhan@liv.ac.uk) Ashton Building, Room G22 http://www.csc.liv.ac.uk/~khan/comp218

The Chomsky Hierarchy Languages exist which are not regular; Noam Chomsky categorised regular and other languages as follows: Language Class Grammar Automaton 3 Regular NFA or DFA 2 Context-Free Push Down Automaton 1 Context-Sensitive Linear-Bounded Automaton 0 Unrestricted Turing machine M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 2

Type 3 - Regular Languages A regular language is one which can be: represented by a regular grammar, described using a regular expression, or accepted using an NFA or a DFA. M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 3

Type 2 - Context-Free Languages A Context-Free Grammar (CFG) is one whose production rules are of the form: A α where A is any single non-terminal, and α is any combination of terminals and non-terminals. A NFA/DFA cannot recognise strings from this type of language since we must be able to "remember" information somehow. CFG is accepted using Push-Down Automaton which is like a DFA except that we are also allowed to use a stack (memory). M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 4

Type 1 - Context-Sensitive Languages Context-Sensitive grammars may have more than one symbol on the left-hand-side of their production rules (provided that at least one of them is a non-terminal). However, the production rules must now obey the following: The number of symbols on the left-hand-side must not exceed the number of symbols on the right-hand-side We do not allow rules of the form A ε unless A is the start symbol and does not occur on the right-hand-side of any rule. M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 5

Type 0 - Unrestricted (Free) Languages Free grammars have absolutely no restrictions on their grammar rules, (except, of course, that there must be at least one non-terminal on the left-hand-side). The type of automata which can recognise such a language is basically a NFA/DFA with an infinitely-long list at its disposal to use as a store; this is called a Turing machine. M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 6

Context-free Grammars (CFG) M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 7

Grammar M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 8

Context-free Grammars Show how CFGs can be converted into normal forms, i.e. equivalent CFGs that have additional syntactic restrictions Use normal form to show that pushdown automata are the class of machines that accept CFLs. Parsing is the process of checking that a sequence of symbols is generated by a context-free grammar Consider classes of parsing algorithms expressible as restricted classes of pushdown automata (note: general pushdown automata are impractical to implement, unlike finite automata) M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 9

Context-free Grammars M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 10

Example M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 11

Example of using the grammar M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 12

Another Example M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 13

Example of using the grammar M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 14

Finite languages M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 15

Notation M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 16

Notation M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 17

Types of rules in CFG There are three types of rules in CFG 1. Union Rule: S A B 2. Production Rule: S AB 3. Closure Rule: S AS ε M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 18

Examples M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 19

More Examples L = ε, a, b, bb, aa, aaa, bbb,, a n, b n n 0 L = ε, ab, aabb, aaabbb,, a n b n n 0 L = ε, ab, abab, ababab,, ab n n 0 L = a n b m n, m 0 L = a n b m c k : n, m, k 0 Well balances parentheses: (()(()))() M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 20

Regular Languages are Context-free... M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 21

Regular Grammar M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 22

An equivalent definition The above definition is used in Hopcroft and Ullman. The previous definition is used in Temblay and Sorenson. M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 23

Conversion to restricted form M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 24

Regular Grammar to NFA M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 25

How to prove the construction is valid M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 26

Example M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 27

Example of conversion from grammar to FA M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 28

Example of conversion from grammar to FA M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 29

Example of conversion from grammar to FA M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 30

Another Example M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 31

Example (contd.) M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 32

Example: some arithmetic expressions M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 33

Ambiguity Parsing is the problem of: given a grammar and a string, find a derivation of the string using the grammar. (example on previous slide!) Given our claim that programming languages are often described using grammars, this is a key problem for compiler. We prefer unambiguous CFGs (ones where all derivations of a string are essentially the same, noting that variables of a CFG often correspond to specific structures of a program, e.g. arithmetic expression, procedure, statement, method etc. M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 34

Ambiguity (continued) M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 35

Parse Trees (a.k.a. syntax trees, derivation trees M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 36

Parse Trees (continued) M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 37

Rewriting a grammar M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 38

Rewriting a grammar (contd.) M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 39

Leftmost/rightmost derivations M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 40

Leftmost/rightmost derivations (contd.) M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 41

Another example of a simple ambiguous grammar M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 42

Example (contd.) M S Khan (Univ. of Liverpool) COMP218 Decision, Computation and Language 43