logo
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, b, m, x
from proveit.linear_algebra import MatrixExp, MatrixMult, ScalarMult
from proveit.logic import Equals, Forall, InSet
from proveit.numbers import Complex, Exp, NaturalPos
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [b], instance_expr = Forall(instance_param_or_params = [A, x], instance_expr = Equals(MatrixMult(MatrixExp(A, m), x), MatrixMult(Exp(b, m), x)), condition = Equals(MatrixMult(A, x), ScalarMult(b, x))), domain = Complex), InSet(m, 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_{b \in \mathbb{C}}~\left[\forall_{A, x~|~\left(A \thinspace x\right) = \left(b \cdot x\right)}~\left(\left(A^{m} \thinspace x\right) = \left(b^{m} \thinspace x\right)\right)\right] \textrm{ if } m \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: 11
operand: 5
2Operationoperator: 13
operands: 4
3ExprTuple5
4ExprTuple42, 6
5Lambdaparameter: 41
body: 8
6Literal
7ExprTuple41
8Conditionalvalue: 9
condition: 10
9Operationoperator: 11
operand: 15
10Operationoperator: 13
operands: 14
11Literal
12ExprTuple15
13Literal
14ExprTuple41, 16
15Lambdaparameters: 30
body: 17
16Literal
17Conditionalvalue: 18
condition: 19
18Operationoperator: 21
operands: 20
19Operationoperator: 21
operands: 22
20ExprTuple23, 24
21Literal
22ExprTuple25, 26
23Operationoperator: 29
operands: 27
24Operationoperator: 29
operands: 28
25Operationoperator: 29
operands: 30
26Operationoperator: 31
operands: 32
27ExprTuple33, 35
28ExprTuple34, 35
29Literal
30ExprTuple40, 35
31Literal
32ExprTuple41, 35
33Operationoperator: 36
operands: 37
34Operationoperator: 38
operands: 39
35Variable
36Literal
37ExprTuple40, 42
38Literal
39ExprTuple41, 42
40Variable
41Variable
42Variable