logo

Expression of type Lambda

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 Lambda, Q, Qx, f, fx, x
from proveit.logic import Equals, Forall, Implies, InSet
from proveit.numbers import Sum, ZeroSet, zero
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = Lambda([f, Q], Implies(Forall(instance_param_or_params = sub_expr1, instance_expr = Equals(fx, zero), condition = Qx), InSet(Sum(index_or_indices = sub_expr1, summand = fx, condition = Qx), ZeroSet)))
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(f, Q\right) \mapsto \left(\left[\forall_{x~|~Q\left(x\right)}~\left(f\left(x\right) = 0\right)\right] \Rightarrow \left(\left[\sum_{x~|~Q\left(x\right)}~f\left(x\right)\right] \in \left\{0\right\}\right)\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 1
body: 2
1ExprTuple27, 28
2Operationoperator: 3
operands: 4
3Literal
4ExprTuple5, 6
5Operationoperator: 7
operand: 11
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11
9Literal
10ExprTuple12, 13
11Lambdaparameter: 30
body: 14
12Operationoperator: 15
operand: 20
13Operationoperator: 17
operand: 24
14Conditionalvalue: 19
condition: 26
15Literal
16ExprTuple20
17Literal
18ExprTuple24
19Operationoperator: 21
operands: 22
20Lambdaparameter: 30
body: 23
21Literal
22ExprTuple25, 24
23Conditionalvalue: 25
condition: 26
24Literal
25Operationoperator: 27
operand: 30
26Operationoperator: 28
operand: 30
27Variable
28Variable
29ExprTuple30
30Variable