Skip to main content

Automatic music composition using answer set programming


Music composition used to be a pen and paper activity. These days music is often composed with the aid of computer software, even to the point where the computer composes parts of the score autonomously. The composition of most styles of music is governed by rules. We show that by approaching the automation, analysis and verification of composition as a knowledge representation task and formalising these rules in a suitable logical language, powerful and expressive intelligent composition tools can be easily built. This application paper describes the use of answer set programming to construct an automated system, named Anton, that can compose melodic, harmonic and rhythmic music, diagnose errors in human compositions and serve as a computer-aided composition tool. The combination of harmonic, rhythmic and melodic composition in a single framework makes Anton unique in the growing area of algorithmic composition. With near real-time composition, Anton reaches the point where it can not only be used as a component in an interactive composition tool but also has the potential for live performances and concerts or automatically generated background music in a variety of applications. With the use of a fully declarative language and an “off-the-shelf” reasoning engine, Anton provides the human composer a tool which is significantly simpler, more compact and more versatile than other existing systems.

Hide All
Allen, J. F. 1983. Maintaining knowledge about temporal intervals. CACM 26, 198203.
Anders, T. 2007. Composing Music by Composing Rules: Design and Usage of a Generic Music Constraint System. PhD thesis, Queen's University, Belfast, Department of Music.
Arom, S. 1991. African Polyphony and Polyrhythm. Cambridge University Press, Cambridge, UK.
Baral, C. 2003. Knowledge Representation, Reasoning and Declarative Problem Solving. Cambridge University Press, Cambridge, UK.
Baral, C. and Gelfond, M. 2000. Reasoning agents in dynamic domains. In Logic-based Artificial Intelligence, Minker, J., Ed. Kluwer Academic, 257279.
Bel, B. 1998. Migrating musical concepts: An overview of the Bol processor. Computer Music Journal 22, 2, 5664.
Boenn, G. 2007. Composing rhythms based upon Farey sequences. In Digital Music Research Network Conference, Gibson, I., Stansbie, A., Stavropoulos, N., Eds.
Boenn, G. 2008. The importance of Husserl's phenomenology of internal time-consciousness for music analysis and composition. In Proc. of the ICMC 2008. Scholarly Publishing Office of the University of Michigan Library. vol. 2008. Belfast.
Boenn, G. 2009. Automated Analysis and Transcription of Rhythm Data and their Use for Composition. PhD thesis, University of Bath, Bath, UK.
Boenn, G., Brain, M., De Vos, M. and Ffitch, J. 2008. Automatic composition of melodic and harmonic music by answer set programming. In International Conference on Logic Programming, ICLP08. Lecture Notes in Computer Science, vol. 4386. Springer, Berlin/Heidelberg, 160174.
Boulanger, R., Ed. 2000. The Csound Book: Tutorials in Software Synthesis and Sound Design. MIT Press, Cambridge, MA.
Brain, M., Cliffe, O. and De Vos, M. 2009. A pragmatic programmer's guide to answer set programming. In Proc of the 2nd Workshop of Software Engineering for Answer Set Programming (SEA'09), De Vos, Marina and Schaub, T., Eds. 49–63.
Brain, M., Crick, T., De Vos, M. and Fitch, J. 2006. TOAST: Applying answer set programming to superoptimisation. In International Conference on Logic Programming, Etalle, S. and Truszcynski, M., Eds. 270284. LNCS, Springer.
Brain, M., De Vos, M. and Satoh, K. 2007a. Smodels-IE: Improving the cache utilisation of smodels. In Proc. of the 4th Workshop on Answer Set Programming: Advances in Theory and Implementation, Costantini, S. and Watson, R., Eds. Porto, Portugal, 309313.
Brain, M., Gebser, M., Pührer, J., Schaub, T., Tompits, H. and Woltran, S. 2007b. “That is illogical captain!”—The debugging support tool spock for answer-set programs: System description. In Proc. of the Workshop on Software Engineering for Answer Set Programming (SEA'07), De Vos, M. and Schaub, T., Eds. CEUR, vol. 281. 7185.
Brothwell, A. and ffitch, J. 2008. An automatic blues band. In 6th International Linux Audio Conference, Barknecht, F. and Rumori, M., Eds. Tribun EU, Brno, Czech Republic, Kunsthochscule für Medien Köln, 1217.
Buccafurri, F. and Caminiti, G. 2005. A social semantics for multi-agent systems. In LPNMR, Baral, C., Greco, G., Leone, N. and Terracina, G., Eds. Lecture Notes in Computer Science, vol. 3662. Springer, 317329.
Buccafurri, F. and Gottlob, G. 2002. Multiagent compromises, joint fixpoints, and stable models. In Computational Logic: Logic Programming and Beyond, Essays in Honour of Robert A. Kowalski, Part I, Kakas, A. C. and Sadri, F., Eds. Lecture Notes in Computer Science, vol. 2407. Springer, 561585.
Chuang, J. 1995. Mozart's Musikalisches Würfelspiel. URL:
Cliffe, O., De Vos, M., Brain, M. and Padget, J. 2008. ASPVIZ: Declarative visualisation and animation using answer set programming. In Logic Programming, de la Banda, M. Garcia and Pontelli, E., Eds. Lecture Notes in Computer Science. Springer, Berlin/Heidelberg, 724728.
Cliffe, O., De Vos, M. and Padget, J. 2006. Specifying and analysing agent-based social institutions using answer set programming. In Selected revised papers from the workshops on Agent, Norms and Institutions for Regulated Multi-Agent Systems (ANIREM) and Organizations and Organization Oriented Programming (OOOP) at AAMAS'05, Boissier, O., Padget, J., Dignum, V., Lindemann, G., Matson, E., Ossowski, S., Sichman, J. and Vazquez-Salceda, J., Eds. LNCS, vol. 3913. Springer-Verlag, Berlin, 99113.
Cope, D. 2006. A musical learning algorithm. Computer Music Journal 28, 3 (Fall), 1227.
de la Motte, D. 1981. Kontrapunkt. dtv/Bärenreiter, München.
De Vos, M. and Vermeir, D. 1999. Choice logic programs and Nash equilibria in strategic games. In Computer Science Logic (CSL'99), Flum, J. and Rodríguez-Artalejo, M., Eds. Lecture Notes in Computer Science, vol. 1683. Springer-Verlag, Madrid, Spain, 266276.
De Vos, M. and Vermeir, D. 2004. Extending answer sets for logic programming agents. Annals of Mathematics and Artifical Intelligence 42, 1–3 (Sept.), 103139. Special Issue on Computational Logic in Multi-Agent Systems.
Ebcioğlu, K. 1986. An Expert System for Harmonization of Chorales in the Style of J.S. Bach. PhD thesis, State University of New York, Buffalo, Department of Computer Science.
Eiter, T., Faber, W., Leone, N. and Pfeifer, G. 1999. The diagnosis frontend of the DLV system. AI Communications 12, 1–2, 99111.
Eiter, T., Faber, W., Leone, N., Pfeifer, G. and Polleres, A. 2002. The DLVK planning system. In European Conference, JELIA 2002, Flesca, S., Greco, S., Leone, N. and Ianni, G., Eds. LNAI, vol. 2424. Springer Verlag, Cosenza, Italy, 541544.
Eiter, T., Leone, N., Mateis, C., Pfeifer, G. and Scarcello, F. 1998. The KR system DLV: Progress report, comparisons and benchmarks. In KR'98: Principles of Knowledge Representation and Reasoning, Cohn, A. G., Schubert, L. and Shapiro, S. C., Eds. Morgan Kaufmann, San Francisco, California, 406417.
Erdem, E., Lifschitz, V., Nakhleh, L. and Ringe, D. 2003. Reconstructing the evolutionary history of indo-european languages using answer set programming. In PADL, Dahl, V. and Wadler, P., Eds. LNCS, vol. 2562. Springer, 160176.
Erdem, E., Lifschitz, V. and Ringe, D. 2006. Temporal phylogenetic networks and logic programming. TPLP 6, 5, 539558.
Fux, J. 1965, orig 1725. The Study of Counterpoint from Johann Joseph Fux's Gradus ad Parnassum. W. W. Norton & Company.
Gebser, M., Kaufmann, B., Neumann, A. and Schaub, T. 2007. Conflict-driven answer set solving. In Proc. of the 20th International Joint Conference on Artificial Intelligence (IJCAI'07), Veloso, M., Ed. AAAI Press/MIT Press, 386392. URL:
Gebser, M., Schaub, T. and Thiele, S. 2007. GrinGo: A new grounder for answer set programming. In Proc. of the 9th International Conference on Logic Programming and Nonmonotonic Reasoning (LPNMR'07), Baral, C., Brewka, G. and Schlipf, J., Eds. Lecture Notes in Artificial Intelligence, vol. 4483. Springer-Verlag, Berlin, 266271.
Gelfond, M. and Lifschitz, V. 1988. The stable model semantics for logic programming. In Logic Programming, Proc. of the 5th International Conference and Symposium, Kowalski, R. A. and Bowen, K. A., Eds. MIT Press, Seattle, Washington, 10701080.
Gelfond, M. and Lifschitz, V. 1991. Classical negation in logic programs and disjunctive databases. New Generation Computing 9, 3–4, 365386.
Giunchiglia, E., Lierler, Y. and Maratea, M. 2004. SAT-based answer set programming. In Proc. of the 18th National Conference on Artificial Intelligence (AAAI-04), McGuinness, D. L. and Ferguson, G., Eds. AAAI Press/The MIT Press, 6166.
Goranko, V., Montanari, A. and Sciavicco, G. 2003. A road map on interval temporal logics and duration calculi. Journal of Applied Non-Classical Logics 14, 954.
Grell, S., Schaub, T. and Selbig, J. 2006. Modelling biological networks by action languages via answer set programming. In Proc. of the International Conference on Logic Programming (ICLP'06), Etalle, S. and Truszczyński, M., Eds. LNCS, vol. 4079. Springer-Verlag, Berlin, 285299.
Gressmann, J., Janhunen, T., Mercer, R., Schaub, T., Thiele, S. and Tichy, R. 2005. Platypus: A platform for distributed answer set solving. In Proc. of the 8th International Conference on Logic Programming and Nonmonotonic Reasoning (LPNMR'05), Baral, C., Greco, G., Leone, N. and Terracina, G., Eds. 227–239.
Hajdu, G. 1993. Low energy and equal spacing. The multifactorial evolution of tuning systems. Interface 22, 319333.
Hardy, G. and Wright, E. 1938. An Introduction to the Theory of Numbers, 4th ed.Oxford University Press, Oxford.
Konczak, K. 2006. Voting theory in answer set programming. In Proc. of the Twentieth Workshop on Logic Programming (WLP'06), Fink, M., Tompits, H. and Woltran, S., Eds. No. INFSYS RR-1843-06-02 in Technical Report Series. Technische Universität Wien, Vienna, 4553.
Leach, J. L. 1999. Algorithmic Composition and Musical Form. PhD thesis, University of Bath, School of Mathematical Sciences, Bath, UK.
Lewis, G. E. 2000. Too many notes: Computers, complexity and culture in voyager. Leonardo Music Journal 10, 3339.
Lierler, Y. 2008. Abstract answer set solvers. In ICLP '08: Proc. of the 24th International Conference on Logic Programming. Springer-Verlag, Berlin/Heidelberg, 377391.
Lierler, Y. and Maratea, M. 2004. Cmodels-2: SAT-based answer set solver enhanced to non-tight programs. In Proc. of the 7th International Conference on Logic Programming and Nonmonotonic Reasoning, LNCS, vol. 2923. Springer, 346350.
Lifschitz, V. 2002. Answer set programming and plan generation. Journal of Artificial Intelligence 138, 1–2, 3954.
Mileo, A. and Schaub, T. 2006. Extending ordered disjunctions for policy enforcement: Preliminary report. In Proc. of the International Workshop on Preferences in Logic Programming Systems (PREFS'06), Pontelli, E. and Son, T., Eds. 45–59.
Niemelä, I. and Simons, P. 1997. Smodels: An implementation of the stable model and well-founded semantics for normal LP. In Proc. of the 4th International Conference on Logic Programing and Nonmonotonic Reasoning, Dix, J., Furbach, U. and Nerode, A., Eds. LNAI, vol. 1265. Springer, Berlin, 420429.
Niemelä, I., Simons, P. and Soininen, T. 1999. Stable model semantics of weight constraint rules. In LPNMR, Gelfond, M., Leone, N. and Pfeifer, G., Eds. Lecture Notes in Computer Science, vol. 1730. Springer, 317331.
Padovani, L. and Provetti, A. 2004. Qsmodels: ASP planning in interactive gaming environment. In JELIA, Alferes, J. J. and Leite, J. A., Eds. Lecture Notes in Computer Science, vol. 3229. Springer, 689692.
Partch, H. 1979. Genesis of a Music. Da Capo Press, New York.
Rohrmeier, M. 2006. Towards Modelling Harmonic Movement in Music: Analysing Properties and Dynamic Aspects of pc set Sequences in Bach's Chorales. Tech. Rep. DCRR-004, Darwin College, University of Cambridge.
Soininen, T. and Niemelä, I. 1999. Developing a declarative rule language for applications in product configuration. In Proc. of the First International Workshop on Practical Aspects of Declarative Languages (PADL '99), LNCS. Springer, San Antonio, Texas, 305319.
Syrjänen, T. and Niemelä, I. 2001. The smodels system. In Proc. of the 6th International Conference on Logic Programming and Nonmonotonic Reasoning, Eiter, T., Faber, W. and Truszczynski, M., Eds. Lecture Notes in Computer Science 2173 Springer, 434438.
Thakar, M. 1990. Counterpoint. Yale University Press, New Haven, Connecticut.
Ward, J. and Schlipf, S. 2004. Answer set programming with clause learning. In Proc. of the 7th International Conference on Logic Programming and Nonmonotonic Reasoning, Lifschitz, V. and Niemelä, I., Eds. LNCS, vol. 2923. Springer, 302313.
Xenakis, I. 1992. Formalized Music. Bloomington Press, Stuyvesant, NY, USA.
Recommend this journal

Email your librarian or administrator to recommend adding this journal to your organisation's collection.

Theory and Practice of Logic Programming
  • ISSN: 1471-0684
  • EISSN: 1475-3081
  • URL: /core/journals/theory-and-practice-of-logic-programming
Please enter your name
Please enter a valid email address
Who would you like to send this to? *



Full text views

Total number of HTML views: 0
Total number of PDF views: 47 *
Loading metrics...

Abstract views

Total abstract views: 356 *
Loading metrics...

* Views captured on Cambridge Core between September 2016 - 20th March 2018. This data will be updated every 24 hours.