Giter VIP home page Giter VIP logo

Comments (4)

MasonProtter avatar MasonProtter commented on June 11, 2024

Another thing I think we should support is nested rule application. e.g.

@rule(sin(+(~~x)) 
      => sin(@acrule(~y::multiple_of(2π) 
                     => zero(~y))(+(~~x...))))

This basically says that there is a rule (you can drop multiples of from sums) which only applies inside the body of a trig function. Currently this is an error:

julia> @rule sin(+(~~x)) => sin(@acrule(~y::multiple_of(2π) => zero(~y))(+(~~x...)))
ERROR: LoadError: syntax: invalid syntax (escape (outerref @acrule))
Stacktrace:
 [1] top-level scope at REPL[13]:1
in expression starting at <macrocall>:0

from symbolicutils.jl.

shashi avatar shashi commented on June 11, 2024

Interesting case! Seems like it's only needed because + is ac but sin is not... otherwise you could write @acrule sin(+(~y::multiple_of(pi), ...etc...)).

from symbolicutils.jl.

MasonProtter avatar MasonProtter commented on June 11, 2024

Okay, turns out this works if you just separate out the rules:

using SymbolicUtils
@vars x y a::Integer
r = let
    r_inner = RuleSet([@acrule ~y::multiple_of(2π) => zero(~y)])
    @rule sin(+(~~x)) => sin(r_inner(+(~~x...)))
end

julia> r(sin(x + 2π*a + y))
(sin(x + y))

from symbolicutils.jl.

shashi avatar shashi commented on June 11, 2024

I'm closing this because I think we have the most important items here, let's open new issues as need arises.

The Segment optimizations are not very useful anymore since we do most of those complex rules using @acrule.

from symbolicutils.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.