src/Pure/tctical.ML
changeset 30145 09817540ccae
parent 29272 fb3ccf499df5
child 31945 d5f186aa0bed
equal deleted inserted replaced
30144:56ae4893e8ae 30145:09817540ccae
   347   CSUBGOAL (fn (goal, i) => goalfun (Thm.term_of goal, i));
   347   CSUBGOAL (fn (goal, i) => goalfun (Thm.term_of goal, i));
   348 
   348 
   349 (*Returns all states that have changed in subgoal i, counted from the LAST
   349 (*Returns all states that have changed in subgoal i, counted from the LAST
   350   subgoal.  For stac, for example.*)
   350   subgoal.  For stac, for example.*)
   351 fun CHANGED_GOAL tac i st =
   351 fun CHANGED_GOAL tac i st =
   352     let val np = nprems_of st
   352     let val np = Thm.nprems_of st
   353         val d = np-i                 (*distance from END*)
   353         val d = np-i                 (*distance from END*)
   354         val t = List.nth(prems_of st, i-1)
   354         val t = Thm.term_of (Thm.cprem_of st i)
   355         fun diff st' =
   355         fun diff st' =
   356             nprems_of st' - d <= 0   (*the subgoal no longer exists*)
   356             Thm.nprems_of st' - d <= 0   (*the subgoal no longer exists*)
   357             orelse
   357             orelse
   358              not (Pattern.aeconv (t,
   358              not (Pattern.aeconv (t, Thm.term_of (Thm.cprem_of st' (Thm.nprems_of st' - d))))
   359                                   List.nth(prems_of st',
       
   360                                            nprems_of st' - d - 1)))
       
   361     in  Seq.filter diff (tac i st)  end
   359     in  Seq.filter diff (tac i st)  end
   362     handle Subscript => Seq.empty  (*no subgoal i*);
   360     handle Subscript => Seq.empty  (*no subgoal i*);
   363 
   361 
   364 fun (tac1 THEN_ALL_NEW tac2) i st =
   362 fun (tac1 THEN_ALL_NEW tac2) i st =
   365   st |> (tac1 i THEN (fn st' => Seq.INTERVAL tac2 i (i + nprems_of st' - nprems_of st) st'));
   363   st |> (tac1 i THEN (fn st' => Seq.INTERVAL tac2 i (i + nprems_of st' - nprems_of st) st'));