logo

Expression of type Conditional

from the theory of proveit.logic.sets.cartesian_products

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, m, x
from proveit.core_expr_types import A_1_to_m, a_1_to_m
from proveit.logic import And, CartProd, Equals, Forall, InSet
from proveit.logic.sets.cartesian_products import a_in_A__1_to_m
from proveit.numbers import NaturalPos
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [x, A_1_to_m, a_1_to_m], instance_expr = Equals(InSet(x, CartProd(A_1_to_m)), And(Equals(x, [a_1_to_m]), a_in_A__1_to_m)).with_wrapping_at(2)), 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_{x, A_{1}, A_{2}, \ldots, A_{m}, a_{1}, a_{2}, \ldots, a_{m}}~\left(\begin{array}{c} \begin{array}{l} \left(x \in \left(A_{1} \times  A_{2} \times  \ldots \times  A_{m}\right)\right) =  \\ \left(\left(x = \left(a_{1}, a_{2}, \ldots, a_{m}\right)\right)\land \left(a_{1} \in A_{1}\right) \land  \left(a_{2} \in A_{2}\right) \land  \ldots \land  \left(a_{m} \in A_{m}\right)\right) \end{array} \end{array}\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: 3
operand: 6
2Operationoperator: 30
operands: 5
3Literal
4ExprTuple6
5ExprTuple34, 7
6Lambdaparameters: 8
body: 9
7Literal
8ExprTuple25, 24, 29
9Operationoperator: 21
operands: 10
10ExprTuple11, 12
11Operationoperator: 30
operands: 13
12Operationoperator: 14
operands: 15
13ExprTuple25, 16
14Literal
15ExprTuple17, 18
16Operationoperator: 19
operands: 20
17Operationoperator: 21
operands: 22
18ExprRangelambda_map: 23
start_index: 33
end_index: 34
19Literal
20ExprTuple24
21Literal
22ExprTuple25, 26
23Lambdaparameter: 40
body: 27
24ExprRangelambda_map: 28
start_index: 33
end_index: 34
25Variable
26ExprTuple29
27Operationoperator: 30
operands: 31
28Lambdaparameter: 40
body: 35
29ExprRangelambda_map: 32
start_index: 33
end_index: 34
30Literal
31ExprTuple36, 35
32Lambdaparameter: 40
body: 36
33Literal
34Variable
35IndexedVarvariable: 37
index: 40
36IndexedVarvariable: 38
index: 40
37Variable
38Variable
39ExprTuple40
40Variable