On the Representation of Datatypes in Isabelle/HOL

On the Representation of Datatypes in Isabelle/HOL

On the Representation of Datatyp es in Isab elleHOL N Volker FernUniversitat Hagen Germany Abstract Representation of datatyp es is a necessary prerequisite if one wants to proverat her than p ostulate the characteristic theorems of datatyp es This pap er intro duces two notions of representation functions for typ es and shows how representations of comp osed typ es can b e calculated from representations of their constituents Together with a representation of basic typ es due to Paulson this provides a basis for the mechanization of datatyp es in Isab elleHOL Intro duction Datatyp es are imp ortant ingredients of many theories mo delling computations We will b e concerned here with datatyp es which are generated from a numb er of elements and functions the constructors This means that every element of the typ e can b e written as a constructor term ie as an application of constructors to constructors Furthermore our datatyp es will b e freely generated by the constructors ie the constructors are distinct and injective This implies that every element of the datatyp e is denoted by a unique constructor term As a consequence suchtyp es enjoy a structural induction theorem and allow the denition of functions by primitive recursion In the categorical setting these typ es arise as initial elements in certain categories of algebras Therefore one also sp eaks of initial algebras Other names used are recursive or inductivetyp es without laws We will simply call them datatyp es y destructor functions whose domain is The dual kind of typ es are characterized b the carrier of the typ e An example for such a codatatyp e are innite lists Although parts of our discussion should carry over to codatatyp es we will not consider them here Currently the Isab elleHOL system provides a datatyp e denition package which hasanumb er of shortcomings The prop erties of the new typ es are p ostulated axiomatically The declaration of a typ e T maynotcontain applications of typ e op erators to T This forbids denitions like a b Tree LEAF a j NODE b a b Tree List There is no supp ort for mutually recursive datatyp es We will outline in this pap er an approach which aims to prove the characteristic theo rems of the new datatyp e This is achieved by representing typ es by sets of a certain typ e whichwas intro duced byPaulson for exactly this purp ose Our main contri bution is the derivation of representations of typ e expressions from representations of its constituents This construction based on a generalization of the map function from lists to an arbitrary datatyp e The typ e a b Tree mo dels trees with arbitrary nite branching and elements of a resp b in the leafs resp no des This example is inspired from a slightly simpler datatyp e in That article discusses some basic questions concerning automatic supp ort for datatyp es in another higher order pro of assistant namely the HOL system We are currently working on an implementation along the lines suggested in this pap er We stress that this pap er rep orts on work in progress and do es not claim to b e the nal word on representations of datatyp es in higher order logic Map for arbitrary datatyp es Atseveral places of our exp osition we will make use of the fact that for every datatyp e map whichistheT analogue of the wellknown function T one can dene a function T map on lists Since the denition of the general mapping function is technically some what involved we will illustrate it rst by a couple of examples Recall that lists can b e dened by the datatyp e declaration a List j Cons a a List For the typ e T List the function T map agrees with map ie wehave List map a b a List b List and map f List List map f Cons x xs Cons fx List map fxs Intuitively List map preserves the structure given by the list constructors and Cons but changes the values of those constructor arguments whose typ e in is a For the datatyp e Tree dened ab ove the typ e of the mapping function is Tree map a b a b a a Tree b b Tree map is dened by primitive recursion The recursive o ccur Again the function Tree rence of Tree within List is reected by an application of List map to Tree map f f map f f LEAF a LEAF f a Tree Tree map f f NODE a ts NODE f a List map Tree map f f ts For ary datatyp es ie unparameterized typ es suchasnat the mapping function map f is the identity on that typ e Next we will showhow to dene the function T for the case of an arbitrary one parameter datatyp e aT with m constructors The declaration of suchatyp e has the form aT C T j j C T m m where T is the j th argumenttyp e of constructor C Of course the number of typ e i j i arguments can vary from constructor to constructor and can also b e zero Every T is i j atyp e expression build up from the typ e variable a recursive o ccurrences of aT and previously dened datatyp es Note that T is only allowed to o ccur with the parameter a ie instantiations of T are not allowed Let f b e some function from a typ e A to another typ e B Then the mapping of f over T map f AT BT T preserves constructors For a constructor C with k arguments we therefore have i T map f C x x C h T x h T x i i i k i i i i k i k T On ary constructors the function T map f is the identity for certain functions h i j As indicated by the notation the function h T dep ends on the typ e T in i j i j Ty is dened by induction on the structure of Ty as follows For a typ e expression Ty h h a f h aT T map f h T T D D map h T h T l l D stands here for an arbitrary previously datatyp e of some arity l For a general n ary datatyp e T the typ e of the mapping function is T map a b a b a a T b b T n n n n The general denition of T map f f follows exactly the same scheme as for the n T stays the same except that case n The denition of the auxiliary functions h i j equation is replaced by setting h a f i i for i n Although it is not usual in higher order logic the pro duct and sum typ e themselves can b e dened as datatyp es a b Inl a j Inr b a b a b Their mapping op erators are characterized by the following equations map f g Inl a Inl fa Sum map f g Inr b Inr gb Sum Prod map f g a b fa gb A treatment of the generalized mapping function in the categorical framework can b e found in Another generic function For the denition of representing sets we will b e interested in computing the range of T map f f It turns out that this can b e expressed in terms of another generic n function set a set a set a a T set T n n set A A which can b e dened for an arbitrary n ary datatyp e T Intuitively T n will consist of those elements of T which can b e generated from the sets A A n The meaning of generated will b e made precise using inductive denitions First let us consider the example of the typ e List The function List set a set a List set should takeasetA into the set of all lists with elements in A This set is characterized by the following twointro duction rules a A l List set A List set A Cons a l List set A Note how each rule corresp onds to the typing of one List constructor In fact wecan deriveevery rule systematically from the typing rule of the corresp onding constructor by simply replacing the name List by List set and a by A For a general datatyp e a a T with m constructors we obtain analogously n m intro duction rules for T set A A from the typing rules of the constructors n set and a by A for i n by replacing the name T by T i i By the principle of inductive denition a nite numb er of rules such as the ones ab ove uniquely sp ecies a set cf chapter of and the literature cited there This set is the intersection of all the sets which comply to those rules Supp ort for inductive denitions in higher order logic pro of systems has b een des crib ed in and Both approaches implement inductively dened sets as least xed p oints Our interest in T set stems from the equality range T map f f T set range f range f n n set is obviously monotonic We note the fact that T Representations of typ es The principal means to add new typ es in Isab elleHOL without risking inconsistencies is the subtype facility This function is similar to the HOL systems new type definition and allows to dene a new typ e T which is isomorphic to a nonempty subset S of an existing typ e RT Isomorphic here means that there exists an injective function T rep from the new typ e T onto its representing set S In the subtype package the new typ e is declared and constants are intro duced for the representation function T rep and an inverse abstraction function T The inverse relationship b etween these two abs functions and the fact that the representing set S is the image of the representation function are p ostulated as axioms RT T_rep T S T_abs Figure Denition of new typ es using subtype The use of the subtype declaration is the only waytoavoid the intro duction of non trivial axioms in the denition of a datatyp e T in Isab elleHOL It implies the following sub division of our task Construct a representing set S Dene the new typ e T byasubtype declaration This requires a pro of that S is not empty Dene the constructors by using the abstraction and representation functions Generate and prove the characteristic theorems In the following we will b e considering not just the representation of a single typ e but of a whole class C of typ es Such a representation

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    13 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us