-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Supertype of Symbolic expressions #16
Comments
That's for Julia to act like that when tracing. In order for symbolic analysis to handle this, you can just choose for |
Yes, we already do that.... |
Yeah, the issues is that it doesn’t help dispatch. |
Variable{T} is definitely not good enough, but I think it's a "good enough default" for generic tracing (since you can't do Variable{T} <: T, though we're asking compiler folk to allow it if possible). That said, if there's something that allows you to take finer control of tracing , like a Cassette-y thing, then it can act like |
Here's a minimal implementation of a symbolic system with custom IRTools pass that does at the repl: julia> using .Syms
julia> begin
f(x::Float64) = 1 + sin(x)^(1/2)
g(x::Vector{Int}) = x'x + 2
x = Sym{Float64}(:x)
y = Sym{Vector{Int}}(:y)
end
y::Array{Int64,1}
julia> sym() do
f(g(y) + x)
end
(1 + sin((adjoint(y) * y + 2) + x) ^ 0.5) :: Float64 where {x::Float64, y::Array{Int64,1}} This could also be implemented in Cassette if the ReflectOn branch ever merges. |
Pretty nice! What does Is anyone else feeling that we should split out just the symbolic.jl (just the type definitions) file into a SymbolicBase package, and then have the simplification + methods in this package? This is because if we're going to make this the basis of ModelingToolkit types, then I don't want stuff to keep breaking for Chris & co. But there's also the issue that a large part of why you'd want a base package is to avoid piracy which would mean that these methods would have to be defined in the Base package. |
With the IRTools/Cassette approach we can say that there's a specific entrypoint using SymbolicBase # just the types
using Symbolics: symrun # this package?
symrun() do
... # here + , * etc are defined
end In other words this is saying: "run something in the symbolic context" This would make ModelingToolkit code have a bunch of |
No, because most usage doesn't need tracing. So it wouldn't be all that common. |
Oh so you want both a bunch of methods and a tracing context... Yes the default methods could just be limited to Then I don't think we need to worry about splitting this package up right now. |
Ha ha, I was never sure beyond "mike said this makes |
We really want
But can't have it easily.
Some approaches:
@vars a::AbstractMatrix b::Real c::Complex
should generate different Variable types with the right super type. This reminds me of the NamedTuples.jl from Julia 0.6.A resolution of this should fix #8
The text was updated successfully, but these errors were encountered: