src/Pure/goal.ML
changeset 23414 927203ad4b3a
parent 23356 dbe3731241c3
child 23418 c195f6f13769
     1.1 --- a/src/Pure/goal.ML	Sun Jun 17 18:47:03 2007 +0200
     1.2 +++ b/src/Pure/goal.ML	Mon Jun 18 23:30:46 2007 +0200
     1.3 @@ -8,8 +8,8 @@
     1.4  signature BASIC_GOAL =
     1.5  sig
     1.6    val SELECT_GOAL: tactic -> int -> tactic
     1.7 +  val PRECISE_CONJUNCTS: int -> tactic -> int -> tactic
     1.8    val CONJUNCTS: tactic -> int -> tactic
     1.9 -  val PRECISE_CONJUNCTS: int -> tactic -> int -> tactic
    1.10  end;
    1.11  
    1.12  signature GOAL =
    1.13 @@ -29,8 +29,8 @@
    1.14    val prove_global: theory -> string list -> term list -> term -> (thm list -> tactic) -> thm
    1.15    val extract: int -> int -> thm -> thm Seq.seq
    1.16    val retrofit: int -> int -> thm -> thm -> thm Seq.seq
    1.17 +  val precise_conjunction_tac: int -> int -> tactic
    1.18    val conjunction_tac: int -> tactic
    1.19 -  val precise_conjunction_tac: int -> int -> tactic
    1.20    val asm_rewrite_goal_tac: bool * bool * bool -> (simpset -> tactic) -> simpset -> int -> tactic
    1.21    val rewrite_goal_tac: thm list -> int -> tactic
    1.22    val norm_hhf_tac: int -> tactic
    1.23 @@ -180,28 +180,48 @@
    1.24  
    1.25  (* multiple goals *)
    1.26  
    1.27 -val conj_tac = SUBGOAL (fn (goal, i) =>
    1.28 -  if can Logic.dest_conjunction goal then rtac Conjunction.conjunctionI i
    1.29 -  else no_tac);
    1.30 +local
    1.31  
    1.32 -val conjunction_tac = TRY o REPEAT_ALL_NEW conj_tac;
    1.33 +fun conj_intrs n =
    1.34 +  let
    1.35 +    val cert = Thm.cterm_of ProtoPure.thy;
    1.36 +    val names = Name.invents Name.context "A" n;
    1.37 +    val As = map (fn name => cert (Free (name, propT))) names;
    1.38 +  in
    1.39 +    Thm.generalize ([], names) 0
    1.40 +      (Drule.implies_intr_list As (Conjunction.intr_list (map Thm.assume As)))
    1.41 +  end;
    1.42 +
    1.43 +fun count_conjs A =
    1.44 +  (case try Logic.dest_conjunction A of
    1.45 +    NONE => 1
    1.46 +  | SOME (_, B) => count_conjs B + 1);
    1.47 +
    1.48 +in
    1.49  
    1.50  val precise_conjunction_tac =
    1.51    let
    1.52      fun tac 0 i = eq_assume_tac i
    1.53        | tac 1 i = SUBGOAL (K all_tac) i
    1.54 -      | tac n i = conj_tac i THEN TRY (fn st => tac (n - 1) (i + 1) st);
    1.55 +      | tac 2 i = rtac Conjunction.conjunctionI i
    1.56 +      | tac n i = rtac (conj_intrs n) i;
    1.57    in TRY oo tac end;
    1.58  
    1.59 +val conjunction_tac = TRY o REPEAT_ALL_NEW (SUBGOAL (fn (goal, i) =>
    1.60 +  let val n = count_conjs goal
    1.61 +  in if n < 2 then no_tac else precise_conjunction_tac n i end));
    1.62 +
    1.63 +fun PRECISE_CONJUNCTS n tac =
    1.64 +  SELECT_GOAL (precise_conjunction_tac n 1
    1.65 +    THEN tac
    1.66 +    THEN PRIMITIVE (Conjunction.uncurry ~1));
    1.67 +
    1.68  fun CONJUNCTS tac =
    1.69    SELECT_GOAL (conjunction_tac 1
    1.70      THEN tac
    1.71      THEN PRIMITIVE (Conjunction.uncurry ~1));
    1.72  
    1.73 -fun PRECISE_CONJUNCTS n tac =
    1.74 -  SELECT_GOAL (precise_conjunction_tac n 1
    1.75 -    THEN tac
    1.76 -    THEN PRIMITIVE (Conjunction.uncurry ~1));
    1.77 +end;
    1.78  
    1.79  
    1.80  (* rewriting *)