logo

Expression of type Lambda

from the theory of proveit.numbers.modular

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, L, Lambda, S, c, x
from proveit.logic import Card, Equals, InSet, SetOfAll
from proveit.numbers import Add, Mod, Real
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = Lambda(c, Conditional(Equals(Card(SetOfAll(instance_param_or_params = sub_expr1, instance_element = Mod(Add(x, c), L), domain = S)), Card(SetOfAll(instance_param_or_params = sub_expr1, instance_element = Mod(x, L), domain = S))), InSet(c, Real)))
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())
c \mapsto \left\{|\left\{\left(x + c\right) ~\textup{mod}~ L\right\}_{x \in S}| = |\left\{x ~\textup{mod}~ L\right\}_{x \in S}| \textrm{ if } c \in \mathbb{R}\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 38
body: 2
1ExprTuple38
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 30
operands: 7
5Literal
6ExprTuple8, 9
7ExprTuple38, 10
8Operationoperator: 12
operand: 14
9Operationoperator: 12
operand: 15
10Literal
11ExprTuple14
12Literal
13ExprTuple15
14Operationoperator: 17
operand: 19
15Operationoperator: 17
operand: 20
16ExprTuple19
17Literal
18ExprTuple20
19Lambdaparameter: 37
body: 21
20Lambdaparameter: 37
body: 23
21Conditionalvalue: 24
condition: 26
22ExprTuple37
23Conditionalvalue: 25
condition: 26
24Operationoperator: 28
operands: 27
25Operationoperator: 28
operands: 29
26Operationoperator: 30
operands: 31
27ExprTuple32, 33
28Literal
29ExprTuple37, 33
30Literal
31ExprTuple37, 34
32Operationoperator: 35
operands: 36
33Variable
34Variable
35Literal
36ExprTuple37, 38
37Variable
38Variable