logo

Expression of type Conditional

from the theory of proveit.numbers.summation

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, Function, R, S, a, f, fa, fx, g, gy, n, x, y
from proveit.logic import Card, Equals, Forall, Implies, InSet, SetOfAll
from proveit.numbers import Complex, Natural, Sum
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [y]
expr = Conditional(Forall(instance_param_or_params = [f, g, R, S], instance_expr = Implies(Forall(instance_param_or_params = [a], instance_expr = InSet(fa, Complex), domain = R), Equals(Sum(index_or_indices = [x], summand = fx, domain = R), Sum(index_or_indices = sub_expr1, summand = Function(f, [gy]), domain = S))), conditions = [Equals(SetOfAll(instance_param_or_params = sub_expr1, instance_element = gy, domain = S), R), Equals(Card(S), n), Equals(Card(R), 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_{f, g, R, S~|~\left\{g\left(y\right)\right\}_{y \in S} = R, |S| = n, |R| = n}~\left(\left[\forall_{a \in R}~\left(f\left(a\right) \in \mathbb{C}\right)\right] \Rightarrow \left(\left[\sum_{x \in R}~f\left(x\right)\right] = \left[\sum_{y \in S}~f\left(g\left(y\right)\right)\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: 20
operand: 5
2Operationoperator: 64
operands: 4
3ExprTuple5
4ExprTuple33, 6
5Lambdaparameters: 7
body: 8
6Literal
7ExprTuple62, 71, 68, 70
8Conditionalvalue: 9
condition: 10
9Operationoperator: 11
operands: 12
10Operationoperator: 13
operands: 14
11Literal
12ExprTuple15, 16
13Literal
14ExprTuple17, 18, 19
15Operationoperator: 20
operand: 27
16Operationoperator: 25
operands: 22
17Operationoperator: 25
operands: 23
18Operationoperator: 25
operands: 24
19Operationoperator: 25
operands: 26
20Literal
21ExprTuple27
22ExprTuple28, 29
23ExprTuple30, 68
24ExprTuple31, 33
25Literal
26ExprTuple32, 33
27Lambdaparameter: 66
body: 34
28Operationoperator: 36
operand: 45
29Operationoperator: 36
operand: 46
30Operationoperator: 38
operand: 47
31Operationoperator: 41
operand: 70
32Operationoperator: 41
operand: 68
33Variable
34Conditionalvalue: 43
condition: 44
35ExprTuple45
36Literal
37ExprTuple46
38Literal
39ExprTuple47
40ExprTuple70
41Literal
42ExprTuple68
43Operationoperator: 64
operands: 48
44Operationoperator: 64
operands: 49
45Lambdaparameter: 67
body: 50
46Lambdaparameter: 73
body: 51
47Lambdaparameter: 73
body: 52
48ExprTuple53, 54
49ExprTuple66, 68
50Conditionalvalue: 55
condition: 56
51Conditionalvalue: 57
condition: 58
52Conditionalvalue: 69
condition: 58
53Operationoperator: 62
operand: 66
54Literal
55Operationoperator: 62
operand: 67
56Operationoperator: 64
operands: 61
57Operationoperator: 62
operand: 69
58Operationoperator: 64
operands: 65
59ExprTuple66
60ExprTuple67
61ExprTuple67, 68
62Variable
63ExprTuple69
64Literal
65ExprTuple73, 70
66Variable
67Variable
68Variable
69Operationoperator: 71
operand: 73
70Variable
71Variable
72ExprTuple73
73Variable