Dear Mathias,
The Lifting package manages the registered quotients in a map with the name of the type
constructor as a key. So even if you could trick setup_lifting into accepting a theorem of
the form
type_definition Rep Abs {x. inv x}
the lift_definition command would not be able to find the setup, because it constructs the
lifting relation based on the type constructors that appear in the types of the raw term
and the lifted constant. One would have to extend the implementation of
Lifting_Term.prove_schematic_quot_thm accordingly to also support TFree.
Moreover, you'd have to make sure that the quotient theorem setup does not leak into any
interpretation, in which the type variables get instantiated or generalised. Otherwise,
the internal data structures of the Lifting package would be messed up.
Finally, I am not sure that your approach will actually work for code generation. The
steps of lift_definition for a subtype copy are fairly limited except when it comes to
code generation for compound return types. For example, if your function returns something
like 'inv list (rather than a plain 'inv), then lift_definition internally generates a
number of types and auxiliary constants and lifts the invariant to those types such that
the code generator can handle them. I cannot see how this construction would work for an
unspecified 'inv (otherwise, we could have done the construction once and for all for such
an arbitrary 'inv and then just reused everything).
Andreas