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, Forall, SetOfAll, SubsetEq
from proveit.numbers import Add, Mod, Real
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = Lambda(S, Conditional(Forall(instance_param_or_params = [c], instance_expr = 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))), domain = Real), SubsetEq(S, 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())
S \mapsto \left\{\forall_{c \in \mathbb{R}}~\left(|\left\{\left(x + c\right) ~\textup{mod}~ L\right\}_{x \in S}| = |\left\{x ~\textup{mod}~ L\right\}_{x \in S}|\right) \textrm{ if } S \subseteq \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: 43
body: 2
1ExprTuple43
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple43, 19
9Lambdaparameter: 47
body: 11
10ExprTuple47
11Conditionalvalue: 12
condition: 13
12Operationoperator: 14
operands: 15
13Operationoperator: 39
operands: 16
14Literal
15ExprTuple17, 18
16ExprTuple47, 19
17Operationoperator: 21
operand: 23
18Operationoperator: 21
operand: 24
19Literal
20ExprTuple23
21Literal
22ExprTuple24
23Operationoperator: 26
operand: 28
24Operationoperator: 26
operand: 29
25ExprTuple28
26Literal
27ExprTuple29
28Lambdaparameter: 46
body: 30
29Lambdaparameter: 46
body: 32
30Conditionalvalue: 33
condition: 35
31ExprTuple46
32Conditionalvalue: 34
condition: 35
33Operationoperator: 37
operands: 36
34Operationoperator: 37
operands: 38
35Operationoperator: 39
operands: 40
36ExprTuple41, 42
37Literal
38ExprTuple46, 42
39Literal
40ExprTuple46, 43
41Operationoperator: 44
operands: 45
42Variable
43Variable
44Literal
45ExprTuple46, 47
46Variable
47Variable