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

Conditionally skip a branch of an expression tree in walks #2

Open
0x0f0f0f opened this issue Sep 5, 2021 · 1 comment
Open

Conditionally skip a branch of an expression tree in walks #2

0x0f0f0f opened this issue Sep 5, 2021 · 1 comment

Comments

@0x0f0f0f
Copy link
Member

0x0f0f0f commented Sep 5, 2021

Strictly related to
JuliaSymbolics/TermInterface.jl#6

Let's say that I have
f . (A -> B) ⊗ g as an input expression and with a Postwalk I want to apply this set of rules:

g => g . (B -> C)
A => A . Ob(A)
B => B . Ob(B)
etc...

My goal is to apply all the rewrites only if the input expressions have not been tagged. Tagging means adding an outer expression with operation(ex) = (.) (dot, called a type tag). Therefore, I do not want to match and transverse on left . right expressions.
For example, f in the input expression IS tagged, while g IS NOT.
I do want to tag g and the outer \otimes, but I do not want to tag anything that is inside f . (A -> B).
See Metatheory.jl/test/category/test_cat.jl.

A simple solution would be not treating left . right expressions as trees in this context. But right after this task is done, i need to treat them like trees. Overriding the TermInterface.istree every time seems like an incorrect approach. Is conditional skipping of branches of expr. trees in Rewriters possible?

@0x0f0f0f
Copy link
Member Author

0x0f0f0f commented Sep 5, 2021

cc @shashi

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

1 participant