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, InSet
from proveit.numbers import Complex, sqrt
from proveit.physics.quantum import Qmult
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Exists(instance_param_or_params = [U], instance_expr = Equals(A, Qmult(U, sqrt(Qmult(Adj(A), A)))), domain = Unitary(n)), InSet(A, MatrixSpace(field = Complex, rows = n, columns = n)))
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\{\exists_{U \in \textrm{U}\left(n\right)}~\left(A = \left(U \thinspace \sqrt{\left(A^{\dagger} \thinspace A\right)}\right)\right) \textrm{ if } A \in \mathbb{C}^{n \times 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: 17
operands: 5
3Literal
4ExprTuple6
5ExprTuple40, 7
6Lambdaparameter: 24
body: 9
7Operationoperator: 10
operands: 11
8ExprTuple24
9Conditionalvalue: 12
condition: 13
10Literal
11NamedExprsfield: 14
rows: 26
columns: 26
12Operationoperator: 15
operands: 16
13Operationoperator: 17
operands: 18
14Literal
15Literal
16ExprTuple40, 19
17Literal
18ExprTuple24, 20
19Operationoperator: 31
operands: 21
20Operationoperator: 22
operand: 26
21ExprTuple24, 25
22Literal
23ExprTuple26
24Variable
25Operationoperator: 27
operands: 28
26Variable
27Literal
28ExprTuple29, 30
29Operationoperator: 31
operands: 32
30Operationoperator: 33
operands: 34
31Literal
32ExprTuple35, 40
33Literal
34ExprTuple36, 37
35Operationoperator: 38
operand: 40
36Literal
37Literal
38Literal
39ExprTuple40
40Variable