Skip to content

Conversation

@0x0f0f0f
Copy link
Member

@0x0f0f0f 0x0f0f0f commented Sep 16, 2021

This is an attempt to unify the Symbolics ecosystem following a layered protocol approach, in order to maintain code as general as possible without sacrificing all the performance optimizations of SU, and in order to extend SU support to e-graph rewriting, non-evaluating symbolic-replacement rules (--> operator) and a new, drop-in, alternative friendly syntax:

  • TermInterface is the glue package between all symbolics manipulation packages
  • Metatheory.jl provides all the generic term rewriting utilities (Rule, ACRule, EGraphs, matchers, Rewriters,...) on any type that satisfies TermInterface.jl
  • SymbolicUtils.jl provides the specifically optimized types and simplification rules for mathematical symbolic expressions (Add, Mul, Div, PolyForm), and code generation etc...

This follows the the last diagram of https://discourse.julialang.org/t/a-recap-of-the-state-of-the-symbolics-ecosystem/68022 and should in principle simplify the dependencies, CI fragmentation and versioning, in contrast to #352 that would have provided a lot of CI fragmentation and dependency versioning hell

This needs JuliaSymbolics/Metatheory.jl#77 to be merged and released first

The imported modules from Metatheory are

using Metatheory # generic term rewriting 
using Metatheory.Rules # RewriteRule, ACRule, DynamicRule
using Metatheory.Rewriters # Rewriter combinators
using Metatheory.SUSyntax # Use the SymbolicUtils rule language for defining rules.

If you want to try out the new syntax, replace SUSyntax with NewSyntax. In the new syntax, symbols in patterns (x) are slot variables, x... is used for segment variables, => for substitution rules, |> for dynamic rules, == and != for bidirectional e-graph specific rules.

@0x0f0f0f 0x0f0f0f added the help wanted Extra attention is needed label Sep 16, 2021
@0x0f0f0f 0x0f0f0f requested review from YingboMa and shashi September 16, 2021 09:02
@0x0f0f0f
Copy link
Member Author

0x0f0f0f commented Sep 27, 2021

All the stuff works if you locally clone and add the SU#lower_to_mt and MT#lower_from_su branches

Some stuff left to do:
Merge and release JuliaSymbolics/Metatheory.jl#77
Merge master into this branch
Fix timerewrite
Fix the benchmark tests and compare them, in case, tweak performance of lowered features

@0x0f0f0f
Copy link
Member Author

@shashi could you please retrigger buildkite benchmark?

@0x0f0f0f
Copy link
Member Author

Everything should be working and this PR should be ready to be reviewed

@shashi
Copy link
Member

shashi commented Oct 15, 2021

It seems the buildkite failure is unrelated?

@shashi
Copy link
Member

shashi commented Oct 15, 2021

Okay now we get a nice error message that is relevant.

@0x0f0f0f
Copy link
Member Author

Okay now we get a nice error message that is relevant.

Fact is that we want to use @rule from Metatheory when benchmarking this branch and @rule from SU when benchmarking master. How to proceed?

@0x0f0f0f 0x0f0f0f changed the title [WIP] Move generic term rewriting features to Metatheory.jl Move generic term rewriting features to Metatheory.jl Oct 16, 2021
@0x0f0f0f
Copy link
Member Author

Okay now we get a nice error message that is relevant.

Fact is that we want to use @rule from Metatheory when benchmarking this branch and @rule from SU when benchmarking master. How to proceed?

Dumb question. SymbolicUtils.jl re-exports Metatheory.jl's @rule in this PR. Should work now.

@codecov-commenter
Copy link

Codecov Report

Merging #368 (987f6f6) into master (5860207) will increase coverage by 1.49%.
The diff coverage is 87.50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #368      +/-   ##
==========================================
+ Coverage   83.54%   85.03%   +1.49%     
==========================================
  Files          12       10       -2     
  Lines        1489     1203     -286     
==========================================
- Hits         1244     1023     -221     
+ Misses        245      180      -65     
Impacted Files Coverage Δ
src/code.jl 81.67% <ø> (ø)
src/utils.jl 57.74% <ø> (-0.91%) ⬇️
src/types.jl 84.99% <60.00%> (ø)
src/rule.jl 96.15% <100.00%> (+11.07%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5860207...987f6f6. Read the comment docs.

@shashi shashi merged commit 701636b into master Oct 18, 2021
@shashi
Copy link
Member

shashi commented Oct 18, 2021

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

help wanted Extra attention is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants