Hi everyone,
What is the expected behavior of sorts in proof export?
When looking at the exported version (in Isabelle/Scala) of some subpart of the HOL session, I noticed that sorts (in type variables, in propositions' type arguments) are always empty (at least in the few theories I looked) in places I would expect them not to be (definitions/propositions in a typeclass context).
However, in the type arguments of a theory's Spec_Rules, they are present as I would expect them to be.
Is that normal?
I've been staring at the code for a few days and could not find where that comes from. All I found is that, when I ran a test on a session with Pure + theory HOL.Groups, in every call to Export_theory.encode_thm, the typargs in standard_prop_of thm (Some proof0) are always of empty sort. It looks like Zterm.standard_vars does not remove sorts, so from what I understand, a theories' thms are already void of sorts when the export happens. Is that normal ?
What I found to get the sorts:
Doing this (and changing src/Pure/Build/export_theory.scala to read the sorts of consts) I indeed got sorts when I needed them most in consts, theorems, and intermediary proofs. Other important sorts can be found in the theories' arities (in particular instantiations' constants' internal names contain enough information to find the associated arity and extract its typargs)
Last updated: Jul 10 2026 at 21:07 UTC