Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/simplify_rules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ let
@rule(exp(~x)^(~y) => exp(~x * ~y))
]

TYPE_RULES = [
@rule(~x::_isinteger => Int(~x))
]

BOOLEAN_RULES = [
@rule((true | (~x)) => true)
@rule(((~x) | true) => true)
Expand Down Expand Up @@ -142,6 +146,7 @@ let
If(x -> !ispow(x) && is_operation(^)(x),
Chain(CANONICALIZE_POW)),
If(is_operation(^), Chain(POW_RULES)),
Chain(TYPE_RULES)
] |> RestartedChain

rule_tree
Expand Down
8 changes: 8 additions & 0 deletions test/rulesets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ end
@test simplify(Term(zero, [x + 2])) == 0
end

@testset "Types" begin
@syms x

# should convert to int
@test simplify(7.0) === 7
@test simplify(7.0*x) === 7*x
end

@testset "LiteralReal" begin
@syms x1::LiteralReal x2::LiteralReal
s = cos(x1 * 3.2) - x2 * 5.8 + x2 * 1.2
Expand Down
Loading