Documentation

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

Named native sum destructors #

The standard sum encoding begins with a constructor bit. These total destructors retain the tag test, payload-tail transducer and conditional default substitution. The opposite-constructor default is explicit, so clients can extract a typed payload without a decoder callback or an invalid cast.

Main definitions #

def Turing.MultiTapeTM.Internal.NativeCompiler.optionPayload {Alpha : Type u_1} (enc : Alpha ↪ List Bool) :
NativeCompiler (fun (value : Option Alpha) => ((encOption enc) value).tail) (encOption enc) encBits

Emit the untagged payload word of a standard option encoding.

def Turing.MultiTapeTM.Internal.NativeCompiler.optionGetD {Alpha : Type u_1} (default : Alpha) (enc : Alpha ↪ List Bool) :
NativeCompiler (fun (value : Option Alpha) => value.getD default) (encOption enc) enc

Extract an optional payload, using the explicit default on none.

Test whether a standard encoded list is empty.

def Turing.MultiTapeTM.Internal.NativeCompiler.listHeadPayload {Alpha : Type u_1} (enc : Alpha ↪ List Bool) :
NativeCompiler (fun (list : List Alpha) => undelimit ((encList enc) list)) (encList enc) encBits

Emit the first framed list element as a raw payload word. On the empty list this emits the frame parser's total empty-word result, which is replaced by listHeadD.

def Turing.MultiTapeTM.Internal.NativeCompiler.listHeadD {Alpha : Type u_1} (default : Alpha) (enc : Alpha ↪ List Bool) :
NativeCompiler (fun (list : List Alpha) => list.headD default) (encList enc) enc

First list element, or the explicit default on the empty list.

def Turing.MultiTapeTM.Internal.NativeCompiler.listGetDUnary {Alpha : Type u_1} (default : Alpha) (enc : Alpha ↪ List Bool) :
NativeCompiler (fun (input : List Alpha × ℕ) => input.1.getD input.2 default) (encProd (encList enc) encUnary) enc

Unary-indexed list access, including the direct suffix scan and total head default.

def Turing.MultiTapeTM.Internal.NativeCompiler.sumLeftD {Alpha : Type u_1} {Beta : Type u_2} (default : Alpha) (encLeft : Alpha ↪ List Bool) (encRight : Beta ↪ List Bool) :
NativeCompiler (Sum.elim id (Function.const Beta default)) (encSum encLeft encRight) encLeft

Extract a left payload, using the explicit default on right inputs.

def Turing.MultiTapeTM.Internal.NativeCompiler.sumRightD {Alpha : Type u_1} {Beta : Type u_2} (default : Beta) (encLeft : Alpha ↪ List Bool) (encRight : Beta ↪ List Bool) :
NativeCompiler (Sum.elim (Function.const Alpha default) id) (encSum encLeft encRight) encRight

Extract a right payload, using the explicit default on left inputs.