logo

Expression of type Conditional

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, 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 = Conditional(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))), 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())
\left\{|\left\{\left(c + x\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()
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: 3
operands: 4
2Operationoperator: 28
operands: 5
3Literal
4ExprTuple6, 7
5ExprTuple35, 8
6Operationoperator: 10
operand: 12
7Operationoperator: 10
operand: 13
8Literal
9ExprTuple12
10Literal
11ExprTuple13
12Operationoperator: 15
operand: 17
13Operationoperator: 15
operand: 18
14ExprTuple17
15Literal
16ExprTuple18
17Lambdaparameter: 36
body: 19
18Lambdaparameter: 36
body: 21
19Conditionalvalue: 22
condition: 24
20ExprTuple36
21Conditionalvalue: 23
condition: 24
22Operationoperator: 26
operands: 25
23Operationoperator: 26
operands: 27
24Operationoperator: 28
operands: 29
25ExprTuple30, 31
26Literal
27ExprTuple36, 31
28Literal
29ExprTuple36, 32
30Operationoperator: 33
operands: 34
31Variable
32Variable
33Literal
34ExprTuple35, 36
35Variable
36Variable