logo

Expression of type Forall

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 a, b, p
from proveit.logic import And, Equals, Forall, Not
from proveit.numbers import Divides, GCD, NaturalPos, greater, one
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [a, b], instance_expr = Forall(instance_param_or_params = [p], instance_expr = Not(And(Divides(p, a), Divides(p, b))), domain = NaturalPos, condition = greater(p, one)), domain = NaturalPos, condition = 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())
\forall_{a, b \in \mathbb{N}^+~|~gcd\left(a, b\right) = 1}~\left[\forall_{p \in \mathbb{N}^+~|~p > 1}~(\lnot \left(\left(p \rvert a\right) \land \left(p \rvert b\right)\right))\right]
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 6
operand: 2
1ExprTuple2
2Lambdaparameters: 26
body: 3
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 30
operands: 8
6Literal
7ExprTuple9
8ExprTuple10, 11, 12
9Lambdaparameter: 44
body: 14
10Operationoperator: 32
operands: 15
11Operationoperator: 32
operands: 16
12Operationoperator: 17
operands: 18
13ExprTuple44
14Conditionalvalue: 19
condition: 20
15ExprTuple43, 38
16ExprTuple45, 38
17Literal
18ExprTuple21, 39
19Operationoperator: 22
operand: 27
20Operationoperator: 30
operands: 24
21Operationoperator: 25
operands: 26
22Literal
23ExprTuple27
24ExprTuple28, 29
25Literal
26ExprTuple43, 45
27Operationoperator: 30
operands: 31
28Operationoperator: 32
operands: 33
29Operationoperator: 34
operands: 35
30Literal
31ExprTuple36, 37
32Literal
33ExprTuple44, 38
34Literal
35ExprTuple39, 44
36Operationoperator: 41
operands: 40
37Operationoperator: 41
operands: 42
38Literal
39Literal
40ExprTuple44, 43
41Literal
42ExprTuple44, 45
43Variable
44Variable
45Variable