Skip to content
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

Rules work with @syms but not with @variables #1435

Open
ebelnikola opened this issue Feb 10, 2025 · 3 comments
Open

Rules work with @syms but not with @variables #1435

ebelnikola opened this issue Feb 10, 2025 · 3 comments

Comments

@ebelnikola
Copy link

Hi!

I noticed the following behavior similar to what was mentioned in this issue. When I apply a rule to a function defined via "@variables" it does not work, while with "@syms" everything is fine. Here is a minimal example:

using Symbolics
@variables a(..)
@syms b(i1, i2)::Real
println("types are the same: ", (a(2, 1) |> typeof) == (b(2, 1) |> typeof)) # prints true
ra = @rule a(~i1, ~i2) => a(~i2, ~i1) where {~i1>~i2}
rb = @rule b(~i1, ~i2) => b(~i2, ~i1) where {~i1>~i2}
println("result of the rule application on a: ", ra(a(2, 1))) # prints nothing
println("result of the rule application on b: ", rb(b(2, 1))) # prints b(1,2)

There is no documentation on pattern matching, so I don't know if this is intended or not.

@ChrisRackauckas
Copy link
Member

It needs to unwrap. It would be nice if we made them auto-unwrap and wrap.

@ebelnikola
Copy link
Author

What should be unwrapped exactly? I tried ra(Symbolics.unwrap(a(2, 1))). This does not change the result. Also, note that there is the test showing that a(2,1) and b(2,1) are of the same type.

@ChrisRackauckas
Copy link
Member

Sounds like there's something deeper going on here then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants