Polynomials over Scalar¶
The kernel's FORMAL_POLYNOMIAL literal kind (the kernel additions, K2,
and the kernel's theory page on polynomials) makes formal polynomials
literals with kernel arithmetic. This page is the polynomial theory over
Scalar: the evaluation constant peval, its axioms and their model, and
reification, which turns a polynomial expression into the evaluation of a
literal.
Definitions P-1 (the ring) and P-2 (its canonical representation), the kind's laws, and Theorem C-11P are on the kernel's polynomials page; the numbering here continues from them.
Evaluation¶
Definition P-3. For an environment \(\rho : \mathbb Z \to \hat S\) and a polynomial \(P\),
computed with the operations of \(\hat S\). The finite sum and products are well defined in any order, because \(+\) and \(\cdot\) are commutative monoids on \(\hat S\) (Theorems X-1 and X-2); the empty sum is \(0\) and the empty product \(1\). In particular \(\operatorname{eval}(X_i, \rho) = 1 \cdot \rho(i) = \rho(i)\) and \(\operatorname{eval}(c, \rho) = c\) for every environment.
Theorem P-2 (evaluation is a homomorphism on finite environments). For every environment, \(\operatorname{eval}(X_i, \rho) = \rho(i)\) and \(\operatorname{eval}(c, \rho) = c\). If \(\rho(i)\) is finite for every \(i\), then for all \(P, Q \in \mathbb Q[X]\) and \(n \ge 1\):
where the operations on the right are those of \(\hat S\).
Proof. The first two equations are the computation in Definition P-3. On a finite environment every term of the sum is finite (Theorem X-3), so the evaluation is computed in \(\mathbb C\), where it is the unique ring homomorphism \(\mathbb Q[X] \to \mathbb C\) extending \(X_i \mapsto \rho(i)\) (the universal property of polynomial rings); and on finite values the operations of \(\hat S\) are those of \(\mathbb C\) (Definitions X-2 and X-3). \(\square\)
The guard is necessary: for \(\rho(0) = D_1\), \(\operatorname{eval}(X_0 - X_0, \rho) = \operatorname{eval}(0, \rho) = 0\), but \(\operatorname{eval}(X_0, \rho) - \operatorname{eval}(X_0, \rho) = I\). Polynomial identities in \(\hat S\) hold only for finite values (Theorem X-4).
Axioms in the logic¶
Definition P-4 (the polynomial theory over Scalar). The
scalar package declares:
- a type constructor \(\mathsf{Poly}\) of arity 0, and the literal kind
FORMAL_POLYNOMIALwith carrier \(\mathsf{Poly}\), whose base is thescalarprofile's rational kind (carrier \(\mathsf{Scalar}\), domain "finite and real"); its operations bound to constants \(\mathsf{pzero}\), \(\mathsf{pone}\), \(\mathsf{padd}\), \(\mathsf{pmul}\), \(\mathsf{pneg}\), \(\mathsf{ppow}\), \(\mathsf X : \mathsf{Scalar} \to \mathsf{Poly}\) (INDET), and \(\mathsf{pconst} : \mathsf{Scalar} \to \mathsf{Poly}\) (COEFF), with \(\mathsf{padd}\) and \(\mathsf{pmul}\) declared ACU with units \(\mathsf{pzero}\) and \(\mathsf{pone}\), and the laws Q1 to Q8 as axioms of the theory (true in the model below); - \(\mathsf{peval} : \mathsf{Poly} \to (\mathsf{Scalar} \to \mathsf{Scalar}) \to \mathsf{Scalar}\), with the axioms \(\mathrm{integer}(i) \Rightarrow \mathsf{peval}(\mathsf X(i), \rho) = \rho(i)\), \(\mathrm{finite}(c) \land \mathrm{real}(c) \Rightarrow \mathsf{peval}(\mathsf{pconst}(c), \rho) = c\), and the homomorphism axioms of Theorem P-2 for \(+\), \(\cdot\), \(-\), and natural powers, each guarded by \(\forall i.\, \mathrm{integer}(i)\Rightarrow\mathrm{finite}(\rho(i))\).
Theorem P-3 (consistency). The polynomial theory has a model: interpret \(\mathsf{Poly}\) as \(\mathbb R[X_i : i \in \mathbb Z]\), the operations as the ring operations, \(\mathsf X(i) = X_i\) for integers \(i\) and \(0\) otherwise, \(\mathsf{pconst}(c) = c\) for finite real \(c\) and \(0\) otherwise, and \(\mathsf{peval}\) as in Definition P-3 (with real coefficients). The laws Q1 to Q8 hold in this ring, the evaluation axioms by Theorem P-2, and by the kernel's Theorem C-11P the literals then have exactly one interpretation that satisfies the literal scheme: \(\varphi(F) = F \in \mathbb Q[X] \subset \mathbb R[X]\). \(\square\)
Environments are functions \(\mathsf{Scalar} \to \mathsf{Scalar}\) on the integers rather than lists, so that the theory needs no inductive type. The atoms \(t_0, \dots, t_{n-1}\) of an expression are packed as \(\rho = \lambda i.\, \mathrm{if}\ i = 0\ \mathrm{then}\ t_0\ \mathrm{else}\ \cdots\ \mathrm{else}\ 0\), which is finite everywhere when every \(t_j\) is. The conditional is definable from choice in the classical profile (\(\mathrm{if}\ b\ \mathrm{then}\ x\ \mathrm{else}\ y := \varepsilon(\lambda z.\, (b \to z = x) \land (\neg b \to z = y))\)), its two reduction equations are theorems, and \(i = j\) on integer literals evaluates by conversion; so proving \(\rho(j) = t_j\) takes at most \(n\) steps, or \(O(\log n)\) with a balanced tree of conditionals. Each lemma \(\rho(j) = t_j\) is proved once per atom and reused at every occurrence.
Reification¶
Definition P-5. A polynomial expression over atoms
\(t_0, \dots, t_{n-1}\) is built from the atoms, rational literals, \(+\),
\(\cdot\), \(-\), and powers by positive literal natural numbers. Zero, negative and nonliteral
powers are opaque atoms: scalar 0^0 is Indeterminate, whereas the formal
ring has pzero^0 = pone. Its size is its
number of operator and leaf occurrences.
Theorem P-4 (reification). For every polynomial expression \(e\) over atoms \(\bar t\), let \(P_e \in \mathbb Q[X_0, \dots, X_{n-1}]\) be computed by structural recursion on \(e\): \(X_j\) for the atom \(t_j\), \(c\) for a literal \(c\), and the ring operations for \(+\), \(\cdot\), \(-\), and powers. Then
is derivable, by a derivation with one instance of an axiom of Theorem P-2 per operator or leaf occurrence of \(e\), plus one lookup lemma \(\rho_{\bar t}(j) = t_j\) per atom. The polynomial arithmetic in \(P_e\) is done by literal conversion, which costs no derivation steps.
\(P_e\) is unique only in two senses: it is the value of the recursion, and it is the only polynomial \(P\) for which \(e = \operatorname{eval}(P, \rho)\) holds for all finite values of the atoms read as independent variables; for atoms that are algebraically independent (no nonzero polynomial vanishes at their values under every valuation), it is the only one that satisfies the display. For related atoms, other polynomials may satisfy the display: for \(t_0 = \sin x\), \(t_1 = \cos x\), and \(e = t_0^2 + t_1^2\), both \(X_0^2 + X_1^2\) and \(1\) do, since \(\sin^2 x + \cos^2 x = 1\).
Proof. Structural recursion on \(e\). An atom \(t_j\) gives \(P = X_j\) by the axiom for indeterminates (and \(\rho_{\bar t}(j) = t_j\), by evaluating the conditional); a literal \(c\) gives \(P = c\) by the constant axiom. For \(e = e_1 + e_2\), the recursive derivations give \(e_k = \operatorname{eval}(P_k, \rho)\); one instance of the addition axiom gives \(\operatorname{eval}(P_1, \rho) + \operatorname{eval}(P_2, \rho) = \operatorname{eval}(\mathsf{padd}(P_1, P_2), \rho)\), and conversion evaluates \(\mathsf{padd}(P_1, P_2)\) to the literal \(P_1 + P_2\). The other operators are the same. Uniqueness, in the second sense: two polynomials \(P, P'\) with \(\operatorname{eval}(P, \rho) = \operatorname{eval}(P', \rho)\) for all finite \(\rho\) are equal, because a polynomial over \(\mathbb Q\) that vanishes on all of \(\mathbb C^n\) is zero. \(\square\)
Theorem P-5 (deciding polynomial identities). For polynomial expressions \(e_1, e_2\) over the same atoms:
- if \(P_{e_1} = P_{e_2}\), then \(\big(\bigwedge_j \mathrm{finite}(t_j)\big) \Rightarrow e_1 = e_2\) is derivable with a derivation linear in the sizes of \(e_1\) and \(e_2\);
- if \(P_{e_1} \ne P_{e_2}\), then \(e_1 = e_2\) fails for some finite complex values of the atoms, treated as independent variables.
Proof. (1) Reify both sides (Theorem P-4), then use symmetry and transitivity; the two literals are the same node. (2) The nonzero polynomial \(P_{e_1} - P_{e_2}\) has a non-root in \(\mathbb C^n\). \(\square\)
Statement 2 is completeness relative to the atoms as independent variables. Atoms that are related, such as \(\sin x\) and \(\cos x\), need further rules (here \(\sin^2 x + \cos^2 x = 1\)), which are not polynomial identities.
Theorem P-6 (rational expressions). For rational expressions (Definition
X-5), polynorm writes each side as \(p/q\) with polynomial expressions \(p\)
and \(q\), proves \(e_1 = e_2\) under the generic guard (finite atoms and
nonzero denominators) from the polynomial identity \(p_1 q_2 = p_2 q_1\) and
the guarded field laws (Theorem X-5), and states the guard explicitly. Its
correctness is Theorem X-6, and the guard is generic in the sense of
Definition X-6.
For example, \((x^2 - 1)/(x - 1) = x + 1\): \(p_1 = x^2 - 1\), \(q_1 = x - 1\),
\(p_2 = x + 1\), \(q_2 = 1\), and \(p_1 q_2 = x^2 - 1 = p_2 q_1\) as literals; the
guard is \(\mathrm{finite}(x) \land x - 1 \ne 0\). Under the assumption
\(x > 2\), linarith discharges \(x - 1 \ne 0\) (the kernel's Theorem Z-6) and the session
hypothesis gives \(\mathrm{finite}(x)\), so the answer is strict.