The composition of most styles of music is governed by rules. The natural statement of these rules is declarative (“The highest
and lowest notes in a piece must be separated by a consonant interval”) and non deterministic (“The base note of a key can
be followed by any note in the key”). We show that by approaching the automation and analysis of composition as a knowledge
representation task and formalising these rules in a suitable logical language, powerful and expressive intelligent composition
tools can easily be built. This paper describes the use of answer set programming to construct an automated system that can
compose both melodic and harmonic music, diagnose errors in human compositions and serve as a computer-aided composition tool.
The use of a fully declarative language and an “off-the-shelf” reasoning engine allows the creation of tools which are significantly
simpler, smaller and more flexible than those produced by existing approaches. It also combines harmonic and melodic composition
in a single framework, which is a new feature in the growing area of algorithmic composition.