src/HOL/Tools/res_clause.ML
changeset 21470 7c1b59ddcd56
parent 21432 625797c592b2
child 21509 6c5755ad9cae
equal deleted inserted replaced
21469:1e45e9ef327e 21470:7c1b59ddcd56
   415 	  val (vss,fss) = add_typs_aux tss
   415 	  val (vss,fss) = add_typs_aux tss
   416       in
   416       in
   417 	  (vss, fs union fss)
   417 	  (vss, fs union fss)
   418       end;
   418       end;
   419 
   419 
   420 (** Too general means, positive equality literal with a variable X as one operand,
       
   421   when X does not occur properly in the other operand. This rules out clearly
       
   422   inconsistent clauses such as V=a|V=b, though it by no means guarantees soundness. **)
       
   423 
       
   424 fun occurs a (UVar(b,_)) = a=b
       
   425   | occurs a (Fun (_,_,ts)) = exists (occurs a) ts
       
   426 
       
   427 (*Is the first operand a variable that does not properly occur in the second operand?*)
       
   428 fun too_general_terms (UVar _, UVar _) = false
       
   429   | too_general_terms (Fun _, _) = false
       
   430   | too_general_terms (UVar (a,_), t) = not (occurs a t);
       
   431 
       
   432 fun too_general_lit (Literal (true, Predicate("equal",_,[x,y]))) =
       
   433       too_general_terms (x,y) orelse too_general_terms(y,x)
       
   434   | too_general_lit _ = false;
       
   435 
       
   436 
       
   437 
   420 
   438 (** make axiom and conjecture clauses. **)
   421 (** make axiom and conjecture clauses. **)
   439 
   422 
   440 exception MAKE_CLAUSE;
   423 exception MAKE_CLAUSE;
   441 fun make_clause (clause_id, axiom_name, th, kind) =
   424 fun make_clause (clause_id, axiom_name, th, kind) =
   442   let val term = prop_of th
   425   let val (lits,types_sorts) = literals_of_term (prop_of th)
   443       val (lits,types_sorts) = literals_of_term term
       
   444   in if forall isFalse lits 
   426   in if forall isFalse lits 
   445      then error "Problem too trivial for resolution (empty clause)"
   427      then error "Problem too trivial for resolution (empty clause)"
   446      else if kind=Axiom andalso forall too_general_lit lits 
       
   447      then (Output.debug ("Omitting " ^ axiom_name ^ ": equalities are too general"); 
       
   448            raise MAKE_CLAUSE)
       
   449      else Clause {clause_id = clause_id, axiom_name = axiom_name, th = th, 
   428      else Clause {clause_id = clause_id, axiom_name = axiom_name, th = th, 
   450                   kind = kind, literals = lits, types_sorts = types_sorts}
   429                   kind = kind, literals = lits, types_sorts = types_sorts}
   451   end;		     
   430   end;		     
   452 
   431 
   453 fun get_tvar_strs [] = []
   432 fun get_tvar_strs [] = []