An indexed model of recursive types for foundational proof-carrying code