I can’t imagine a title that really describes what I’m after, so apologies for that…
I’m currently working with geometric objects (for no particular reason), and I’m wondering if there’s a good way to implement the use of two different, yet equivalent, definitions for something, such that no matter what you are given, prolog can fill in as many unknowns as possible.
Concrete example:
An equaliateral triangle can be defined as a triangle with 3 sides of equal length. It can also be defined as a triangle with 3 equal angles (which happen to be 60° if they’re planar, 90° if drawn on a sphere, etc).
On top of that, side lengths and angles can be calculated from each other given the right information.
So I’m wondering if there’s a simple way that I could write a predicate that could deduce if a triangle is equilateral no matter what combination of sides and angles I have, assuming enough info is given to prove one way or another?
My default would be to write two predicates:
equilateral( line(A), line(B), line(C) ) :-
length(line(A), L),
length(line(B), L),
length(line(C), L).
equilateral( angle(A), angle(B), angle(C) ) :-
degrees(angle(A), D),
degrees(angle(B), D),
degrees(angle(C), D).
But even doing things this way, I can’t think of a way to tell prolog to take what it knows (what I’ve given it elsewhere) about line-angle relationships to calculate for these. Seems like I’d need a million if-then clauses to handle the cases where it has mixed info.
Not an important project, but if anyone has ideas on simple ways to account for mixed-info scenarios, I’d love to hear your thoughts!