# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = [s, t]
sub_expr3 = [U]
sub_expr4 = [var_ket_u]
sub_expr5 = [phase]
sub_expr6 = Add(t, one)
sub_expr7 = Add(t, s)
sub_expr8 = Interval(one, t)
sub_expr9 = Interval(sub_expr6, sub_expr7)
sub_expr10 = Mult(two_pow_t, phase)
sub_expr11 = Unitary(two_pow_s)
sub_expr12 = InSet(phase, IntervalCO(zero, one))
sub_expr13 = [ExprRange(sub_expr1, Measure(basis = Z), one, t), ExprRange(sub_expr1, Gate(operation = I).with_implicit_representation(), one, s)]
sub_expr14 = MultiQubitElem(element = Gate(operation = QPE(U, t), part = sub_expr1), targets = Interval(one, sub_expr7))
sub_expr15 = Interval(zero, subtract(two_pow_t, one))
sub_expr16 = ExprRange(sub_expr1, MultiQubitElem(element = Output(state = var_ket_u, part = sub_expr1), targets = sub_expr9), one, s)
sub_expr17 = Equals(MatrixMult(U, var_ket_u), ScalarMult(Exp(e, Mult(two, pi, i, phase)), var_ket_u))
sub_expr18 = [ExprRange(sub_expr1, Input(state = ket_plus), one, t), ExprRange(sub_expr1, MultiQubitElem(element = Input(state = var_ket_u, part = sub_expr1), targets = sub_expr9), one, s)]
sub_expr19 = [ExprRange(sub_expr1, sub_expr14, one, t), ExprRange(sub_expr1, sub_expr14, sub_expr6, sub_expr7)]
expr = And(Forall(instance_param_or_params = sub_expr2, instance_expr = Forall(instance_param_or_params = sub_expr3, instance_expr = Forall(instance_param_or_params = sub_expr4, instance_expr = Forall(instance_param_or_params = sub_expr5, instance_expr = Equals(Prob(Qcircuit(vert_expr_array = VertExprArray(sub_expr18, sub_expr19, sub_expr13, [ExprRange(sub_expr1, MultiQubitElem(element = Output(state = NumKet(sub_expr10, t), part = sub_expr1), targets = sub_expr8), one, t), sub_expr16]))), one), domain = Real, conditions = [InSet(sub_expr10, sub_expr15), sub_expr17]).with_wrapping(), domain = s_ket_domain, condition = normalized_var_ket_u).with_wrapping(), domain = sub_expr11).with_wrapping(), domain = NaturalPos).with_wrapping(), Forall(instance_param_or_params = sub_expr2, instance_expr = Forall(instance_param_or_params = sub_expr3, instance_expr = Forall(instance_param_or_params = sub_expr4, instance_expr = Forall(instance_param_or_params = sub_expr5, instance_expr = greater(Prob(Qcircuit(vert_expr_array = VertExprArray(sub_expr18, sub_expr19, sub_expr13, [ExprRange(sub_expr1, MultiQubitElem(element = Output(state = NumKet(Mod(Round(sub_expr10), two_pow_t), t), part = sub_expr1), targets = sub_expr8), one, t), sub_expr16]))), frac(four, Exp(pi, two))), domain = Real, conditions = [sub_expr12, sub_expr17]).with_wrapping(), domain = s_ket_domain, condition = normalized_var_ket_u).with_wrapping(), domain = sub_expr11).with_wrapping(), domain = NaturalPos).with_wrapping(), Forall(instance_param_or_params = [eps], instance_expr = Forall(instance_param_or_params = [s, n], instance_expr = Forall(instance_param_or_params = [U, var_ket_u, phase], instance_expr = Forall(instance_param_or_params = [t], instance_expr = greater_eq(ProbOfAll(instance_param_or_params = [m], instance_element = Qcircuit(vert_expr_array = VertExprArray(sub_expr18, sub_expr19, sub_expr13, [ExprRange(sub_expr1, MultiQubitElem(element = Output(state = NumKet(m, t), part = sub_expr1), targets = sub_expr8), one, t), sub_expr16])), domain = sub_expr15, condition = LessEq(ModAbs(subtract(frac(m, two_pow_t), phase), one), Exp(two, Neg(n)))).with_wrapping(), subtract(one, eps)), domain = NaturalPos, condition = greater_eq(t, Add(n, Ceil(Log(two, Add(two, frac(one, Mult(two, eps)))))))).with_wrapping(), domains = [sub_expr11, s_ket_domain, Real], conditions = [sub_expr12, normalized_var_ket_u, sub_expr17]).with_wrapping(), domain = NaturalPos, condition = greater_eq(n, two)).with_wrapping(), domain = IntervalOC(zero, one)).with_wrapping()).with_wrapping_at(1,3)