Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.Internal.NativeCompiler.Equality

Named native encoded-word equality #

This module retains the direct one-work-tape zip machine used to compare two encoded words. The first framed word is copied to a work tape; the two words are then scanned in lockstep, including the distinction between a missing symbol and either Boolean symbol. The tidy wrapper and its cleanup are part of the retained machine and of the exact resource formulas.

wordEqBool emits encBool. Branching clients use wordEqTest, which explicitly composes the charged boolToTest conversion instead of treating [false] as the empty false-test word.

Main definitions #

A constructor view of the direct zip-machine control states.

The constructor view of zip-machine states is injective.

Constructive encoding of the direct zip-machine control states.

def Turing.MultiTapeTM.Internal.NativeCompiler.ofZipTransducer {Alpha : Type u} {Beta : Type v} {Gamma : Type u_1} {State : Type} [Fintype State] {f : Alpha × Beta → Gamma} (encFirst : Alpha ↪ List Bool) (encSecond : Beta ↪ List Bool) (encOut : Gamma ↪ List Bool) (transducer : ZipTransducer State) (stateEncoding : State ↪ ℕ) (run_eq : ∀ (input : Alpha × Beta), transducer.run transducer.q₀ (encFirst input.1) (encSecond input.2) = encOut (f input)) :
NativeCompiler f (encPair encFirst encSecond) encOut

Retain a zip transducer through the direct machine and the existing tidy normal form. The clock and workspace expose the kernel bound and every cleanup term.

Compare two words, remembering whether their lengths and every symbol agree.

theorem Turing.MultiTapeTM.Internal.NativeCompiler.wordEqT_run (equal : Bool) (first second : List Bool) :
wordEqT.run equal first second = [equal && decide (first = second)]

The word-equality zip transducer emits the one-bit Boolean equality result.

The word-equality transducer, started in its designated initial state, decides equality of its two input words.

def Turing.MultiTapeTM.Internal.NativeCompiler.wordEqBool {Alpha : Type u_1} (enc : Alpha ↪ List Bool) :
NativeCompiler (fun (input : Alpha × Alpha) => decide (enc input.1 = enc input.2)) (encPair enc enc) encBool

Equality of two values under a shared injective encoding, with one-bit Boolean output.

def Turing.MultiTapeTM.Internal.NativeCompiler.wordEqTest {Alpha : Type u_1} (enc : Alpha ↪ List Bool) :
NativeCompiler (fun (input : Alpha × Alpha) => decide (enc input.1 = enc input.2)) (encPair enc enc) encTest

Equality in the empty/nonempty branch-test encoding, with the conversion explicitly retained.