From tfm%computer-lab.cambridge.ac.uk@NSFnet-Relay.AC.UK  Sun Jan 21 06:38:21 1990
Received: by iris.ucdavis.edu (5.57/UCD.EECS.2.0)
        id AA12223; Sun, 21 Jan 90 06:38:21 PST
Received: from ucdavis.ucdavis.edu by clover.ucdavis.edu (5.59/UCD.EECS.1.11)
        id AA19351; Sun, 21 Jan 90 06:43:37 PST
Received: by ucdavis.ucdavis.edu (5.51/UCD1.41)
        id AA12713; Sun, 21 Jan 90 06:29:17 PST
Received: from sun.nsfnet-relay.ac.uk by vax.NSFnet-Relay.AC.UK
           via Janet with NIFTP  id aa05652; 20 Jan 90 21:24 GMT
Received: from moorhen.cl.cam.ac.uk by gnnt.Cl.Cam.AC.UK id aa15835;
          20 Jan 90 21:32 GMT
Received: by uk.ac.cam.cl.moorhen (4.0/SMI-3.0DEV3)
        id AA10716; Sat, 20 Jan 90 21:31:55 GMT
Date: Sat, 20 Jan 90 21:31:55 GMT
From: tfm%computer-lab.cambridge.ac.uk@NSFnet-Relay.AC.UK
Message-Id: <9001202131.AA10716@uk.ac.cam.cl.moorhen>
To: info-hol%clover.ucdavis.edu@NSFnet-Relay.AC.UK
Subject: another remark about FIRST_ASSUM.

A footnote about FIRST_ASSUM
----------------------------

Regarding my previous message about failure and FIRST_ASSUM, info-hol
readers may be interested in the following trivial observation.

The problem
-----------

The problem was the behaviour of the tactic "FIRST_ASSUM f" if the
function f:thm->tactic fails when applied to some assumption of the
goal.  It was observed that for the goal:

    set_goal (["T"; "!x:num. P x \/ Q x"; "F"], "G:bool");;

attempting to generate a case split on "P n" or "Q n" by using the tactic

    FIRST_ASSUM (STRIP_ASSUME_TAC o SPEC "n:num")

would fail, since SPEC "n" fails on the assumption "T".

The solution
------------

The proposed solution was to filter out the theorems for which SPEC fails
by using the following "filtering" version of FIRST_ASSUM:

    ASSUM_LIST (FIRST o (mapfilter (STRIP_ASSUME_TAC o SPEC "n:num")))

Another proposed solution was:

    FIRST_ASSUM (\th. STRIP_ASSUME_TAC(SPEC "n:num" th) ? NO_TAC)

This works because the "?" catches any failures of SPEC and
yields NO_TAC, which can itself fail when applied to the goal.

Another solution
----------------

An alternative solution is to make use of the evaluation strategy of ML, as
is done in the following tactic:

    FIRST_ASSUM (\th g. STRIP_ASSUME_TAC (SPEC "n:num" th) g)

Semantically, this function is the same as

    FIRST_ASSUM (STRIP_ASSUME_TAC o SPEC "n:num")

except that the extra lambda-abstraction (in particular, the "\g") prevents
premature failure of the function to which FIRST_ASSUM is applied.

Try it ... it works!

Tom

