Closed owiecc closed 3 months ago
@YingboMa
We could have @rule a a::(nonzero && noninfinite)/a => a
Where
nonzero(x::Symbolic) = getmetadata(x, SignAnalysis) != 0
and
nonzero(g::EGraph, x::EClass) = let sign Metatheory.getdata(x, SignAnalysis, nothing)
sign != 0 && !isnothing(sign)
end
(same goes for noninfinite
)
Where &&
is the unary functional and (&&)(a::Function, b::Function) = x -> a(x) && b(x)
Now
using SymbolicUtils
@syms a
simplify(a/a)
gives
1
Simplification of a simple division
a/a
is currently not performed by the package.I am aware of the special cases where
a = 0
ora = ∞
but these could be avoided if we attach metadata (e.g.nonzero
) to the variable. There was a small discussion on metadata in https://github.com/JuliaSymbolics/Symbolics.jl/pull/351#issuecomment-901453080PS. Should we have a documented set of metadata (potentially) handled by the package? I cannot find any documentation on this.