logo

Expression of type ExprTuple

from the theory of proveit.logic.sets.cardinality

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, ExprTuple, Lambda, N, S, n
from proveit.core_expr_types import Len, x_1_to_n
from proveit.logic import Card, Distinct, Equals, Exists, Forall, InSet
from proveit.numbers import NaturalPos, greater_eq
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x_1_to_n]
expr = ExprTuple(Lambda(n, Conditional(Forall(instance_param_or_params = [S, N], instance_expr = Exists(instance_param_or_params = sub_expr1, instance_expr = Distinct(x_1_to_n), domain = S, condition = Equals(Len(operands = sub_expr1), N)), condition = greater_eq(Card(S), N)), InSet(n, NaturalPos))))
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(n \mapsto \left\{\forall_{S, N~|~|S| \geq N}~\left[\exists_{x_{1}, x_{2}, \ldots, x_{n} \in S~|~|\left(x_{1}, x_{2}, \ldots, x_{n}\right)| = N}~\textrm{distinct}\left(x_{1}, x_{2}, \ldots, x_{n}\right)\right] \textrm{ if } n \in \mathbb{N}^+\right..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameter: 45
body: 3
2ExprTuple45
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 37
operands: 8
6Literal
7ExprTuple9
8ExprTuple45, 10
9Lambdaparameters: 11
body: 12
10Literal
11ExprTuple41, 36
12Conditionalvalue: 13
condition: 14
13Operationoperator: 15
operand: 19
14Operationoperator: 17
operands: 18
15Literal
16ExprTuple19
17Literal
18ExprTuple36, 20
19Lambdaparameters: 40
body: 21
20Operationoperator: 22
operand: 41
21Conditionalvalue: 24
condition: 25
22Literal
23ExprTuple41
24Operationoperator: 26
operands: 40
25Operationoperator: 27
operands: 28
26Literal
27Literal
28ExprTuple29, 30
29ExprRangelambda_map: 31
start_index: 44
end_index: 45
30Operationoperator: 32
operands: 33
31Lambdaparameter: 49
body: 34
32Literal
33ExprTuple35, 36
34Operationoperator: 37
operands: 38
35Operationoperator: 39
operands: 40
36Variable
37Literal
38ExprTuple46, 41
39Literal
40ExprTuple42
41Variable
42ExprRangelambda_map: 43
start_index: 44
end_index: 45
43Lambdaparameter: 49
body: 46
44Literal
45Variable
46IndexedVarvariable: 47
index: 49
47Variable
48ExprTuple49
49Variable