tidied
authorpaulson
Fri Dec 23 17:34:46 2005 +0100 (2005-12-23)
changeset 18508c5861e128a95
parent 18507 9b8b33098ced
child 18509 d2d96f12a1fc
tidied
src/HOL/Tools/meson.ML
src/HOL/Tools/polyhash.ML
src/HOL/Tools/res_atp_setup.ML
     1.1 --- a/src/HOL/Tools/meson.ML	Fri Dec 23 15:21:05 2005 +0100
     1.2 +++ b/src/HOL/Tools/meson.ML	Fri Dec 23 17:34:46 2005 +0100
     1.3 @@ -292,15 +292,6 @@
     1.4  (*Raises an exception if any Vars in the theorem mention type bool; they
     1.5    could cause make_horn to loop! Also rejects functions whose arguments are 
     1.6    Booleans or other functions.*)
     1.7 -fun check_is_fol th = 
     1.8 -  let val {prop,...} = rep_thm th
     1.9 -  in if exists (has_bool o fastype_of) (term_vars prop)  orelse
    1.10 -        not (Term.is_first_order ["all","All","Ex"] prop) orelse
    1.11 -        has_bool_arg_const prop  orelse  
    1.12 -        has_meta_conn prop
    1.13 -  then raise THM ("check_is_fol", 0, [th]) else th
    1.14 -  end;
    1.15 -
    1.16  fun check_is_fol_term term =
    1.17      if exists (has_bool o fastype_of) (term_vars term)  orelse
    1.18          not (Term.is_first_order ["all","All","Ex"] term) orelse
    1.19 @@ -308,6 +299,8 @@
    1.20          has_meta_conn term
    1.21      then raise TERM("check_is_fol_term",[term]) else term;
    1.22  
    1.23 +fun check_is_fol th = (check_is_fol_term (prop_of th); th);
    1.24 +
    1.25  
    1.26  (*Create a meta-level Horn clause*)
    1.27  fun make_horn crules th = make_horn crules (tryres(th,crules))
    1.28 @@ -356,10 +349,12 @@
    1.29  		  handle INSERT => true;
    1.30  
    1.31  (*Like TRYALL eq_assume_tac, but avoids expensive THEN calls*)
    1.32 -fun TRYALL_eq_assume_tac 0 st = Seq.single st
    1.33 -  | TRYALL_eq_assume_tac i st =
    1.34 -       TRYALL_eq_assume_tac (i-1) (eq_assumption i st)
    1.35 -       handle THM _ => TRYALL_eq_assume_tac (i-1) st;
    1.36 +fun TRYING_eq_assume_tac 0 st = Seq.single st
    1.37 +  | TRYING_eq_assume_tac i st =
    1.38 +       TRYING_eq_assume_tac (i-1) (eq_assumption i st)
    1.39 +       handle THM _ => TRYING_eq_assume_tac (i-1) st;
    1.40 +
    1.41 +fun TRYALL_eq_assume_tac st = TRYING_eq_assume_tac (nprems_of st) st;
    1.42  
    1.43  (*Loop checking: FAIL if trying to prove the same thing twice
    1.44    -- if *ANY* subgoal has repeated literals*)
    1.45 @@ -371,7 +366,7 @@
    1.46  (* net_resolve_tac actually made it slower... *)
    1.47  fun prolog_step_tac horns i =
    1.48      (assume_tac i APPEND resolve_tac horns i) THEN check_tac THEN
    1.49 -    TRYALL eq_assume_tac;
    1.50 +    TRYALL_eq_assume_tac;
    1.51  
    1.52  (*Sums the sizes of the subgoals, ignoring hypotheses (ancestors)*)
    1.53  fun addconcl(prem,sz) = size_of_term(Logic.strip_assums_concl prem) + sz
    1.54 @@ -458,7 +453,7 @@
    1.55  		      EVERY1 [skolemize_prems_tac negs,
    1.56  			      METAHYPS (cltac o make_clauses)]) 1,
    1.57              expand_defs_tac]) i st
    1.58 -  handle THM _ => no_tac st;	(*probably from check_is_fol*)		      
    1.59 +  handle TERM _ => no_tac st;	(*probably from check_is_fol*)		      
    1.60  
    1.61  (** Best-first search versions **)
    1.62  
    1.63 @@ -549,6 +544,7 @@
    1.64  (*Maps the clause  [P1,...Pn]==>False to [P1,...,P(i-1),P(i+1),...Pn] ==> ~P*)
    1.65  fun select_literal i cl = negate_head (make_last i cl);
    1.66  
    1.67 +
    1.68  (*Top-level Skolemization. Allows part of the conversion to clauses to be
    1.69    expressed as a tactic (or Isar method).  Each assumption of the selected 
    1.70    goal is converted to NNF and then its existential quantifiers are pulled
    1.71 @@ -556,8 +552,6 @@
    1.72    leaving !!-quantified variables. Perhaps Safe_tac should follow, but it
    1.73    might generate many subgoals.*)
    1.74  
    1.75 -
    1.76 -
    1.77  val skolemize_tac = 
    1.78    SUBGOAL
    1.79      (fn (prop,_) =>
    1.80 @@ -570,7 +564,6 @@
    1.81       end);
    1.82  
    1.83  
    1.84 -
    1.85  (*Top-level conversion to meta-level clauses. Each clause has  
    1.86    leading !!-bound universal variables, to express generality. To get 
    1.87    disjunctions instead of meta-clauses, remove "make_meta_clauses" below.*)
     2.1 --- a/src/HOL/Tools/polyhash.ML	Fri Dec 23 15:21:05 2005 +0100
     2.2 +++ b/src/HOL/Tools/polyhash.ML	Fri Dec 23 17:34:46 2005 +0100
     2.3 @@ -4,7 +4,7 @@
     2.4   * See file mosml/copyrght/copyrght.att for details.
     2.5   *
     2.6   * Original author: John Reppy, AT&T Bell Laboratories, Murray Hill, NJ 07974
     2.7 - * Current version largely by Joseph Hurd
     2.8 + * Current version from the Moscow ML distribution, copied by permission.
     2.9   *)
    2.10  
    2.11  (* Polyhash -- polymorphic hashtables as in the SML/NJ Library *)
    2.12 @@ -382,26 +382,13 @@
    2.13  	  end
    2.14  
    2.15     (*Added by lcp.
    2.16 -      This is essentially the hashpjw function described in Compilers:
    2.17 +      This is essentially the  described in Compilers:
    2.18        Principles, Techniques, and Tools, by Aho, Sethi and Ullman.*)
    2.19 - (*  local infix << >>
    2.20 -	 val left = Word.fromInt (Word.wordSize - 4)
    2.21 -	 val right = Word.fromInt (Word.wordSize - 8)
    2.22 -	 open Word
    2.23 -   in  
    2.24 -   val mask = 0wxf << left
    2.25 -   fun hashw (u,w) =
    2.26 -     let val w' = (w << 0w4) + u
    2.27 -	 val g = Word.andb(w', mask)  
    2.28 -     in  
    2.29 -	 if g <> 0w0 then Word.xorb(g, Word.xorb(w', g >> right))
    2.30 -	 else w'
    2.31 -     end;
    2.32 -   end;*)
    2.33  
    2.34 -   (*This version is also recommended by Aho et al. and does not trigger the Poly/ML bug*)
    2.35 -   val hmulti = Word.fromInt 65599;
    2.36 -   fun hashw (u,w) = Word.+ (u, Word.*(hmulti,w))
    2.37 +   (*This hash function is recommended in Compilers: Principles, Techniques, and
    2.38 +     Tools, by Aho, Sethi and Ullman. The hashpjw function, which they particularly
    2.39 +     recommend, triggers a bug in versions of Poly/ML up to 4.2.0.*)
    2.40 +   fun hashw (u,w) = Word.+ (u, Word.*(0w65599,w))
    2.41  
    2.42     fun hashw_char (c,w) = hashw (Word.fromInt (Char.ord c), w);
    2.43     
     3.1 --- a/src/HOL/Tools/res_atp_setup.ML	Fri Dec 23 15:21:05 2005 +0100
     3.2 +++ b/src/HOL/Tools/res_atp_setup.ML	Fri Dec 23 17:34:46 2005 +0100
     3.3 @@ -284,9 +284,8 @@
     3.4  
     3.5  fun cnf_hyps_thms ctxt = 
     3.6      let val ths = ProofContext.prems_of ctxt
     3.7 -	val prems = ResClause.union_all (map ResAxioms.cnf_axiom_aux ths)
     3.8      in
     3.9 -	prems
    3.10 +	ResClause.union_all (map ResAxioms.skolem_thm ths)
    3.11      end;
    3.12  
    3.13  (**** clausification ****)