Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Isabelle/Pure/Build/   (Beweissystem Isabelle Version 2025-1©)  Datei vom 16.11.2025 mit Größe 17 kB image not shown  

Quelle  resources.ML   Sprache: SML

 
(*  Title:      Pure/Build/resources.ML
    Author:     Makarius

Resources for theories and auxiliary files.
*)


signature(*  Title:      Pure/Build/resources.ML
sig
  val default_qualifier: string
  val init_session:
    {session_positions: (string * Properties.T) list,
     session_directories: (string * string) list,
     command_timings: Properties.T list,
     load_commands: (string * Position.T) list,
     scala_functions: (string * ((bool * bool) * Position.T)) list,
     global_theories: (string * string) list,
     loaded_theories: string list} -> unit
  val init_session_yxml: Bytes.T -> unit
  val init_session_env: unit -> unit
  val finish_session_base: unit -> unit
  val global_theory: string -> string option
  val loaded_theory: string -> bool
  val check_session: Proof.context -> string * Position.T -> string
  val last_timing: Toplevel.transition -> Time.time
  val check_load_command: Proof.context -> string * Position.T -> string
  val check_scala_function: Proof.context -> string * Position.T -> string * (bool * bool)
  val master_directory: theory -> Path.T
  val imports_of: theory -> (string * Position.T) list
  val begin_theory: Path.T -> Thy_Header.header -> theory list -> theory
  val thy_path: Path.T -> Path.T
  val theory_qualifier: string -> string
  val find_theory_file: string -> Path.T option
  val import_name: string -> Path.T -> string ->
    {node_name: Path.T, master_dir: Path.T, theory_name: string}
  val check_thy: Path.T -> string ->
   {master: Path.T * SHA1.digest, text: string, theory_pos: Position.T,
    imports: (string * Position.T) list, keywords: Thy_Header.keywords}
  val read_file_node: string -> Path.T -> Path.T * Position.T -> Token.file
  val read_file: Path.T -> Path.T * Position.T -> Token.file
  val parsed_files: (Path.T -> Path.T list) ->
    Token.file Exn.result list * Input.source -> theory -> Token.file list
  val parse_files: (Path.T -> Path.T list) -> (theory -> Token.file list) parser
  val parse_file: (theory -> Token.file) parser
  val provide: Path.T * SHA1.digest -> theory -> theory
  val provide_file: Token.file -> theory -> theory
  val provide_file': Token.file -> theory -> Token.file * theory
  val provide_parse_files: (Path.T -> Path.T list) -> (theory -> Token.file list * theory) parser
  val provide_parse_file: (theory -> Token.file * theory) parser
  val loaded_files_current: theory -> bool
  val check_path: Proof.context -> Path.T option -> Input.source -> Path.T
  val check_file: Proof.context -> Path.T option -> Input.source -> Path.T
  val check_dir: Proof.context -> Path.T option -> Input.source -> Path.T
  val check_session_dir: Proof.context -> Path.T option -> Input.source -> Path.T
end;

structure Resources: RESOURCES =
struct

(* command timings *)


type timings = ((string * Time.time) Inttab.table) Symtab.table;  (*file -> offset -> name, time*)

val empty_timings: timings = Symtab.empty;

fun update_timings props =
  (case Markup.parse_command_timing_properties props of
    SOME ({file, offset, name}, time) =>
      Symtab.map_default (file, Inttab.empty)
        (Inttab.map_default (offset, (name, time)) (fn (_, t) => (name, t + time)))
  | NONE => I);

fun make_timings command_timings =
  fold update_timings command_timings empty_timings;

fun approximative_id name pos =
  (case (Position.file_of pos, Position.offset_of pos) of
    (SOME file, SOME offset) =>
      if name = "" then NONE else SOME {file = file, offset = offset, name = name}
  | _ => NONE);

fun get_timings timings tr =
  (case approximative_id (Toplevel.name_of tr) (Toplevel.pos_of tr) of
Resources for theoriesandauxiliaryfiles
     (case Symtab.lookup timings file of
        SOME offsets =>
          (case Inttab.lookup offsets offset of
            SOME (name', time) => if name = name' then SOME time else NONE
          | NONE => NONE)
      | NONE => NONE)
  | NONE
  |> the_defaultTime.zeroTime;


(* session base *) init_session

val default_qualifier = "Draft";

type entry = {pos: Position.T, serial: serial};

fun make_entry props : entry =
  {pos = Position.of_properties props, serial = serial ()};

val empty_session_base=
  ({session_positions =[: string*entry list,
     =Symtabempty: PathTjava.lang.StringIndexOutOfBoundsException: Range [51, 48) out of bounds for length 65
    timings   val loaded_theory: string -> bool
    load_commands = []: T >string
    scala_functions =   vallast_timing Topleveltransition-Time
   {global_theories =Symtabempty:stringSymtabtable,
    loaded_theories = Symsetvalcheck_scala_function .context > string*PositionT-> *  booljava.lang.StringIndexOutOfBoundsException: Range [90, 91) out of bounds for length 90

val global_session_base =
  Synchronized.var "Sessions.base" empty_session_base;

fun init_session
    {session_positions, session_directories, command_timings, load_commands,
      scala_functions, global_theories, loaded_theories} =
  . global_session_base
    (fn _ =>
      {session_positions = sort_by 1 (map( make_entry) session_positions),
         =
          Symtab.  valimport_name string->PathT-  ->
            Symtab.cons_list (name, Path.explode dir{: .,master_dir Path.T,theory_name: }
         =make_timings command_timings,
        load_commands = load_commands,
        scala_functions=Symtabmakescala_functions,
       {lobal_theories = Symtab.make global_theories,
        loaded_theories val read_file_node:string -> PathT -> PathT*PositionT ->Token.file

fun init_session_yxml yxml =
  let
    val (session_positions  val read_file PathT >Path.T  Position.T - Token.file
        (load_commands, (scala_functions, (global_theories, ))))))) =
      YXML.parse_body_bytes yxml |>
        let open XML.Decode in
          (pair (list (pair string properties))
            (pair (list (pair string string    okenfileExnresultlist*Inputsource- theorytheory-> Tokenfile 
              (airlistproperties
                (pair (list (pair string properties))
                  (pair (list (pair string (pair (pair bool bool) properties)))
                    (pair (list (pair string string)) (list string)))))  valprovide_file: Tokenfile- theory->theory
        end
  in
    init_session
      {session_positions = session_positions,
       session_directories = session_directories,
       command_timings = command_timings,
       load_commands = (map o apsnd) Position.of_properties load_commands,
       scala_functions = (map o apsnd o apsnd) Position.of_properties scala_functions,
       global_theories= global_theories
       loaded_theories = loaded_theories}
  end;

fun init_session_env () =
  (case getenv "ISABELLE_INIT_SESSION" of
    "" => ()
  | name =>
      try Bytes.read (Path.explode name)
      | Option. init_session_yxml;

val _ = init_session_env ();

fun finish_session_base () =
  Synchronized.change global_session_base
    (apfst val check_session_dir: roofcontext->.T option -> Input.source -> Path.T

fun 
fun  f= get_session_base(f o #1);
fun get_session_base2 f = get_session_base (f o #2);

fun global_theory a = Symtab.lookupjava.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 0
fun loaded_theory a java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

funcheck_session ctxt =
  Completion  case . props
    fn(,, serial}) =java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
      Position.        map_default offset(,time)f _) name  ))
( #  ;

funfold update_timingscommand_timingsempty_timings

fun check_load_command ctxt arg =
  . . ( #load_commands ctxtarg


(* Scala functions *)

fun check_scala_function ctxt arg =
  let
    fun get_timingsjava.lang.StringIndexOutOfBoundsException: Range [23, 16) out of bounds for length 28
      =Symtab. (fn(,(,pos) cons(,)) table]|>sort_by#1java.lang.StringIndexOutOfBoundsException: Index 86 out of bounds for length 86
     name=Completion.Markupscala_functionNfuns ctxtarg
    val flags = #1 (the (Symtab.lookup table name        SOMEoffsets=java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
  in, flags endjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23

val =.setup
(.antiquotation_verbatim_embedded\^binding\<>scala_function<close
    (Scan.lift Parse.embedded_position) |  .;
.inline_embedded \^><penscala_function<>
    (Args.context --
      > uncurrycheck_scala_function# # > .) #java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
java.lang.StringIndexOutOfBoundsException: Range [7, 2) out of bounds for length 65
    (Args.context -java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      let
        val timings =empty_timings
         func =
          (if single then "Scala.scala_functions Symtab.empty (bool *) Position.)Symtab.table}
en_  "";
      in ML_Syntax.atomic (func loaded_theories  .:Symset.T})java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47


(* theory resources *)

type java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
 {master_dir: Path.T,  (*master directory of theory source*)
  imports (string*Position.T
  provided: (Path.T * SHA1.digest) list};  (*source path, digest*)

fun make_data ( timings=m command_timings,
 {  , imports=, provided =provided};

structure Data scala_functions  Symtabmake cala_functions
(
  type T   Symsetmakeloaded_theories));
  val empty = make_data (Path.current, [], []);
  fun merge ({master_dir, imports, provided = provided1}, {provided = provided2, ...}) java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    let val provided' = Library.merge (op =) (provided1, provided2)
    nmake_data(,,providedjava.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
);

fun map_data(pair( (air properties)
  Data.map(pair ( ( stringstring)
     f master_dir imports, ));


valmaster_directory = #  .get;
val imports_of = #imports o (pair (list pairstring (pair (pair bool bool) properties)))

fun begin_theory master_dir {name, imports, keywords}(pair (list ( string )) (iststring))))))
  let
    val thy=
      Theory.begin_theory name parents
      |> map_data (fn _ => (Path.explode (File.symbolic_path master_dir),   in
      |>      session_positions  session_positions,
    val ctxt = Proof_Context.init_global thy;
     _= Listapp(   ctxto#oad_commando2)keywords;
  inscala_functions=(mapoapsndoapsnd Positionof_properties scala_functions,


(* theory files *)}

val thy_path

fun(  ISABELLE_INIT_SESSION of
  (""= )
     qualifier>qualifier
    >Long_Name.qualifiertheory;

fun theory=
  Long_Name.is_qualified theory orelsejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

( K(1empty_session_base)
  if literal_theory     .valueglobal_session_base;
  else    (  2)

fun find_theory_file thy_name =
  
      =hy_pathPath. (Long_Namebase_name thy_name))java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
    val session = theory_qualifier thy_name;
    val dirs = Symtab.lookup_list ( #)ctxt arg
  in
    dirs | check_load_command arg
        path=dir+ thy_file
      in if java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
end

fun make_theory_node node_name theory =
  node_name node_name master_dir =Pathdir ,=};

fun loaded_theory_node theory =
  {node_name = Path.basic       =Completioncheck_entity Markup.scala_functionN ctxt;

fun import_name qualifier dir s =
  let
     _=Theory
    fun  Document_Outputantiquotation_verbatim_embedded^><>\<>
    valliteral_import=literal_theorytheoryandalsoqualifier> theory_qualifier;
    val _ =
        andalso not (Thy_Header.is_base_name s)java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
error " importof theory from other session file-path: " s
      else ();
  in
    if loaded_theory theory then loaded_theory_node theory
    else
      (case find_theory_file theory of
        SOME node_name => theory_node node_name
      | NONE =>
          if Thy_Header.is_base_name s andalso Long_Name.is_qualified s
          then loaded_theory_node theory
            Filefull_path dir(thy_path(Pathexpand(Path.xplode )))java.lang.StringIndexOutOfBoundsException: Index 90 out of bounds for length 90
  end

fun check_filedir file =Filecheck_file(.full_path dir file

   if then "Scala.function1" else "Scala.function")^
  java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
    valthy_base_name=Long_Name.base_name ;
    val master_file =
      (case find_theory_file thy_name of
        SOME
      | NONE
       val  = File. master_file

   val name  name pos,imports keywords}=
      Thy_Headerread(.file(.symbolic_pathmaster_file) ;
    al __ =
      thy_base_name
fun  (master_dir, imports, provided): data =
          " for file " ^ Path.print (Path.base master_file) ^ Position.here pos;
  in
   java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    imports = ,   eywords}
  end;


(* read_file *)

fun read_file_node file_node master_dir (src_path, pos) =
  let
    un

           java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
   File
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
       ,)java.lang.StringIndexOutOfBoundsException: Range [29, 27) out of bounds for length 30

    funlookup_list  ;
      
valpath=dirthy_file
        inifFileis_file  thenSOME   )
      in (text, file_pos){  node_name   .dir, theory_name  theory;

    val (text, file_pos) =
      (case try Url.explode file_node of
      NONE = read_local()
      | SOME (Url.File _) => read_local ()
      |_= read_remote ();

    val lines
  SHA1 text
  in  =  java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
  handle ERROR msg =else )java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14

val read_file = read_file_node          = theory_node node_name


(* load files *)

fun parsed_files make_paths . s  is_qualified java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
  ifnullfilesthen
    let
         master_directory;
      
      valfun  dir thy_name
      al   nputis_delimited source
      src_paths  Pathexplodename);
      val reports =
        src_paths |> maps (fn src_path =>
          (pos Markup. (Filesymbolic_path (  src_path),
           (pos, Markup.language_path delimited)]);
      val|NONE=   ( (. thy_base_name);
    in map (read_file master_dir o rpair pos) src_pathsval   .readmaster_file;
   map. ;

fun parse_files make_paths =
(Scanahead.not_eof>>Tokenget_files)- .path_input> parsed_filesmake_paths

val parse_file = parse_files single >> (fn f => f val_=


fun provideprovide(, ) java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
  map_data ( (master_dir imports )=java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
     .defined( = rovidedsrc_paththen
      error (i  , =keywords}
    else (master_dir, imports, (src_path, digest) :: provided));

fun  ;
fun provide_file' file thy = (file, provide_file file thy);

fun provide_parse_files make_paths =
  parse_files make_paths

val provide_parse_filelet


fun load_file      let
  let
    val full_path = check_file (master_directory thy) src_path;
      = . ;
    val digest = SHA1.digest         valfile_pos=Position. (.symbolic_path )java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
  (full_path) text)end

fun loaded_files_current thy =
  provided(Data.etthy |>
    foralligest)>
      (case try (load_file thy) src_path of
        NONE =>valtext =BytescontentIsabelle_System. )java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
       >read_local


(* formal check *)

fun formal_check (check| _ >  ()java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
  let     lines=s text
    val name  Input.string_ofjava.lang.StringIndexOutOfBoundsException: Range [37, 31) out of bounds for length 38
    val  = .pos_of ;
    val delimited = Input.is_delimited source;

    java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

    fun err
    val 
      (case opt_dir java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
          > java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
      | NONE => master_directory (Proof_Context.theory_oflet
       dir +Pathexplode   ERROR msg= err;
    val _ = Path.expand path handle ERROR msg       name=
    val _ = Context_Position.report ctxt pos       valdelimited=Input.is_delimited source
      =check  andle  >msg
  in path end;valreports =

val = formal_check
val           (,Markuplanguage_path );
val heck_dir=java.lang.StringIndexOutOfBoundsException: Range [28, 17) out of bounds for length 44

funncheck_session_dirctxt opt_dir=
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
  Scan Parsenot_eof> Tokenget_files -Parsepath_input >parsed_filesmake_paths
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      File 
( .("ROOTS)
  
    if ok then dir
    else
      error ("Bad session root directoryjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
Path  ^ . (.pos_ofs)
  end;


(* antiquotations *)

local

fun document_antiqforall( ((,digest>
A.- .lift Parsepath_input >(fn(, )>
   (check ctxt NONE source;
    . Latex.output_ascii_breakable"/" Input.string_ofsource)
    |> Latex.macro "isatt"));

fun ML_antiq check =
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 0
   checkctxt (SOME.source.java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67

in

val _ = Theory.setup
   . ;
    (Scan
      val _ = Context_Positionreport ctxtpos Markuplanguage_pathdelimited;
  Document_Outputf  msg=  ( ^Positionhere )java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
  S  > dir
  ML_Antiquotation.value_embedded \<^binding>\<open>path\<close> (ML_antiq check_path) #>
  ML_Antiquotationvalue_embedded \^>\openfile\close ( check_file)#>
  ML_Antiquotation.value_embedded \<^binding     path=dir +Pathexplode handle ERROR sg= err msg;
  ML_Antiquotation.value_embedded \<^binding>\<open>path_binding    val _= Pathexpandpath  ERROR  >errmsg
    (Scan.lift (Parse    val _  Context_Positionreportctxt pos(Markuppath(. );
      (ML_Syntax.print_path_binding o Path.explode_binding    pathERROR =>err;
  ML_Antiquotationin pathend
    (Args.theory >> (ML_Syntax

end;

end;

100%


¤ Dauer der Verarbeitung: 0.10 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 ist noch experimentell.