Computational Philosophy / Minima and Maxima in Music Composition

Minima and Maxima in Music Composition

SOCRATES : A sequence of notes is composed using the prior method with propositions, which can be written as part of a logical formula. Given “The mushrooms are planted, therefore the mushrooms are watered” and “The mushrooms are watered, therefore the mushrooms grow”, what is the conclusion?
LUCIAN : “The mushrooms are planted, therefore the mushrooms grow”.
SOCRATES : Suppose “The mushrooms are planted” represents the first note, ‘C’, “the mushrooms are watered” represents the second note, ‘B’, and “the mushrooms grow” represents the third note, ‘C’. What are the changes in whether the note goes up or down?
LUCIAN : The music goes down from ‘C’ to ‘B’, (represented as '-') then up from ‘B’ to ‘C’ (represented as '+').
SOCRATES : What are the minima and maxima in this music?
LUCIAN : ‘C’ is a maximum, ‘B’ is a minimum and ‘C’ is a maximum. If there is a change in whether the music goes up or down, then the note just before the change is the maxima or minima, respectively.

%% ?- find_minima_and_maxima([+,+,-,-], [c, d, e, d, c], Music).
%% Music = [c, e, c] ;

%% find_minima_and_maxima(Changes,Music1,Music2).
%% Changes - List of +'s or -'s, indicating whether a note should
%% go up or down from the last one, respectively.
%% Music1 - List of notes
%% Music2 - List of notes which are minima and maxima of Music1

find_minima_and_maxima([Change1|Changes],[Note1,Note2|Music1],Music2) :-

%% find_minima_and_maxima1(Changes,Music1,Change,Note2,Note1,Music2).
%% Changes - as for find_minima_and_maxima/3
%% Music1 - rest of music
%% Change - '+' - go up a note
%% '-' - go down a note
%% Note2 - second note
%% Note1 - first note
%% Music2 - list of notes

find_minima_and_maxima1([],[],_,Note1,Music1,Music2) :-
find_minima_and_maxima1([Change1|Changes],[Note1|Music1],Change1,_,Music2,Music3) :-
find_minima_and_maxima1([Change1|Changes],[Note1|Music1],Change2,Note2,Music2,Music3) :-
not(Change1=Change2), append(Music2,[Note2],Music4),

Hosted by