logo
In [1]:
import proveit
from proveit import defaults, Variable
from proveit import p, a_star, b_star
from proveit.logic import InSet, Equals
from proveit.numbers import (zero, two, NaturalPos, 
                             Rational, RationalNonZero, RationalPos, 
                             Abs, greater, Mult, frac, Divides, GCD, Exp, sqrt)
In [2]:
%proving sqrt2_is_not_rational
With these allowed/disallowed theorem/theory presumptions (e.g., to avoid circular dependencies), we begin our proof of
sqrt2_is_not_rational:
(see dependencies)

Setting up a contradiction proof by first assuming $\sqrt{2} \in \mathbb{Q}$

In [3]:
sqrt_2_is_rational = InSet(sqrt(two), Rational)
sqrt_2_is_rational:
In [4]:
defaults.assumptions = [sqrt_2_is_rational]
defaults.assumptions:

If $\sqrt{2}$ is in $\mathbb{Q}$, then $\left|\sqrt{2}\right|$ is in $\mathbb{Q^+}$

($\sqrt{2} \in \mathbb{Q^+}$ as well by convention, but this proof is really about showing that no squared rational number is equal to $2$.)

We know that a non-zero rational raised to a rational power is non-zero.

In [5]:
sqrt(two).deduce_not_zero()

The absolute value of a non-zero rational is a positive rational.

In [6]:
abs_sqrt_2_is_rational_pos = InSet(Abs(sqrt(two)), RationalPos).prove()
abs_sqrt_2_is_rational_pos:  ⊢  

Choose relatively prime $a^*$ and $b^*$ such $\left| \sqrt{2} \right| = a^* / b^*$ assuming $\sqrt{2} \in \mathbb{Q}$

(Relatively prime means there are no nontrivial common divisors; that is, $gcd(a^*, b^*) = 1$ where $gcd$ is the "greatest common divisor")

In [7]:
abs_sqrt_2_is_rational_pos.choose_reduced_rational_fraction(a_star, b_star)
Creating Skolem 'constant(s)': (a_star, b_star).
Call the Judgment.eliminate(a_star, b_star) to complete the Skolemization
(when the 'constant(s)' are no longer needed).
Adding to defaults.assumptions:

From $\sqrt{2} = a^* / b^*$, derive $2 \cdot (b^*)^2 = (a^*)^2$

In [8]:
sqrt_2_equation = Equals(Abs(sqrt(two)), frac(a_star, b_star)).prove()
sqrt_2_equation:  ⊢  
In [9]:
sqrt_2_equation = sqrt_2_equation.right_mult_both_sides(b_star)
sqrt_2_equation: , , ,  ⊢  
In [10]:
sqrt_2_equation = sqrt_2_equation.square_both_sides()
sqrt_2_equation: , , ,  ⊢  
In [11]:
two_bStar_sqrd__eq__a_star_sqrd = sqrt_2_equation.inner_expr().lhs.distribute()
two_bStar_sqrd__eq__a_star_sqrd: , , ,  ⊢  

Now prove that $2~|~a^*$ via $2 \cdot (b^*)^2 = (a^*)^2$

In [12]:
InSet(Exp(b_star, two), NaturalPos).prove()

Proving $2~|~(2 \cdot (b^*)^2)$ is trivial knowing $(b^*)^2 \in \mathbb{N^+}$

In [13]:
two_divides_two_bStar_sqrd = Divides(two, Mult(two, Exp(b_star, two))).prove()
two_divides_two_bStar_sqrd:  ⊢  
In [14]:
two_bStar_sqrd__eq__a_star_sqrd.sub_right_side_into(two_divides_two_bStar_sqrd)
, , ,  ⊢  

$2~|~(a^*)$ was proven as a side-effect of $2~|~(a^*)^2$ since any integer is even if its square is even

In [15]:
two_divides_a_star = Divides(two, a_star).prove()
two_divides_a_star: , , ,  ⊢  

Next derive $2~|~b^*$ from $2 \cdot (b^*)^2 = (a^*)^2$ and $2~|~(a^*)$ in a few steps

Derive $2^{2}~|~(a^{*})^{2}$ from $2~|~(a^{*})$

In [16]:
two_sqrd__divides__a_star_sqrd = \
    two_divides_a_star.introduce_common_exponent(two, auto_simplify=False)
two_sqrd__divides__a_star_sqrd: , , ,  ⊢  

Derive $2^{2}~|~2 \cdot (b^{*})^2$ from $2^{2}~|~(a^{*})^2$

In [17]:
two_sqrd__divides__two_bStar_sqrd = \
    two_bStar_sqrd__eq__a_star_sqrd.sub_left_side_into(
        two_sqrd__divides__a_star_sqrd)
two_sqrd__divides__two_bStar_sqrd: , , ,  ⊢  

Derive $2~|~(b^*)^2$ from $2^{2}~|~2 \cdot (b^{*})^2$

In [18]:
two_sqrd__eq__two_times_two = Exp(two, two).expansion(auto_simplify=False)
two_sqrd__eq__two_times_two:  ⊢  
In [19]:
two_sqrd__eq__two_times_two.sub_right_side_into(
    two_sqrd__divides__two_bStar_sqrd)
, , ,  ⊢  
In [20]:
Divides(two, Exp(b_star, two)).prove()
, , ,  ⊢  

Finally, derive $2~|~(b^*)$ from $2~|~(b^*)^2$

In [21]:
two_divides_bStar = Divides(two, b_star).prove()
two_divides_bStar: , , ,  ⊢  

Prove a contradiction given that $2~|~(a^*)$, $2~|~(b^*)$, and $a^*$ and $b^*$ were chosen to be relatively prime

In [22]:
a_star_bStar_relatively_prime = GCD(a_star, b_star).deduce_relatively_prime()
a_star_bStar_relatively_prime: , ,  ⊢  
In [23]:
two_does_not_divide_both = a_star_bStar_relatively_prime.instantiate({p:two})
two_does_not_divide_both: , ,  ⊢  
In [24]:
contradiction_with_choices = two_does_not_divide_both.derive_contradiction()
contradiction_with_choices: , , ,  ⊢  

Use the existence of $a^*$ and $b^*$, assuming $\sqrt{2} \in \mathbb{Q}$, to eliminate extra assumptions (effective Skolemization)

In [25]:
contradiction = contradiction_with_choices.eliminate(a_star, b_star)
contradiction:  ⊢  

Prove $\sqrt{2} \notin \mathbb{Q}$ via contradiction

In [26]:
sqrt2_impl_F = contradiction.as_implication(hypothesis=sqrt_2_is_rational)
sqrt2_impl_F:  ⊢  
In [27]:
sqrt2_impl_F.deny_antecedent(assumptions=[])
sqrt2_is_not_rational has been proven.  Now simply execute "%qed".
In [28]:
%qed
proveit.numbers.exponentiation.sqrt2_is_not_rational has been proven.
Out[28]:
 step typerequirementsstatement
0instantiation1, 2  ⊢  
  : , :
1theorem  ⊢  
 proveit.logic.sets.membership.fold_not_in_set
2instantiation3, 4, 5, 6  ⊢  
  : , :
3theorem  ⊢  
 proveit.logic.booleans.implication.modus_tollens_denial
4instantiation7  ⊢  
  :
5deduction8  ⊢  
6theorem  ⊢  
 proveit.logic.booleans.negation.not_false
7conjecture  ⊢  
 proveit.numbers.number_sets.rational_numbers.rational_membership_is_bool
8modus ponens9, 10  ⊢  
9instantiation11, 12, 13, 151  ⊢  
  : , : , : , : , : , :
10instantiation23, 14, 15  ⊢  
  : , :
11theorem  ⊢  
 proveit.logic.booleans.quantification.existence.skolem_elim
12instantiation16  ⊢  
  : , :
13instantiation16  ⊢  
  : , :
14instantiation17, 94  ⊢  
  :
15generalization18  ⊢  
16conjecture  ⊢  
 proveit.numbers.numerals.decimals.tuple_len_2_typical_eq
17conjecture  ⊢  
 proveit.numbers.number_sets.rational_numbers.reduced_nat_pos_ratio
18deduction19, ,  ⊢  
19instantiation20, 21, 22, , ,  ⊢  
  :
20theorem  ⊢  
 proveit.logic.booleans.negation.negation_contradiction
21instantiation23, 42, 24, , ,  ⊢  
  : , :
22instantiation25, 151, 26, ,  ⊢  
  :
23theorem  ⊢  
 proveit.logic.booleans.conjunction.and_if_both
24instantiation43, 27, 75, 28, , ,  ⊢  
  : , :
25instantiation29, 131, 154, 30, ,  ⊢  
  : , :
26conjecture  ⊢  
 proveit.numbers.numerals.decimals.less_1_2
27instantiation149, 54, 154  ⊢  
  : , : , :
28instantiation31, 49, 32, 33, 51, , ,  ⊢  
  : , : , :
29conjecture  ⊢  
 proveit.numbers.divisibility.GCD_one_def
30instantiation34, 79  ⊢  
  : , :
31conjecture  ⊢  
 proveit.numbers.divisibility.common_factor_elimination
32instantiation149, 144, 35  ⊢  
  : , : , :
33instantiation86, 36, 37, , ,  ⊢  
  : , : , :
34theorem  ⊢  
 proveit.logic.booleans.conjunction.right_from_and
35instantiation152, 153, 55  ⊢  
  : , : , :
36instantiation38, 39, 47, , ,  ⊢  
  : , : , :
37instantiation40, 49  ⊢  
  :
38theorem  ⊢  
 proveit.logic.equality.sub_left_side_into
39instantiation41, 75, 44, 151, 42, , ,  ⊢  
  : , : , :
40conjecture  ⊢  
 proveit.numbers.exponentiation.square_expansion
41conjecture  ⊢  
 proveit.numbers.divisibility.common_exponent_introduction
42instantiation43, 44, 75, 45, , ,  ⊢  
  : , :
43conjecture  ⊢  
 proveit.numbers.divisibility.even__if__power_is_even
44instantiation149, 54, 131  ⊢  
  : , : , :
45instantiation86, 46, 47, , ,  ⊢  
  : , : , :
46instantiation48, 49, 50, 51  ⊢  
  : , :
47instantiation86, 52, 53, , ,  ⊢  
  : , : , :
48conjecture  ⊢  
 proveit.numbers.divisibility.left_factor_divisibility
49instantiation149, 144, 57  ⊢  
  : , : , :
50instantiation149, 54, 55  ⊢  
  : , : , :
51instantiation85, 151  ⊢  
  :
52instantiation56, 57, 58, 122, 59, , ,  ⊢  
  : , : , :
53instantiation60, 61, 138, 151, 62*,  ⊢  
  : , : , :
54conjecture  ⊢  
 proveit.numbers.number_sets.integers.nat_pos_within_int
55instantiation63, 64, 96  ⊢  
  : , :
56conjecture  ⊢  
 proveit.numbers.exponentiation.exp_eq_real
57instantiation149, 132, 65  ⊢  
  : , : , :
58instantiation66, 71, 145,  ⊢  
  : , :
59instantiation67, 145, 71, 68, 69, 70*, , ,  ⊢  
  : , : , :
60conjecture  ⊢  
 proveit.numbers.exponentiation.posnat_power_of_product
61instantiation149, 144, 71  ⊢  
  : , : , :
62instantiation72, 114, 73*  ⊢  
  :
63conjecture  ⊢  
 proveit.numbers.exponentiation.exp_natpos_closure
64instantiation149, 74, 154  ⊢  
  : , : , :
65instantiation149, 139, 75  ⊢  
  : , : , :
66conjecture  ⊢  
 proveit.numbers.multiplication.mult_real_closure_bin
67conjecture  ⊢  
 proveit.numbers.multiplication.right_mult_eq_real
68instantiation76, 122, 145, 77,  ⊢  
  : , :
69instantiation78, 79  ⊢  
  : , :
70instantiation86, 80, 81,  ⊢  
  : , : , :
71instantiation149, 132, 82  ⊢  
  : , : , :
72conjecture  ⊢  
 proveit.numbers.exponentiation.square_abs_rational_simp
73instantiation83, 151, 84  ⊢  
  : , :
74conjecture  ⊢  
 proveit.numbers.number_sets.natural_numbers.nat_pos_within_nat
75instantiation149, 146, 96  ⊢  
  : , : , :
76conjecture  ⊢  
 proveit.numbers.division.div_real_closure
77instantiation85, 154  ⊢  
  :
78theorem  ⊢  
 proveit.logic.booleans.conjunction.left_from_and
79assumption  ⊢  
80instantiation86, 87, 88,  ⊢  
  : , : , :
81instantiation89, 90, 91, 92  ⊢  
  : , : , : , :
82instantiation149, 93, 94  ⊢  
  : , : , :
83conjecture  ⊢  
 proveit.numbers.exponentiation.nth_power_of_nth_root
84instantiation95, 96  ⊢  
  :
85conjecture  ⊢  
 proveit.numbers.number_sets.natural_numbers.nonzero_if_is_nat_pos
86theorem  ⊢  
 proveit.logic.equality.sub_right_side_into
87instantiation97, 111, 112, 98, 99,  ⊢  
  : , : , : , : , :
88instantiation119, 100, 101  ⊢  
  : , : , :
89conjecture  ⊢  
 proveit.logic.equality.four_chain_transitivity
90instantiation128, 102  ⊢  
  : , : , :
91instantiation128, 103  ⊢  
  : , : , :
92instantiation137, 111  ⊢  
  :
93conjecture  ⊢  
 proveit.numbers.number_sets.rational_numbers.rational_pos_within_rational
94instantiation104, 105  ⊢  
  :
95conjecture  ⊢  
 proveit.numbers.number_sets.natural_numbers.natural_lower_bound
96conjecture  ⊢  
 proveit.numbers.numerals.decimals.nat2
97conjecture  ⊢  
 proveit.numbers.division.mult_frac_cancel_denom_left
98instantiation149, 107, 106  ⊢  
  : , : , :
99instantiation149, 107, 108  ⊢  
  : , : , :
100instantiation128, 109  ⊢  
  : , : , :
101instantiation128, 110  ⊢  
  : , : , :
102instantiation130, 111  ⊢  
  :
103instantiation130, 112  ⊢  
  :
104conjecture  ⊢  
 proveit.numbers.absolute_value.abs_rational_nonzero_closure
105instantiation113, 114, 115  ⊢  
  :
106instantiation149, 116, 135  ⊢  
  : , : , :
107conjecture  ⊢  
 proveit.numbers.number_sets.complex_numbers.real_nonzero_within_complex_nonzero
108instantiation149, 116, 117  ⊢  
  : , : , :
109instantiation128, 118  ⊢  
  : , : , :
110instantiation119, 120, 121  ⊢  
  : , : , :
111instantiation149, 144, 122  ⊢  
  : , : , :
112instantiation149, 144, 123  ⊢  
  : , : , :
113conjecture  ⊢  
 proveit.numbers.number_sets.rational_numbers.nonzero_rational_is_rational_nonzero
114assumption  ⊢  
115instantiation124, 136, 125  ⊢  
  : , :
116conjecture  ⊢  
 proveit.numbers.number_sets.real_numbers.rational_nonzero_within_real_nonzero
117instantiation149, 142, 126  ⊢  
  : , : , :
118instantiation127, 138  ⊢  
  :
119axiom  ⊢  
 proveit.logic.equality.equals_transitivity
120instantiation128, 129  ⊢  
  : , : , :
121instantiation130, 138  ⊢  
  :
122instantiation152, 153, 131  ⊢  
  : , : , :
123instantiation149, 132, 133  ⊢  
  : , : , :
124conjecture  ⊢  
 proveit.numbers.exponentiation.exp_rational_non_zero__not_zero
125instantiation134, 135, 136  ⊢  
  : , :
126instantiation149, 150, 154  ⊢  
  : , : , :
127conjecture  ⊢  
 proveit.numbers.multiplication.elim_one_left
128axiom  ⊢  
 proveit.logic.equality.substitution
129instantiation137, 138  ⊢  
  :
130conjecture  ⊢  
 proveit.numbers.division.frac_one_denom
131assumption  ⊢  
132conjecture  ⊢  
 proveit.numbers.number_sets.real_numbers.rational_within_real
133instantiation149, 139, 140  ⊢  
  : , : , :
134conjecture  ⊢  
 proveit.numbers.division.div_rational_nonzero_closure
135instantiation149, 142, 141  ⊢  
  : , : , :
136instantiation149, 142, 143  ⊢  
  : , : , :
137conjecture  ⊢  
 proveit.numbers.multiplication.elim_one_right
138instantiation149, 144, 145  ⊢  
  : , : , :
139conjecture  ⊢  
 proveit.numbers.number_sets.rational_numbers.int_within_rational
140instantiation149, 146, 147  ⊢  
  : , : , :
141instantiation149, 150, 148  ⊢  
  : , : , :
142conjecture  ⊢  
 proveit.numbers.number_sets.rational_numbers.nonzero_int_within_rational_nonzero
143instantiation149, 150, 151  ⊢  
  : , : , :
144conjecture  ⊢  
 proveit.numbers.number_sets.complex_numbers.real_within_complex
145instantiation152, 153, 154  ⊢  
  : , : , :
146conjecture  ⊢  
 proveit.numbers.number_sets.integers.nat_within_int
147theorem  ⊢  
 proveit.numbers.numerals.decimals.nat1
148conjecture  ⊢  
 proveit.numbers.numerals.decimals.posnat1
149theorem  ⊢  
 proveit.logic.sets.inclusion.superset_membership_from_proper_subset
150conjecture  ⊢  
 proveit.numbers.number_sets.integers.nat_pos_within_nonzero_int
151conjecture  ⊢  
 proveit.numbers.numerals.decimals.posnat2
152theorem  ⊢  
 proveit.logic.sets.inclusion.unfold_subset_eq
153instantiation155, 156  ⊢  
  : , :
154assumption  ⊢  
155theorem  ⊢  
 proveit.logic.sets.inclusion.relax_proper_subset
156conjecture  ⊢  
 proveit.numbers.number_sets.real_numbers.nat_pos_within_real
*equality replacement requirements