@@ -58,7 +58,17 @@ symtype(::Symbolic{T}) where {T} = T
5858
5959Base. isequal (s:: Symbolic , x) = false
6060Base. isequal (x, s:: Symbolic ) = false
61- Base. isequal (x:: Symbolic , y:: Symbolic ) = false
61+
62+ function Base. isequal (t1:: Symbolic , t2:: Symbolic )
63+ t1 === t2 && return true
64+ (istree (t1) && istree (t2)) || return false
65+ a1 = arguments (t1)
66+ a2 = arguments (t2)
67+
68+ isequal (operation (t1), operation (t2)) &&
69+ length (a1) == length (a2) &&
70+ all (isequal (l,r) for (l, r) in zip (a1,a2))
71+ end
6272# ## End of interface
6373
6474"""
@@ -155,7 +165,7 @@ function (f::Sym)(args...)
155165end
156166
157167"""
158- ` promote_symtype(f::Sym{FnType{X,Y}}, arg_symtypes...)`
168+ promote_symtype(f::Sym{FnType{X,Y}}, arg_symtypes...)
159169
160170The output symtype of applying variable `f` to arugments of symtype `arg_symtypes...`.
161171if the arguments are of the wrong type then this function will error.
@@ -287,15 +297,6 @@ function Base.hash(t::Term{T}, salt::UInt) where {T}
287297 hashvec (arguments (t), hash (operation (t), hash (T, salt)))
288298end
289299
290- function Base. isequal (t1:: Term , t2:: Term )
291- t1 === t2 && return true
292- a1 = arguments (t1)
293- a2 = arguments (t2)
294-
295- isequal (operation (t1), operation (t2)) && length (a1) == length (a2) &&
296- all (isequal (l,r) for (l, r) in zip (a1,a2))
297- end
298-
299300function term (f, args... ; type = nothing )
300301 if type === nothing
301302 T = rec_promote_symtype (f, symtype .(args)... )
@@ -618,7 +619,7 @@ struct Pow{X, B, E} <: Symbolic{X}
618619 exp:: E
619620end
620621
621- function Pow (a,b)
622+ function Pow (a, b)
622623 _iszero (b) && return 1
623624 _isone (b) && return a
624625 Pow {promote_symtype(^, symtype(a), symtype(b)), typeof(a), typeof(b)} (a,b)
0 commit comments