# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = Add(_t, _s)
sub_expr3 = Add(_t, one)
sub_expr4 = Interval(one, _t)
sub_expr5 = Interval(sub_expr3, sub_expr2)
sub_expr6 = [ExprRange(sub_expr1, Measure(basis = Z), one, _t), _s_wire]
sub_expr7 = MultiQubitElem(element = Input(state = TensorProd(_Psi_ket, _ket_u), part = sub_expr1), targets = Interval(one, sub_expr2))
sub_expr8 = [ExprRange(sub_expr1, MultiQubitElem(element = Output(state = NumKet(m, _t), part = sub_expr1), targets = sub_expr4), one, _t), ExprRange(sub_expr1, MultiQubitElem(element = Output(state = _ket_u, part = sub_expr1), targets = sub_expr5), one, _s)]
expr = Equals(Prob(Qcircuit(vert_expr_array = VertExprArray([ExprRange(sub_expr1, sub_expr7, one, _t).with_wrapping_at(2,6), ExprRange(sub_expr1, sub_expr7, sub_expr3, sub_expr2).with_wrapping_at(2,6)], sub_expr6, sub_expr8))), Prob(Qcircuit(vert_expr_array = VertExprArray([ExprRange(sub_expr1, MultiQubitElem(element = Input(state = _Psi_ket, part = sub_expr1), targets = sub_expr4), one, _t), ExprRange(sub_expr1, MultiQubitElem(element = Input(state = _ket_u, part = sub_expr1), targets = sub_expr5), one, _s)], sub_expr6, sub_expr8))))