Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.Complexity.InSpace.BinaryIrreducible

Native binary-polynomial trial components #

divisorPasses_inSpace certifies the exact trial predicate used by isIrreducibleCode and its counter scan, on binary candidate/divisor codes. The native remainder call retains the two codes and charges conversion of their coefficient words, the two remainder registers and its scalar callees. Both live binary lengths are computed from binary encodings, without expanding a code to unary or allocating a divisor table.

The counted trial run is uniform in its initial divisor and binary iteration count. Its native workspace includes the retained candidate, moving divisor and Boolean accumulator at every prefix. This is an original resource analysis of the existing trial predicate. Its complete counter traversal returns exactly isIrreducibleCode; the private early-exit scan has that same value by its existing agreement theorem. This does not identify their step traces or certify modulus selection, Horner or seed composition, which remain open under #6747.

Main results #

Candidate and divisor codes for a binary-polynomial trial.

  • candidate : ℕ

    Binary code of the polynomial whose divisors are tested.

  • divisor : ℕ

    Binary code of the possible divisor.

theorem Turing.BinaryField.encDivisorInput_candidate_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → DivisorInput} :
MultiTapeTM.ComputableInSpace g✝ encIn✝ encDivisorInput S✝ → MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).candidate) encIn✝ MultiTapeTM.encNat S✝
theorem Turing.BinaryField.encDivisorInput_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget x0 x1 : γ → ℕ} (h0 : MultiTapeTM.ComputableInSpace x0 encIn MultiTapeTM.encNat budget) (h1 : MultiTapeTM.ComputableInSpace x1 encIn MultiTapeTM.encNat budget) :
MultiTapeTM.ComputableInSpace (fun (x : γ) => { candidate := x0 x, divisor := x1 x }) encIn encDivisorInput budget

Binary candidate, framed, followed by binary divisor.

@[reducible, inline]

The tuple of the fields of encDivisorInput.

theorem Turing.BinaryField.encDivisorInput_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 T0 S0 x1 T1 S1 : γ → ℕ} (h0 : MultiTapeTM.ComputableInO x0 encIn MultiTapeTM.encNat T0 S0) (h1 : MultiTapeTM.ComputableInO x1 encIn MultiTapeTM.encNat T1 S1) :
MultiTapeTM.ComputableInO (fun (x : γ) => { candidate := x0 x, divisor := x1 x }) encIn encDivisorInput (fun (x : γ) => T0 x + T1 x) fun (x : γ) => S0 x + S1 x
theorem Turing.BinaryField.encDivisorInput_mk_polyTime {γ : Type} {encIn : γ ↪ List Bool} {x0 x1 : γ → ℕ} (h0 : MultiTapeTM.ComputableInPolyTime x0 encIn MultiTapeTM.encNat) (h1 : MultiTapeTM.ComputableInPolyTime x1 encIn MultiTapeTM.encNat) :
MultiTapeTM.ComputableInPolyTime (fun (x : γ) => { candidate := x0 x, divisor := x1 x }) encIn encDivisorInput
theorem Turing.BinaryField.encDivisorInput_divisor_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → DivisorInput} :
MultiTapeTM.ComputableInSpace g✝ encIn✝ encDivisorInput S✝ → MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).divisor) encIn✝ MultiTapeTM.encNat S✝

The exact original divisor-pass predicate, in native work space linear in the two binary codes. Live lengths, decoded coefficient words and the complete remainder callee are charged.

State of a counter trial: retained candidate, next divisor and accumulated pass bit.

  • candidate : ℕ

    Binary candidate, unchanged during the trial.

  • divisor : ℕ

    Next divisor code to test.

  • good : Bool

    Whether every divisor tested so far passed the original predicate.

theorem Turing.BinaryField.encTrialState_divisor_polyTime {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → TrialState} :
theorem Turing.BinaryField.encTrialState_candidate_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → TrialState} :
MultiTapeTM.ComputableInSpace g✝ encIn✝ encTrialState S✝ → MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).candidate) encIn✝ MultiTapeTM.encNat S✝
theorem Turing.BinaryField.encTrialState_good_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → TrialState} :
MultiTapeTM.ComputableInSpace g✝ encIn✝ encTrialState S✝ → MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).good) encIn✝ MultiTapeTM.encBool S✝
theorem Turing.BinaryField.encTrialState_candidate_polyTime {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → TrialState} :
theorem Turing.BinaryField.encTrialState_good_polyTime {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → TrialState} :
@[reducible, inline]

The tuple of the fields of encTrialState.

theorem Turing.BinaryField.encTrialState_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 T0 S0 x1 T1 S1 : γ → ℕ} {x2 : γ → Bool} {T2 S2 : γ → ℕ} (h0 : MultiTapeTM.ComputableInO x0 encIn MultiTapeTM.encNat T0 S0) (h1 : MultiTapeTM.ComputableInO x1 encIn MultiTapeTM.encNat T1 S1) (h2 : MultiTapeTM.ComputableInO x2 encIn MultiTapeTM.encBool T2 S2) :
MultiTapeTM.ComputableInO (fun (x : γ) => { candidate := x0 x, divisor := x1 x, good := x2 x }) encIn encTrialState (fun (x : γ) => T0 x + (T1 x + T2 x)) fun (x : γ) => S0 x + (S1 x + S2 x)
theorem Turing.BinaryField.encTrialState_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget x0 x1 : γ → ℕ} {x2 : γ → Bool} (h0 : MultiTapeTM.ComputableInSpace x0 encIn MultiTapeTM.encNat budget) (h1 : MultiTapeTM.ComputableInSpace x1 encIn MultiTapeTM.encNat budget) (h2 : MultiTapeTM.ComputableInSpace x2 encIn MultiTapeTM.encBool budget) :
MultiTapeTM.ComputableInSpace (fun (x : γ) => { candidate := x0 x, divisor := x1 x, good := x2 x }) encIn encTrialState budget
theorem Turing.BinaryField.encTrialState_divisor_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → TrialState} :
MultiTapeTM.ComputableInSpace g✝ encIn✝ encTrialState S✝ → MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).divisor) encIn✝ MultiTapeTM.encNat S✝
theorem Turing.BinaryField.encTrialState_mk_polyTime {γ : Type} {encIn : γ ↪ List Bool} {x0 x1 : γ → ℕ} {x2 : γ → Bool} (h0 : MultiTapeTM.ComputableInPolyTime x0 encIn MultiTapeTM.encNat) (h1 : MultiTapeTM.ComputableInPolyTime x1 encIn MultiTapeTM.encNat) (h2 : MultiTapeTM.ComputableInPolyTime x2 encIn MultiTapeTM.encBool) :
MultiTapeTM.ComputableInPolyTime (fun (x : γ) => { candidate := x0 x, divisor := x1 x, good := x2 x }) encIn encTrialState
theorem Turing.BinaryField.encTrialState_mk_deg :
MultiTapeTM.ComputableInDegree (fun (p : ℕ × ℕ × Bool) => { candidate := p.1, divisor := p.2.1, good := p.2.2 }) encTrialStateFields encTrialState 1 1

Binary candidate and divisor, each framed, followed by the accumulator bit.

Test one divisor with the original predicate and increment the binary cursor.

Native step space includes the retained candidate and the entire divisor-test callee.

Binary candidate, starting divisor and iteration count; no list of trials is stored.

  • candidate : ℕ

    Candidate code.

  • first : ℕ

    First divisor code.

  • count : ℕ

    Number of consecutive divisor codes to test.

theorem Turing.BinaryField.encTrialInput_count_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → TrialInput} :
MultiTapeTM.ComputableInSpace g✝ encIn✝ encTrialInput S✝ → MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).count) encIn✝ MultiTapeTM.encNat S✝
theorem Turing.BinaryField.encTrialInput_mk_polyTime {γ : Type} {encIn : γ ↪ List Bool} {x0 x1 x2 : γ → ℕ} (h0 : MultiTapeTM.ComputableInPolyTime x0 encIn MultiTapeTM.encNat) (h1 : MultiTapeTM.ComputableInPolyTime x1 encIn MultiTapeTM.encNat) (h2 : MultiTapeTM.ComputableInPolyTime x2 encIn MultiTapeTM.encNat) :
MultiTapeTM.ComputableInPolyTime (fun (x : γ) => { candidate := x0 x, first := x1 x, count := x2 x }) encIn encTrialInput
theorem Turing.BinaryField.encTrialInput_candidate_polyTime {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → TrialInput} :
theorem Turing.BinaryField.encTrialInput_count_polyTime {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → TrialInput} :
theorem Turing.BinaryField.encTrialInput_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget x0 x1 x2 : γ → ℕ} (h0 : MultiTapeTM.ComputableInSpace x0 encIn MultiTapeTM.encNat budget) (h1 : MultiTapeTM.ComputableInSpace x1 encIn MultiTapeTM.encNat budget) (h2 : MultiTapeTM.ComputableInSpace x2 encIn MultiTapeTM.encNat budget) :
MultiTapeTM.ComputableInSpace (fun (x : γ) => { candidate := x0 x, first := x1 x, count := x2 x }) encIn encTrialInput budget
theorem Turing.BinaryField.encTrialInput_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 T0 S0 x1 T1 S1 x2 T2 S2 : γ → ℕ} (h0 : MultiTapeTM.ComputableInO x0 encIn MultiTapeTM.encNat T0 S0) (h1 : MultiTapeTM.ComputableInO x1 encIn MultiTapeTM.encNat T1 S1) (h2 : MultiTapeTM.ComputableInO x2 encIn MultiTapeTM.encNat T2 S2) :
MultiTapeTM.ComputableInO (fun (x : γ) => { candidate := x0 x, first := x1 x, count := x2 x }) encIn encTrialInput (fun (x : γ) => T0 x + (T1 x + T2 x)) fun (x : γ) => S0 x + (S1 x + S2 x)
theorem Turing.BinaryField.encTrialInput_mk_deg :
MultiTapeTM.ComputableInDegree (fun (p : ℕ × ℕ × ℕ) => { candidate := p.1, first := p.2.1, count := p.2.2 }) encTrialInputFields encTrialInput 1 1

Three binary naturals in field order, the first two framed.

theorem Turing.BinaryField.encTrialInput_first_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → TrialInput} :
MultiTapeTM.ComputableInSpace g✝ encIn✝ encTrialInput S✝ → MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).first) encIn✝ MultiTapeTM.encNat S✝
theorem Turing.BinaryField.encTrialInput_first_polyTime {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {g✝ : γ✝ → TrialInput} :
theorem Turing.BinaryField.encTrialInput_candidate_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → TrialInput} :
MultiTapeTM.ComputableInSpace g✝ encIn✝ encTrialInput S✝ → MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).candidate) encIn✝ MultiTapeTM.encNat S✝
@[reducible, inline]

The tuple of the fields of encTrialInput.

A counted trial run, implemented by repeated native scalar steps rather than List.range.

Every tested divisor contributes the exact original predicate, including out-of-range and zero codes; there are no monicity or candidate-size preconditions on this iteration contract.

Uniform native counted trial space, linear in the binary candidate/start/count words. The cursor is at most first + count at every prefix; the step certificate includes binary length processing and polynomial-remainder workspace. Running time is left existential.

theorem Turing.BinaryField.trialRun_isIrreducibleCode (m : ℕ) :
(decide (2 ≤ m) && (trialRun { candidate := m, first := 0, count := m }).good) = Cslib.isIrreducibleCode m

Starting at code zero and testing exactly candidate-many codes gives the original irreducibility predicate after its lower-bound test. The list appears only in the specification of isIrreducibleCode, not in trialRun or its native implementation.

The existing total irreducibility test on a binary code has a native linear-workspace implementation by counted trial division. Both live binary lengths and every remainder call are included; no unary candidate, divisor list or multiplication table is materialized.