logo

Expression of type ExprTuple

from the theory of proveit.numbers.addition

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, ExprTuple, Lambda, a, b, c, d
from proveit.logic import And, Equals, InSet
from proveit.numbers import Add, Integer, Mult, frac
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([a, b, c, d], Conditional(Equals(Add(frac(a, b), frac(c, d)), frac(Add(Mult(a, d), Mult(b, c)), Mult(b, d))), And(InSet(a, Integer), InSet(b, Integer), InSet(c, Integer), InSet(d, Integer)))))
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(a, b, c, d\right) \mapsto \left\{\left(\frac{a}{b} + \frac{c}{d}\right) = \frac{\left(a \cdot d\right) + \left(b \cdot c\right)}{b \cdot d} \textrm{ if } a \in \mathbb{Z} ,  b \in \mathbb{Z} ,  c \in \mathbb{Z} ,  d \in \mathbb{Z}\right..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameters: 2
body: 3
2ExprTuple39, 41, 42, 40
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11
8Literal
9ExprTuple12, 13, 14, 15
10Operationoperator: 31
operands: 16
11Operationoperator: 29
operands: 17
12Operationoperator: 21
operands: 18
13Operationoperator: 21
operands: 19
14Operationoperator: 21
operands: 20
15Operationoperator: 21
operands: 22
16ExprTuple23, 24
17ExprTuple25, 26
18ExprTuple39, 27
19ExprTuple41, 27
20ExprTuple42, 27
21Literal
22ExprTuple40, 27
23Operationoperator: 29
operands: 28
24Operationoperator: 29
operands: 30
25Operationoperator: 31
operands: 32
26Operationoperator: 37
operands: 33
27Literal
28ExprTuple39, 41
29Literal
30ExprTuple42, 40
31Literal
32ExprTuple34, 35
33ExprTuple41, 40
34Operationoperator: 37
operands: 36
35Operationoperator: 37
operands: 38
36ExprTuple39, 40
37Literal
38ExprTuple41, 42
39Variable
40Variable
41Variable
42Variable