Skip to content

Commit

Permalink
Merge branch 'cm/symbolictypes' of github.com:AlgebraicJulia/Diagramm…
Browse files Browse the repository at this point in the history
…aticEquations.jl into cm/symbolictypes
  • Loading branch information
quffaro committed Sep 10, 2024
2 parents e82e826 + e23459f commit f32b3c0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/symbolictheoryutils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,13 @@ macro operator(head, body)
result = quote end

# construct the function on basic symbolics
argnames = [gensym(:x) for _ in 1:arity]
argclaus = [:($a::Symbolic) for a in argnames]
push!(result.args, quote
@nospecialize
function $f(args...)
s = promote_symtype($f, args...)
SymbolicUtils.Term{s}($f, [args...])
function $f($(argclaus...))
s = promote_symtype($f, $(argnames...))
SymbolicUtils.Term{s}($f, Any[$(argnames...)])
end
export $f
end)
Expand Down
24 changes: 24 additions & 0 deletions test/klausmeier.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,27 @@ symbmodel = SymbolicContext(Phytodynamics)
dexpr = DecaExpr(symbmodel)
symbmodel′ = SymbolicContext(dexpr)
# TODO variables are the same but the equations don't match

n = ps.vars[1]
SymbolicUtils.symtype(n)
Δ(n)

r = @rule Δ(~n) => (d((d(~n))))

t2 = r(Δ(n))
t2 |> dump


using SymbolicUtils.Rewriters
using SymbolicUtils: promote_symtype
r = @rule ((~n)) => ~n
nested_star_cancel = Postwalk(Chain([r]))
nested_star_cancel(d(((n))))
nsc = nested_star_cancel

isequal(nsc(((d(n)))), d(n))
dump(nsc(((d(n)))))
dump(d(n))
((d(((n)))))
nsc(((d(((n))))))
nsc(nsc(((d(((n)))))))

0 comments on commit f32b3c0

Please sign in to comment.