logo

Axioms for the theory of proveit.core_expr_types.tuples

In [1]:
import proveit
# Prepare this notebook for defining the axioms of a theory:
%axioms_notebook # Keep this at the top following 'import proveit'.
from proveit import ExprTuple, ExprRange
from proveit import a, b, c, d, f, i, j, m, n, fab
from proveit.logic import Forall, Equals, And, NotEquals, InSet
from proveit.core_expr_types import Len
from proveit.core_expr_types import \
    (a_1_to_i, a_1_to_ip1, b_1_to_i, b_1_to_j, b_1_to_ip1, c_1_to_i, a_ip1, b_ip1,
     x_1_to_n, y_1_to_n, tuple_len_incr_equiv, fi, fj, f_jp1, 
     f_i_to_j, f_i_to_jp1, f__x_1_to_n, f__y_1_to_n, iter_ext_equiv)
from proveit.numbers import zero, one
from proveit.numbers import Natural, NaturalPos, Add, subtract
In [2]:
%begin axioms
Defining axioms for theory 'proveit.core_expr_types.tuples'
Subsequent end-of-cell assignments will define axioms
%end_axioms will finalize the definitions

Define the length of an ExprTuple:

In [3]:
tuple_len_0 = Equals(Len([]), zero)
tuple_len_0:
In [4]:
tuple_len_incr = Forall(i, Forall((a_1_to_i, b), 
                                  Equals(Len([a_1_to_i, b]), 
                                         Add(i, one))),
                        domain = Natural)
tuple_len_incr:

Range length

Defining tuple equality

In [5]:
tuple_eq_def = Forall(i, Forall((a_1_to_i, b, c_1_to_i, d),
                                Equals(Equals([a_1_to_i, b], [c_1_to_i, d]),
                                       And(Equals([a_1_to_i], [c_1_to_i]), 
                                           Equals(b, d))) \
                                .with_wrap_after_operator()),
                      domain = Natural)
tuple_eq_def:
In [6]:
tuple_neq_with_diff_len = Forall(
    (i, j), Forall((a_1_to_i, b_1_to_j),
                   NotEquals([a_1_to_i], [b_1_to_j])),
    domain=Natural,
    condition=NotEquals(i, j))
tuple_neq_with_diff_len:

Collapsing and extending ranges

In [7]:
empty_range_def = Forall((f, i, j), Equals(ExprTuple(f_i_to_j), 
                                           ExprTuple()),
                         conditions=[Equals(Add(j, one), i)])
empty_range_def:
In [ ]:
 
In [8]:
range_extension_def = Forall((f, i, j), iter_ext_equiv,
                             conditions=[InSet(Len([f_i_to_j]), 
                                               Natural)])
range_extension_def:
In [9]:
%end axioms
These axioms may now be imported from the theory package: proveit.core_expr_types.tuples