diff --git a/src/QSymbolicsBase/predefined.jl b/src/QSymbolicsBase/predefined.jl index bc15880..96af471 100644 --- a/src/QSymbolicsBase/predefined.jl +++ b/src/QSymbolicsBase/predefined.jl @@ -179,7 +179,7 @@ const CPHASE = CPHASEGate() abstract type AbstractSingleBosonOp <: Symbolic{AbstractOperator} end abstract type AbstractSingleBosonGate <: AbstractSingleBosonOp end # TODO maybe an IsUnitaryTrait is a better choice -isexpr(::AbstractSingleBosonOp) = false +isexpr(::AbstractSingleBosonGate) = false basis(::AbstractSingleBosonGate) = inf_fock_basis @withmetadata struct NumberOp <: AbstractSingleBosonOp end diff --git a/src/QSymbolicsBase/rules.jl b/src/QSymbolicsBase/rules.jl index 66494ae..d5e140c 100644 --- a/src/QSymbolicsBase/rules.jl +++ b/src/QSymbolicsBase/rules.jl @@ -104,8 +104,6 @@ RULES_EXPAND = [ @rule(+(~~ops) * ~o1 => +(map(op -> op * ~o1, ~~ops)...)), @rule(⊗(~~ops1::_vecisa(Symbolic{AbstractBra})) * ⊗(~~ops2::_vecisa(Symbolic{AbstractKet})) => *(map(*, ~~ops1, ~~ops2)...)), @rule(⊗(~~ops1::_vecisa(Symbolic{AbstractOperator})) * ⊗(~~ops2::_vecisa(Symbolic{AbstractOperator})) => ⊗(map(*, ~~ops1, ~~ops2)...)), - @rule(~o1::_isa(Symbolic{AbstractOperator}) * ⊗(~~ops) => ⊗(map(op -> ~o1 * op, ~~ops)...)), - @rule(⊗(~~ops) * ~o1::_isa(Symbolic{AbstractOperator}) => ⊗(map(op -> op * ~o1, ~~ops)...)), ] # diff --git a/test/test_trace.jl b/test/test_trace.jl index bc03e21..ef4f59a 100644 --- a/test/test_trace.jl +++ b/test/test_trace.jl @@ -23,6 +23,7 @@ exp2 = A⊗(B⊗C + D⊗E) @test isequal(ptrace(𝒪, 1), SPartialTrace(𝒪, 1)) @test isequal(ptrace(𝒪, 2), SPartialTrace(𝒪, 2)) @test isequal(ptrace(A, 1), tr(A)) + @test isequal(ptrace(A*(B+C), 1), tr(A*B)+tr(A*C)) @test_throws ArgumentError ptrace(A, 2) @test isequal(QuantumSymbolics.basis(ptrace(𝒪, 1)), SpinBasis(1//2)) @test isequal(QuantumSymbolics.basis(ptrace(𝒪, 2)), SpinBasis(1//2))