logo

Expression of type And

from the theory of proveit.logic.booleans.quantification.universality

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 Function, P, n
from proveit.core_expr_types import P__x_1_to_n, P__x_1_to_np1, x_1_to_n, x_1_to_np1
from proveit.logic import And, Forall, Implies
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
expr = And(Function(P, []), Forall(instance_param_or_params = [n], instance_expr = Implies(Forall(instance_param_or_params = [x_1_to_n], instance_expr = P__x_1_to_n), Forall(instance_param_or_params = [x_1_to_np1], instance_expr = P__x_1_to_np1)).with_wrapping_at(2), domain = Natural))
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())
P\left(\right) \land \left[\forall_{n \in \mathbb{N}}~\left(\begin{array}{c} \begin{array}{l} \left[\forall_{x_{1}, x_{2}, \ldots, x_{n}}~P\left(x_{1}, x_{2}, \ldots, x_{n}\right)\right] \Rightarrow  \\ \left[\forall_{x_{1}, x_{2}, \ldots, x_{n + 1}}~P\left(x_{1}, x_{2}, \ldots, x_{n + 1}\right)\right] \end{array} \end{array}\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: 1
operands: 2
1Literal
2ExprTuple3, 4
3Operationoperator: 27
operands: 5
4Operationoperator: 20
operand: 7
5ExprTuple
6ExprTuple7
7Lambdaparameter: 38
body: 9
8ExprTuple38
9Conditionalvalue: 10
condition: 11
10Operationoperator: 12
operands: 13
11Operationoperator: 14
operands: 15
12Literal
13ExprTuple16, 17
14Literal
15ExprTuple38, 18
16Operationoperator: 20
operand: 22
17Operationoperator: 20
operand: 23
18Literal
19ExprTuple22
20Literal
21ExprTuple23
22Lambdaparameters: 26
body: 24
23Lambdaparameters: 28
body: 25
24Operationoperator: 27
operands: 26
25Operationoperator: 27
operands: 28
26ExprTuple29
27Variable
28ExprTuple30
29ExprRangelambda_map: 31
start_index: 39
end_index: 38
30ExprRangelambda_map: 31
start_index: 39
end_index: 32
31Lambdaparameter: 40
body: 33
32Operationoperator: 34
operands: 35
33IndexedVarvariable: 36
index: 40
34Literal
35ExprTuple38, 39
36Variable
37ExprTuple40
38Variable
39Literal
40Variable