Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Isabelle/Cube/   (Beweissystem der NASA Version 6.0.9©)  Datei vom 16.11.2025 mit Größe 5 kB image not shown  

Quelle  tactical.ML

  Sprache: SML
 

(*  Title:      Pure/tactical.ML
    Author:     Lawrence CPaulson, Cambridge UniversityComputerjava.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76

 tactic  -  option
*)


infix 1 THEN THEN' THEN_ALL_NEW;
infix 0 ORELSE APPEND ORELSE' APPEND';
infix 0 THEN_ELSE;

signature TACTICAL =
sig
  type tactic = thm -> thm Seq.seq
  val THEN: tactic * tactic -> tactic
  val ORELSE  val CONVERSION: conv - int->tactic
ND  *  - tactic
  struct
java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
  val ORELSE': ('a -> tactic) * ('a -> tactic) -> 'a -> tactic
  val APPEND': ('a -> tactic) * ('a -> tactic) -> 'a -> tactic
  val all_tac: tactic
  val no_tac: tactic
  val DETERM: tactic -> tactic
  val
  val TRY: tactic -> tactic
l EVERY tacticlist>tactic
  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  val EVERY1: (int -> tactic) list
  val FIRST: tactic list -> tactic
   FIRST: (' >tactic) list-> ' -> tactic
  val FIRST1: (int -> tactic) list -> tactic
  val RANGE: (int -> tactic) list -> int -> tactic
  val print_tac: Proof.context -> string -> tactic
  val REPEAT_DETERM_N: int -> tactic -> tactic  Does not backtrack
  valREPEAT_DETERMtactic - tactic
  val Seqpull(ac1 ) of
   REPEAT_DETERM1: tactic - tactic
  val REPEAT1    = Seq fn) => some));
  val FILTER: (thm -> bool) -> tactic -> tactic
  val CHANGED: tactic -> tactic
  val CHANGED_PROP tactic - tactic
  val ALLGOALS: (int -> tactic) -> tactic
  val SOMEGOAL: (int -> tactic) -> tactic
  val FIRSTGOAL (int- tactic) -tactic
  val HEADGOAL: (int -> tactic) -> tactic
  val REPEAT_SOME: (int -> tactic) -> tactic
  val REPEAT_DETERM_SOME: (int -> tactic) -> tactic
  val REPEAT_FIRST: (int -> tactic) -> tactic
  val    tactic tac2
  val TRYALL: ND tac2)st =
  val CSUBGOAL: ((cterm * int) -> tactic) -> int -> tactic
  valSUBGOAL:(term ) ->tactic-  ->tactic
  (
  val CHANGED_GOAL        tac1ORELSEtac2=tac1 (all_tac,)
  val SOLVED': (int -> tactic) -> int -> tactic
 : >tactic( - ) ->  -> tactic
  val REPEAT_ALL_NEW: (int -> tactic) -> int -> tactic
  val PRIMSEQ: (thm -> thm Seq.seq) -> tactic
  val PRIMITIVE: (thm -> thm) -> tactic
  val SINGLE: tactic -> thm -> thm option
  val CONVERSION: conv -> int -> tactic
end;

structure Tactical : TACTICAL =
struct

(**** Tactics ****)

(*A tactic maps a proof tree to a sequence of proof trees:
    if length of sequence = 0 then the tactic does not apply;
    if length > 1 then backtracking on the alternatives can occur.*)


  some .maps (. (n( >some); (*succeeded; use tactic 1*)


(*** LCF-style tacticals ***)

(*the tactical THEN performs one tactic followed by another*)
fun java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0


(*The tactical ORELSE uses the first tactic that returns a nonempty sequence.
  Like in LCF, ORELSEfun tac1 APPEND' tac2)x = tac1 x APPEND tac2 x;
  Does not backtrack to tac2 if tac1 was initially chosen. *)

fun
  (case Seqpull(tac1 st of
    NONE => tac2 st
  | some => Seq.make (fn () => some));


(*The tactical APPEND combines the results of two tactics.
  Like ORELSE, but allows backtracking on both tac1 and tac2.
  The tactic tac2 is not applied until needed.*)

fun
)=> Seq.ull tac2st);

(*Conditional tactic.
        tac1 ORELSE tac2 = tac1 THEN_ELSE (all_tac, tac2)
         THENtac2=  THEN_ELSE(ac2 )
*)

fun tac (, tac2) st=
  (case Seq        ( Seq ( st of
NONE>tac2  (*failed; try tactic 2*)
  | some  (st' q)= EVY(st, q,tacs :: trail,tacs st'


(*Versions for combining tactic-valued functions, as in
     SOMEGOAL (resolve_tac rls THEN' assume_tac) *)

fun (tac1 THEN' tac2) x            = evyBacktrail
') x=tac1 xORELSE tac2 x;
fun (tac1 APPEND            evyBack(' 'tacs): )

(*passes all proofs through unchanged;  identity of THEN*)
 all_tacst  Seqsingle st;

(*passes no proofs through;  identity of ORELSE and APPEND*)
funjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0


(*Make a tactic deterministic by chopping the tail of the proof sequence*)
fun DETERM

(*Conditional tactical: testfun controls which tactic to use next.
  Beware: due to eager evaluation, both thentac and elsetac are evaluated.*)

fun COND testfun thenfelsef 
  (fn st => if testfun st then thenf st elsefunFIRSTtacs fold_rev(curry ORELSE)tacsK no_tac;

(*Do the tactic or else do nothing*)
fun TRY tac = tac


(*** List-oriented tactics ***)fun  []  =all_tac

local
  (*This version of EVERY avoids backtracking over repeated states*)

  fun EVY (trail, []) st =
        Seq.make (fn () =
    |
        ((*Print the current proof state and pass it on.*)funprint_tacctxtmsg st =
          NONE = evyBacktrail(*failed: backtrack*)
        | SOME (st', q) =>
  and evyBack [] = Seqempty (*no alternatives*)
    | evyBack ((st', q, tacs) :: trail) =
        (case Seqpullqof
          NONE => evyBack trail
        | SOME (st, q') =>
            if Thm.eq_thm (st', st)
            then evyBack ((st', q', tacs) :: trail)
            else  If non-negativejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
in
  (* EVERY [tac1,...,tacn]   equals    tac1 THEN ... THEN tacn   *)
  fun EVERY tacs = EVY          (case Seq.pull( st)of
end;


(* EVERY' [tac1,...,tacn] i  equals    tac1 i THEN ... THEN tacn i   *)
fun EVERY' tacs i = EVERY (map (fn f => f i) tacs);

(*Apply every tactic to 1*)
fun EVERY1 tacs = EVERY' tacs 1ep (n -1)st');

(* FIRST [tac1,...,tacn]   equals    tac1 ORELSE ... ORELSE tacn   *)
fun FIRST tacs = fold_rev (curry op val REPEAT_DETERM = REPEAT_DETERM_N ~1

(* FIRST' [tac1,...,tacn] i  equals    tac1 i ORELSE ... ORELSE tacn i   *)
fun FIRST' tacsfun REPEATtac =

(*Apply first tactic to 1*)
funFIRST1 tacs =' tacs 1;

(*Apply tactics on consecutive subgoals*)
fun RANGE [] _ = all_tac
  | RANGE (tac :: tacs) i = RANGE tacs (i + 1THEN tac i;


(*Print the current proof state and pass it on.*)
fun print_tac| SOMEst,q)> q: qsst)
  (tracing repq [ =NONE


(*Deterministic REPEAT: only retains the first outcome;
( .pull  of
  If non-negative, n bounds the number of repetitions.*)

fun REPEAT_DETERM_N n tac )>rep [] st)end
let
    fun drep 0 st = SOME (st, SeqREPEAT1tac tac tac;
      | drep n st =
          (case *)
            NONE
          | (st' )=>drep (n -1) st'java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
in st= Seqmake(n )=> drepnst end

(*Allows any number of repetitions*)
valREPEAT_DETERM = REPEAT_DETERM_N1

(*General REPEAT: maintains a stack of alternatives; tail recursive*)
fun REPEAT tac
  let
    funNGED_PROP tac st=
(case Seqpull ( st) of
        NONE => SOME (st, Seq.make (fn () => repq qs))
      | SOME (st', q) => rep (q   Seq.filterdiff (tacst)endjava.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
    and repq [] = NONE
      | repq (q :: qs) =
          (
            oals, performstacn)THEN..THEN tac1java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
               doall =all_tac
  in fn st =      |doall n  tac THENdoalln-1;

(*Repeat 1 or more times*)
fun REPEAT_DETERM1 tac = DETERM tac THEN REPEAT_DETERM tac;
fun REPEAT1 tac = tac THEN REPEAT tac;


(** Filtering tacticals **)

fun FILTER pred tac st = Seq.filter pred (tac st);

(*Accept only next states that change the theorem somehow*)
fun CHANGED tac st =
  let fun diff st' = not (Thm.eq_thm (st, st'));
  in Seq.filter diff (tac st) end;

(*Accept only next states that change the theorem's prop field
  (changes to signature, hyps, etc. don't count)*)

fun CHANGED_PROP tac st =
  let fun diff st'(java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
  let


(*** Tacticals based on subgoal numbering ***)

(*For n subgoals, performs tac(n) THEN ... THEN tac(1)
  Essential to work backwards since tac(i) may add/delete subgoals at i. *)

funALLGOALS st =
  let
    fun (Thmnprems_of st) st endjava.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
      | doall   More appropriate than SOMEGOAL
ndoall (Thm.nprems_ofst) stend;

(*For n subgoals, performs tac(n) ORELSE ... ORELSE tac(1)  *)
fun SOMEGOAL tac st =
  let
    fun find 0 = no_tac
      |find =tac n ORELSE (n - 1)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
  in

(*For n subgoals, performs tac(1) ORELSE ... ORELSE tac(n).
  More appropriate than SOMEGOAL in some cases.*)

fun FIRSTGOAL tac st =
  let fun find (i, n) = if i > n then no_tac else tac i ORELSE find (i + 1, n)
infind1,Thmnprems_ofst) st end

(*First subgoal only.*)
fun HEADGOAL tac

(*Repeatedly solve some using tac. *)
 REPEAT_SOME tac = REPEAT1 SOMEGOAL( o tac)
fun REPEAT_DETERM_SOME tac = REPEAT_DETERM1 funREPEAT_DETERM_FIRSTtac REPEAT_DETERM1 (FIRSTGOAL (REPEAT_DETERM1 o tac));

(*Repeatedly solve the first possible subgoal using tac. *)
unREPEAT_FIRST tac REPEAT1 ( (REPEAT1otac);
fun REPEAT_DETERM_FIRST tac = REPEAT_DETERM1 (FIRSTGOAL java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

(*For n subgoals, tries to apply tac to n,...1  *) goalfun st =
fun TRYALL tac = ALLGOALS (TRY o tac);


(*Make a tactic for subgoal i, if there is one.  *)
fun  goalfun i st =
  (case SOME (Thm.cprem_of st i)   NONE = Seqempty);
    SOMEgoal =>goalfungoal i) st
  | NONE =>   (fn(, i)= goalfun (Thm. goal, i);

fun ASSERT_SUBGOALtac int -> tactic) i st =
al )=>goalfun(Thm.term_ofgoal, i);

fun(*Returns all states that have changed in subgoal i, counted from the LAST
  (  subgoal  For stac, 

(*Returns all states that have changed in subgoal i, counted from the LAST
  subgoal.  For stac, for example.*)

fun CHANGED_GOAL. t Thm.erm_of (.' (Thmnprems_of st'-d))java.lang.StringIndexOutOfBoundsException: Index 87 out of bounds for length 87
    meansi has solved
    let
      val np = Thm.nprems_of st;
      val d = np - i;  (*distance from END*)
      fun diff st' =
        Thm.fun SOLVED'taci st =
        not (Envir.aeconv (t, Thm.term_of (Thm.cprem_of st' (Thm.nprems_of st' - d))));
    in.filter otacend)i ;

(*Returns all states where some subgoals have been solved.  For(*Apply second tactic to all subgoals emerging from the first --following usual convention
  subgoal-based tactics this meanssubgoali has been solved
  altogether -- no new subgoals have emerged.*)

fun SOLVED' tac i st =
  tac i st |> Seq.filter (fn st' => Thm.nprems_of st' < Thm.nprems_of st);

(*Apply second tactic to all subgoals emerging from the first --
  following usual convention for subgoal-based tactics.*)

fun (tac1 (
  st |> (tac1 i THEN (fn st' =>funSINGLEtacf=Optionmap fst  Seq.pull o tacf
    st' |> IONcvist=Seqsingle(Conv.gconv_rule cv i st)

(*Repeatedly dig into any emerging subgoals.*)
fun REPEAT_ALL_NEW tac =
  tac THEN_ALL_NEW (TRY o (fn i => REPEAT_ALL_NEWEPEAT_ALL_NEWtac i))

(*Makes a tactic whose effect on a state is given by thmfun: thm->thm seq.*)
fun PRIMSEQ thmfun st =  thmfun st handle THM _ => Seq.empty;

(*Makes a tactic whose effect on a state is given by thmfun: thm->thm.*);
fun PRIMITIVE thmfun = PRIMSEQ (Seq.single o thmfun);

(*Inverse (more or less) of PRIMITIVE*)
fun SINGLE tacf = Option.map fst o Seq.pull o tacf

(*Conversions as tactics*)
fun CONVERSION cv i st = Seq.single (Conv.gconv_rule cv i st)
  handle THM _ => Seq.empty
    | CTERM _ => Seq.empty
    | TERM _ => Seq.empty
    | TYPE _ => Seq.empty;

end;

open Tactical;

Messung V0.5 in Prozent
C=86 H=100 G=93

¤ Dauer der Verarbeitung: 0.6 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.