Draft — mutable and not usable as a dependency; its citation marks the draft state.

Lax58.CertifiedDerivation

Field-encoding agreement (infrastructure)

concepts/Lax58/CertifiedDerivation.lean · lax-58

definition

Loading review…

Sign in with ORCID

Community review

Flags

Each flag is tied to a public ORCID identity and explains why this concept may be incorrect.

No flags have been submitted.

    Community review

    Flag this concept

    State precisely what appears incorrect. This explanation will be public under your ORCID name.

    No source line selected.

    Concept map

    Proven claimDefinitionThis conceptRelated conceptA → B: B builds on A

    Infrastructure

    An agreement witness fixes an encoder and a proposition, supplies an implementation equal to that encoder, and carries a proof of the proposition. The operations below retain natural values, erase subtype proofs, and enumerate finite families in intrinsic order.

    This record is bookkeeping for generated certificates, not a standalone definition of advice-freedom: an arbitrary encoder and an arbitrary true proposition can have an agreement witness. The constructor equations generated for a particular datatype supply the semantic specification.

    Use Lax58.CertifiedDerivationElabLax58.CertifiedDerivationElab for the closed derivation command. Its field resolver accepts only approved primitives and previously generated datatype witnesses, never arbitrary values of this record. Constructor privacy alone is not a proof boundary; the indexed specification and equality obligation prevent replacing a specified encoder with a different function.

    Lean source view on GitHub

    1import Lax58.StructuralCombinators
    2
    3/-!
    4---
    5title: Field-encoding agreement (infrastructure)
    6type: infrastructure
    7---
    8
    9An agreement witness fixes an encoder and a proposition, supplies an
    10implementation equal to that encoder, and carries a proof of the proposition.
    11The operations below retain natural values, erase subtype proofs, and
    12enumerate finite families in intrinsic order.
    13
    14This record is bookkeeping for generated certificates, not a standalone
    15definition of advice-freedom: an arbitrary encoder and an arbitrary true
    16proposition can have an agreement witness. The constructor equations generated
    17for a particular datatype supply the semantic specification.
    18
    19Use `Lax58.CertifiedDerivationElab` for the closed derivation command. Its
    20field resolver accepts only approved primitives and previously generated
    21datatype witnesses, never arbitrary values of this record. Constructor
    22privacy alone is not a proof boundary; the indexed specification and equality
    23obligation prevent replacing a specified encoder with a different function.
    24-/
    25
    26namespace Lax58.CertifiedDerivation
    27
    28open Lax58.StructuralPresentation Lax58.StructuralCombinators
    29
    30universe u
    31
    32/-- A checked implementation of a specified canonical encoder and law.
    33Both specifications are type indices, so even tactics accessing the private
    34constructor cannot replace them. Provenance of the specifications comes from
    35the closed derivation command, which never accepts arbitrary witness values. -/
    36structure CertifiedFieldEncoding (α : Type u) (canonical : α → Raw) (laws : Prop) where
    37 private mk ::
    38 toRaw : α → Raw
    39 agrees : toRaw = canonical
    40 checked : laws
    41
    42namespace CertifiedFieldEncoding
    43
    44/-- Package a specified encoder with a proof of its law. This constructs only
    45an agreement value: it does not register a datatype or certify the provenance
    46of the supplied specification. The derivation command alone manages that
    47registry, after inspecting the source constructors. -/
    48def ofLaws {α : Type u} (canonical : α → Raw) {laws : Prop} (checked : laws) :
    49 CertifiedFieldEncoding α canonical laws :=
    50 ⟨canonical, rfl, checked⟩
    51
    52/-- The law fixed by a certificate's type, not chosen by its implementation. -/
    53def Laws {α : Type u} {canonical : α → Raw} {laws : Prop}
    54 (_P : CertifiedFieldEncoding α canonical laws) : Prop := laws
    55
    56/-- The natural-number primitive. -/
    57def nat : CertifiedFieldEncoding Nat Raw.nat (∀ n : Nat, Raw.nat n = Raw.nat n) :=
    58Raw.nat, rfl, fun _ => rfl⟩
    59
    60/-- Finite indices retain their natural value. -/
    61def fin (n : Nat) : CertifiedFieldEncoding (Fin n) (fun i => Raw.nat i.val)
    62 (∀ i : Fin n, Raw.nat i.val = Raw.nat i.val) :=
    63fun i => Raw.nat i.val, rfl, fun _ => rfl⟩
    64
    65/-- Erase only a subtype's proof, retaining its certified computational field. -/
    66def subtype {α : Type u} {canonical : α → Raw} {laws : Prop}
    67 (P : CertifiedFieldEncoding α canonical laws) (p : α → Prop) :
    68 CertifiedFieldEncoding (Subtype p) (fun x => canonical x.val) laws :=
    69fun x => canonical x.val, rfl, P.checked
    70
    71/-- Enumerate a possibly dependent finite family in intrinsic index order. -/
    72def family {n : Nat} {α : Fin n → Type u}
    73 {canonical : (i : Fin n) → α i → Raw} {laws : Fin n → Prop}
    74 (P : (i : Fin n) → CertifiedFieldEncoding (α i) (canonical i) (laws i)) :
    75 CertifiedFieldEncoding ((i : Fin n) → α i)
    76 (fun f => Raw.fields (List.ofFn fun i => canonical i (f i))) (∀ i, laws i) :=
    77fun f => Raw.fields (List.ofFn fun i => canonical i (f i)),
    78 rfl, fun i => (P i).checked
    79
    80end CertifiedFieldEncoding
    81
    82end Lax58.CertifiedDerivation
    83

    Community review

    Discussion

    Ask a question or add context. Endorsements and structured flags are kept in the review panel above; your ORCID profile must share a public name.

    0 comments

    Loading discussion…