logo
In [1]:
import proveit
theory = proveit.Theory() # the theorem's theory
from proveit import a, defaults, Function, m, n, P, x
from proveit.logic import Equals, InSet, Not, NotEquals
from proveit.numbers import zero, one, Add, Div, frac, Less, LessEq, Mult, Neg, subtract
from proveit.numbers import Complex, Natural
from proveit.numbers.negation import neg_not_eq_zero
from proveit.numbers.number_sets.natural_numbers import fold_forall_natural
In [2]:
%proving finite_geom_sum
With these allowed/disallowed theorem/theory presumptions (e.g., to avoid circular dependencies), we begin our proof of
finite_geom_sum:
(see dependencies)
In [3]:
defaults.assumptions = finite_geom_sum.all_conditions()
defaults.assumptions:
In [4]:
Mult.change_simplification_directives(combine_all_exponents=True)

Instantiate the Induction Theorem for an induction proof

In [5]:
finite_geom_sum.instance_expr
In [6]:
fold_forall_natural
In [7]:
induction_inst = fold_forall_natural.instantiate({Function(P,n):finite_geom_sum.instance_expr})
induction_inst: ,  ⊢  

Note that the base case was proven automatically via auto-simplification.

Inductive Step

In [8]:
inductive_step = induction_inst.antecedent.operands[1]
inductive_step:
In [9]:
inductive_step.conditions.entries
In [10]:
defaults.assumptions = defaults.assumptions + inductive_step.conditions.entries
defaults.assumptions:
In [11]:
sum_zero_to_m_plus_one = induction_inst.antecedent.operands[1].instance_expr.lhs
sum_zero_to_m_plus_one:
In [12]:
zero_less_eq_m = LessEq(zero, m).prove()
zero_less_eq_m:  ⊢  
In [13]:
zero_less_eq_m.right_add_both_sides(one)
In [14]:
zero_less_than_m_plus_1 = Less(zero, Add(m, one)).prove()
zero_less_than_m_plus_1:  ⊢  
In [15]:
# also need to have m+1 != -1 for later inductive step(s)
neg_one_less_than_m_plus_1 = zero_less_than_m_plus_1.add_left(Neg(one))
neg_one_less_than_m_plus_1:  ⊢  
In [16]:
NotEquals(Neg(one), Add(m, one)).prove()
In [17]:
sum_zero_to_m_plus_one_split = sum_zero_to_m_plus_one.partition_last()
sum_zero_to_m_plus_one_split:  ⊢  
In [18]:
for the_assumption in defaults.assumptions:
    if isinstance(the_assumption, Equals):
        print("{}".format(the_assumption))
        inductive_hypothesis = the_assumption
inductive_hypothesis
(Sum_{i = 0}^{m} x^{i}) = ((1 - x^{m + 1}) / (1 - x))
In [19]:
inductive_hypothesis_judgment = inductive_hypothesis.prove()
inductive_hypothesis_judgment:  ⊢  
In [20]:
sum_zero_to_m_plus_one_simplified_01 = inductive_hypothesis_judgment.sub_right_side_into(sum_zero_to_m_plus_one_split)
sum_zero_to_m_plus_one_simplified_01: ,  ⊢  
In [21]:
alg_expr_01 = sum_zero_to_m_plus_one_simplified_01.rhs.operands[1]
alg_expr_01:
In [22]:
alg_expr_02 = frac(Mult(subtract(one, x), alg_expr_01), subtract(one, x))
alg_expr_02:
In [23]:
alg_manip_01 = alg_expr_02.cancelation(subtract(one, x))
alg_manip_01: , ,  ⊢  
In [24]:
sum_zero_to_m_plus_one_simplified_02 = (
    alg_manip_01.sub_left_side_into(sum_zero_to_m_plus_one_simplified_01.
    inner_expr().rhs.operands[1]))
sum_zero_to_m_plus_one_simplified_02: , , ,  ⊢  
In [25]:
sum_zero_to_m_plus_one_simplified_03 = sum_zero_to_m_plus_one_simplified_02.inner_expr().rhs.operands[1].numerator.distribute(0)
sum_zero_to_m_plus_one_simplified_03: , , ,  ⊢  
In [26]:
sum_zero_to_m_plus_one_simplified_04 = sum_zero_to_m_plus_one_simplified_03.inner_expr().rhs.factor(frac(one, subtract(one, x)))
sum_zero_to_m_plus_one_simplified_04: , , ,  ⊢  
In [27]:
Less(Neg(one), Add(m, one)).prove()
In [28]:
sum_zero_to_m_plus_one_formula = inductive_step.instance_expr.rhs.factorization(frac(one, subtract(one, x)))
sum_zero_to_m_plus_one_formula: , ,  ⊢  
In [29]:
sum_zero_to_m_plus_one_formula.inner_expr().rhs.operands[1].operands[1].operand.exponent.commute()
, ,  ⊢  
In [30]:
inductive_step.instance_expr.conclude_via_transitivity()
, , ,  ⊢  
In [31]:
inductive_step.prove()

Finishing Up

The final steps are a little complicated because of the extra constraints in the theorem imposed on $x$ (i.e. $x \in \mathbb{C}, x \ne 1$), so we derive the consequent but then instantiate to get domains and conditions as assumptions, and then generalize over the $x$ and $n$ simultaneously.

In [32]:
induction_inst_consequent_intermediate = induction_inst.derive_consequent()
induction_inst_consequent_intermediate: ,  ⊢  
finite_geom_sum may now be readily provable (assuming required theorems are usable).  Simply execute "%qed".
In [33]:
induction_inst_consequent_intermediate_inst = induction_inst_consequent_intermediate.instantiate({n:n})
induction_inst_consequent_intermediate_inst: , ,  ⊢  
In [34]:
induction_inst_consequent_intermediate_inst.generalize([x,n], domain_lists=[[Complex, Natural]], conditions=[NotEquals(x, one)])
In [35]:
%qed
proveit.numbers.summation.finite_geom_sum has been proven.
Out[35]:
 step typerequirementsstatement
0generalization1  ⊢  
1instantiation2, 3, ,  ⊢  
  :
2modus ponens4, 5,  ⊢  
3assumption  ⊢  
4instantiation6, 7*, 8*,  ⊢  
  :
5instantiation9, 10, 11,  ⊢  
  : , :
6conjecture  ⊢  
 proveit.numbers.number_sets.natural_numbers.fold_forall_natural
7instantiation108, 12, 13,  ⊢  
  : , : , :
8instantiation108, 14, 15  ⊢  
  : , : , :
9theorem  ⊢  
 proveit.logic.booleans.conjunction.and_if_both
10axiom  ⊢  
 proveit.logic.booleans.true_axiom
11generalization16,  ⊢  
12instantiation17, 178, 18, 132, 19, 20,  ⊢  
  : , : , : , :
13instantiation21, 125  ⊢  
  :
14instantiation121, 130, 178, 175, 131, 122, 157, 139  ⊢  
  : , : , : , : , : , :
15instantiation129, 175, 178, 130, 132, 131, 157, 139, 133*  ⊢  
  : , : , : , : , : , :
16instantiation108, 22, 23, , ,  ⊢  
  : , : , :
17axiom  ⊢  
 proveit.core_expr_types.operations.operands_substitution
18instantiation143  ⊢  
  : , :
19instantiation24, 82, 25*  ⊢  
  : , :
20instantiation108, 26, 27,  ⊢  
  : , : , :
21axiom  ⊢  
 proveit.logic.booleans.eq_true_intro
22instantiation59, 28, 29, , ,  ⊢  
  : , : , :
23instantiation70, 30, ,  ⊢  
  : , :
24axiom  ⊢  
 proveit.numbers.summation.sum_single
25instantiation31, 151  ⊢  
  :
26instantiation99, 32  ⊢  
  : , : , :
27instantiation33, 96, 97,  ⊢  
  :
28instantiation59, 34, 35, , ,  ⊢  
  : , : , :
29instantiation52, 36, 37, 38, 39*, ,  ⊢  
  : , : , : , :
30instantiation59, 40, 41, ,  ⊢  
  : , : , :
31conjecture  ⊢  
 proveit.numbers.exponentiation.exp_zero_eq_one
32instantiation99, 42  ⊢  
  : , : , :
33conjecture  ⊢  
 proveit.numbers.division.frac_cancel_complete
34instantiation43, 44, 45, , ,  ⊢  
  : , : , :
35instantiation46, 130, 175, 131, 139, 151, 144, 47*, 48*,  ⊢  
  : , : , : , : , : , :
36instantiation99, 49, ,  ⊢  
  : , : , :
37instantiation99, 50, ,  ⊢  
  : , : , :
38instantiation70, 51, ,  ⊢  
  : , :
39instantiation52, 53, 54, 55,  ⊢  
  : , : , : , :
40instantiation70, 56, ,  ⊢  
  : , :
41instantiation57, 157, 156  ⊢  
  : , :
42instantiation99, 58  ⊢  
  : , : , :
43theorem  ⊢  
 proveit.logic.equality.sub_left_side_into
44instantiation59, 60, 61,  ⊢  
  : , : , :
45instantiation62, 63, 64, 144, 65*, 66*, ,  ⊢  
  : , : , :
46conjecture  ⊢  
 proveit.numbers.multiplication.distribute_through_subtract
47instantiation112, 144,  ⊢  
  :
48instantiation67, 151, 142, 103, 80*, 68*,  ⊢  
  : , : , :
49instantiation70, 69, ,  ⊢  
  : , :
50instantiation70, 71, ,  ⊢  
  : , :
51instantiation72, 175, 178, 130, 73, 131, 74, 111, 113, ,  ⊢  
  : , : , : , : , : , :
52conjecture  ⊢  
 proveit.logic.equality.four_chain_transitivity
53instantiation121, 130, 178, 175, 131, 75, 139, 134, 113,  ⊢  
  : , : , : , : , : , :
54instantiation121, 178, 130, 75, 76, 131, 139, 134, 144, 135,  ⊢  
  : , : , : , : , : , :
55instantiation77, 175, 130, 131, 139, 144, 135,  ⊢  
  : , : , : , : , : , : , : , :
56instantiation93, 139, 98, 96, 97, 78*, ,  ⊢  
  : , : , :
57conjecture  ⊢  
 proveit.numbers.addition.commutation
58instantiation108, 79, 80  ⊢  
  : , : , :
59theorem  ⊢  
 proveit.logic.equality.sub_right_side_into
60instantiation81, 82, 162, 83, 84*  ⊢  
  : , : , : , :
61assumption  ⊢  
62conjecture  ⊢  
 proveit.numbers.division.frac_cancel_left
63instantiation85, 96, 97,  ⊢  
  :
64instantiation176, 86, 87  ⊢  
  : , : , :
65instantiation88, 96  ⊢  
  :
66instantiation89, 144,  ⊢  
  :
67conjecture  ⊢  
 proveit.numbers.exponentiation.product_of_posnat_powers
68instantiation108, 90, 91  ⊢  
  : , : , :
69instantiation93, 139, 111, 96, 97, 92*, ,  ⊢  
  : , : , :
70theorem  ⊢  
 proveit.logic.equality.equals_reversal
71instantiation93, 139, 113, 96, 97, 94*, ,  ⊢  
  : , : , :
72conjecture  ⊢  
 proveit.numbers.multiplication.distribute_through_sum
73instantiation143  ⊢  
  : , :
74instantiation95, 139, 96, 97,  ⊢  
  : , :
75instantiation143  ⊢  
  : , :
76instantiation143  ⊢  
  : , :
77conjecture  ⊢  
 proveit.numbers.addition.subtraction.add_cancel_general_rev
78instantiation112, 98,  ⊢  
  :
79instantiation99, 100  ⊢  
  : , : , :
80instantiation101, 151  ⊢  
  :
81axiom  ⊢  
 proveit.numbers.summation.sum_split_last
82conjecture  ⊢  
 proveit.numbers.number_sets.integers.zero_is_int
83instantiation102, 103  ⊢  
  :
84instantiation108, 104, 105  ⊢  
  : , : , :
85conjecture  ⊢  
 proveit.numbers.number_sets.complex_numbers.nonzero_complex_is_complex_nonzero
86conjecture  ⊢  
 proveit.numbers.number_sets.complex_numbers.real_nonzero_within_complex_nonzero
87instantiation176, 106, 107  ⊢  
  : , : , :
88conjecture  ⊢  
 proveit.numbers.multiplication.elim_one_right
89conjecture  ⊢  
 proveit.numbers.division.frac_one_denom
90instantiation121, 175, 178, 130, 122, 131, 139, 157  ⊢  
  : , : , : , : , : , :
91instantiation108, 109, 110  ⊢  
  : , : , :
92instantiation112, 111,  ⊢  
  :
93conjecture  ⊢  
 proveit.numbers.division.mult_frac_left
94instantiation112, 113,  ⊢  
  :
95conjecture  ⊢  
 proveit.numbers.division.div_complex_closure
96instantiation155, 139, 114  ⊢  
  : , :
97instantiation115, 116  ⊢  
  : , :
98instantiation155, 139, 117,  ⊢  
  : , :
99axiom  ⊢  
 proveit.logic.equality.substitution
100instantiation118, 139  ⊢  
  :
101conjecture  ⊢  
 proveit.numbers.exponentiation.complex_x_to_first_power_is_x
102conjecture  ⊢  
 proveit.numbers.number_sets.natural_numbers.natural_pos_is_pos
103instantiation119, 175, 130, 131, 174, 120  ⊢  
  : , : , : , : , :
104instantiation121, 130, 178, 175, 131, 122, 157, 139, 123  ⊢  
  : , : , : , : , : , :
105instantiation124, 139, 157, 125  ⊢  
  : , : , :
106conjecture  ⊢  
 proveit.numbers.number_sets.real_numbers.rational_nonzero_within_real_nonzero
107instantiation176, 126, 127  ⊢  
  : , : , :
108axiom  ⊢  
 proveit.logic.equality.equals_transitivity
109instantiation128, 175, 130, 131, 139, 157  ⊢  
  : , : , : , : , : , : , :
110instantiation129, 130, 178, 175, 131, 132, 139, 157, 133*  ⊢  
  : , : , : , : , : , :
111instantiation155, 139, 134,  ⊢  
  : , :
112conjecture  ⊢  
 proveit.numbers.multiplication.elim_one_left
113instantiation155, 144, 135,  ⊢  
  : , :
114instantiation145, 151  ⊢  
  :
115conjecture  ⊢  
 proveit.numbers.addition.subtraction.nonzero_difference_if_different
116instantiation136, 137  ⊢  
  : , :
117instantiation145, 138,  ⊢  
  :
118conjecture  ⊢  
 proveit.numbers.addition.elim_zero_left
119conjecture  ⊢  
 proveit.numbers.addition.add_nat_pos_from_nonneg
120conjecture  ⊢  
 proveit.numbers.numerals.decimals.less_0_1
121conjecture  ⊢  
 proveit.numbers.addition.disassociation
122instantiation143  ⊢  
  : , :
123instantiation145, 139  ⊢  
  :
124conjecture  ⊢  
 proveit.numbers.addition.subtraction.add_cancel_triple_23
125instantiation140  ⊢  
  :
126conjecture  ⊢  
 proveit.numbers.number_sets.rational_numbers.nonzero_int_within_rational_nonzero
127instantiation176, 141, 142  ⊢  
  : , : , :
128conjecture  ⊢  
 proveit.numbers.addition.leftward_commutation
129conjecture  ⊢  
 proveit.numbers.addition.association
130axiom  ⊢  
 proveit.numbers.number_sets.natural_numbers.zero_in_nats
131conjecture  ⊢  
 proveit.core_expr_types.tuples.tuple_len_0_typical_eq
132instantiation143  ⊢  
  : , :
133conjecture  ⊢  
 proveit.numbers.numerals.decimals.add_1_1
134instantiation145, 144,  ⊢  
  :
135instantiation145, 146,  ⊢  
  :
136theorem  ⊢  
 proveit.logic.equality.not_equals_symmetry
137assumption  ⊢  
138instantiation150, 151, 147,  ⊢  
  : , :
139instantiation176, 160, 148  ⊢  
  : , : , :
140axiom  ⊢  
 proveit.logic.equality.equals_reflexivity
141conjecture  ⊢  
 proveit.numbers.number_sets.integers.nat_pos_within_nonzero_int
142conjecture  ⊢  
 proveit.numbers.numerals.decimals.posnat1
143conjecture  ⊢  
 proveit.numbers.numerals.decimals.tuple_len_2_typical_eq
144instantiation150, 151, 149,  ⊢  
  : , :
145conjecture  ⊢  
 proveit.numbers.negation.complex_closure
146instantiation150, 151, 152,  ⊢  
  : , :
147instantiation155, 157, 156  ⊢  
  : , :
148instantiation176, 163, 153  ⊢  
  : , : , :
149instantiation176, 160, 154  ⊢  
  : , : , :
150conjecture  ⊢  
 proveit.numbers.exponentiation.exp_complex_closure
151assumption  ⊢  
152instantiation155, 156, 157  ⊢  
  : , :
153instantiation176, 170, 169  ⊢  
  : , : , :
154instantiation176, 163, 158  ⊢  
  : , : , :
155conjecture  ⊢  
 proveit.numbers.addition.add_complex_closure_bin
156instantiation176, 160, 159  ⊢  
  : , : , :
157instantiation176, 160, 161  ⊢  
  : , : , :
158instantiation176, 170, 162  ⊢  
  : , : , :
159instantiation176, 163, 164  ⊢  
  : , : , :
160conjecture  ⊢  
 proveit.numbers.number_sets.complex_numbers.real_within_complex
161instantiation165, 166, 174  ⊢  
  : , : , :
162instantiation167, 168, 169  ⊢  
  : , :
163conjecture  ⊢  
 proveit.numbers.number_sets.real_numbers.rational_within_real
164instantiation176, 170, 171  ⊢  
  : , : , :
165theorem  ⊢  
 proveit.logic.sets.inclusion.unfold_subset_eq
166instantiation172, 173  ⊢  
  : , :
167conjecture  ⊢  
 proveit.numbers.addition.add_int_closure_bin
168instantiation176, 177, 174  ⊢  
  : , : , :
169instantiation176, 177, 175  ⊢  
  : , : , :
170conjecture  ⊢  
 proveit.numbers.number_sets.rational_numbers.int_within_rational
171instantiation176, 177, 178  ⊢  
  : , : , :
172theorem  ⊢  
 proveit.logic.sets.inclusion.relax_proper_subset
173conjecture  ⊢  
 proveit.numbers.number_sets.real_numbers.nat_within_real
174assumption  ⊢  
175theorem  ⊢  
 proveit.numbers.numerals.decimals.nat1
176theorem  ⊢  
 proveit.logic.sets.inclusion.superset_membership_from_proper_subset
177conjecture  ⊢  
 proveit.numbers.number_sets.integers.nat_within_int
178conjecture  ⊢  
 proveit.numbers.numerals.decimals.nat2
*equality replacement requirements