Documentation

Transfer.Translate.ParamTranslate

The term-level ⟦·⟧ synthesizer (the parametricity translation) #

The type-directed engine synthesizes a Param witness for a type and transfers a goal. This module adds the term-level parametricity translation ⟦·⟧ of Trocq/paramcoq: a MetaM recursion over a term t producing both its transferred term t' and a proof of relatedness R t t', by the four core rules:

The ⟦·⟧ produces relatedness proof terms (validated: the demos below construct the proof and the kernel type-checks it). The app rule's fR a a' aR and the lam rule's abstraction are the parametricity combinators; the function relation RArrow here is ParamArrow.R_arrow specialized to bare Prop-relations.

Scope #

The translation is complete for the first-order, same-domain fragment: const/var/app/lam over registered constants, producing checked relatedness proofs. What it does not cover — the remaining metaprogramming, distinct from this core:

For the goals proof transfer exercises (∀-statements, function/value relations over registered domains), the type-directed engine (param_transfer, forallTransfer, param_resolve) already closes them; this module is the term-level companion that exhibits the proof terms.

def Transfer.Param.RArrow {A A' B B' : Type} (PA : A → A' → Prop) (PB : B → B' → Prop) (f : A → B) (f' : A' → B') :

The function relation (Trocq R_arrow, bare-Prop form): f, f' send PA-related arguments to PB-related results.

Equations
Instances For

    The term-level parametricity translation ⟦·⟧. Given a context mapping bound variables to their (transferred var, relatedness proof) and a database mapping constants to (transferred const, relatedness witness), returns the transferred term together with its relatedness proof. See the module docstring for the four rules.

    Demonstrations (the synthesizer in action) #

    Each run_meta block builds the transferred term + relatedness proof and the kernel type-checks the proof (inferType would error on an ill-typed term), so each is a checked validation.