diff --git a/src/deca/ThDEC.jl b/src/deca/ThDEC.jl index e71701b..c174175 100644 --- a/src/deca/ThDEC.jl +++ b/src/deca/ThDEC.jl @@ -203,13 +203,12 @@ end @alias (Δ₀, Δ₁, Δ₂) => Δ -# Base.show(io::IO, - +# TODO: Determine what we need to do for .+ @operator +(S1, S2)::DECQuantity begin @match (S1, S2) begin PatInferredTypes(_) => InferredType (PatScalar(_), PatScalar(_)) => Scalar - (PatScalar(_), PatFormParams([i,d,s,n])) || (PatFormParams([i,d,s,n]), PatScalar(_)) => S1 # commutativity + (PatScalar(_), PatFormParams([i,d,s,n])) || (PatFormParams([i,d,s,n]), PatScalar(_)) => Form{i, d, s, n} # commutativity (PatFormParams([i1,d1,s1,n1]), PatFormParams([i2,d2,s2,n2])) => begin if (i1 == i2) && (d1 == d2) && (s1 == s2) && (n1 == n2) Form{i1, d1, s1, n1} @@ -298,18 +297,18 @@ function Base.nameof(::typeof(★), s) Symbol("★$(as_sub(isdual(s) ? dim(space(s)) - dim(s) : dim(s)))$(inv)") end -function SymbolicUtils.symtype(::Type{<:Quantity}, qty::Symbol, space::Symbol) +function SymbolicUtils.symtype(::Type{<:Quantity}, qty::Symbol, space::Symbol, dim::Int = 2) @match qty begin :Scalar => Scalar :Constant => Const :Parameter => Parameter :Literal => Literal - :Form0 => PrimalForm{0, space, 1} - :Form1 => PrimalForm{1, space, 1} - :Form2 => PrimalForm{2, space, 1} - :DualForm0 => DualForm{0, space, 1} - :DualForm1 => DualForm{1, space, 1} - :DualForm2 => DualForm{2, space, 1} + :Form0 => PrimalForm{0, space, dim} + :Form1 => PrimalForm{1, space, dim} + :Form2 => PrimalForm{2, space, dim} + :DualForm0 => DualForm{0, space, dim} + :DualForm1 => DualForm{1, space, dim} + :DualForm2 => DualForm{2, space, dim} :Infer => InferredType _ => error("Received $qty") end diff --git a/src/symbolictheoryutils.jl b/src/symbolictheoryutils.jl index 63dafc9..7746559 100644 --- a/src/symbolictheoryutils.jl +++ b/src/symbolictheoryutils.jl @@ -43,7 +43,7 @@ Creates an operator `foo` with arguments which are types in a given Theory. This (@rule expr1) ... (@rule exprN) -end +end ``` builds ``` @@ -81,7 +81,7 @@ macro operator(head, body) end (f, types, Theory) = ph(head) - # Passing types to functions requires that we type the signature with ::Type{T}. + # Passing types to functions requires that we type the signature with ::Type{T}. # This means that the user would have to write `my_op(::Type{T1}, ::Type{T2}, ...)` # As a convenience to the user, we allow them to specify the signature using just the types themselves: # `my_op(T1, T2, ...)` @@ -89,15 +89,15 @@ macro operator(head, body) sort_constraints = [:($S<:$Theory) for S in types] arity = length(sort_types) - # Parse the body for @rule calls. + # Parse the body for @rule calls. block, rulecalls = @match Base.remove_linenums!(body) begin Expr(:block, block, rules...) => (block, rules) s => nothing end - + # initialize the result result = quote end - + # construct the function on basic symbolics argnames = [gensym(:x) for _ in 1:arity] argclaus = [:($a::Symbolic) for a in argnames] @@ -110,17 +110,17 @@ macro operator(head, body) export $f - Base.show(io::IO, ::typeof($f)) = print(io, $f) + # Base.show(io::IO, ::typeof($f)) = print(io, $f) end) - # if there are rewriting rules, add a method which accepts the function symbol and its arity + # if there are rewriting rules, add a method which accepts the function symbol and its arity # (to prevent shadowing on operators like `-`) if !isempty(rulecalls) push!(result.args, quote function rules(::typeof($f), ::Val{$arity}) [($(rulecalls...))] end - + rules(::typeof($f)) = rules($f, Val{1}) end) end @@ -158,7 +158,7 @@ macro alias(body) push!(result.args, quote function $alias(s...) - $rep(s...) + $rep(s...) end export $alias @@ -171,4 +171,3 @@ export @alias alias(x) = error("$x has no aliases") export alias - diff --git a/test/acset2symbolic.jl b/test/acset2symbolic.jl index 685e06d..0212a7e 100644 --- a/test/acset2symbolic.jl +++ b/test/acset2symbolic.jl @@ -186,8 +186,8 @@ end distr_d = @decapode begin A::Form0 - B::Form0 - C::Form0 + B::Form1 + C::Form2 C == d(∧(A, B)) end @@ -199,8 +199,8 @@ end distr_d_res = @decapode begin A::Form0 - B::Form0 - C::Form0 + B::Form1 + C::Form2 C == ∧(d(A), B) + ∧(A, d(B)) end