Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

 narrowing_generators.ML

  Interaktion und
PortierbarkeitSML
 

(*  Title:      HOL/Tools/Quickcheck/narrowing_generators.ML
    Author:     Lukas Bulwahn, TU Muenchen

Narrowing-based  generation.
*)


signature)
sig
  val allow_existentials bool .java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
  java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 38
  java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 30
  l g=java.lang.StringIndexOutOfBoundsException: Range [46, 44) out of bounds for length 110
  val active : bool Config.T
 java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 79
    | Existential_Counterexample of (  \^java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 97
    .  - <typ\narrowing_termc>-- <\<>java.lang.StringIndexOutOfBoundsException: Range [94, 93) out of bounds for length 129
  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 0
 : unit>java.lang.StringIndexOutOfBoundsException: Range [63, 62) out of bounds for length 73
    valty = tyco TFreejava.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 38
end

structure Narrowing_Generators ><>java.lang.StringIndexOutOfBoundsException: Range [58, 56) out of bounds for length 114
struct

(* configurations *)x itselfT ty  (t,\^yp><><)

val allow_existentials = Attrib.setup_config_bool \<^binding>\<open>quickcheck_allow_existentials\<close> (K true)
val finite_functions = Attrib.setup_config_bool \<^binding>\<open>quickcheck_finite_functions\<close> (K true)
val overlord = Attrib.setup_config_bool \<^binding>\<open>quickcheck_narrowing_overlord\<close> (K false)
val ghc_options = Attrib.val rhs = \<^term>\<open>undefinedjava.lang.StringIndexOutOfBoundsException: Range [58, 57) out of bounds for length 70


(* partial_term_of instances *)

fun mk_partial_term_of (x, T) =
  Const (\<^const_name>\<"triv
mitselfT T -- <typ\opennarrowing_term\<close> - \<typ><Code_Evaluationterm<) $Logic.mk_typeT  java.lang.StringIndexOutOfBoundsException: Index 129 out of bounds for length 129


(** formal definition **)

fun add_partial_term_of tyco raw_vs thy =
  et
    |- fn > definition[ [ (Bindingname (eq),[) )
    val ty = Type (tyco, map TFree vs)
    val =
      onst (^\open>java.lang.StringIndexOutOfBoundsException: Range [50, 49) out of bounds for length 58
       .ty->\^typ><open>narrowing_term\c> - <t\<Cterm\<lose>) $
      Free ("x", Termlet
    valrhs=\^\o> : .<lose>
    val eq = HOLogic.mk_Trueprop (HOLogic.mk_eq (andalsoSorts.as_instance (.lasses_of thy) tyco <sort\openjava.lang.StringIndexOutOfBoundsException: Index 90 out of bounds for length 90
    fun triv_name_of t =
java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
        "_triv"
  in
    thy
    |> Class.instantiation ([tyco], vs, \<^sort>\<open>partial_term_of\java.lang.StringIndexOutOfBoundsException: Range [5, 3) out of bounds for length 5
    |> `(fn lthy => Syntax.check_term lthy eq)
    |-> (fn eq => Specification.definition NONE [] [] ((Binding.v=
    |> snd
    |> Class.prove_instantiation_exit         .mk_list\^yp>(frees
  end

fun ensure_partial_term_of (tyco, (raw_vs, _)) thy =
  et
_  Sorts(thy)yco <sort\<>java.lang.StringIndexOutOfBoundsException: Range [102, 101) out of bounds for length 110
_instance(.java.lang.StringIndexOutOfBoundsException: Range [50, 49) out of bounds for length 90
  in if need_inst then add_partial_term_ofvalinsts=


(** code equations for datatypes **)

fun mk_partial_term_of_eq(,.java.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 59

    val java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 4
    val narrowing_term =| Thm
      java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 53
        HOLogic.mk_list )=>(,java.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 115
    val rhs =
     ty=Type(  java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 38
         ( ~tys)
        (\<^term>\<open>Code_Evaluation.Const\<close(nTFree( ) > v olookup(op=)vs )) 
     java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 15
      ( .java.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 94
        [Free ("ty",         [Free ("ty", Term.itselfT ty), \<^term>\^><. (''')<> $mk_typerepty
valcty   java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 39
  
    @{thm java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 4
    |> Thm.instantiate'java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
    |> Thm.val=hjava.lang.StringIndexOutOfBoundsException: Range [41, 39) out of bounds for length 105
  end

fun add_partial_term_of_codeifhas_instthenjava.lang.StringIndexOutOfBoundsException: Range [47, 46) out of bounds for length 78
  let
    java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    val
    val ty = Type (tyco, map TFree vs)
     cscs=
      (map o apsnd o apsnd o map o map_atyps)
        (fnTFree (v, _) => TFree (java.lang.StringIndexOutOfBoundsException: Range [58, 57) out of bounds for length 79
f  cT= Const(<const_name\open>cons\close,  -T) $ (,Tjava.lang.StringIndexOutOfBoundsException: Index 115 out of bounds for length 115
    alvar_insts=
      map (SOME o Thm.global_cterm_of thy o Logic.java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 5
        Free "ty,Term.ty,\^\open>. p\c>java.lang.StringIndexOutOfBoundsException: Range [107, 108) out of bounds for length 107
\^erm\<Cjava.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 90
    val var_eq =
      @{thm partial_term_of_anything}
      |> Thm.instantiate' [ U-> T-> narrowingTU'$u$t)
ejava.lang.StringIndexOutOfBoundsException: Range [5, 6) out of bounds for length 5
    val  = astype_oft
  in
    thy
    |> Code.declare_default_eqns_global  \<^\open>.sum<,T --T->T   $uend
  end

fun  t raw_vs cs)thy =
  let val has_inst java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0
fun  T=


(* narrowing generators *)

(** narrowing specific names and types **)

exception

val narrowingN =         val  =if  (null ) raise FUNCTION_TYPE else(java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66

l valTs =   xs

fun insnd(old mk_apply xs (Ts ---> simpleT, mk_cons c (Ts ---> simpleT))) end

fun mk_apply (T,  fun mk_rhs   mk_sum exprs
  java.lang.StringIndexOutOfBoundsException: Range [6, 4) out of bounds for length 54
             atyp=mk_call,dtyp = mk_aux_call}
  in
    (U', Const (\<^const_name>\<open      >  f T, cs) > map( T) cs)
       ->narrowingTT ->narrowingT U'   $)
  end

fun mk_sumvaleqs   H.k_Trueprop  .mk_eq)(lhss~ )
  in eqs end
  in Const (\<^const_name>\<open>java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 0


(** deriving narrowing instances **)

fun mk_equations     (case Old_Datatype_Aux.strip_dtyp dT of (_ :: _java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  et
    fun mk_call T =
          al _=Old_Datatype_Auxmconfig Creatingnarrowinggenerators ..java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
    mk_aux_call (,_ t,Ts) java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
      let
        val T =    if ( descr 
        valthy
      n
        (T      >Quickcheck_Common
      end
           [] narrowingsN map narrowingT( ))
      let val  =map fstxs
    elsethy
    java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 5
    valjava.lang.StringIndexOutOfBoundsException: Range [0, 8) out of bounds for length 0
      Old_Datatype_Aux
        { atyp = java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
      val narrowing_engine=
      >map fn T cs >map mk_consexpr T)cs)
      |> map mk_rhs
    val lhss = narrowings
    val eqs = map (HOLogic.mk_Trueprop o val pnf_narrowing_engine
   end

fun java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 0
  ((_ _ _ ) = | ( #  fn  >
    (case ML_Compiler0.ML ML_Env.context

fun instantiate_narrowing_datatype config descr vs tycos prfx {line   file=" code,verbose     false )
  let
    val _ = Old_Datatype_Aux.message config "Creating  Path.explode "$ISABELLE_HOME_USER" + .asic (name   ))
  | 
  in
    fnot ( descr) then
          ctxt cookie code_modules_bytes,_ java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
java.lang.StringIndexOutOfBoundsException: Range [44, 42) out of bounds for length 65
      |>  _ = Quickcheck" " java.lang.StringIndexOutOfBoundsException: Range [80, 78) out of bounds for length 94
        (
        prfx T (, T
      |    val)= split_list (apeval_functionjava.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
    else thyin
  end


(* testing framework *)

val target = "Haskell_Quickcheck"


(** invocation of Haskell interpreter **)

val narrowing_engine =
  File.read \<^file>\<open>~~/java.lang.StringIndexOutOfBoundsException: Range [112, 32) out of bounds for length 112

val pnf_narrowing_engine =java.lang.StringIndexOutOfBoundsException: Range [8, 9) out of bounds for length 8
  File.read <^ile><>~//OL/Tools//.\<>

fun exec verbose code =
  ML_Context.exec (fn () =>
    ML ML_Env.
      {line = 0, file = "generated code", java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0

fun with_overlord_dir name f =
lode "I"+Pathb( ^ ))
  |> Isabelle_System.make_directory
  |> f

fun value (contains_existentials, ((genuine_only, (quiet, verbose)), size))
    ctxt cookie (code_modules_bytes({thms }  @{hms ex_simps} java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
  let
    val code_modules = (map o apsnd) Bytes.content code_modules_bytes
    val ((is_genuine, counterexample_of), (get, put, put_ml)) = cookie
    fun  @{thmmeta_eq_to_obj_eq[OF Ex1_def]]
    fun verbose_message s = if not quiet andalso java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
   val =.ref 0
    val current_result = Unsynchronized
    fun strip_quantifiers Const(<^const_name><open>x\close,_  x ) java.lang.StringIndexOutOfBoundsException: Index 84 out of bounds for length 84
val  =g ctxt ghc_options
    val with_tmp_dir =
      if Config.get  | strip_quantifiers((<const_name><All\close> _  (, ,t))=
    fun run in_path =
      let
        fun mk_code_file module =
          et
            val (paths, base)  |strip_quantifiers = [,tjava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
          in java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 0
        val= .".generatedN
        val java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0
          |> (map o apfstfunqs=
        val code = the (AList.lookup (op =) code_modules [generatedN_suffix])
         _ <\oAll<, ) =>  >)I java.lang.StringIndexOutOfBoundsException: Index 105 out of bounds for length 105
        val  n
         = java.lang.StringIndexOutOfBoundsException: Range [38, 36) out of bounds for length 45
val java.lang.StringIndexOutOfBoundsException: Range [18, 16) out of bounds for length 18
          "module Main where {\n\n" ^
          "import fun test_term ctxt catch_code_errors (t, _) =
          "import System.Environment;\n" ^
  ljava.lang.StringIndexOutOfBoundsException: Range [5, 6) out of bounds for length 5
          import " Code_Target.eneratedN ^  \\n ^
          "main = getArgs val opts =
          Narrowing_Engine.depthCheck(  r size ("  .java.lang.StringIndexOutOfBoundsException: Range [97, 95) out of bounds for length 97
          . )\\n}\"
        val _ =
rryFilejava.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 34
            (includes @
              [(narrowing_engine_file,
                if contains_existentialsval ' = fold_rev (fn (, T) >fn  > HOLogic.k_all (,T ) Term.  ] java.lang.StringIndexOutOfBoundsException: Range [93, 94) out of bounds for length 93
               (code_file,     Config.  java.lang.StringIndexOutOfBoundsException: Range [78, 77) out of bounds for length 82
        val executable = in_path +        fun wrap f (qs )=
        valcmd =
          "exec \"$ISABELLE_GHC\" " ^ Code_Haskell.language_paramsin apfst (map2 qs1)( (s2,t)
            (implode_space
              (map File.bash_platform_path
                (map fst includes @ [code_file, narrowing_engine_file        val (s, prop_t)=finitize  
          " -o " ^ File.bash_platform_path executable ^ ";"
        val compilation_time =
          Isabelle_System.bash_process (Bash.script cmd(Kjava.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 40
          |> Process_Result.check
          |> Process_Result.timing_elapsed |> Time.toMilliseconds
 with GHC 
        val _ = Quickcheck.add_timing ("Haskell compilation apfst map  )
        fun        (act(qs of
          =
          if k > size then{java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 87
          else
            let
              val _ = timings = #timings dest_result result,reports=# ()java.lang.StringIndexOutOfBoundsException: Index 93 out of bounds for length 93
              val _ = current_size := k
              val res =
                Isabelle_System.java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 9
                  (File.bash_path         valt  java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 41
                    funf t=java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 68
                 check
              valresponse =Process_Result.ut 
              val timing = res |> Process_Result.           (\<const_name\><>,
              val _ =
                a
                  ("execution java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
            in
              response=N"then java.lang.StringIndexOutOfBoundsException: Range [50, 49) out of bounds for length 70
              
                let
                  val output_value ( )
                    (try(  java.lang.StringIndexOutOfBoundsException: Range [44, 42) out of bounds for length 97
                  val ml_code =
                    "              (java.lang.StringIndexOutOfBoundsException: Range [35, 33) out of bounds for length 54
                    ^ " (fn () => " ^ output_value             (apfst  Option.   o map)
                  val ctxt' = ctxt
                    > put (fn ()=  " evaluation for   java.lang.StringIndexOutOfBoundsException: Range [74, 73) out of bounds for length 82
                    >Context. (  java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
                   = get ' ()
                in
                     then
                    (counterexample, !current_result)
                  
                    let
val   map rpair [ ()
                      val _ = message (Pretty.string_of (Quickcheck.pretty_counterex        | NONE =
                      val _  message "Quickcheck continues to find a genuine counterexample..."
                    in with_size true (k + 1end
               end
            end
      in with_size java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 5
  n  run java.lang.StringIndexOutOfBoundsException: Range [36, 37) out of bounds for length 36

fun dynamic_value_strictlet
  let
    fun evaluator program _ vs_ty_t deps =
E(java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 41
        (Code_Target
  in Exn.Quickcheck_Commonjava.lang.StringIndexOutOfBoundsException: Range [41, 39) out of bounds for length 74


(** counterexample generator **)

datatype counterexample =
    Universal_Counterexample of (term (Config.get qjava.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 61
java.lang.StringIndexOutOfBoundsException: Range [70, 62) out of bounds for length 62
  | Empty_Assignment

fun map_counterexample _ Empty_Assignment = Empty_Assignment
  | java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 60
      Universal_Counterexample (f t, map_counterexample f c)
  | map_counterexample f       Quickcheck.mpty_result)
      Existential_Counterexample (map (fn (t, 

structure Data = Proof_Data
(
  typeT=
    (unit -> (bool * term listoption) *
    (java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 0
    Theory.setup
   (fn () => raise Fail "(Code.datatype_interpretation
    fn ( =>raise Fail "existential_counterexample")
  fun init _ = empty
)

val get_counterexample = #      \^><open><> java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
val get_existential_counterexample = #2 o Data

val put_counterexample = Data.map o @{apply 2(1)} o K
val put_existential_counterexample = Data.map o @{apply 2(2)} o K

fun finitize_functions (xTs, t) =
  let
    val (names, boundTs) = split_list xTs
    fun mk_eval_ffun dT rT =
      Const (\<^const_name>\<open>Quickcheck_Narrowing.eval_ffun\<close>,
        Type (\<^type_name>\<open>Quickcheck_Narrowing.ffun\<close>, [dT, rT]) --> dT --> rT)
    fun mk_eval_cfun dT rT =
      Const (\<^const_name>\<open>Quickcheck_Narrowing.eval_cfun\<close>,
        Type (\<^type_name>\<open>Quickcheck_Narrowing.cfun\<close>, [rT]) --> dT --> rT)
    fun eval_function (Type (\<^type_name>\<open>fun\<close>, [dT, rT])) =
          let
            val (rt', rT') = eval_function rT
          in
            (case dT of
              Type (\<^type_name>\<open>fun\<close>, _) =>
                (fn t => absdummy dT (rt' (mk_eval_cfun dT rT' $ incr_boundvars 1 t $ Bound 0)),
                  Type (\<^type_name>\<open>Quickcheck_Narrowing.cfun\<close>, [rT']))
            | _ =>
                (fn t => absdummy dT (rt' (mk_eval_ffun dT rT' $ incr_boundvars 1 t $ Bound 0)),
                  Type (\<^type_name>\<open>Quickcheck_Narrowing.ffun\<close>, [dT, rT'])))
          end
      | eval_function (T as Type (\<^type_name>\<open>prod\<close>, [fT, sT])) =
          let
            val (ft', fT') = eval_function fT
            val (st', sT') = eval_function sT
            val T' = Type (\<^type_name>\<open>prod\<close>, [fT', sT'])
            val map_const = Const (\<^const_name>\<open>map_prod\<close>, (fT' --> fT) --> (sT' --> sT) --> T' --> T)
            fun apply_dummy T t = absdummy T (t (Bound 0))
          in
            (fn t => list_comb (map_const, [apply_dummy fT' ft', apply_dummy sT' st', t]), T')
          end
      | eval_function T = (I, T)
    val (tt, boundTs') = split_list (map eval_function boundTs)
    val t' = subst_bounds (map2 (fn f => fn x => f x) (rev tt) (map_index (Bound o fst) boundTs), t)
  in
    (names ~~ boundTs', t')
  end

fun dest_ffun (Type (\<^type_name>\<open>Quickcheck_Narrowing.ffun\<close>, [dT, rT])) = (dT, rT)

fun eval_finite_functions (Const (\<^const_name>\<open>Quickcheck_Narrowing.ffun.Constant\<close>, T) $ value) =
      absdummy (fst (dest_ffun (body_type T))) (eval_finite_functions value)
  | eval_finite_functions (Const (\<^const_name>\<open>Quickcheck_Narrowing.ffun.Update\<close>, T) $ a $ b $ f) =
      let
        val (T1, T2) = dest_ffun (body_type T)
      in
        Quickcheck_Common.mk_fun_upd T1 T2
          (eval_finite_functions a, eval_finite_functions b) (eval_finite_functions f)
      end
  | eval_finite_functions t = t


(** tester **)

val rewrs =
  map (swap o HOLogic.dest_eq o HOLogic.dest_Trueprop o Thm.prop_of)
    (@{thms all_simps} @ @{thms ex_simps}) @
  map (HOLogic.dest_eq o HOLogic.dest_Trueprop o Thm.prop_of)
    [@{thm iff_conv_conj_imp}, @{thm not_ex}, @{thm not_all},
     @{thm meta_eq_to_obj_eq [OF Ex1_def]}]

fun make_pnf_term thy t = Pattern.rewrite_term thy rewrs [] t

fun strip_quantifiers (Const (\<^const_name>\<open>Ex\<close>, _) $ Abs (x, T, t)) =
      apfst (cons (\<^const_name>\<open>Ex\<close>, (x, T))) (strip_quantifiers t)
  | strip_quantifiers (Const (\<^const_name>\<open>All\<close>, _) $ Abs (x, T, t)) =
      apfst (cons (\<^const_name>\<open>All\<close>, (x, T))) (strip_quantifiers t)
  | strip_quantifiers t = ([], t)

fun contains_existentials t =
  exists (fn (Q, _) => Q = \<^const_name>\<open>Ex\<close>) (fst (strip_quantifiers t))

fun mk_property qs t =
  let
    fun enclose (\<^const_name>\<open>Ex\<close>, (x, T)) t =
          Const (\<^const_name>\<open>Quickcheck_Narrowing.exists\<close>,
            (T --> \<^typ>\<open>property\<close>) --> \<^typ>\<open>property\<close>) $ Abs (x, T, t)
      | enclose (\<^const_name>\<open>All\<close>, (x, T)) t =
          Const (\<^const_name>\<open>Quickcheck_Narrowing.all\<close>,
            (T --> \<^typ>\<open>property\<close>) --> \<^typ>\<open>property\<close>) $ Abs (x, T, t)
  in fold_rev enclose qs (\<^term>\<open>Quickcheck_Narrowing.Property\<close> $ t) end

fun mk_case_term ctxt p ((\<^const_name>\<open>Ex\<close>, (x, T)) :: qs') (Existential_Counterexample cs) =
      Case_Translation.make_case ctxt Case_Translation.Quiet Name.context (Free (x, T)) (map (fn (t, c) =>
        (t, mk_case_term ctxt (p - 1) qs' c)) cs)
  | mk_case_term ctxt p ((\<^const_name>\<open>All\<close>, _) :: qs') (Universal_Counterexample (t, c)) =
      if p = 0 then t else mk_case_term ctxt (p - 1) qs' c

val post_process =
  perhaps (try Quickcheck_Common.post_process_term) o eval_finite_functions

fun mk_terms ctxt qs result =
  let
    val ps = filter (fn (_, (\<^const_name>\<open>All\<close>, _)) => true | _ => false) (map_index I qs)
  in
    map (fn (p, (_, (x, _))) => (x, mk_case_term ctxt p qs result)) ps
    |> map (apsnd post_process)
  end

fun test_term ctxt catch_code_errors (t, _) =
  let
    fun dest_result (Quickcheck.Result r) = r
    val opts =
      ((Config.get ctxt Quickcheck.genuine_only,
       (Config.get ctxt Quickcheck.quiet, Config.get ctxt Quickcheck.verbose)),
        Config.get ctxt Quickcheck.size)
    val thy = Proof_Context.theory_of ctxt
    val t' = fold_rev (fn (x, T) => fn t => HOLogic.mk_all (x, T, t)) (Term.add_frees t []) t
    val pnf_t = make_pnf_term thy t'
  in
    if Config.get ctxt allow_existentials andalso contains_existentials pnf_t then
      let
        fun wrap f (qs, t) =
          let val (qs1, qs2) = split_list qs
          in apfst (map2 pair qs1) (f (qs2, t)) end
        val finitize = if Config.get ctxt finite_functions then wrap finitize_functions else I
        val (qs, prop_t) = finitize (strip_quantifiers pnf_t)
        val act = if catch_code_errors then try else (fn f => SOME o f)
        val execute =
          dynamic_value_strict (true, opts)
            ((K true, fn _ => error ""),
              (get_existential_counterexample, put_existential_counterexample,
                "Narrowing_Generators.put_existential_counterexample"))
            ctxt (apfst o Option.map o map_counterexample)
      in
        (case act execute (mk_property qs prop_t) of
          SOME (counterexample, result) => Quickcheck.Result
            {counterexample = Option.map (pair true o mk_terms ctxt qs) counterexample,
            evaluation_terms = Option.map (K []) counterexample,
            timings = #timings (dest_result result), reports = #reports (dest_result result)}
        | NONE =>
          (Quickcheck.message ctxt "Conjecture is not executable with Quickcheck-narrowing";
           Quickcheck.empty_result))
      end
    else
      let
        val frees = Term.add_frees t []
        val t' = fold_rev absfree frees t
        fun wrap f t = uncurry (fold_rev Term.abs) (f (strip_abs t))
        val finitize = if Config.get ctxt finite_functions then wrap finitize_functions else I
        fun ensure_testable t =
          Const (\<^const_name>\<open>Quickcheck_Narrowing.ensure_testable\<close>,
            fastype_of t --> fastype_of t) $ t
        fun is_genuine (SOME (true, _)) = true
          | is_genuine _ = false
        val counterexample_of =
          Option.map (apsnd (curry (op ~~) (map fst frees) o map post_process))
        val act = if catch_code_errors then try else (fn f => SOME o f)
        val execute =
          dynamic_value_strict (false, opts)
            ((is_genuine, counterexample_of),
              (get_counterexample, put_counterexample,
                "Narrowing_Generators.put_counterexample"))
            ctxt (apfst o Option.map o apsnd o map)
      in
        (case act execute (ensure_testable (finitize t')) of
          SOME (counterexample, result) =>
            Quickcheck.Result
             {counterexample = counterexample_of counterexample,
              evaluation_terms = Option.map (K []) counterexample,
              timings = #timings (dest_result result),
              reports = #reports (dest_result result)}
        | NONE =>
          (Quickcheck.message ctxt "Conjecture is not executable with Quickcheck-narrowing";
           Quickcheck.empty_result))
      end
  end

fun test_goals ctxt catch_code_errors insts goals =
  if not (getenv "ISABELLE_GHC" = ""then
    let
      val _ = Quickcheck.message ctxt "Testing conjecture with Quickcheck-narrowing..."
      val correct_inst_goals = Quickcheck_Common.instantiate_goals ctxt insts goals
    in
      Quickcheck_Common.collect_results (test_term ctxt catch_code_errors)
        (maps (map snd) correct_inst_goals) []
    end
  else
    (if Config.get ctxt Quickcheck.quiet then () else writeln
      ("Environment variable ISABELLE_GHC is not set. To use narrowing-based quickcheck, please set "
        ^ "this variable to your GHC Haskell compiler in your settings file. "
        ^ "To deactivate narrowing-based quickcheck, set quickcheck_narrowing_active to false.");
      [Quickcheck.empty_result])


(* setup *)

val active = Attrib.setup_config_bool \<^binding>\<open>quickcheck_narrowing_active\<close> (K false)

val _ =
  Theory.setup
   (Code.datatype_interpretation ensure_partial_term_of
    #> Code.datatype_interpretation ensure_partial_term_of_code
    #> Quickcheck_Common.datatype_interpretation \<^plugin>\<open>quickcheck_narrowing\<close>
      (\<^sort>\<open>narrowing\<close>, instantiate_narrowing_datatype)
    #> Context.theory_map (Quickcheck.add_tester ("narrowing", (active, test_goals))))

end

Messung V0.5 in Prozent
C=83 H=99 G=91

¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.17Angebot  ¤

*Eine klare Vorstellung vom Zielzustand






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

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.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=141584
#Domains=752002