[isabelle-dev] Resolve with premises

2013-01-18 Thread Peter Lammich
Hi all,

as the question currently arose on the users list, I remembered that I
have the following method laying around since several month. I'm using
it frequently in apply-style scripts (Mainly to apply induction
hypotheses).

We discussed here in Munich whether we should add it to Isabelle. Should
we? Opinions?

Peter


---

ML {*
  (* Resolve with premises. Copied and adjusted from
Goal.assume_rule_tac. *)
fun rprems_tac ctxt = Goal.norm_hhf_tac THEN' CSUBGOAL (fn (goal, i)
=
  let
fun non_atomic (Const (==, _) $ _ $ _) = true
  | non_atomic (Const (all, _) $ _) = true
  | non_atomic _ = false;

val ((_, goal'), ctxt') = Variable.focus_cterm goal ctxt;
val goal'' = Drule.cterm_rule 
  (singleton (Variable.export ctxt' ctxt)) goal';
val Rs = filter (non_atomic o Thm.term_of) 
  (Drule.strip_imp_prems goal'');

val ethms = Rs | map (fn R =
  (Raw_Simplifier.norm_hhf (Thm.trivial R)));
  in eresolve_tac ethms i end
  );

(* Resolve with premise. Copied and adjusted from
Goal.assume_rule_tac. *)
fun rprem_tac n ctxt = Goal.norm_hhf_tac THEN' CSUBGOAL (fn (goal,
i) =
  let
val ((_, goal'), ctxt') = Variable.focus_cterm goal ctxt;
val goal'' = Drule.cterm_rule 
  (singleton (Variable.export ctxt' ctxt)) goal';

val R = nth (Drule.strip_imp_prems goal'') (n - 1)
val rl = Raw_Simplifier.norm_hhf (Thm.trivial R)
  in
etac rl i
  end
  );

  val setup =
  Method.setup @{binding rprems} 
(Scan.lift (Scan.option Parse.nat)  (fn i = fn ctxt = 
  SIMPLE_METHOD' (
case i of
  NONE = rprems_tac ctxt
| SOME i = rprem_tac i ctxt
  ))
) 
Resolve with premises



*}

setup setup


(* EXAMPLES: *)


lemma \lbrakk A\LongrightarrowB; B\LongrightarrowC; A \rbrakk
\Longrightarrow C
  apply (rprems 2) -- Explicitely specify number of premise
  apply (rprems 1)
  .

lemma \lbrakk A\LongrightarrowB; B\LongrightarrowC; A \rbrakk
\Longrightarrow C
  apply (rprems) -- Resolve with any matching premise, 
first to last, backtracking
  apply (rprems)
  .

--


___
isabelle-dev mailing list
isabelle-...@in.tum.de
https://mailmanbroy.informatik.tu-muenchen.de/mailman/listinfo/isabelle-dev


[isabelle-dev] Metis: Unused Theorem Reduces Run-Time?

2013-01-18 Thread Tjark Weber
Hi,

The new AFP entry on Kleene Algebras contains a metis call
(http://afp.hg.sourceforge.net/hgweb/afp/afp/file/082b389cb3f8/thys/Kleene_Algebra/Kleene_Algebra.thy#l652)
that generates a warning about an unused theorem local.opp_mult_def.
Not passing opp_mult_def as an argument to metis gets rid of the
warning, but increases run-time of this metis call from ~ 1 s to ~ 15 s
on my machine.

Best regards,
Tjark


___
isabelle-dev mailing list
isabelle-...@in.tum.de
https://mailmanbroy.informatik.tu-muenchen.de/mailman/listinfo/isabelle-dev


Re: [isabelle-dev] Metis: Unused Theorem Reduces Run-Time?

2013-01-18 Thread Jasmin Christian Blanchette
Hi Tjark,

Am 18.01.2013 um 16:44 schrieb Tjark Weber:

 The new AFP entry on Kleene Algebras contains a metis call
 (http://afp.hg.sourceforge.net/hgweb/afp/afp/file/082b389cb3f8/thys/Kleene_Algebra/Kleene_Algebra.thy#l652)
 that generates a warning about an unused theorem local.opp_mult_def.
 Not passing opp_mult_def as an argument to metis gets rid of the
 warning, but increases run-time of this metis call from ~ 1 s to ~ 15 s
 on my machine.

Sure, these things happen with pretty much any tool that performs a heuristic 
search. There are even (rare) cases where taking out the unused theorems will 
lead to an unprovable first-order problem (because of incompletenesses in the 
translation of HO constructs).

What's your concrete suggestion here?

Cheers,

Jasmin

___
isabelle-dev mailing list
isabelle-...@in.tum.de
https://mailmanbroy.informatik.tu-muenchen.de/mailman/listinfo/isabelle-dev