Composing Music with Grammars. grammar the whole system and structure of a language or of languages in general, usually taken as consisting of syntax.

Slides:



Advertisements
Similar presentations
Translator Architecture Code Generator ParserTokenizer string of characters (source code) string of tokens abstract program string of integers (object.
Advertisements

Grammars, Languages and Parse Trees. Language Let V be an alphabet or vocabulary V* is set of all strings over V A language L is a subset of V*, i.e.,
COGN1001: Introduction to Cognitive Science Topics in Computer Science Formal Languages and Models of Computation Qiang HUO Department of Computer.
Grammars.
Chapter Chapter Summary Languages and Grammars Finite-State Machines with Output Finite-State Machines with No Output Language Recognition Turing.
ISBN Chapter 3 Describing Syntax and Semantics.
CSE 3302 Programming Languages Chengkai Li, Weimin He Spring 2008 Syntax Lecture 2 - Syntax, Spring CSE3302 Programming Languages, UT-Arlington ©Chengkai.
CS 330 Programming Languages 09 / 13 / 2007 Instructor: Michael Eckmann.
Chapter 3 Describing Syntax and Semantics Sections 1-3.
1 Understanding Natural Language The Natural Language Understanding Problem 14.1Deconstructing Language: A Symbolic Analysis 14.2Syntax 14.3Syntax.
Chapter 3 Describing Syntax and Semantics Sections 1-3.
CSE (c) S. Tanimoto, 2008 Natural Language Understanding 1 Natural Language Understanding Outline: Motivation Structural vs Statistical Approaches.
Parsing — Part II (Ambiguity, Top-down parsing, Left-recursion Removal)
Chapter 3 Describing Syntax and Semantics Sections 1-3.
Chapter 3: Formal Translation Models
COP4020 Programming Languages
Syntactic Pattern Recognition Statistical PR:Find a feature vector x Train a system using a set of labeled patterns Classify unknown patterns Ignores relational.
Languages and Grammars MSU CSE 260. Outline Introduction: E xample Phrase-Structure Grammars: Terminology, Definition, Derivation, Language of a Grammar,
Models of Generative Grammar Smriti Singh. Generative Grammar  A Generative Grammar is a set of formal rules that can generate an infinite set of sentences.
S YNTAX. Outline Programming Language Specification Lexical Structure of PLs Syntactic Structure of PLs Context-Free Grammar / BNF Parse Trees Abstract.
(2.1) Grammars  Definitions  Grammars  Backus-Naur Form  Derivation – terminology – trees  Grammars and ambiguity  Simple example  Grammar hierarchies.
Language Translation Principles Part 1: Language Specification.
EECS 6083 Intro to Parsing Context Free Grammars
Lee CSCE 314 TAMU 1 CSCE 314 Programming Languages Syntactic Analysis Dr. Hyunyoung Lee.
1 Syntax and Semantics The Purpose of Syntax Problem of Describing Syntax Formal Methods of Describing Syntax Derivations and Parse Trees Sebesta Chapter.
Grammars.
Computer Science 112 Fundamentals of Programming II Recursive Processing of Languages.
CCSB354 ARTIFICIAL INTELLIGENCE (AI)
Languages & Strings String Operations Language Definitions.
ICS611 Introduction to Compilers Set 1. What is a Compiler? A compiler is software (a program) that translates a high-level programming language to machine.
Introduction Syntax: form of a sentence (is it valid) Semantics: meaning of a sentence Valid: the frog writes neatly Invalid: swims quickly mathematics.
1 CS 385 Fall 2006 Chapter 14 Understanding Natural Language (omit 14.4)
Chapter 10: Compilers and Language Translation Invitation to Computer Science, Java Version, Third Edition.
CS 355 – PROGRAMMING LANGUAGES Dr. X. Topics Introduction The General Problem of Describing Syntax Formal Methods of Describing Syntax.
Winter 2007SEG2101 Chapter 71 Chapter 7 Introduction to Languages and Compiler.
Languages A Language L over a finite alphabet  is a set of strings of characters from the alphabet. Examples are : 1.L = { s | s is a grammatical English.
1 Chapter 3 Describing Syntax and Semantics. 3.1 Introduction Providing a concise yet understandable description of a programming language is difficult.
Languages A Language L over a finite alphabet  is a set of strings of characters from the alphabet. Examples are : 1.L = { s | s is a grammatical English.
Languages, Grammars, and Regular Expressions Chuck Cusack Based partly on Chapter 11 of “Discrete Mathematics and its Applications,” 5 th edition, by Kenneth.
Grammars CPSC 5135.
CSNB143 – Discrete Structure Topic 11 – Language.
ISBN Chapter 3 Describing Syntax and Semantics.
1 Syntax In Text: Chapter 3. 2 Chapter 3: Syntax and Semantics Outline Syntax: Recognizer vs. generator BNF EBNF.
Copyright © Curt Hill Languages and Grammars This is not English Class. But there is a resemblance.
Parsing Introduction Syntactic Analysis I. Parsing Introduction 2 The Role of the Parser The Syntactic Analyzer, or Parser, is the heart of the front.
Grammars Grammars can get quite complex, but are essential. Syntax: the form of the text that is valid Semantics: the meaning of the form – Sometimes semantics.
Chapter 3 Describing Syntax and Semantics
Artificial Intelligence: Natural Language
Syntax The Structure of a Language. Lexical Structure The structure of the tokens of a programming language The scanner takes a sequence of characters.
ISBN Chapter 3 Describing Syntax and Semantics.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
SYNTAX.
Grammars A grammar is a 4-tuple G = (V, T, P, S) where 1)V is a set of nonterminal symbols (also called variables or syntactic categories) 2)T is a finite.
Syntax and Semantics Form and Meaning of Programming Languages Copyright © by Curt Hill.
Parsing and Code Generation Set 24. Parser Construction Most of the work involved in constructing a parser is carried out automatically by a program,
CSC312 Automata Theory Lecture # 26 Chapter # 12 by Cohen Context Free Grammars.
Programming Languages and Design Lecture 2 Syntax Specifications of Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern.
Lecture 16: Modeling Computation Languages and Grammars Finite-State Machines with Output Finite-State Machines with No Output.
GRAMMARS & PARSING. Parser Construction Most of the work involved in constructing a parser is carried out automatically by a program, referred to as a.
1 CS Programming Languages Class 04 September 5, 2000.
NATURAL LANGUAGE PROCESSING
7.2 Programming Languages - An Introduction to Informatics WMN Lab. Hye-Jin Lee.
Chapter 3 – Describing Syntax CSCE 343. Syntax vs. Semantics Syntax: The form or structure of the expressions, statements, and program units. Semantics:
Chapter 2. Formal Languages Dept. of Computer Engineering, Hansung University, Sung-Dong Kim.
Modeling Arithmetic, Computation, and Languages Mathematical Structures for Computer Science Chapter 8 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesAlgebraic.
System Software Unit-1 (Language Processors) A TOY Compiler
Compiler Design 4. Language Grammars
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Discrete Maths 13. Grammars Objectives
Visual Programming Languages ICS 539 Icon System Visual Languages & Visual Programming, Chapter 1, Editor Chang, 1990 ICS Department KFUPM Sept. 1,
Presentation transcript:

Composing Music with Grammars

grammar the whole system and structure of a language or of languages in general, usually taken as consisting of syntax and morphology (including inflections) and sometimes also phonology and semantics. a particular analysis of the system and structure of language or of a specific language. a set of actual or presumed prescriptive notions about correct use of a language Computing: a set of rules governing what strings are valid or allowable in a language or text.

syntax - the arrangement of words and phrases to create well-formed sentences in a language. morphology - the study of the forms of things, in particular Linguistics: the study of the forms of words. semantics - the branch of linguistics and logic concerned with meaning. the meaning of a word, phrase, sentence, or text

Definitions token - grammatical symbol root token – root of parse tree vocabulary (V)– all the tokens plus the null token alphabet of terminals (T)– subset of vocabulary language (L) – subset of finite concatenations of tokens of T alphabet of non-terminals (N) – categories of macrostructures in V sentential form – sequence of non-terminals production (rewrtiting) rule – LHS  RHS

Generative Grammar expressed as a quadruple G = (N,T,∑,P) G - generative grammar N - alphabet of non-terminals T - alphabet of terminals ∑ - root token P - collection of production rules of the form: α → β, where α, β ∈ (N ∪ T) ∗, and (N ∩ T) = Ø. (“ ∗ ”denotes the powerset or set of all subsets)

Chomsky’s four types of grammars Free (type 0) – imposes no restrictions on the form of the production rule. Intermediate strings can expand and contract in length. Allows for infinite strings and null strings. Context-sensitive (type 1) – A α B → A β B. alpha produces beta in the context of A and B. α → Ø is forbidden. Context-free (type 2) – very useful with regards to natural language and programming. Good for representing multi-leveled syntactic formations of music. Any non-terminal (representing a macrostructural category like motive, phrase, sentence, section, movement, entire piece, etc.) may generate a string of tokens at a lower level. Finite-state (type 3) – no more than one non-terminal token may appear on each side of any production rule. Type 2 does not have this limitation.

Production/Rewrite Rules Random selection Serial selection – Useful for musical purposes. No object is selected again until all the others are selected. (Compare to serialism) Finite-state transition matrix – successive productions depend on previous productions. For example: LHS-> (A ) (B ) (C ) (D ) Selection functions – higher level complex functions that return an integer value that corresponds to an object index. Meta-production rule – a single generation by a rule is to be substituted for all occurrences of the LHS of the rule. An example of horizontal dependency.

The Bol Processor (Bel and Kippen) A tabla-oriented generative grammar based on machne learning. Acquires knowledge through parsing expert input, and attempted generation, followed by expert approval or disapproval.

EMI – experiments in Musical Intelligence (David Cope, UC Santa Cruz) Arguably the most successful and developed automated grammar for music making. Analyzes the style of a composer through batch input of a multitude of pieces. Produces pieces of music that are highly faithful to the composer’s style. Developed in response to writer’s block occurring after the spending of a large commission for an opera. Composed in 10 days.

David Cope discusses EMI in a Radiolab interview

SenGen Production Rules Sentence -> [PrepositionalPhrase], + NounPhrase1 + VerbPhrase VerbPhrase1 -> [AdverbPhrase] + Verb1 + [PrepositionalPhrase || AdverbPhrase] VerbPhrase2 -> [AdverbPhrase] + Verb2 + NounPhrase + [PrepositionalPhrase || AdverbPhrase] NounPhrase -> [Determiner,90%] + [AdjectivePhrase] + Noun + [PrepositionalPhrase] NounPhrase1 -> [Determiner,90%] + [AdjectivePhrase] + agent AdverbPhrase -> [AdverbPhrase,25%] + Adverb AdjectivePhrase -> [AdverbPhrase,15%] + Adjective + [PrepositionalPhrase] PrepositionalPhrase -> Preposition + NounPhrase + [, + PrepositionalPhrase] (last stacked PrepPhrase preceeded by and)

Note: credit must be given to Curtis Roads and Paul Wieneke from whose paper Grammars as Representations for Music, I quote directly at times in this presentation as well as the New Oxford American Dictionary application bundled with Mac OS X. S.R. Holtzman deserves credit for the section on production rules taken from Using Generative Grammars for Music Composition. For a proper bibliography, see my accompanying paper, Composing Music with Grammars.