this post was submitted on 25 Dec 2024
65 points (100.0% liked)

Programmer Humor

35292 readers
173 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
65
submitted 4 months ago* (last edited 4 months ago) by [email protected] to c/[email protected]
 
% Piano Axioms

% Axiom 1: Law of Excluded Gray
key_type(white).
key_type(black).

% Axiom 2: The C Postulate
key_color(c, white).

% Axiom 3: The Diatonic Scale
next_white_key(c, d).
next_white_key(d, e).
next_white_key(e, f).
next_white_key(f, g).
next_white_key(g, a).
next_white_key(a, b).
next_white_key(b, c).

% Axiom 4: The Semitone Anomaly
semitone_gap(e, f, 1).
semitone_gap(b, c, 1).
semitone_gap(X, Y, 2) :- 
    next_white_key(X, Y),
    X \= e,
    X \= b.

% Axiom 5: Black Key Entropy
has_black_key_between(X, Y) :-
    next_white_key(X, Y),
    semitone_gap(X, Y, 2).

% Axiom 6: The "8 is 12" Principle.
octave_size(12).

% Axiom 7: Out of Bounds Exception
total_keys(88).

% Theorem 1: Conservation of "Wrong Notes"
style(jazz) :-
    wrong_notes > 0,
    write('All wrong notes are now intentional').
top 5 comments
sorted by: hot top controversial new old
[–] [email protected] 16 points 4 months ago

Oh, a very rare programming-maths-music meme. Best I can do is 50.

[–] [email protected] 4 points 4 months ago (2 children)
[–] [email protected] 17 points 4 months ago

They're being defined right in this post. 🙃

Prolog is a language that allows you to specify a whole bunch of rules/axioms and then you can query logical conclusions that can be made from these.

If you go to https://swish.swi-prolog.org/ and click on "Create a [Program]", then paste the post text on the left side (without the Theorem 1, as that one doesn't compile), then you can query it in the bottom right.
For example, if you ask it between which keys there's a gap of just 1 semitone:

?- semitone_gap(X, Y, 1)

Then it will first tell you that X=e & Y=f, as the first possible solution. Then you can click "Next" and it'll tell you another solution is X=b & Y=c.

[–] [email protected] 13 points 4 months ago

Just a joke on what makes a piano, i suppose the pun is intended but Peano's axiom are famous mathematical axioms.

[–] [email protected] 4 points 4 months ago