/*---------------------------------------------------------------- Basic function for construction of equations in Geometric Theorem proving ----------------------------------------------------------------*/ put('geometry2,1,'version); generate_ideal(hypotheses,conclusions):= append(hypotheses, makelist(1-genpar()*conclusions[i],i,1,length(conclusions))); /* X, Y, Z on the plane are colinear */ collinear(X,Y,Z):= det(matrix(cons(1,X),cons(1,Y),cons(1,Z))); /* Vector AB and CD are perpendicular */ perpendicular(A,B,C,D):= (B-A).(D-C); /* AB and CD have equal length */ equidistant(A,B,C,D):=(B-A).(B-A)-(D-C).(D-C); /* AB and CD are parallel */ parallel(A,B,C,D):=det(matrix(B-A,D-C)); /* M is the midpoint of AB; 2 equations */ midpoint(M,A,B):=2*M-(A+B); /* Points A and B are identical */ identical(A,B):=B-A; /* D is the distance between A and B */ distance(A,B,D):=D^2-(B-A).(B-A); /* Angle P with cos COS_P and sin SIN_P is the angle ABC where segments AB and BC have lengths D_AB and D_BC */ angle(COS_P,SIN_P,A,B,C,D_AB,D_BC):= [ cos_p^2+sin_p^2-1, distance(A,B,D_AB), distance(B,C,D_BC), COS_P*D_AB*D_BC-(C-B).(A-B), SIN_P*D_AB*D_BC-det(matrix(C-B,A-B)) ]; /* Point X is on ellipse with center at O with semi-axes a and b */ ellipse(X,O,a,b):= b^2*(X[1]-O[1])^2+a^2*(x[2]-o[2])^2-a^2*b^2;