| 7218 |      1 | (*  Title       : HOL/Real/Hyperreal/fuf.ml
 | 
|  |      2 |     ID          : $Id$
 | 
|  |      3 |     Author      : Jacques D. Fleuriot
 | 
|  |      4 |     Copyright   : 1998  University of Cambridge
 | 
|  |      5 |                   1999  University of Edinburgh
 | 
|  |      6 |     Description : Simple tactics to help proofs involving our 
 | 
|  |      7 |                   free ultrafilter (FreeUltrafilterNat). We rely
 | 
|  |      8 |                   on the fact that filters satisfy the  finite 
 | 
|  |      9 |                   intersection property.
 | 
|  |     10 | *)
 | 
|  |     11 | 
 | 
|  |     12 | exception FUFempty;
 | 
|  |     13 | 
 | 
|  |     14 | fun get_fuf_hyps [] zs = zs
 | 
|  |     15 | |   get_fuf_hyps (x::xs) zs = 
 | 
|  |     16 |         case (concl_of x) of 
 | 
|  |     17 |         (_ $ (Const ("Not",_) $ (Const ("op :",_) $ _ $
 | 
|  |     18 |              Const ("HyperDef.FreeUltrafilterNat",_)))) =>  get_fuf_hyps xs 
 | 
|  |     19 |                                               ((x RS FreeUltrafilterNat_Compl_mem)::zs)
 | 
|  |     20 |        |(_ $ (Const ("op :",_) $ _ $
 | 
|  |     21 |              Const ("HyperDef.FreeUltrafilterNat",_)))  =>  get_fuf_hyps xs (x::zs)
 | 
|  |     22 |        | _ => get_fuf_hyps xs zs;
 | 
|  |     23 | 
 | 
|  |     24 | fun Intprems [] = raise FUFempty
 | 
|  |     25 | |   Intprems [x] = x
 | 
|  |     26 | |   Intprems (x::y::ys) = 
 | 
|  |     27 |       Intprems (([x,y] MRS FreeUltrafilterNat_Int) :: ys);
 | 
|  |     28 | 
 | 
|  |     29 | (*---------------------------------------------------------------  
 | 
|  |     30 |    solves goals of the form 
 | 
|  |     31 |     [| A1: FUF; A2: FUF; ...; An: FUF |] ==> B : FUF   
 | 
|  |     32 |    where A1 Int A2 Int ... Int An <= B 
 | 
|  |     33 |  ---------------------------------------------------------------*)
 | 
|  |     34 | 
 | 
|  |     35 | val Fuf_tac = METAHYPS(fn prems =>
 | 
|  |     36 |                     (rtac ((Intprems (get_fuf_hyps prems [])) RS
 | 
|  |     37 |                            FreeUltrafilterNat_subset) 1) THEN 
 | 
|  |     38 |                     Auto_tac);
 | 
|  |     39 | 
 | 
|  |     40 | fun fuf_tac (fclaset,fsimpset) i = METAHYPS(fn prems =>
 | 
|  |     41 |                     (rtac ((Intprems (get_fuf_hyps prems [])) RS
 | 
|  |     42 |                            FreeUltrafilterNat_subset) 1) THEN 
 | 
|  |     43 |                     auto_tac (fclaset,fsimpset)) i;
 | 
|  |     44 | 
 | 
|  |     45 | (*---------------------------------------------------------------  
 | 
|  |     46 |    solves goals of the form 
 | 
|  |     47 |     [| A1: FUF; A2: FUF; ...; An: FUF |] ==> P
 | 
|  |     48 |    where A1 Int A2 Int ... Int An <= {} since {} ~: FUF
 | 
|  |     49 |    (i.e. uses fact that FUF is a proper filter)
 | 
|  |     50 |  ---------------------------------------------------------------*)
 | 
|  |     51 | 
 | 
|  |     52 | val Fuf_empty_tac = METAHYPS(fn prems => 
 | 
|  |     53 |                     (rtac ((Intprems (get_fuf_hyps prems [])) RS
 | 
|  |     54 |                            (FreeUltrafilterNat_subset RS 
 | 
|  |     55 |                            (FreeUltrafilterNat_empty RS notE))) 1) 
 | 
|  |     56 |                      THEN Auto_tac);
 | 
|  |     57 | 
 | 
|  |     58 | fun fuf_empty_tac (fclaset,fsimpset) i = METAHYPS(fn prems => 
 | 
|  |     59 |                     (rtac ((Intprems (get_fuf_hyps prems [])) RS
 | 
|  |     60 |                            (FreeUltrafilterNat_subset RS 
 | 
|  |     61 |                           (FreeUltrafilterNat_empty RS notE))) 1) 
 | 
|  |     62 |                      THEN auto_tac (fclaset,fsimpset)) i;
 | 
|  |     63 | 
 | 
|  |     64 | (*---------------------------------------------------------------  
 | 
|  |     65 |   All in one -- not really needed.
 | 
|  |     66 |  ---------------------------------------------------------------*)
 | 
|  |     67 | 
 | 
|  |     68 | fun Fuf_auto_tac i = SOLVE (Fuf_empty_tac i) ORELSE TRY(Fuf_tac i);
 | 
|  |     69 | 
 | 
|  |     70 | fun fuf_auto_tac (fclaset,fsimpset) i = 
 | 
|  |     71 |      SOLVE (fuf_empty_tac (fclaset,fsimpset) i) 
 | 
|  |     72 |      ORELSE TRY(fuf_tac (fclaset,fsimpset) i);
 | 
|  |     73 | 
 | 
|  |     74 | (*---------------------------------------------------------------  
 | 
|  |     75 |    In fact could make this the only tactic: just need to
 | 
|  |     76 |    use contraposition and then look for empty set.
 | 
|  |     77 |  ---------------------------------------------------------------*)
 | 
|  |     78 | 
 | 
|  |     79 | fun Ultra_tac i = rtac ccontr i THEN Fuf_empty_tac i;
 | 
|  |     80 | fun ultra_tac (fclaset,fsimpset) i = rtac ccontr i THEN 
 | 
|  |     81 |               fuf_empty_tac (fclaset,fsimpset) i;
 | 
|  |     82 | 
 |