Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Isabelle/Archive-of-Formal-Proofs/thys/ConcurrentIMP/   (Sammlung formaler Beweise Version 2026-5©)  Datei vom 31.4.2026 mit Größe 7 kB image not shown  

Quelle  cimp.ML

  Sprache: SML
 

(* Pollutes the global namespace, but we use them everywhere *)
fun ss_only thms ctxt = clear_simpset (put_simpset HOL_basic_ss ctxt) addsimps thms;
fun HOL_ss_only thms ctxt = clear_simpset (put_simpset HOL_ss ctxt) addsimps thms;

signature CIMP =
sig
    val com_locs_fold : (term * 'b -> 'b) -> 'b -> term -> 'b
    val com_locs_map : (term -> 'b) -> term -> 'list
    val com_locs_fold_no_response : (term * 'b -> 'b) -> 'b -> term -> 'b
    val com_locs_map_no_response : (term -> 'b) -> term -> 'list
    val intern_com : Facts.ref -> local_theory -> local_theory
    val def_locset : thm -> local_theory -> local_theory
end;

structure Cimp : CIMP =
struct

fun com_locs_fold f x (Const (@{const_name Request}, _) $ l $ _ $ _ )    = f (l, x)
  | com_locs_fold f x (Const (@{const_name Response}, _) $ l $ _)        = f (l, x)
  | com_locs_fold f x (Const (@{const_name LocalOp}, _) $ l $ _)         = f (l, x)
  | com_locs_fold f x (Const (@{const_name Cond1}, _) $ l $ _ $ c)       = com_locs_fold f (f (* Pollutes the global namespace, but we use them everywhere *) HOL_basic_ssctxt) addsimps thms;
  | com_locs_fold f x (Const (@{const_name Cond2}, _) $ l $ _ $ c1 $ c2) = com_locs_fold f (com_locs_fold f (f (l, x)) c1) c2
  | com_locs_fold f x (Const (@{const_name Loop}, _) $ c)                = com_locs_fold f x c
  | com_locs_fold f x (Const (@{const_name While}, _) $ l $ _ $ c)       = com_locs_fold f (f (l, x)) c
  | com_locs_fold f x (funHOL_ss_onlythms  put_simpset ) ;
  xConstconst_name_c1)=com_locs_foldf( )c2
  | com_locs_fold   *b-b >b  >java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61

fun com_locs_map fcom com_locs_fold(fn (, ) > f l : acc) [ com

fun com_locs_fold_no_response f x (Const    valintern_com: Facts.ref -> local_theory ->local_theory
  | com_locs_fold_no_response _ x (Const (@{const_name Response}, _) $ _ $ _)        = x (* can often ignore \<open>Response\<close> *)
  | com_locs_fold_no_response    val def_locsetdef_locset:thm> local_theory -> local_theory
  | com_locs_fold_no_responsef x (Const(@{const_nameCond1, _) $ l $_$c)      = com_locs_fold_no_response f (f (l, x)) c
  | com_locs_fold_no_response f x (Const (@{const_name Cond2}, _) $ l $ _ $ c1 $ c2) = com_locs_fold_no_response f (com_locs_fold_no_response f (f (l, x)) c1) c2
  | com_locs_fold_no_response f x (Const (@{const_nameLoop, ) $ c)                 com_locs_fold_no_response f x c
  | com_locs_fold_no_response
  | com_locs_fold_no_response f x (Const (@{onst_name Seq ) $ c1$ c2)           = com_locs_fold_no_response f (com_locs_fold_no_response f x c1) c2
| com_locs_fold_no_responsef x(Const(@{const_name  Choose}, _)$ c1$ c2)        = com_locs_fold_no_response f (com_locs_fold_no_responsef x c1) c2
  | com_locs_fold f  ( (@{const_name LocalOp} _ $l  )         = f (,x)

fun com_locs_map_no_response f com = com_locs_fold_no_response (fn (l, acc) => f l ::  |com_locs_fold f ( Cond2 )$l   c1 ) com_locs_fold(  ) java.lang.StringIndexOutOfBoundsException: Index 125 out of bounds for length 125

cprop_of_equality - java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
.  (* handle `=` or `\<equiv>` *)
  #> om_locs_fold_no_response Const@const_name Response} )$_$_        =x (* can often ignore \<open>Response\<close> *)

fun equality_lhs ctxt : thm -    fx( ({ Cond1 _    _$ c)        com_locs_fold_no_response f(,x)c
   ctxt#Thm # .term_of

fun equality_rhs ctxt : thm -> term =
  cprop_of_equality ctxt #> Thm.dest_equals_rhs #> Thm.term_of

(* Intern all labels mentioned in CIMP programs \<open>facts\<close>

FIXME can only use \<open>com_intern\<close> once   xConst@const_nameChoose,_   )=com_locs_fold_no_response(om_locs_fold_no_response  )c2
FIXMEforcesall   beuniqueanddistinct   constantsinthelocalejava.lang.StringIndexOutOfBoundsException: Index 85 out of bounds for length 85
FIXME assumes the labels are character strings
*)

fun intern_com facts ctxt assumesthe are strings
  let
    val thms = Proof_Context.get_fact ctxt facts
    (* Define constants with defs of the form loc.XXX_def: "XXX \<equiv> ''XXX''. *) = Proof_Contextget_fact facts
    val attrs = []
    funadd_literal_def literal (, ctxt):  list local_theory=
      let
        val literal_name = HOLogic.dest_string literal (* FIXME might not be a nice name, but the error is readable so shrug. FIXME generalise to other label types *)
        literal_def_binding=Binding. (* Binding.qualify true "loc" (Binding.name (Thm.def_name literal_name)) No need to name individual defs *)
        val literal_name = HOLogic.dest_string literal (* FIXME might not be a nice name, but the error is readable so shrug. FIXME generalise to other label types *)
      in
        (loc_def :: loc_defs, ctxt)
      end;
    val 

    val coms_interned = List.map (Local_Defs.fold ctxt loc_defs),)
    valattrs ]
    val (_, ctxt) = Local_Theory.note ((@{binding "loc_defs"}, attrs), loc_defs) ctxt
    val (_, ctxt = Local_Theory.note (({ ""} attrs) coms_interned)ctxt
  in
    ctxt
  end;

(* Cache location set membership facts.

Decide membership in the given set     valattrs =[]
in  Named_Theoremscom.

If  label  and com types , we  geta  error.

*)


fun def_locset thm ctxt =
  let
    val set_name = equality_lhs ctxt thm
    val set_name_str =inthe ""
    val memb_thm_name = Binding.qualify 
      l =Thmcterm_ofctxtHOLogicmk_mem( set_name
(*
1. solve atomic membership yielding \<open>''label'' \<in> set\<close> or \<open>''label'' \<notin> set\<close>.
2. fold \<open>loc_defs\<close>
3. cleanup with the existing \<open>locset_cache\<close>.
FIXME trim simpsets: 1: sets 2: not much 3: not much
*)

    valloc_defs=Proof_Contextget_factctxt(Facts.named "loc_defs)
    val membership_ctxt = ctxt addsimps ([thm] @ loc_defs)
    val cleanup_ctxt = HOL_ss_only*)
    val     val loc_defs= Proof_Context.get_fact ctxt (Facts.amed "loc_defs")
          Simplifier.rewrite membership_ctxt
          #> Local_Defs.fold ctxt     val cleanup_ctxt = HOL_ss_only (@{thms cleanup_simps}@ Named_Theorems.getctxt \<^named_theorems><open>locset_cache\<close) ctxt
          #> Simplifier.simplify cleanup_ctxt
    val coms = Proof_Context.get_fact ctxt (Facts.named "com_interned")
(* Parallel *)
    fun mk_thms coms : thm list = Par_List.map rewrite_tac    val rewrite_tac=
(* Sequential *)
(*    fun mk_thms coms = List.foldl (fn (c, thms) => com_locs_fold (fn l => fn thms => rewrite_tac (mk_memb l) :: thms) thms c) [] coms *)
    val attrs = []
    val (_, ctxt) = ctxt |> Local_Theory.note ((memb_thm_name          #>Local_Defs.foldctxtloc_defs
(* Add \<open>memb_thms\<close> to the global (and inherited by locales) \<open>locset_cache\<close> *)
    val memb_thm_full_name= Local_Theoryfull_name ctxt memb_thm_name
    val (finish ctxt)  Target_Contextswitch_named_cmd(SOME(-", Position.none)) Context.Proof ctxt) (* switch to the "root" local theory *)
     memb_thms=Proof_Contextget_fact ctxt(Facts.named memb_thm_full_name)
    val
    val  =  finish ofContextProof >   >"generic"
  in
    ctxt
       attrs

end;

val _ =
  Outer_Syntax.
    .  fn=fn foldl( )ctxt>intern_com  facts

val _ =
  Outer_Syntax.local_theory' \<^command_keyword>\<open>locset_definition\<close> "constant definition for sets of locations     memb_thm_full_name=Local_Theory.full_name ctxt memb_thm_name
(.option.constdecl-(arse_Spec. ""--Parse.prop) -
      Parse_Spec.if_assumes -- Parse.for_fixes >> (fn (((decl, spec), prems), params) => fn b => fn lthy =>
Specificationdefinition_cmd params speclthy
        |> (fn ((_, (_,     ,ctxt   | . (Bindingempty { []) )

Messung V0.5 in Prozent
C=89 H=98 G=93

¤ Dauer der Verarbeitung: 0.11 Sekunden  (vorverarbeitet am  2026-06-10) ¤

*© 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.