Documentation

CslibFrontier.Foundations.Algebra.Polynomial.SignLabelPolynomial

An integer polynomial recognizing a family of sign tests #

Clearing the positive denominators in the squared-error score gives a single integer polynomial. At a point where every test value is zero or in the advertised dyadic range in magnitude, the polynomial is positive exactly when all target signs hold. The value has a uniform margin from zero.

The weighted fingerprint label uses the same denominators to test an integer sum of signs together with a qualifying positive test.

Adapted from ClearedSignTests, RootLabelPolynomial and FingerprintLabelPolynomial in lean-canny at commit 970f28a5ecefc1327402ade16c068aa4b1b2c183.

noncomputable def Polynomial.signLabelPolynomial {m : ℕ} (B : ℕ) (g : Fin m → Polynomial ℤ) (target : Fin m → SignType) :

The integer polynomial for the score with denominators cleared. Each deviation is multiplied by all the other denominators before squaring.

theorem Polynomial.eval₂_signLabelPolynomial_margin {m : ℕ} (B : ℕ) (g : Fin m → Polynomial ℤ) (target : Fin m → SignType) (x : ℝ) (hvalues : ∀ (i : Fin m), have v := eval₂ (Int.castRingHom ℝ) x (g i); v = 0 ∨ (2 ^ B)⁻¹ ≤ |v| ∧ |v| ≤ 2 ^ B) :
have y := eval₂ (Int.castRingHom ℝ) x (signLabelPolynomial B g target); (1 / 2 ≤ y ∨ y ≤ -1 / 2) ∧ (0 < y ↔ ∀ (i : Fin m), SignType.sign (eval₂ (Int.castRingHom ℝ) x (g i)) = target i)

If every real test value is zero or has magnitude in the dyadic range, the label has margin at least one half and is positive exactly on agreement.

noncomputable def Polynomial.fingerprintLabelPolynomial {m : ℕ} (B M : ℕ) (g : Fin (m + 1) → Polynomial ℤ) (w : Fin m → ℕ) (target : ℤ) :

The integer fingerprint label with the dyadic denominators cleared. Slot zero qualifies the point. The subsequent slots contribute to the weighted fingerprint. The dyadic product uses M + 1 repetitions, where M bounds the total weight.

theorem Polynomial.eval₂_fingerprintLabelPolynomial_margin {m : ℕ} (B M : ℕ) (g : Fin (m + 1) → Polynomial ℤ) (w : Fin m → ℕ) (target : ℤ) (x : ℝ) (hw : ∑ i : Fin m, w i ≤ M) (hvalues : ∀ (i : Fin (m + 1)), have v := eval₂ (Int.castRingHom ℝ) x (g i); v = 0 ∨ (2 ^ B)⁻¹ ≤ |v| ∧ |v| ≤ 2 ^ B) :
have v := fun (i : Fin (m + 1)) => eval₂ (Int.castRingHom ℝ) x (g i); have y := eval₂ (Int.castRingHom ℝ) x (fingerprintLabelPolynomial B M g w target); (1 / 2 ≤ y ∨ y ≤ -1 / 2) ∧ (0 < y ↔ ∑ i : Fin m, ↑(w i) * ↑(SignType.sign (v i.succ)) = target ∧ 0 < v 0)

If the total weight is at most M and the test values are zero or within the dyadic range in magnitude, the label has margin at least one half. It is positive exactly when the weighted integer signs match the target and the qualifying test is positive.