logo

Expression of type Conditional

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 Conditional, P, Px, n, x
from proveit.core_expr_types import Pk_a1_to_an, a_1_to_n
from proveit.logic import And, Forall, InSet, Set
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [a_1_to_n], instance_expr = Forall(instance_param_or_params = [P], instance_expr = And(Pk_a1_to_an), condition = Forall(instance_param_or_params = [x], instance_expr = Px, domain = Set(a_1_to_n)))), InSet(n, 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())
\left\{\forall_{a_{1}, a_{2}, \ldots, a_{n}}~\left[\forall_{P~|~\forall_{x \in \left\{a_{1}, a_{2}, \ldots, a_{n}\right\}}~P\left(x\right)}~\left(P\left(a_{1}\right) \land  P\left(a_{2}\right) \land  \ldots \land  P\left(a_{n}\right)\right)\right] \textrm{ if } n \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: 16
operand: 5
2Operationoperator: 28
operands: 4
3ExprTuple5
4ExprTuple37, 6
5Lambdaparameters: 33
body: 7
6Literal
7Operationoperator: 16
operand: 9
8ExprTuple9
9Lambdaparameter: 26
body: 11
10ExprTuple26
11Conditionalvalue: 12
condition: 13
12Operationoperator: 14
operands: 15
13Operationoperator: 16
operand: 19
14Literal
15ExprTuple18
16Literal
17ExprTuple19
18ExprRangelambda_map: 20
start_index: 36
end_index: 37
19Lambdaparameter: 30
body: 21
20Lambdaparameter: 41
body: 22
21Conditionalvalue: 23
condition: 24
22Operationoperator: 26
operand: 38
23Operationoperator: 26
operand: 30
24Operationoperator: 28
operands: 29
25ExprTuple38
26Variable
27ExprTuple30
28Literal
29ExprTuple30, 31
30Variable
31Operationoperator: 32
operands: 33
32Literal
33ExprTuple34
34ExprRangelambda_map: 35
start_index: 36
end_index: 37
35Lambdaparameter: 41
body: 38
36Literal
37Variable
38IndexedVarvariable: 39
index: 41
39Variable
40ExprTuple41
41Variable