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, InSet, SetOfAll, SubsetEq
from proveit.numbers import Add, Mod, Real
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = Lambda(L, Conditional(Forall(instance_param_or_params = [S], instance_expr = Forall(instance_param_or_params = [c], instance_expr = Equals(Card(SetOfAll(instance_param_or_params = sub_expr1, instance_element = Mod(Add(c, x), L), domain = S)), Card(SetOfAll(instance_param_or_params = sub_expr1, instance_element = Mod(x, L), domain = S))), domain = Real), condition = SubsetEq(S, Real)), InSet(L, 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())
L \mapsto \left\{\forall_{S~|~S \subseteq \mathbb{R}}~\left[\forall_{c \in \mathbb{R}}~\left(|\left\{\left(c + x\right) ~\textup{mod}~ L\right\}_{x \in S}| = |\left\{x ~\textup{mod}~ L\right\}_{x \in S}|\right)\right] \textrm{ if } L \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: 49
body: 2
1ExprTuple49
2Conditionalvalue: 3
condition: 4
3Operationoperator: 12
operand: 7
4Operationoperator: 46
operands: 6
5ExprTuple7
6ExprTuple49, 26
7Lambdaparameter: 50
body: 9
8ExprTuple50
9Conditionalvalue: 10
condition: 11
10Operationoperator: 12
operand: 16
11Operationoperator: 14
operands: 15
12Literal
13ExprTuple16
14Literal
15ExprTuple50, 26
16Lambdaparameter: 53
body: 18
17ExprTuple53
18Conditionalvalue: 19
condition: 20
19Operationoperator: 21
operands: 22
20Operationoperator: 46
operands: 23
21Literal
22ExprTuple24, 25
23ExprTuple53, 26
24Operationoperator: 28
operand: 30
25Operationoperator: 28
operand: 31
26Literal
27ExprTuple30
28Literal
29ExprTuple31
30Operationoperator: 33
operand: 35
31Operationoperator: 33
operand: 36
32ExprTuple35
33Literal
34ExprTuple36
35Lambdaparameter: 54
body: 37
36Lambdaparameter: 54
body: 39
37Conditionalvalue: 40
condition: 42
38ExprTuple54
39Conditionalvalue: 41
condition: 42
40Operationoperator: 44
operands: 43
41Operationoperator: 44
operands: 45
42Operationoperator: 46
operands: 47
43ExprTuple48, 49
44Literal
45ExprTuple54, 49
46Literal
47ExprTuple54, 50
48Operationoperator: 51
operands: 52
49Variable
50Variable
51Literal
52ExprTuple53, 54
53Variable
54Variable