# ----------------
# Euler's identity
# ----------------

@prefix math: <http://www.w3.org/2000/10/swap/math#>.
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix complex: <http://eyereasoner.github.io/eye/complex#>.

{ ((?A ?B) (?C ?D)) complex:sum (?E ?F) } <= {
    (?A ?C) math:sum ?E.
    (?B ?D) math:sum ?F.
}.

{ ((?A ?B) (?C ?D)) complex:exponentiation (?E ?F) } <= {
    (?A ?B) complex:polar (?R ?T).
    (?R ?C) math:exponentiation ?Z1.
    ?D math:negation ?Z2.
    (?Z2 ?T) math:product ?Z3.
    (2.718281828459045 ?Z3) math:exponentiation ?Z4.
    (2.718281828459045 ?Z5) math:exponentiation ?R.
    (?D ?Z5) math:product ?Z6.
    (?C ?T) math:product ?Z7.
    (?Z6 ?Z7) math:sum ?Z8.
    ?Z8 math:cos ?Z9.
    (?Z1 ?Z4 ?Z9) math:product ?E.
    ?Z8 math:sin ?Z10.
    (?Z1 ?Z4 ?Z10) math:product ?F.
}.

{ (?X ?Y) complex:polar (?R ?Tp) } <= {
    (?X 2) math:exponentiation ?Z1.
    (?Y 2) math:exponentiation ?Z2.
    (?Z1 ?Z2) math:sum ?Z3.
    (?Z3 0.5) math:exponentiation ?R.
    ?X math:absoluteValue ?Z4.
    (?Z4 ?R) math:quotient ?Z5.
    ?Z5 math:acos ?T.
    (?X ?Y ?T) complex:dial ?Tp.
}.

{ (?X ?Y ?T) complex:dial ?Tp } <= {
    ?X math:notLessThan 0.
    ?Y math:notLessThan 0.
    (0 ?T) math:sum ?Tp.
}.

{ (?X ?Y ?T) complex:dial ?Tp } <= {
    ?X math:lessThan 0.
    ?Y math:notLessThan 0.
    (3.141592653589793 ?T) math:difference ?Tp.
}.

{ (?X ?Y ?T) complex:dial ?Tp } <= {
    ?X math:lessThan 0.
    ?Y math:lessThan 0.
    (3.141592653589793 ?T) math:sum ?Tp.
}.

{ (?X ?Y ?T) complex:dial ?Tp } <= {
    ?X math:notLessThan 0.
    ?Y math:lessThan 0.
    (3.141592653589793 2) math:product ?Z1.
    (?Z1 ?T) math:difference ?Tp.
}.

# query
{
    ((2.718281828459045 0) (0 3.141592653589793)) complex:exponentiation (?A ?B).
    ((?A ?B) (1 0)) complex:sum (?C ?D).
} =^ {
    ((2.718281828459045 0) (0 3.141592653589793)) complex:exponentiation (?A ?B).
    ((?A ?B) (1 0)) complex:sum (?C ?D).
}.
