-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
Unable to reason over ADT #257
Comments
Might be related to #209 |
Ah, I see, the method for |
|
How could it be covered? |
Did you make the types matchable by satisfying TermInterface? |
Nvm, verified. I just pushed a bugfix. You should use TermInterface.jl if you define custom AST types. See |
Let me know if it works for your use case :) |
Thanks for the pointer and the fix! This is super helpful I was able to get it at least running, but it doesn't seem to simplify my expressions. Also, the metadata does not seem to work for my leaf nodes ( module dcac
using Metatheory, Metatheory.TermInterface, Metatheory.EGraphs
# Define the Dim data type
abstract type Dim end
struct Lit <: Dim
value::Int64
end
TermInterface.isexpr(::Dim) = true
TermInterface.children(l::Lit) = [l.value]
TermInterface.metadata(l::Lit) = l.value # This doesn't seem to work
TermInterface.head(l::Lit) = "lit"
# Define constructors for Dim
struct Plus{T<:Dim,U<:Dim} <: Dim
dim1::T
dim2::U
end
TermInterface.children(p::Plus) = [p.dim1, p.dim2]
TermInterface.head(::Plus) = "plus"
TermInterface.maketerm(::Type{Dim}, h, c, metadata) =
if h == "plus"
return Plus(c[1], c[2])
elseif h == "lit"
return Lit(c[1])
end
return false
t = @theory dim1 a b begin
Plus(Lit(0), ~dim1) --> ~dim1
end
ex = Plus(Lit(0), Lit(0))
g= EGraph{Dim}(ex)
saturate!(g,t)
print(extract!(g,astsize))
end |
Hi,
I'm using the
ale/3.0
branch, and I am trying to reason over an ADT implemented with abstract types (code below)It fails with the following error:
Is there a workaround for this, or is this a metatheory.jl issue?
The text was updated successfully, but these errors were encountered: