Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.Encodings.Derive

Policy-driven inductive encoding derivation #

derive_encoding eT (p : P) : T p inspects constructors in declaration order, identifies direct recursion, and calls the checked enc_inductive generator. It adds no serializer or proof pipeline. The selected embeddings determine exactly the explicit command's words and public API.

There are no default field encodings. Open a named policy or register embeddings with @[scoped encoding_rule]. An embedding supplied as a local parameter takes precedence; two matching local embeddings are an error. Otherwise exactly one active registered rule must apply. Rule parameters are inferred from the field type; unresolved embedding parameters are resolved recursively, and instance parameters use Lean's instance synthesis. Other uninferred parameters, cyclic searches, missing rules and multiple applicable rules are errors. Rules have no priorities. The attribute accepts only local and scoped registrations on public embeddings. Successful derivations register their embedding scoped to their namespace. Importing alone does not activate scoped entries; open scoped N activates namespace N.

This command generates public declarations and requires a public target inductive and public encoding rules. It otherwise has the explicit generator's support boundary: small result types, uniform parameters and ordinary direct recursion. It checks structure and resolves every scalar field before generation. List all type, value and encoding parameters explicitly before the colon; ambient section parameters used by a derivation must be listed there too. Keep enc_inductive for complete control over individual fields. Registered embeddings supply neither bit decoders nor certificates for arbitrary recursion; generated bit decoders still take explicit PartialDecoder witnesses.

An explicit field-encoding choice for derive_encoding. Use scoped for an opt-in namespace policy or local for a section. The public declaration returns an embedding into List Bool, possibly after parameters. Matching never uses declaration order or a priority to resolve ambiguity.

Derive and register an encoding using the active explicit policy. Parameter binders and the generated public interface agree with enc_inductive. Constructors and recursion are inferred.

Resolve the explicit field policy before invoking the checked inductive encoding generator.