logo

Expression of type And

from the theory of proveit.logic.booleans.disjunction

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, ExprRange, IndexedVar, Variable, m
from proveit.core_expr_types import A_1_to_m
from proveit.logic import And, Boolean, Forall, InSet, Or
from proveit.numbers import Add, NaturalPos, one, two
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = IndexedVar(A, one)
sub_expr3 = IndexedVar(A, sub_expr1)
sub_expr4 = Add(m, one)
expr = And(Forall(instance_param_or_params = [sub_expr2], instance_expr = InSet(sub_expr2, Boolean), domain = Boolean), Forall(instance_param_or_params = [m], instance_expr = Forall(instance_param_or_params = [ExprRange(sub_expr1, sub_expr3, one, Add(m, two))], instance_expr = InSet(Or(ExprRange(sub_expr1, sub_expr3, one, sub_expr4)), Boolean), condition = ExprRange(sub_expr1, InSet(sub_expr3, Boolean), one, sub_expr4)), domain = NaturalPos, condition = Forall(instance_param_or_params = [A_1_to_m], instance_expr = InSet(Or(A_1_to_m), Boolean), domain = Boolean)))
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_{A_{1} \in \mathbb{B}}~\left(A_{1} \in \mathbb{B}\right)\right] \land \left[\forall_{m \in \mathbb{N}^+~|~\forall_{A_{1}, A_{2}, \ldots, A_{m} \in \mathbb{B}}~\left(\left(A_{1} \lor  A_{2} \lor  \ldots \lor  A_{m}\right) \in \mathbb{B}\right)}~\left[\forall_{A_{1}, A_{2}, \ldots, A_{m + 2}~|~\left(A_{1} \in \mathbb{B}\right), \left(A_{2} \in \mathbb{B}\right), \ldots, \left(A_{m + 1} \in \mathbb{B}\right)}~\left(\left(A_{1} \lor  A_{2} \lor  \ldots \lor  A_{m + 1}\right) \in \mathbb{B}\right)\right]\right]
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
operation'infix' or 'function' style formattinginfixinfix
wrap_positionsposition(s) at which wrapping is to occur; '2 n - 1' is after the nth operand, '2 n' is after the nth operation.()()('with_wrapping_at', 'with_wrap_before_operator', 'with_wrap_after_operator', 'without_wrapping', 'wrap_positions')
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'centercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 45
operands: 1
1ExprTuple2, 3
2Operationoperator: 26
operand: 6
3Operationoperator: 26
operand: 7
4ExprTuple6
5ExprTuple7
6Lambdaparameter: 18
body: 9
7Lambdaparameter: 60
body: 11
8ExprTuple18
9Conditionalvalue: 12
condition: 12
10ExprTuple60
11Conditionalvalue: 13
condition: 14
12Operationoperator: 61
operands: 15
13Operationoperator: 26
operand: 19
14Operationoperator: 45
operands: 17
15ExprTuple18, 64
16ExprTuple19
17ExprTuple20, 21
18IndexedVarvariable: 65
index: 59
19Lambdaparameters: 23
body: 24
20Operationoperator: 61
operands: 25
21Operationoperator: 26
operand: 32
22ExprTuple59
23ExprTuple28
24Conditionalvalue: 29
condition: 30
25ExprTuple60, 31
26Literal
27ExprTuple32
28ExprRangelambda_map: 58
start_index: 59
end_index: 33
29Operationoperator: 61
operands: 34
30Operationoperator: 45
operands: 35
31Literal
32Lambdaparameters: 52
body: 36
33Operationoperator: 54
operands: 37
34ExprTuple38, 64
35ExprTuple39
36Conditionalvalue: 40
condition: 41
37ExprTuple60, 42
38Operationoperator: 51
operands: 43
39ExprRangelambda_map: 53
start_index: 59
end_index: 50
40Operationoperator: 61
operands: 44
41Operationoperator: 45
operands: 46
42Literal
43ExprTuple47
44ExprTuple48, 64
45Literal
46ExprTuple49
47ExprRangelambda_map: 58
start_index: 59
end_index: 50
48Operationoperator: 51
operands: 52
49ExprRangelambda_map: 53
start_index: 59
end_index: 60
50Operationoperator: 54
operands: 55
51Literal
52ExprTuple56
53Lambdaparameter: 67
body: 57
54Literal
55ExprTuple60, 59
56ExprRangelambda_map: 58
start_index: 59
end_index: 60
57Operationoperator: 61
operands: 62
58Lambdaparameter: 67
body: 63
59Literal
60Variable
61Literal
62ExprTuple63, 64
63IndexedVarvariable: 65
index: 67
64Literal
65Variable
66ExprTuple67
67Variable