File size: 2,585 Bytes
9dbc64e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | import OAI.Computability.DepthThree.LanguageParser
import OAI.Computability.DepthThree.AlgebraPolynomial
import OAI.Computability.DepthThree.Hash
import Mathlib.Algebra.Polynomial.Div
namespace OAI
namespace DepthThreeLowerBound
noncomputable section
open scoped BigOperators
namespace ParsedInput
def hashPolynomial (q : ParsedInput) : Polynomial (ZMod 2) :=
BinaryAlgebra.pack fun i =>
BinaryAlgebra.bitValue (BinaryHash.hashBool q.hashSeed q.data i)
def coefficientPolynomial (q : ParsedInput) (j : Fin q.coefficientCount) :
Polynomial (ZMod 2) :=
BinaryAlgebra.pack fun i => BinaryAlgebra.bitValue (q.coefficients j i)
def modulus (q : ParsedInput) : Polynomial (ZMod 2) :=
BinaryAlgebra.inputPolynomialBits q.polynomial
theorem modulus_monic (q : ParsedInput) : q.modulus.Monic :=
BinaryAlgebra.inputPolynomialBits_monic q.polynomial
theorem modulus_degree (q : ParsedInput) :
q.modulus.degree = (q.ringDegree : WithBot ℕ) :=
BinaryAlgebra.inputPolynomialBits_degree q.polynomial
def evaluationPolynomial (q : ParsedInput) : Polynomial (ZMod 2) :=
∑ j : Fin q.coefficientCount,
q.coefficientPolynomial j * q.hashPolynomial ^ j.val
def evaluationRemainder (q : ParsedInput) : Polynomial (ZMod 2) :=
q.evaluationPolynomial %ₘ q.modulus
theorem evaluationRemainder_degree_lt (q : ParsedInput) :
q.evaluationRemainder.degree < (q.ringDegree : WithBot ℕ) := by
rw [evaluationRemainder, ← q.modulus_degree]
exact Polynomial.degree_modByMonic_lt _ q.modulus_monic
def evaluate (q : ParsedInput) : Bool :=
decide (q.evaluationRemainder.coeff 0 = 0)
theorem evaluate_eq_true_iff (q : ParsedInput) :
q.evaluate = true ↔ q.evaluationRemainder.coeff 0 = 0 := by
simp only [evaluate, decide_eq_true_eq]
end ParsedInput
def language (w : List Bool) : Bool :=
match parseInput w with
| none => false
| some q => q.evaluate
theorem language_of_not_fits {w : List Bool} (h : ¬InputFits w) :
language w = false := by
simp only [language, parseInput_of_not_fits h]
theorem language_of_fits {w : List Bool} (h : InputFits w) :
language w = (decodeInput w).evaluate := by
simp only [language, parseInput_of_fits h]
theorem language_eq_true_iff (w : List Bool) :
language w = true ↔
InputFits w ∧ (decodeInput w).evaluationRemainder.coeff 0 = 0 := by
by_cases h : InputFits w
· rw [language_of_fits h, ParsedInput.evaluate_eq_true_iff]
simp only [h, true_and]
· rw [language_of_not_fits h]
simp only [Bool.false_eq_true, h, false_and]
end
end DepthThreeLowerBound
end OAI
|