logo

Expression of type Lambda

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, 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 = 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(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..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 1
body: 2
1ExprTuple38, 40, 41, 39
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple11, 12, 13, 14
9Operationoperator: 30
operands: 15
10Operationoperator: 28
operands: 16
11Operationoperator: 20
operands: 17
12Operationoperator: 20
operands: 18
13Operationoperator: 20
operands: 19
14Operationoperator: 20
operands: 21
15ExprTuple22, 23
16ExprTuple24, 25
17ExprTuple38, 26
18ExprTuple40, 26
19ExprTuple41, 26
20Literal
21ExprTuple39, 26
22Operationoperator: 28
operands: 27
23Operationoperator: 28
operands: 29
24Operationoperator: 30
operands: 31
25Operationoperator: 36
operands: 32
26Literal
27ExprTuple38, 40
28Literal
29ExprTuple41, 39
30Literal
31ExprTuple33, 34
32ExprTuple40, 39
33Operationoperator: 36
operands: 35
34Operationoperator: 36
operands: 37
35ExprTuple38, 39
36Literal
37ExprTuple40, 41
38Variable
39Variable
40Variable
41Variable