logo

Expression of type Lambda

from the theory of proveit.numbers.divisibility

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, p
from proveit.logic import And, Equals, Forall, InSet, Not
from proveit.numbers import Divides, GCD, NaturalPos, greater, one
In [2]:
# build up the expression from sub-expressions
expr = Lambda([a, b], Conditional(Forall(instance_param_or_params = [p], instance_expr = Not(And(Divides(p, a), Divides(p, b))), domain = NaturalPos, condition = greater(p, one)), And(InSet(a, NaturalPos), InSet(b, NaturalPos), Equals(GCD(a, b), one))))
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\right) \mapsto \left\{\forall_{p \in \mathbb{N}^+~|~p > 1}~(\lnot \left(\left(p \rvert a\right) \land \left(p \rvert b\right)\right)) \textrm{ if } a \in \mathbb{N}^+ ,  b \in \mathbb{N}^+ ,  gcd\left(a, b\right) = 1\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 24
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operand: 7
3Operationoperator: 28
operands: 6
4Literal
5ExprTuple7
6ExprTuple8, 9, 10
7Lambdaparameter: 42
body: 12
8Operationoperator: 30
operands: 13
9Operationoperator: 30
operands: 14
10Operationoperator: 15
operands: 16
11ExprTuple42
12Conditionalvalue: 17
condition: 18
13ExprTuple41, 36
14ExprTuple43, 36
15Literal
16ExprTuple19, 37
17Operationoperator: 20
operand: 25
18Operationoperator: 28
operands: 22
19Operationoperator: 23
operands: 24
20Literal
21ExprTuple25
22ExprTuple26, 27
23Literal
24ExprTuple41, 43
25Operationoperator: 28
operands: 29
26Operationoperator: 30
operands: 31
27Operationoperator: 32
operands: 33
28Literal
29ExprTuple34, 35
30Literal
31ExprTuple42, 36
32Literal
33ExprTuple37, 42
34Operationoperator: 39
operands: 38
35Operationoperator: 39
operands: 40
36Literal
37Literal
38ExprTuple42, 41
39Literal
40ExprTuple42, 43
41Variable
42Variable
43Variable