add( complex(A,B), complex(C,D), complex(E,F) ) :- E is A+C, F is B+D. multiply( complex(A,B), complex(C,D), complex(E,F) ) :- E is A*C - B*D, F is A*D + B*C.
Read this as:
The sum of (A,B) and (C,D) is (E,F) if E is the numerical value of A+C and F is the numerical value of B+D.
For this to work, A
,B
,C
,D
must be numbers. is
does arithmetic. Logically speaking,
X is Y
means ``X is the numerical value of the expression Y''.