logo
In [1]:
import proveit
# Automation is not needed when only building an expression:
proveit.defaults.automation = False # This will speed things up.
proveit.defaults.inline_pngs = False # Makes files smaller.
%load_theorem_expr # Load the stored theorem expression as 'stored_expr'
# import the special expression
from proveit.physics.quantum.circuits import circuit_output_equiv
In [2]:
# check that the built expression is the same as the stored expression
assert circuit_output_equiv.expr == stored_expr
assert circuit_output_equiv.expr._style_id == stored_expr._style_id
print("Passed sanity check: circuit_output_equiv matches stored_expr")
Passed sanity check: circuit_output_equiv matches stored_expr
In [3]:
# Show the LaTeX representation of the expression for convenience if you need it.
print(stored_expr.latex())
\forall_{k, m \in \mathbb{N}^+}~\left[\forall_{a, b, U_{1}, U_{2}, \ldots, U_{m}}~\left(\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{a} & \gate{\begin{array}{c} \uparrow \\U_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\U_{2} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\U_{m} \\ \downarrow\end{array}} & \qout{b}
} \end{array}\right) \Rightarrow \left(\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{a} & \gate{\begin{array}{c} \uparrow \\U_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\U_{2} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\U_{m} \\ \downarrow\end{array}} & { /^{k} } \qw
} \end{array}\right) \cong \left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{b} & { /^{k} } \qw
} \end{array}\right)\right)\right)\right]
In [4]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [5]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 7
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple68, 41
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 11
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11
9Literal
10ExprTuple12, 13
11Lambdaparameters: 14
body: 15
12Operationoperator: 17
operands: 16
13Operationoperator: 17
operands: 18
14ExprTuple64, 65, 36
15Operationoperator: 19
operands: 20
16ExprTuple68, 21
17Literal
18ExprTuple41, 21
19Literal
20ExprTuple22, 23
21Literal
22Operationoperator: 32
operands: 24
23Operationoperator: 25
operands: 26
24ExprTuple35, 36, 27
25Literal
26ExprTuple28, 29
27ExprTuple30
28Operationoperator: 32
operands: 31
29Operationoperator: 32
operand: 37
30ExprRangelambda_map: 34
start_index: 67
end_index: 68
31ExprTuple35, 36
32Literal
33ExprTuple37
34Lambdaparameter: 66
body: 38
35ExprTuple39
36ExprRangelambda_map: 40
start_index: 67
end_index: 41
37ExprTuple42
38Operationoperator: 54
operands: 43
39ExprRangelambda_map: 44
start_index: 67
end_index: 68
40Lambdaparameter: 66
body: 45
41Variable
42ExprRangelambda_map: 46
start_index: 67
end_index: 68
43NamedExprselement: 47
targets: 58
44Lambdaparameter: 66
body: 48
45IndexedVarvariable: 49
index: 66
46Lambdaparameter: 66
body: 51
47Operationoperator: 52
operands: 61
48Operationoperator: 54
operands: 53
49Variable
50ExprTuple66
51Operationoperator: 54
operands: 55
52Literal
53NamedExprselement: 56
targets: 58
54Literal
55NamedExprselement: 57
targets: 58
56Operationoperator: 60
operands: 59
57Operationoperator: 60
operands: 61
58Operationoperator: 62
operands: 63
59NamedExprsstate: 64
part: 66
60Literal
61NamedExprsstate: 65
part: 66
62Literal
63ExprTuple67, 68
64Variable
65Variable
66Variable
67Literal
68Variable