logo

Expression of type Conditional

from the theory of proveit.linear_algebra.addition

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 Conditional, K, V, c, i, j, k
from proveit.core_expr_types import a_1_to_i, b_1_to_j, d_1_to_k
from proveit.linear_algebra import VecAdd, VecSpaces
from proveit.logic import Equals, Forall, InClass
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [i, j, k], instance_expr = Forall(instance_param_or_params = [a_1_to_i, b_1_to_j, c, d_1_to_k], instance_expr = Equals(VecAdd(a_1_to_i, b_1_to_j, c, d_1_to_k), VecAdd(a_1_to_i, c, b_1_to_j, d_1_to_k)).with_wrapping_at(2), domain = V), domain = Natural), InClass(V, VecSpaces(K)))
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_{i, j, k \in \mathbb{N}}~\left[\forall_{a_{1}, a_{2}, \ldots, a_{i}, b_{1}, b_{2}, \ldots, b_{j}, c, d_{1}, d_{2}, \ldots, d_{k} \in V}~\left(\begin{array}{c} \begin{array}{l} \left(a_{1} +  a_{2} +  \ldots +  a_{i}+ b_{1} +  b_{2} +  \ldots +  b_{j} + c+ d_{1} +  d_{2} +  \ldots +  d_{k}\right) =  \\ \left(a_{1} +  a_{2} +  \ldots +  a_{i} + c+ b_{1} +  b_{2} +  \ldots +  b_{j}+ d_{1} +  d_{2} +  \ldots +  d_{k}\right) \end{array} \end{array}\right)\right] \textrm{ if } V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\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: 15
operand: 6
2Operationoperator: 4
operands: 5
3ExprTuple6
4Literal
5ExprTuple67, 7
6Lambdaparameters: 8
body: 9
7Operationoperator: 10
operand: 14
8ExprTuple54, 56, 59
9Conditionalvalue: 12
condition: 13
10Literal
11ExprTuple14
12Operationoperator: 15
operand: 18
13Operationoperator: 31
operands: 17
14Variable
15Literal
16ExprTuple18
17ExprTuple19, 20, 21
18Lambdaparameters: 39
body: 22
19Operationoperator: 62
operands: 23
20Operationoperator: 62
operands: 24
21Operationoperator: 62
operands: 25
22Conditionalvalue: 26
condition: 27
23ExprTuple54, 28
24ExprTuple56, 28
25ExprTuple59, 28
26Operationoperator: 29
operands: 30
27Operationoperator: 31
operands: 32
28Literal
29Literal
30ExprTuple33, 34
31Literal
32ExprTuple35, 36, 37, 38
33Operationoperator: 40
operands: 39
34Operationoperator: 40
operands: 41
35ExprRangelambda_map: 42
start_index: 58
end_index: 54
36ExprRangelambda_map: 43
start_index: 58
end_index: 56
37Operationoperator: 62
operands: 44
38ExprRangelambda_map: 45
start_index: 58
end_index: 59
39ExprTuple46, 47, 51, 48
40Literal
41ExprTuple46, 51, 47, 48
42Lambdaparameter: 72
body: 49
43Lambdaparameter: 72
body: 50
44ExprTuple51, 67
45Lambdaparameter: 72
body: 52
46ExprRangelambda_map: 53
start_index: 58
end_index: 54
47ExprRangelambda_map: 55
start_index: 58
end_index: 56
48ExprRangelambda_map: 57
start_index: 58
end_index: 59
49Operationoperator: 62
operands: 60
50Operationoperator: 62
operands: 61
51Variable
52Operationoperator: 62
operands: 63
53Lambdaparameter: 72
body: 64
54Variable
55Lambdaparameter: 72
body: 65
56Variable
57Lambdaparameter: 72
body: 66
58Literal
59Variable
60ExprTuple64, 67
61ExprTuple65, 67
62Literal
63ExprTuple66, 67
64IndexedVarvariable: 68
index: 72
65IndexedVarvariable: 69
index: 72
66IndexedVarvariable: 70
index: 72
67Variable
68Variable
69Variable
70Variable
71ExprTuple72
72Variable