# Common expressions for the theory of proveit.linear_algebra¶

In [1]:
import proveit
# Prepare this notebook for defining the common expressions of a theory:
%common_expressions_notebook # Keep this at the top following 'import proveit'.

from proveit import ExprRange, IndexedVar
from proveit import a, b, i, k, n, x, y, U, V, W
from proveit.core_expr_types import a_k, x_k
from proveit.logic import Or, Set, Difference, NotEquals
from proveit.numbers import zero, one
from proveit.linear_algebra import VecAdd, VecZero, ScalarMult

In [2]:
%begin common

Defining common sub-expressions for theory 'proveit.linear_algebra'
Subsequent end-of-cell assignments will define common sub-expressions
%end_common will finalize the definitions


A binary linear combination:

In [3]:
binary_lin_comb_ax_by = VecAdd(ScalarMult(a, x), ScalarMult(b, y))

binary_lin_comb_ax_by:

A general linear combination:

In [4]:
lin_comb_axn = VecAdd(ExprRange(k, ScalarMult(a_k, x_k), one, n))

lin_comb_axn:

At least one $a_i$ is not zero

In [5]:
some_nonzero_a = Or(ExprRange(k, NotEquals(a_k, zero), one, n))

some_nonzero_a:
In [6]:
%end common

These common expressions may now be imported from the theory package: proveit.linear_algebra