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
from proveit.core_expr_types import Len, x_1_to_n
from proveit.logic import Card, Distinct, Equals, Exists
from proveit.numbers import greater_eq
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x_1_to_n]
expr = ExprTuple(Lambda([S, N], Conditional(Exists(instance_param_or_params = sub_expr1, instance_expr = Distinct(x_1_to_n), domain = S, condition = Equals(Len(operands = sub_expr1), N)), greater_eq(Card(S), N))))
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(S, N\right) \mapsto \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) \textrm{ if } |S| \geq 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
1Lambdaparameters: 2
body: 3
2ExprTuple32, 27
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 10
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10
8Literal
9ExprTuple27, 11
10Lambdaparameters: 31
body: 12
11Operationoperator: 13
operand: 32
12Conditionalvalue: 15
condition: 16
13Literal
14ExprTuple32
15Operationoperator: 17
operands: 31
16Operationoperator: 18
operands: 19
17Literal
18Literal
19ExprTuple20, 21
20ExprRangelambda_map: 22
start_index: 35
end_index: 36
21Operationoperator: 23
operands: 24
22Lambdaparameter: 40
body: 25
23Literal
24ExprTuple26, 27
25Operationoperator: 28
operands: 29
26Operationoperator: 30
operands: 31
27Variable
28Literal
29ExprTuple37, 32
30Literal
31ExprTuple33
32Variable
33ExprRangelambda_map: 34
start_index: 35
end_index: 36
34Lambdaparameter: 40
body: 37
35Literal
36Variable
37IndexedVarvariable: 38
index: 40
38Variable
39ExprTuple40
40Variable