logo

Expression of type Forall

from the theory of proveit.numbers.number_sets.natural_numbers

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 S, x
from proveit.logic import And, Forall, Implies, InSet, SetEquiv, SubsetEq
from proveit.numbers import Add, Natural, one, zero
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [S]
expr = Forall(sub_expr1, Implies(And(InSet(zero, S), Forall([x], InSet(Add(x, one), S), domains = sub_expr1)), SetEquiv(S, Natural)), condition = SubsetEq(S, Natural))
Out[2]:
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(expr.latex())
\forall_{S~|~S \subseteq \mathbb{N}}~\left(\left(\left(0 \in S\right) \land \left[\forall_{x \in S}~\left(\left(x + 1\right) \in S\right)\right]\right) \Rightarrow \left(S \cong \mathbb{N}\right)\right)
In [5]:
expr.style_options()
Out[5]:
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
expr.expr_info()
Out[6]:
 core typesub-expressionsexpression
0Operationoperator: 19
operand: 2
1ExprTuple2
2Lambdaparameter: 30
body: 3
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 14
6Literal
7ExprTuple9, 10
8Literal
9Operationoperator: 11
operands: 12
10Operationoperator: 13
operands: 14
11Literal
12ExprTuple15, 16
13Literal
14ExprTuple30, 17
15Operationoperator: 27
operands: 18
16Operationoperator: 19
operand: 22
17Literal
18ExprTuple21, 30
19Literal
20ExprTuple22
21Literal
22Lambdaparameter: 33
body: 23
23Conditionalvalue: 24
condition: 25
24Operationoperator: 27
operands: 26
25Operationoperator: 27
operands: 28
26ExprTuple29, 30
27Literal
28ExprTuple33, 30
29Operationoperator: 31
operands: 32
30Variable
31Literal
32ExprTuple33, 34
33Variable
34Literal