From @sun.tfl.dk:kimdam@sun.tfl.dk  Sun Jun 17 06:26:55 1990
Received: by iris.ucdavis.edu (5.57/UCD.EECS.2.0)
        id AA01100; Sun, 17 Jun 90 06:26:55 PDT
Received: from [129.142.6.64] by clover.ucdavis.edu (5.59/UCD.EECS.1.11)
        id AA07826; Sun, 17 Jun 90 06:30:21 PDT
Received: by danpost.uni-c.dk (5.57/4.7)
        id AA14591; Sun, 17 Jun 90 13:26:32 GMT
Received: from tfl.dk by vms2.uni-c.dk; Sun, 17 Jun 90 15:28 GMT+2
Received: from sun0.tfl.dk by tfl.dk; Fri, 15 Jun 90 18:17 +0100
Received: from sun1 by sun0.tfl.dk with SMTP (5.61++/IDA-1.2.8) id AA06584;
 Fri, 15 Jun 90 18:18:56 +0200
Received: by sun1.tfl.dk (5.61++/IDA-1.2.8) id AA00628; Fri, 15 Jun 90 18:16:24
 +0200
Date: Fri, 15 Jun 90 18:16:24 +0200
From: kimdam@tfl.dk
Subject: Error in AUTO_SPECL (of Elsa Gunther)
To: info-hol@clover.ucdavis.edu
Message-Id: <9006151616.AA00628@sun1.tfl.dk>
X-Envelope-To: info-hol@clover.ucdavis.edu


There is an error in Elsa Gunther's AUTO_SPECL tactic, which shows
when polymorphic types are to be `swapped'.

An example of the error is showed below:

        #show_types true;;
        #let theseterms = ["x:**";"y:*"];;
        theseterms = ["x:**"; "y:*"] : term list

        #let theorem = GEN_ALL(REFL"(x:*),(y:**)");;
        theorem = |- !(x:*) (y:**). x,y = x,y

        #GEN_ALL (AUTO_SPECL theseterms theorem);;
        |- !(x:*) (y:*). x,y = x,y

The erroneous result is that "x" has type ":*" instead of the expected ":**".

The succesive type instantiation is the error in AUTO_SPECL.  If the type
instantiation is done only once, with the accumulated type information of
all terms involved the we will get the proper result.

A version of AUTO_SPECL that collects all type information before
performing the type instantiation is showed below.


        \Kim Dam Petersen       (kimdam@tfl.dk)

-------------------------8< Cut here >8-------------------------

%AUTO_SPECL : term_list -> thm -> thm  (term_list = [t1;...;tn])
(Automatically tries to instantiate the type of x1...xn to that of t1...tn)

   A |- !x1 ... xn. t(x1,...,xn)
-----------------------------------
     A |- t(t1,...,tn)

%
let AUTO_SPECL theseterms theorem =
(let (xs,thm) = itlist
                  (\t (xs,thm). let (x,thm) = dest_forall thm in ((x.xs),thm))
                  theseterms
                  ([], concl theorem) in
 let types = flat (map2 (\(x,t). snd(match x t)) (rev xs,theseterms)) in
   SPECL theseterms (INST_TYPE types theorem) )?failwith `AUTO_SPECL`;;


