logo

Expression of type Equals

from the theory of proveit.logic.sets.enumeration

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 ExprRange, Function, IndexedVar, P, Px, Variable, a, n, x
from proveit.core_expr_types import a_1_to_n
from proveit.logic import Equals, FALSE, Forall, Or, Set
from proveit.numbers import one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Equals(Or(ExprRange(sub_expr1, Equals(Function(P, [IndexedVar(a, sub_expr1)]), FALSE), one, n)), Equals(Forall(instance_param_or_params = [x], instance_expr = Px, domain = Set(a_1_to_n)), FALSE))
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(\left(P\left(a_{1}\right) = \bot\right) \lor  \left(P\left(a_{2}\right) = \bot\right) \lor  \ldots \lor  \left(P\left(a_{n}\right) = \bot\right)\right) = \left(\left[\forall_{x \in \left\{a_{1}, a_{2}, \ldots, a_{n}\right\}}~P\left(x\right)\right] = \bot\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',)
directionDirection of the relation (normal or reversed)normalnormal('with_direction_reversed', 'is_reversed')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 14
operands: 1
1ExprTuple2, 3
2Operationoperator: 4
operands: 5
3Operationoperator: 14
operands: 6
4Literal
5ExprTuple7
6ExprTuple8, 18
7ExprRangelambda_map: 9
start_index: 32
end_index: 33
8Operationoperator: 10
operand: 13
9Lambdaparameter: 37
body: 12
10Literal
11ExprTuple13
12Operationoperator: 14
operands: 15
13Lambdaparameter: 26
body: 16
14Literal
15ExprTuple17, 18
16Conditionalvalue: 19
condition: 20
17Operationoperator: 22
operand: 34
18Literal
19Operationoperator: 22
operand: 26
20Operationoperator: 24
operands: 25
21ExprTuple34
22Variable
23ExprTuple26
24Literal
25ExprTuple26, 27
26Variable
27Operationoperator: 28
operands: 29
28Literal
29ExprTuple30
30ExprRangelambda_map: 31
start_index: 32
end_index: 33
31Lambdaparameter: 37
body: 34
32Literal
33Variable
34IndexedVarvariable: 35
index: 37
35Variable
36ExprTuple37
37Variable