logo

Expression of type Conditional

from the theory of proveit.physics.quantum.algebra

In [1]:
import proveit
# Automation is not needed when building an expression:
proveit.defaults.automation = False # This will speed things up.
proveit.defaults.inline_pngs = False # Makes files smaller.
%load_expr # Load the stored expression as 'stored_expr'
# import Expression classes needed to build the expression
from proveit import A, Conditional, U, n
from proveit.linear_algebra import Adj, MatrixSpace, Unitary
from proveit.logic import Equals, Exists, Forall, InSet
from proveit.numbers import Complex, NaturalPos, sqrt
from proveit.physics.quantum import Qmult
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [A], instance_expr = Exists(instance_param_or_params = [U], instance_expr = Equals(A, Qmult(U, sqrt(Qmult(Adj(A), A)))), domain = Unitary(n)), domain = MatrixSpace(field = Complex, rows = n, columns = n)), InSet(n, NaturalPos))
expr:
In [3]:
# check that the built expression is the same as the stored expression
assert expr == stored_expr
assert expr._style_id == stored_expr._style_id
print("Passed sanity check: expr matches stored_expr")
Passed sanity check: expr matches stored_expr
In [4]:
# Show the LaTeX representation of the expression for convenience if you need it.
print(stored_expr.latex())
\left\{\forall_{A \in \mathbb{C}^{n \times n}}~\left[\exists_{U \in \textrm{U}\left(n\right)}~\left(A = \left(U \thinspace \sqrt{\left(A^{\dagger} \thinspace A\right)}\right)\right)\right] \textrm{ if } n \in \mathbb{N}^+\right..
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 3
operand: 6
2Operationoperator: 25
operands: 5
3Literal
4ExprTuple6
5ExprTuple34, 7
6Lambdaparameter: 48
body: 8
7Literal
8Conditionalvalue: 9
condition: 10
9Operationoperator: 11
operand: 14
10Operationoperator: 25
operands: 13
11Literal
12ExprTuple14
13ExprTuple48, 15
14Lambdaparameter: 32
body: 17
15Operationoperator: 18
operands: 19
16ExprTuple32
17Conditionalvalue: 20
condition: 21
18Literal
19NamedExprsfield: 22
rows: 34
columns: 34
20Operationoperator: 23
operands: 24
21Operationoperator: 25
operands: 26
22Literal
23Literal
24ExprTuple48, 27
25Literal
26ExprTuple32, 28
27Operationoperator: 39
operands: 29
28Operationoperator: 30
operand: 34
29ExprTuple32, 33
30Literal
31ExprTuple34
32Variable
33Operationoperator: 35
operands: 36
34Variable
35Literal
36ExprTuple37, 38
37Operationoperator: 39
operands: 40
38Operationoperator: 41
operands: 42
39Literal
40ExprTuple43, 48
41Literal
42ExprTuple44, 45
43Operationoperator: 46
operand: 48
44Literal
45Literal
46Literal
47ExprTuple48
48Variable