<<

Artificial Intelligence (AI) & Cellular Automata

Prof Eduardo R Miranda Varèse-Gastprofessor [email protected]

Electronic Music Studio TU Berlin Institute of Communications Research http://www.kgw.tu-berlin.de/ Formal Grammars

Collection of descriptive or prescriptive rules for analysing or generating sequences of symbols. Example: conventions

1) Capital letters such as A, B, C etc. indicate non-terminal nodes (non- terminal symbols of the grammar. 2) Lower cases such as a, b, c, etc. indicate terminal nodes (terminal symbols of the grammar). 3) Symbol  stands for “is defined as” 4) Symbol | stands for “or”

Simple grammar

S  A | B A  aA | a B  bB | b Simple grammar

S  A | B A  aA | a B  bB | b

An example of a sequence generated by this grammar:

S  A  aA  aaA  aaaA  aaaaA  aaaaaA  aaaaaa This sequence can also be represented visually:

S  A  aA  aaA  aaaA  aaaaA  aaaaaA  aaaaaa

It is often more convenient to use a superscript number to indicate the length of a string or substring of identical terminal nodes. Eg., a3b4 corresponds to aaabbbb For generative music grammars are useful for the definition of generative (or production) rules.

Example of a generative production rule system, as a 4 element structure (N, T, P, S) where:

N = set of non-terminal nodes T = set of terminal nodes P = set of production rules in the form of _  _ S = starting symbol

Let us define ({S, A, B}, {a, b}, P, S), where P consists of:

S  aSBC | aBC CB  BC aB  ab bB  bb bC  bc cC  cc S  aSBC | aBC CB  BC aB  ab bB  bb bC  bc cC  cc

Generative sequence example:

S  aSBC  aaBCBC (by using rule S  aBC)  aabCBC (by using rule aB  ab)  aabBCC (by using rule CB  BC)  aabbCC (by using rule bB  bb)  aabbcC (by using rule bC  bc) aabbcc (by using rule cC  cc)

In this system, the string aabbcc is a valid statement because it is possible to trace it back up to the root S. Regular grammar and finite state automata

S  aA | bB A  aA | a B  bB | b

Can be visually represented using graph diagrams, with labelled edges and vertices. Vertices are element of N (non-terminal node) and # is a halting vortex. Any node N can be designated as the starting node, and one or more node be designated as final nodes. In this case they are called finite state (FSM).

The definition differs slightly. Example ({A, B, C, D, E}, {a, b}, P, A, {D, E}) where:

{A, B, C, D, E} is a set of non-terminal nodes {a, b} is a set of terminal nodes P is a set of production rules (see graph) A is the starting node {D, E} is a set of ending nodes Practical uses of formal grammars: Generative example

An example of a grammatical rule for an affirmative sentence (the symbol “+” is used instead of “|”):

S  NS + VS NS  A + N VS  V + NS

Lexicon:

A = {the, a, an} N = {dog, , music, musician, coffee} V = {compose, makes, hears}

Valid sentences:

A computer composers the music. A coffee hears the computer. Transformational example

IF: S(o)  NS(n) + VS(m) NS(n)  A(n) + N(n) VS(n)  V + NS(m)

THEN: S(t)  NS(m) + VS(n) NS(m)  A(m) + N(m) VS(n)  NS(n) + V

Eg:

IF: A musician composes the music THEN: The music a composer composes Musical example

Definition:

Rn = a given reference note (eg., R1 = C4) In = interval between two notes Dn = direction of an interval SEQn = sequence SIMn = simultaneity

Lexicon: I = {minor 2nd, major 2nd, minor 3rd, major 3rd, perfect 4th, augmented 4th, perfect 5th, minor 6th, major 6th, minor 7th, major 7th, octave, none} D = {upwards, downwards}

Rule:

SIM1  SEQ1 + SEQ2 SEQ1  (I5, D1) + (I8, D1) + (I11, D1) SEQ2  (I5, D2) + (I8, D2) Rule:

SIM1  SEQ1 + SEQ2 SEQ1  (I5, D1) + (I8, D1) + (I11, D1) SEQ2  (I5, D2) + (I8, D2) Transformational example

IF:

SIM1  SEQ1 + SEQ2 SEQ1  (I5, D1) + (I8, D1) + (I11, D1) SEQ2  (I5, D2) + (I8, D2)

THEN:

SEQ3  SIM2 + SEQ1 SIM2  SEQ1 + SEQ2 Finite state automata Finite state automata An example using grammars & distribution functions

The rule system (or “grammar”) comprises 4 production rules for generating strings from an alphabet of 3 symbols: T, U and D.

Given an initial token TU, the production rules are defined as follows:

[1] If the last symbol is U, then D can be added at the end of the string [2] The string T? can be replaced by the string T?? [3] If UUU occurs in a string, then UUU can be replaced by D [4] If DD occurs in a string, then DD can be dropped

? = variable that can hold both a symbol of the alphabet or a string. [1] If the last symbol is U, then D can be added at the end of the string [2] The string T? can be replaced by the string T?? [3] If UUU occurs in a string, then UUU can be replaced by D [4] If DD occurs in a string, then DD can be dropped

? = variable that can hold both a symbol of the alphabet or a string.

Example of functioning: given initial token TU

TU initial token TUU by rule 2 TUUU by rule 2 TDU by rule 3 TDUDU by rule 2 TDUDUD by rule1 TDUDUDDUDUD by rule 2 TDUDUUDUD by rule 4 Such strings can be regarded as abstract melodic forms.

Given an initial note, the symbols U and D correspond to the direction of the next note in the melody.

T represents the initial note.

The actual interval (the distance that separates the 2 notes) is selected from a set of prescribed intervals according to a chose distribution function (i.e., probability that the elements of a set will be picked)

Example: I = {10, 20, 21, 30, 32, 45, 46, 55, 56, 61, 70, 71, 85, 86}

1st digit = size of the interval; 2nd, 3rd, etc. 2nd digit = type; major, minor, etc. I = {10, 20, 21, 30, 32, 45, 46, 55, 56, 61, 70, 71, 85, 86}

1 = unison 0 = minor 2 = second 1 = major 3 = third 5 = perfect 4 = fourth 4 = diminished 5 = fifth 6 = augmented 6 = sixth 7 = seventh 8 = octave

TDU TUUDUD (exponential distribution)

TUDUDDUDDUD (linear distribution) Cellular Automata & Music

 Music = sequences of sound structures and variations

 Cellular Automata = pattern generator and pattern propagator Cellular Automata

CA are computer modelling techniques widely used to model systems in which space and time are discrete, and quantities take on a finite set of discrete values.

Cellular automata were originally introduced in the sixties by von Neumann and Ulan as a model of a biological self-reproduction.

They wanted to know if it would be possible for an abstract machine to reproduce; that is, to automatically construct a copy of itself.

Their model consisted of a two-dimensional grid of cells, each cell of which had a number of states, representing the components out of which they built the self-reproducing machine.

Controlled completely by a set of rules designed by its creators, the machine would extend an arm into a virgin portion of the grid, then slowly scan it back and forth, creating a copy of itself - reproducing the patterns of cells at another location in the grid. Since then cellular automata have been repeatedly reintroduced and applied to a considerable variety of purposes.

Many interesting algorithms have been developed during the past thirty years. In general, CA are implemented as a regular array or matrix of variables called cells.

Each cell may assume values from a finite set of integers and each value is normally associated with a colour.

The functioning of a cellular automaton is displayed on the computer screen as a sequence of changing patterns of tiny coloured cells, according to the tick of an imaginary , like an animated film.

At each tick of the clock, the values of all cells change simultaneously, according to a set of transition rules that takes into account the values of their neighbourhood. The following figure illustrates a very simple CA. It consists of an array of 12 cells and each cell can value either 0 or 1, represented by the colours white or black, respectively.

A very simple CA. The right hand figure displays the colours associated to cell values; in this case 0=white and 1

At each tick of the clock, the values of all 12 cells change simultaneously according to a set of rules that determines a new value for each cell. In this case, the rules are based upon the values of its two neighbours.

For example, if a cell is equal to 0 and if both neighbours are equal to 1, then this cell continues equal to zero in the next stage. More sophisticated CA configurations use a matrix of cells that can assume values other than 0 and 1 (and consequently, colours other than black and white).

In these cases, the transition rules normally computes four or eight neighbours. Game of Life Cellular Automata

From one tick of the clock to the next, the cells of the Game of Life cellular automaton can be either alive (i.e., black) or dead (i.e., white), according to the following rules devised by Conway:

• if a cell is dead at time t, it comes alive at time t+1 if it has exactly 3 neighbours alive;

• if a cell is alive at time t, it comes dead at time t+1 if has has fewer than 2 or more than 3 neighbours alive.

These rules are applied simultaneously to all cells of the lattice.

An initial configuration of live cells may either grow interminably, fall into cyclic patterns, or eventually die off. How to map the emergent behaviour of CA onto musical forms? A plausible method: Cartesian representation of note intervals Time Articulation Instrumentation Demon Cyclic Space Cellular Automata

Initialised as a random distribution of coloured cells, it always end up with stable, angular spirals reminiscent of crystalline growths. Demon Cyclic Space Cellular Automata

Each of the n possible states for a cell is represented by a different colour and numbered from 0 to n-1 .

A cell that happens to be in state k at one tick of the clock dominates any adjacent cells that are in state k-1 meaning that these adjacent cells change from k-1 to k.

This rule resembles a natural chain in which a cell in state 2 can dominate a cell in state 1 even if the later is dominating a cell in state 0.

But, since the automaton is cyclic, the chain has no end and a cell in state 0 dominates its neighbouring cells that are in state n-1 . Extensions and Variations Extensions and Variations Example: Listening...

 Entre o Absurdo e o Mistério (chamber orchestra) Cellular automata sound synthesis

• Granular synthesis: powerful sound synthesis technique but difficult to control

• Generates rapid succession of very short sound bursts (‘grains’) that together form larger sound events

• Problem: How to control the production of the grains? One approach: Stochastic techniques

50 % F = 110 Hz A = 0dB

30 % F = 220 Hz A = -3dB 20 % F = 330 Hz A = -6dB 10% F = 440 Hz A = -12dB

Difficult to produce interesting results: - lack dynamic unfolding - monotonous - too “electronic/artificial” Requirements: • Dynamic unfolding: initial ‘noisy’ attack towards oscillatory-like behaviour • Capable of producing a variety of different sounds • High-level parametric control of hundreds of synthesis parameters Requirements: • Dynamic unfolding: initial ‘noisy’ attack towards oscillatory-like behaviour • Capable of producing a variety of different sounds • High-level parametric control of hundreds of synthesis parameters

Our solution: • The emergent behaviour of cellular automata Model of Belousov-Zhabotinsky’s chemical oscillator How to map the emergent behaviour of the CA onto granular synthesis?

? . The emergent behaviour of cellular automata

• What do we need to convey?

Initial ‘chaotic’ attack + oscillatory-like behaviour Method: Each CA configuration c[n] controls a grain n The cellular automata synthesis controller Examples: Chaosynth Examples: voice-like synthesis Listening...

 Olivine Trees (electro-acoustic)