Music, Mathematics, and Microcomputers Building upon a Classical Tradition

— In early Western medieval education, music was taught as one of the quadrivium , which comprised four of the seven liberal arts, in turn built upon an earlier Western classical tradition that produced the trivium . We re-examine music’s close relationship with the other elements of the quadrivium , and further establish links with elements of modern computing theory .


INTRODUCTION
"Quantity is twofold: continuous and discrete.Continuous quantity is concerned with lines, surfaces, and bodies, and is twofold because it is either immobile, which geometry concerns, or it is mobile, which astronomy concerns.Discrete quantity concerns numbers, and is twofold because it is either absolute, which arithmetic concerns (which deals with numbers absolutely), or it is relative, which music concerns (which deals with numbers related to sounds."[14] Thus, the differences between the four liberal arts of the quadrivium was explained in De plana musica (On Plainchant), Chapter 1, by one Johannes de Garlandia (flourished late 13 th century), music theorist and teacher ("magister") at one of the oldest European universities, the University of Paris.This is just one of many such writings on the liberal arts by musical theorists and others.Rooted in classical and medieval Western education, the two main divisions of the liberal arts trivium (grammar, rhetoric, logic) and the quadrivium (arithmetic, geometry, music, astronomy) have formed the basis for Western intellectual thought through many centuries.
In the present educational system, the term "liberal arts" has taken a broader meaning.In undergraduate curricula in United States universities, students are required to enroll in subjects referred to as these liberal arts.The substance of the original seven subjects is retained, even though the subjects themselves may be referred using differing terminology.Thus, for example, music for non-majors is now commonly referred to as "music appreciation"; arithmetic and geometry are studied as branches of mathematics, while astronomy is often incorporated in physics.Subjects of the trivium form an integral part of what is usually labeled "communication skills."Not all students may fully appreciate the value of a "liberal arts education," however.
In this paper, we explore the scientific basis of the original liberal arts and hence, their value in modern education.We limit ourselves to the investigation of one of the subjects of the quadrivium-music-and show how it, as defined by mathematical means, demonstrates great relevance in modern scientific thought and finds application in various fields of computer science.

II. MUSIC AND MATHEMATICS IN THE LIBERAL ARTS
From earliest classical times, music theorists had imparted a mathematical outlook on music by linking it to astronomy within the concept of the "music of the spheres."They developed the musical theories of, amongst others, Pythagoras of Samos (ca.570-495 BC), who was famous not only for the theorem that bears his name.The concern for musical measurement seen in Pythagoras remained a hallmark of music theory that endured all though the medieval (roughly 5 th to 15 th centuries) and Renaissance (roughly 15 th to 17 th centuries) periods.

A. Medieval and Renaissance Music Theory
Medieval music theory had as one of the central topics the question of tuning.For example, the above-quoted Johannes de Garlandia, expressed musical intervals in terms of arithmetical ratios (fig. 1) [14].During this period, many more treatises were written that discussed intervals and pitch.Marchetto of Padua (1274?, flourished 1305-1319), a prominent Trecento (a term referring to the 1300s, i.e., 14 th century) music theorist, in Lucidarium in arte musice plane (Elucidation of the Art of Plainchant), proposed his division of the whole tone, a topic that is hotly debated even today [11,18].
In the late Renaissance period, Michael Praetorius (1571?-1621), a German theorist, composer, and organist, in Syntagma musicum (Musical Syntax), discussed chamber ensemble pitch (modern measurement: 424 Hz), and felt that the increasingly higher pitches of the time strained the voice [20].Pier Francesco Tosi (ca.1653-1732), singer, composer, and theorist, in Opinioni (Opinions), distinguished between small and big semitones in vocal tuning, and emphasized the difference between vocal tuning and equal tempered tuning used for keyboard instruments [21].These works clearly show that the early music writers were concerned not only with theoretical aspects of music, but the performing aspects as well.
It should be noted that pitch was not the only musical element that received mathematical treatment.The notation of musical rhythm was another topic that received much attention from music theorists.Our present day musical notation owes much to the research of these theorists, who were striving to develop a system that was unambiguous, mathematically precise, and responsive to the performing needs of the day.Seminal works in this domain include Jerome of Moravia's (died post 1271) Tractatus de musica (Treatise on Music), in which Johannes de Garlandia is accredited with the authorship of De mensurabili musica (On Measured Music) [13,15].
In modern times, we too may take a mathematically oriented investigation of music theory.Mathematically inclined modern music composers and theorists have incorporated concepts such as the Fibonacci series, the golden ratio, and tessellation, into their works.Among very many, the work of Elliott Carter (who composed atonal music of great rhythmic complexity), Allen Forte (who proposed a musical adaptation of set theory [3]), David Lewin (who applied group theory to music [17]), Guerino Mazzola (who applied topos theory to music [19]), and Alexander Brinkman (who wrote a book on Pascal programming with music applications [1]) may be cited.Indeed, we note that many papers presented in music theory conferences could be adapted, with but minimal alterations, for mathematics conferences.
We shall now bring computational science into the picture by framing music theory and composition within the context of NP-Complete computational theory.We shall model music theory and composition by a pedagogical technique called Species Counterpoint, introduced by Johann Joseph Fux [4] and elaborated by Knud Jeppesen [12].

B. NP-Complete Theory
Introduced by Stephen A. Cook in 1971, NP-Complete theory provides a sound method to categorize a great number of problems taken from a vast array of domains [2].It has facilitated the discovery of literally thousands of non-trivial problems that are fundamentally related in that an efficient solution for any one of them implies an efficient solution to all of them.The implications are enormous, not least for the relevance of seemingly unrelated domains, including music.
Essentially, the theory states that if any NP-Complete problem is solvable in polynomial time, then all problems whose solutions are verifiable in polynomial time (i.e., NP problems) are also solvable in polynomial time; on the other hand, if any non-deterministic polynomial problem (which is another way of describing an NP problem) can be proven not to be solvable in polynomial time, then all NP-Complete problems cannot be solved in polynomial time.Symbolically, this can be expressed as follows: This brings us to the elusive theoretical computer science question, "is P = NP?" which we shall use as motivation for including music as an important field of research in theoretical computer science.Therefore, we now introduce an NP-Complete music problem and show how we can prove it is NP-Complete.

C. An NP-Complete Music Problem
The following music problem is one we have derived from the aforementioned Species Counterpoint, in turn based upon a key musical activity in the fifteenth and sixteenth centuries: polyphonic music composition, and pedagogic activity in the eighteenth.The composition student is asked to add one or more melodic parts, called the "countermelod(y/ies)" to a given primary melody, called the "cantus firmus."A set of rules restricts the choice of melodies that can be added.The product is counterpoint, and in this system, there were five different categories, or species of counterpoint.
We define the music problem in the form of a decision (yes/no answer) problem that is NP-Complete, and proceed to show how this can be proven.In this paper we refer to the problem as SPECIES COUNTERPOINT (after Fux): Given a cantus firmus, a set of harmonic, melodic, and counterpoint rules, is it possible to add two melodic parts that satisfy all the rules?To prove that this problem is NP-Complete, we "restrict" it to a known NP-Complete problem, either THREE-DIMENSIONAL MATCHING (3DM) or BOUNDED TILING [9], after showing that solution verification can be accomplished in polynomial time.We do not show the proof here, but the interested reader can find it in [10].As an illustration of how NP-Complete problems share a fundamental similarity, SPECIES COUNTERPOINT will be found to be similar in form to the FINITE STATE AUTOMATA INTERSECTION problem, also NP-Complete [9].

SPECIES COUNTERPOINT
where CP = mel1, mel2 and meli is a sequence mi1, mi2, …, mic on S, i = 1, 2 and R is defined as follows: Proof.Restrict to 3DM or BOUNDED TILING.

III. MUSIC APPLICATIONS IN COMPUTING
Showing that a problem is NP-Complete fulfils the theoretical portion of our endeavors, but it is only the first step towards practical application in computer science projects.Understanding the theoretical issues certainly enables us to make expedient decisions in the implementation.Our choices are: to give up (too drastic); to attempt instances of the problem that are not no hard to solve; to attempt only small instances of the problem; or to find approximate solutions.

A. Heuristic Algorithms to the Rescue
Mindful of our choices, and assuming we wish not to compromise on the nature of the problem, or to limit ourselves to easier or smaller versions of the problem, we can take the bull by the horns and plunge into a thorough search, but eventually face dire consequences.Alternatively, we can avail ourselves of several feasible heuristic solutions that have been developed in computational science during the short period of its existence.I shows the number of solutions found by a modified exhaustive search algorithm applied to four cantus firmi.The algorithm uses backtracking and pruning of the search tree by eliminating unpromising branches, as soon as they are detected.The heading "Full" refers to complete countermelodies found, while "Partial" refers to incomplete countermelodies that during the search process were found to be no longer promising, and hence discarded [7]. An NP-Complete proof for a problem predicts that a brute force, no holds barred, thorough search process is sooner or later doomed to impracticality, in spite of clever pruning.This is because the computing time of such methods rises very sharply with the size of the problem to be solved: so sharply in fact that even with modern computers, sufficiently large instances of such problems can take years, even centuries, to process.For such non-trivial problem sizes, we need more practical methods.Enter the heuristic algorithms: those that make smart choices during the solution searching process that obviate the need to search every possibility.Such algorithms do not guarantee optimal results, but, if well designed, provide "good enough" solutions.

B. Genetic Algorithms to Create Melodies
One of the most imaginative heuristic search algorithms available is the biologically inspired Genetic Algorithm, so called because the search process adopts the mechanics of evolution by random mutation and natural selection.The pseudo-code for the standard genetic algorithm is given below (fig.2).In this implementation, the evolutionary process is governed by a fitness threshold and by an upper limit to the number of iterations.Example 2. Figure 3 illustrates how crossover and selection in a genetic algorithm produced the optimal countermelody a, aa, g, f, e, d, c, h, d, c#, d to the cantus firmus D, F, E, D, G, F, a, G, F, E, D (only the ancestors to the optimal countermelody are shown here).The optimal countermelody found was, of course, also found by the modified exhaustive search (as one of the 93 Full countermelodies, TABLE I) [7].

C. Artificial Neural Networks to Model Human Preferences
Besides genetic algorithms, another biologically inspired technique called Artificial Neural Network (ANN) is also widely used for Machine Learning.We can use this technique to model, for example, human preferences [8].
Example 4.An artificial neural network system was trained to mimic a music expert's choices.Four rules were applied to each of ten notes.The network comprised three layers having 40, 8, and 5 nodes, respectively (fig.4).

IV. DANCE APPLICATIONS IN COMPUTING
Having established a mathematical foundation to justify various algorithmic designs of the music composition problem, we are now able to show how these techniques can be used in related artistic applications.In the following sections, we define an NP-Complete Dance Choreography problem, and then discuss algorithmic solutions.

A. Dance Choreography, Another NP-Complete Problem
Music composition problems may not necessarily interest non-musicians.But, thanks to implications of the theory, since we have identified music composition problems that are NP-Complete (one of which was described above), we have readily forged conceptual and practical connections to other domains, both concrete and potential.Let us consider one domain that is quite close to the musical arts: dance choreography.We can show that it, too, contains its share of complex problems.We define one of them below and suggest that it, too, is NP-Complete, again by the restriction proof technique, this time to the Hamiltonian Circuit Problem (HC) [16].

INSTANCE:
A Proof.Restrict to HC.
Example 5.As an illustration of the exponential nature of the solution, consider choreographing amalgamations of successive lengths from one to twelve figures.In the following experiment, we chose from a palette of seventeen figures from the Waltz syllabus, and measured the computational time taken for the exhaustive search in clock ticks.To ensure a uniform start, the opening figure in each trial was the figure called "Left foot closed change."No ending figure was specified for any of the amalgamations.The experiment was performed on a 2.3 GHz Intel Core i5 processor, using Terpsichore©, a multimedia-based interactive computer software for dance training and education, copyrighted on July 1, 2011 (Registration Number TXu 1-762-479) [5,6].The following table clearly shows the exponential increase in computational time.

B. Heuristics to the Rescue (Again)
Once again, we turn to heuristic algorithms to alleviate the seemingly insurmountable computational task.Here we implement the Greedy Algorithm, which, as expected of properly designed heuristic algorithms, may not guarantee optimal solutions, but promises vastly shortened computational times.Pseudo-code for the standard Greedy Algorithm is given below (fig.5): Example 6.In the following experiment using the Greedy Algorithm, optimality is defined by the fitness function that takes into account the variety of figures used, with fitness values ranging from 0 (weakest) to 10 (strongest).In this experiment, none of the computations exceeded one clock tick (table III). The dance choreography problem, like the music composition problem, deserves equal computational consideration to those given to hundreds of other NP-Complete problems.As the theory shows, it does not matter for which of these problems we begin designing algorithmic solutions: our efforts in any one direction will directly benefit all others.
Having proven that the music and dance problems are NP-Completeness, we can insert them into an ever enlarging "proof hierarchy" tree, whose root is the SATISFIABILITY (SAT) problem, the first problem to be shown to be NP-Complete by Cook [2], which enabled all subsequent NP-Complete problems to be proven so, directly or indirectly (fig.6).

V. CONCLUSION
We have built upon the strong desire of the classical, medieval, and Renaissance music theorists to link music with mathematics by linking music with computers.We have shown, through concrete examples of NP-Complete music problems, how music can be a fruitful source of computing applications.NP-Complete theory enables us to connect many other domains within a sound, mathematical framework.The exercise of machine intelligence techniques to these problems further highlights the viability of these domains, and points to fruitful avenues for contemporary research.It should be obvious that what we have shown to be possible with just one of the original seven liberal arts can be extended to other liberal arts subjects, ancient or modern.
The implications of a renewed focus on the liberal arts for scientific education in general, and computer science education in particular, are far reaching.It may be more than just a poetic coincidence that the music of the spheres, the beloved topic of the medieval theorists, finds resonance in, say, modern day physics in the form of string theory.
Thus wrote Johannes de Garlandia, "Music is divided into categories, for it is either 'cosmic,' which focuses on the harmony of the orbits of the planetary spheres with respect to each other or on the structure of the elements or on the diversity of the seasons, and in this manner it is a part of astronomy; or it is 'human,' which focuses on the harmony of the qualities of the opposing elements in a composite being existing at a given time, or on the composition of the body and soul, from which results the harmonious conjunction of the parts both rational and irrational, and in this manner it is a part of natural science; or it is "instrumental," which focuses on instruments of harmonious concord."[14]

Figure 2 .
Figure 2. Pseudocode for the Genetic Algorithm.

Figure 4 .
Figure 4. Artificial Neural Network used to predict an expert's evaluation.

Figure 6 .
Figure 6.Partial NP-Completeness proof hierarchy tree showing the derivation of the Music and Dance Choreography problems.

TABLE 1 .
EXHAUSTIVE SEARCH RESULTS FOR VARIOUS CANTUS FIRMI

TABLE II .
PERFORMANCE OF THE EXHAUSTIVE ALGORITHM (WALTZ)

TABLE III .
PERFORMANCE OF THE GREEDY ALGORITHM (WALTZ)