%%%% File: Music World %% Facts... % chopin(N, piece(L), year(M)) :: N is the name of the composer, L is the type of piece, and M is % year that is was created. piece(chopin,type(etude), number(2), key(c)). piece(chopin,type(etude),number(3), key(a)). piece(chopin,type(scherzo),number(3), key(g)). piece(chopin,type(sonata),number(1), key(bfl)). piece(chopin,type(prelude),number(4), key(gfl)). piece(liszt,type(concerto),number(2), key(a)). piece(liszt,type(sonata), number(1), key(f)). % notes(N, beats(L), key(M)) :: N is the name of the note, L is the number of beats, and M is the % name of the key. note(quarter, beat(1), pitch(a)). note(whole, beat(4), pitch(b)). note(half, beat(2), pitch(c)). note(quarter, beat(1), pitch(d)). note(whole, beat(4), pitch(e)). note(half, beat(2), pitch(f)). note(half, beat(2), pitch(g)). %% Rules . . . % pieces :: all those items listed are types of pieces. pieces :- piece(_,type(Name),_,_),write(Name),nl,fail. pieces. % composers :: all those items listed are the composers in the KB. composers :- piece(Composer,_,_,_),write(Composer),nl,fail. composers. % Notes :: all those items listed are notes note :- note(_, _, pitch(Name)), write(Name),nl,fail. note. %%Quarter notes :: The specific pitch printed is a quarter note. quarter(Name) :- note(quarter,_, pitch(Name)),write(Name),nl,fail. %%Half notes :: The specific pitch printed is a half note. half(Name) :- note(half,_, pitch(Name)),write(Name),nl,fail. %%Whole notes :: The specific pitch printed is a whole note. whole(Name) :- note(whole,_, pitch(Name)),write(Name),nl,fail. %beats(Name, A) :: A is the number of beats of the specified note which is Name. beats(Name, A) :- note(Name, beat(B), _), A is B. %beats_of_pitch(Name, A) :: A is the number of beats of the specified pitch. beats_of_pitch(Name, A) :- note(_, beat(B), pitch(Name)), A is B.