logo

Expression of type Conditional

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, 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 = 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\{\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..
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: 3
operand: 6
2Operationoperator: 34
operands: 5
3Literal
4ExprTuple6
5ExprTuple42, 7
6Lambdaparameters: 8
body: 9
7Literal
8ExprTuple38, 33
9Conditionalvalue: 10
condition: 11
10Operationoperator: 12
operand: 16
11Operationoperator: 14
operands: 15
12Literal
13ExprTuple16
14Literal
15ExprTuple33, 17
16Lambdaparameters: 37
body: 18
17Operationoperator: 19
operand: 38
18Conditionalvalue: 21
condition: 22
19Literal
20ExprTuple38
21Operationoperator: 23
operands: 37
22Operationoperator: 24
operands: 25
23Literal
24Literal
25ExprTuple26, 27
26ExprRangelambda_map: 28
start_index: 41
end_index: 42
27Operationoperator: 29
operands: 30
28Lambdaparameter: 46
body: 31
29Literal
30ExprTuple32, 33
31Operationoperator: 34
operands: 35
32Operationoperator: 36
operands: 37
33Variable
34Literal
35ExprTuple43, 38
36Literal
37ExprTuple39
38Variable
39ExprRangelambda_map: 40
start_index: 41
end_index: 42
40Lambdaparameter: 46
body: 43
41Literal
42Variable
43IndexedVarvariable: 44
index: 46
44Variable
45ExprTuple46
46Variable