src/HOL/Nitpick_Examples/minipick.ML
author wenzelm
Wed Oct 12 16:21:07 2011 +0200 (2011-10-12)
changeset 45128 5af3a3203a76
parent 45062 9598cada31b3
child 46092 287a3cefc21b
permissions -rw-r--r--
discontinued obsolete alias structure ProofContext;
     1 (*  Title:      HOL/Nitpick_Examples/minipick.ML
     2     Author:     Jasmin Blanchette, TU Muenchen
     3     Copyright   2009-2010
     4 
     5 Finite model generation for HOL formulas using Kodkod, minimalistic version.
     6 *)
     7 
     8 signature MINIPICK =
     9 sig
    10   val minipick : Proof.context -> int -> term -> string
    11   val minipick_expect : Proof.context -> string -> int -> term -> unit
    12 end;
    13 
    14 structure Minipick : MINIPICK =
    15 struct
    16 
    17 open Kodkod
    18 open Nitpick_Util
    19 open Nitpick_HOL
    20 open Nitpick_Peephole
    21 open Nitpick_Kodkod
    22 
    23 datatype rep =
    24   S_Rep |
    25   R_Rep of bool
    26 
    27 fun check_type ctxt raw_infinite (Type (@{type_name fun}, Ts)) =
    28     List.app (check_type ctxt raw_infinite) Ts
    29   | check_type ctxt raw_infinite (Type (@{type_name prod}, Ts)) =
    30     List.app (check_type ctxt raw_infinite) Ts
    31   | check_type _ _ @{typ bool} = ()
    32   | check_type _ _ (TFree (_, @{sort "{}"})) = ()
    33   | check_type _ _ (TFree (_, @{sort HOL.type})) = ()
    34   | check_type ctxt raw_infinite T =
    35     if raw_infinite T then ()
    36     else raise NOT_SUPPORTED ("type " ^ quote (Syntax.string_of_typ ctxt T))
    37 
    38 fun atom_schema_of S_Rep card (Type (@{type_name fun}, [T1, T2])) =
    39     replicate_list (card T1) (atom_schema_of S_Rep card T2)
    40   | atom_schema_of (R_Rep true) card
    41                    (Type (@{type_name fun}, [T1, @{typ bool}])) =
    42     atom_schema_of S_Rep card T1
    43   | atom_schema_of (rep as R_Rep _) card (Type (@{type_name fun}, [T1, T2])) =
    44     atom_schema_of S_Rep card T1 @ atom_schema_of rep card T2
    45   | atom_schema_of _ card (Type (@{type_name prod}, Ts)) =
    46     maps (atom_schema_of S_Rep card) Ts
    47   | atom_schema_of _ card T = [card T]
    48 val arity_of = length ooo atom_schema_of
    49 val atom_seqs_of = map (AtomSeq o rpair 0) ooo atom_schema_of
    50 val atom_seq_product_of = foldl1 Product ooo atom_seqs_of
    51 
    52 fun index_for_bound_var _ [_] 0 = 0
    53   | index_for_bound_var card (_ :: Ts) 0 =
    54     index_for_bound_var card Ts 0 + arity_of S_Rep card (hd Ts)
    55   | index_for_bound_var card Ts n = index_for_bound_var card (tl Ts) (n - 1)
    56 fun vars_for_bound_var card R Ts j =
    57   map (curry Var 1) (index_seq (index_for_bound_var card Ts j)
    58                                (arity_of R card (nth Ts j)))
    59 val rel_expr_for_bound_var = foldl1 Product oooo vars_for_bound_var
    60 fun decls_for R card Ts T =
    61   map2 (curry DeclOne o pair 1)
    62        (index_seq (index_for_bound_var card (T :: Ts) 0)
    63                   (arity_of R card (nth (T :: Ts) 0)))
    64        (atom_seqs_of R card T)
    65 
    66 val atom_product = foldl1 Product o map Atom
    67 
    68 val false_atom_num = 0
    69 val true_atom_num = 1
    70 val false_atom = Atom false_atom_num
    71 val true_atom = Atom true_atom_num
    72 
    73 fun kodkod_formula_from_term ctxt total card complete concrete frees =
    74   let
    75     fun F_from_S_rep (SOME false) r = Not (RelEq (r, false_atom))
    76       | F_from_S_rep _ r = RelEq (r, true_atom)
    77     fun S_rep_from_F NONE f = RelIf (f, true_atom, false_atom)
    78       | S_rep_from_F (SOME true) f = RelIf (f, true_atom, None)
    79       | S_rep_from_F (SOME false) f = RelIf (Not f, false_atom, None)
    80     fun R_rep_from_S_rep (Type (@{type_name fun}, [T1, T2])) r =
    81         if total andalso T2 = bool_T then
    82           let
    83             val jss = atom_schema_of S_Rep card T1 |> map (rpair 0)
    84                       |> all_combinations
    85           in
    86             map2 (fn i => fn js =>
    87 (*
    88                      RelIf (F_from_S_rep NONE (Project (r, [Num i])),
    89                             atom_product js, empty_n_ary_rel (length js))
    90 *)
    91                      Join (Project (r, [Num i]),
    92                            atom_product (false_atom_num :: js))
    93                  ) (index_seq 0 (length jss)) jss
    94             |> foldl1 Union
    95           end
    96         else
    97           let
    98             val jss = atom_schema_of S_Rep card T1 |> map (rpair 0)
    99                       |> all_combinations
   100             val arity2 = arity_of S_Rep card T2
   101           in
   102             map2 (fn i => fn js =>
   103                      Product (atom_product js,
   104                               Project (r, num_seq (i * arity2) arity2)
   105                               |> R_rep_from_S_rep T2))
   106                  (index_seq 0 (length jss)) jss
   107             |> foldl1 Union
   108           end
   109       | R_rep_from_S_rep _ r = r
   110     fun S_rep_from_R_rep Ts (T as Type (@{type_name fun}, _)) r =
   111         Comprehension (decls_for S_Rep card Ts T,
   112             RelEq (R_rep_from_S_rep T
   113                        (rel_expr_for_bound_var card S_Rep (T :: Ts) 0), r))
   114       | S_rep_from_R_rep _ _ r = r
   115     fun partial_eq pos Ts (Type (@{type_name fun}, [T1, T2])) t1 t2 =
   116         HOLogic.mk_all ("x", T1,
   117                         HOLogic.eq_const T2 $ (incr_boundvars 1 t1 $ Bound 0)
   118                         $ (incr_boundvars 1 t2 $ Bound 0))
   119         |> to_F (SOME pos) Ts
   120       | partial_eq pos Ts T t1 t2 =
   121         if pos andalso not (concrete T) then
   122           False
   123         else
   124           (t1, t2) |> pairself (to_R_rep Ts)
   125                    |> (if pos then Some o Intersect else Lone o Union)
   126     and to_F pos Ts t =
   127       (case t of
   128          @{const Not} $ t1 => Not (to_F (Option.map not pos) Ts t1)
   129        | @{const False} => False
   130        | @{const True} => True
   131        | Const (@{const_name All}, _) $ Abs (_, T, t') =>
   132          if pos = SOME true andalso not (complete T) then False
   133          else All (decls_for S_Rep card Ts T, to_F pos (T :: Ts) t')
   134        | (t0 as Const (@{const_name All}, _)) $ t1 =>
   135          to_F pos Ts (t0 $ eta_expand Ts t1 1)
   136        | Const (@{const_name Ex}, _) $ Abs (_, T, t') =>
   137          if pos = SOME false andalso not (complete T) then True
   138          else Exist (decls_for S_Rep card Ts T, to_F pos (T :: Ts) t')
   139        | (t0 as Const (@{const_name Ex}, _)) $ t1 =>
   140          to_F pos Ts (t0 $ eta_expand Ts t1 1)
   141        | Const (@{const_name HOL.eq}, Type (_, [T, _])) $ t1 $ t2 =>
   142          (case pos of
   143             NONE => RelEq (to_R_rep Ts t1, to_R_rep Ts t2)
   144           | SOME pos => partial_eq pos Ts T t1 t2)
   145        | Const (@{const_name ord_class.less_eq},
   146                 Type (@{type_name fun},
   147                       [Type (@{type_name fun}, [T', @{typ bool}]), _]))
   148          $ t1 $ t2 =>
   149          (case pos of
   150             NONE => Subset (to_R_rep Ts t1, to_R_rep Ts t2)
   151           | SOME true =>
   152             Subset (Difference (atom_seq_product_of S_Rep card T',
   153                                 Join (to_R_rep Ts t1, false_atom)),
   154                     Join (to_R_rep Ts t2, true_atom))
   155           | SOME false =>
   156             Subset (Join (to_R_rep Ts t1, true_atom),
   157                     Difference (atom_seq_product_of S_Rep card T',
   158                                 Join (to_R_rep Ts t2, false_atom))))
   159        | @{const HOL.conj} $ t1 $ t2 => And (to_F pos Ts t1, to_F pos Ts t2)
   160        | @{const HOL.disj} $ t1 $ t2 => Or (to_F pos Ts t1, to_F pos Ts t2)
   161        | @{const HOL.implies} $ t1 $ t2 =>
   162          Implies (to_F (Option.map not pos) Ts t1, to_F pos Ts t2)
   163        | t1 $ t2 =>
   164          (case pos of
   165             NONE => Subset (to_S_rep Ts t2, to_R_rep Ts t1)
   166           | SOME pos =>
   167             let
   168               val kt1 = to_R_rep Ts t1
   169               val kt2 = to_S_rep Ts t2
   170               val kT = atom_seq_product_of S_Rep card (fastype_of1 (Ts, t2))
   171             in
   172               if pos then
   173                 Not (Subset (kt2, Difference (kT, Join (kt1, true_atom))))
   174               else
   175                 Subset (kt2, Difference (kT, Join (kt1, false_atom)))
   176             end)
   177        | _ => raise SAME ())
   178       handle SAME () => F_from_S_rep pos (to_R_rep Ts t)
   179     and to_S_rep Ts t =
   180       case t of
   181         Const (@{const_name Pair}, _) $ t1 $ t2 =>
   182         Product (to_S_rep Ts t1, to_S_rep Ts t2)
   183       | Const (@{const_name Pair}, _) $ _ => to_S_rep Ts (eta_expand Ts t 1)
   184       | Const (@{const_name Pair}, _) => to_S_rep Ts (eta_expand Ts t 2)
   185       | Const (@{const_name fst}, _) $ t1 =>
   186         let val fst_arity = arity_of S_Rep card (fastype_of1 (Ts, t)) in
   187           Project (to_S_rep Ts t1, num_seq 0 fst_arity)
   188         end
   189       | Const (@{const_name fst}, _) => to_S_rep Ts (eta_expand Ts t 1)
   190       | Const (@{const_name snd}, _) $ t1 =>
   191         let
   192           val pair_arity = arity_of S_Rep card (fastype_of1 (Ts, t1))
   193           val snd_arity = arity_of S_Rep card (fastype_of1 (Ts, t))
   194           val fst_arity = pair_arity - snd_arity
   195         in Project (to_S_rep Ts t1, num_seq fst_arity snd_arity) end
   196       | Const (@{const_name snd}, _) => to_S_rep Ts (eta_expand Ts t 1)
   197       | Bound j => rel_expr_for_bound_var card S_Rep Ts j
   198       | _ => S_rep_from_R_rep Ts (fastype_of1 (Ts, t)) (to_R_rep Ts t)
   199     and partial_set_op swap1 swap2 op1 op2 Ts t1 t2 =
   200       let
   201         val kt1 = to_R_rep Ts t1
   202         val kt2 = to_R_rep Ts t2
   203         val (a11, a21) = (false_atom, true_atom) |> swap1 ? swap
   204         val (a12, a22) = (false_atom, true_atom) |> swap2 ? swap
   205       in
   206         Union (Product (op1 (Join (kt1, a11), Join (kt2, a12)), true_atom),
   207                Product (op2 (Join (kt1, a21), Join (kt2, a22)), false_atom))
   208       end
   209     and to_R_rep Ts t =
   210       (case t of
   211          @{const Not} => to_R_rep Ts (eta_expand Ts t 1)
   212        | Const (@{const_name All}, _) => to_R_rep Ts (eta_expand Ts t 1)
   213        | Const (@{const_name Ex}, _) => to_R_rep Ts (eta_expand Ts t 1)
   214        | Const (@{const_name HOL.eq}, _) $ _ => to_R_rep Ts (eta_expand Ts t 1)
   215        | Const (@{const_name HOL.eq}, _) => to_R_rep Ts (eta_expand Ts t 2)
   216        | Const (@{const_name ord_class.less_eq},
   217                 Type (@{type_name fun},
   218                       [Type (@{type_name fun}, [_, @{typ bool}]), _])) $ _ =>
   219          to_R_rep Ts (eta_expand Ts t 1)
   220        | Const (@{const_name ord_class.less_eq}, _) =>
   221          to_R_rep Ts (eta_expand Ts t 2)
   222        | @{const HOL.conj} $ _ => to_R_rep Ts (eta_expand Ts t 1)
   223        | @{const HOL.conj} => to_R_rep Ts (eta_expand Ts t 2)
   224        | @{const HOL.disj} $ _ => to_R_rep Ts (eta_expand Ts t 1)
   225        | @{const HOL.disj} => to_R_rep Ts (eta_expand Ts t 2)
   226        | @{const HOL.implies} $ _ => to_R_rep Ts (eta_expand Ts t 1)
   227        | @{const HOL.implies} => to_R_rep Ts (eta_expand Ts t 2)
   228        | Const (@{const_name bot_class.bot},
   229                 T as Type (@{type_name fun}, [T', @{typ bool}])) =>
   230          if total then empty_n_ary_rel (arity_of (R_Rep total) card T)
   231          else Product (atom_seq_product_of (R_Rep total) card T', false_atom)
   232        | Const (@{const_name top_class.top},
   233                 T as Type (@{type_name fun}, [T', @{typ bool}])) =>
   234          if total then atom_seq_product_of (R_Rep total) card T
   235          else Product (atom_seq_product_of (R_Rep total) card T', true_atom)
   236        | Const (@{const_name insert}, Type (_, [T, _])) $ t1 $ t2 =>
   237          if total then
   238            Union (to_S_rep Ts t1, to_R_rep Ts t2)
   239          else
   240            let
   241              val kt1 = to_S_rep Ts t1
   242              val kt2 = to_R_rep Ts t2
   243            in
   244              RelIf (Some kt1,
   245                     if arity_of S_Rep card T = 1 then
   246                       Override (kt2, Product (kt1, true_atom))
   247                     else
   248                       Union (Difference (kt2, Product (kt1, false_atom)),
   249                              Product (kt1, true_atom)),
   250                     Difference (kt2, Product (atom_seq_product_of S_Rep card T,
   251                                               false_atom)))
   252            end
   253        | Const (@{const_name insert}, _) $ _ => to_R_rep Ts (eta_expand Ts t 1)
   254        | Const (@{const_name insert}, _) => to_R_rep Ts (eta_expand Ts t 2)
   255        | Const (@{const_name trancl},
   256                 Type (_, [Type (_, [Type (_, [T', _]), _]), _])) $ t1 =>
   257          if arity_of S_Rep card T' = 1 then
   258            if total then
   259              Closure (to_R_rep Ts t1)
   260            else
   261              let
   262                val kt1 = to_R_rep Ts t1
   263                val true_core_kt = Closure (Join (kt1, true_atom))
   264                val kTx =
   265                  atom_seq_product_of S_Rep card (HOLogic.mk_prodT (`I T'))
   266                val false_mantle_kt =
   267                  Difference (kTx,
   268                      Closure (Difference (kTx, Join (kt1, false_atom))))
   269              in
   270                Union (Product (Difference (false_mantle_kt, true_core_kt),
   271                                false_atom),
   272                       Product (true_core_kt, true_atom))
   273              end
   274          else
   275            raise NOT_SUPPORTED "transitive closure for function or pair type"
   276        | Const (@{const_name trancl}, _) => to_R_rep Ts (eta_expand Ts t 1)
   277        | Const (@{const_name inf_class.inf},
   278                 Type (@{type_name fun},
   279                       [Type (@{type_name fun}, [_, @{typ bool}]), _]))
   280          $ t1 $ t2 =>
   281          if total then Intersect (to_R_rep Ts t1, to_R_rep Ts t2)
   282          else partial_set_op true true Intersect Union Ts t1 t2
   283        | Const (@{const_name inf_class.inf}, _) $ _ =>
   284          to_R_rep Ts (eta_expand Ts t 1)
   285        | Const (@{const_name inf_class.inf}, _) =>
   286          to_R_rep Ts (eta_expand Ts t 2)
   287        | Const (@{const_name sup_class.sup},
   288                 Type (@{type_name fun},
   289                       [Type (@{type_name fun}, [_, @{typ bool}]), _]))
   290          $ t1 $ t2 =>
   291          if total then Union (to_R_rep Ts t1, to_R_rep Ts t2)
   292          else partial_set_op true true Union Intersect Ts t1 t2
   293        | Const (@{const_name sup_class.sup}, _) $ _ =>
   294          to_R_rep Ts (eta_expand Ts t 1)
   295        | Const (@{const_name sup_class.sup}, _) =>
   296          to_R_rep Ts (eta_expand Ts t 2)
   297        | Const (@{const_name minus_class.minus},
   298                 Type (@{type_name fun},
   299                       [Type (@{type_name fun}, [_, @{typ bool}]), _]))
   300          $ t1 $ t2 =>
   301          if total then Difference (to_R_rep Ts t1, to_R_rep Ts t2)
   302          else partial_set_op true false Intersect Union Ts t1 t2
   303        | Const (@{const_name minus_class.minus},
   304                 Type (@{type_name fun},
   305                       [Type (@{type_name fun}, [_, @{typ bool}]), _])) $ _ =>
   306          to_R_rep Ts (eta_expand Ts t 1)
   307        | Const (@{const_name minus_class.minus},
   308                 Type (@{type_name fun},
   309                       [Type (@{type_name fun}, [_, @{typ bool}]), _])) =>
   310          to_R_rep Ts (eta_expand Ts t 2)
   311        | Const (@{const_name Pair}, _) $ _ $ _ => to_S_rep Ts t
   312        | Const (@{const_name Pair}, _) $ _ => to_S_rep Ts t
   313        | Const (@{const_name Pair}, _) => to_S_rep Ts t
   314        | Const (@{const_name fst}, _) $ _ => raise SAME ()
   315        | Const (@{const_name fst}, _) => raise SAME ()
   316        | Const (@{const_name snd}, _) $ _ => raise SAME ()
   317        | Const (@{const_name snd}, _) => raise SAME ()
   318        | @{const False} => false_atom
   319        | @{const True} => true_atom
   320        | Free (x as (_, T)) =>
   321          Rel (arity_of (R_Rep total) card T, find_index (curry (op =) x) frees)
   322        | Term.Var _ => raise NOT_SUPPORTED "schematic variables"
   323        | Bound _ => raise SAME ()
   324        | Abs (_, T, t') =>
   325          (case (total, fastype_of1 (T :: Ts, t')) of
   326             (true, @{typ bool}) =>
   327             Comprehension (decls_for S_Rep card Ts T, to_F NONE (T :: Ts) t')
   328           | (_, T') =>
   329             Comprehension (decls_for S_Rep card Ts T @
   330                            decls_for (R_Rep total) card (T :: Ts) T',
   331                            Subset (rel_expr_for_bound_var card (R_Rep total)
   332                                                           (T' :: T :: Ts) 0,
   333                                    to_R_rep (T :: Ts) t')))
   334        | t1 $ t2 =>
   335          (case fastype_of1 (Ts, t) of
   336             @{typ bool} =>
   337             if total then
   338               S_rep_from_F NONE (to_F NONE Ts t)
   339             else
   340               RelIf (to_F (SOME true) Ts t, true_atom,
   341                      RelIf (Not (to_F (SOME false) Ts t), false_atom,
   342                      None))
   343           | T =>
   344             let val T2 = fastype_of1 (Ts, t2) in
   345               case arity_of S_Rep card T2 of
   346                 1 => Join (to_S_rep Ts t2, to_R_rep Ts t1)
   347               | arity2 =>
   348                 let val res_arity = arity_of (R_Rep total) card T in
   349                   Project (Intersect
   350                       (Product (to_S_rep Ts t2,
   351                                 atom_seq_product_of (R_Rep total) card T),
   352                        to_R_rep Ts t1),
   353                       num_seq arity2 res_arity)
   354                 end
   355             end)
   356        | _ => raise NOT_SUPPORTED ("term " ^
   357                                    quote (Syntax.string_of_term ctxt t)))
   358       handle SAME () => R_rep_from_S_rep (fastype_of1 (Ts, t)) (to_S_rep Ts t)
   359   in to_F (if total then NONE else SOME true) [] end
   360 
   361 fun bound_for_free total card i (s, T) =
   362   let val js = atom_schema_of (R_Rep total) card T in
   363     ([((length js, i), s)],
   364      [TupleSet [], atom_schema_of (R_Rep total) card T |> map (rpair 0)
   365                    |> tuple_set_from_atom_schema])
   366   end
   367 
   368 fun declarative_axiom_for_rel_expr total card Ts
   369                                    (Type (@{type_name fun}, [T1, T2])) r =
   370     if total andalso body_type T2 = bool_T then
   371       True
   372     else
   373       All (decls_for S_Rep card Ts T1,
   374            declarative_axiom_for_rel_expr total card (T1 :: Ts) T2
   375                (List.foldl Join r (vars_for_bound_var card S_Rep (T1 :: Ts) 0)))
   376   | declarative_axiom_for_rel_expr total _ _ _ r =
   377     (if total then One else Lone) r
   378 fun declarative_axiom_for_free total card i (_, T) =
   379   declarative_axiom_for_rel_expr total card [] T
   380       (Rel (arity_of (R_Rep total) card T, i))
   381 
   382 fun kodkod_problem_from_term ctxt total raw_card raw_infinite t =
   383   let
   384     val thy = Proof_Context.theory_of ctxt
   385     fun card (Type (@{type_name fun}, [T1, T2])) =
   386         reasonable_power (card T2) (card T1)
   387       | card (Type (@{type_name prod}, [T1, T2])) = card T1 * card T2
   388       | card @{typ bool} = 2
   389       | card T = Int.max (1, raw_card T)
   390     fun complete (Type (@{type_name fun}, [T1, T2])) =
   391         concrete T1 andalso complete T2
   392       | complete (Type (@{type_name prod}, Ts)) = forall complete Ts
   393       | complete T = not (raw_infinite T)
   394     and concrete (Type (@{type_name fun}, [T1, T2])) =
   395         complete T1 andalso concrete T2
   396       | concrete (Type (@{type_name prod}, Ts)) = forall concrete Ts
   397       | concrete _ = true
   398     val neg_t = @{const Not} $ Object_Logic.atomize_term thy t
   399     val _ = fold_types (K o check_type ctxt raw_infinite) neg_t ()
   400     val frees = Term.add_frees neg_t []
   401     val bounds =
   402       map2 (bound_for_free total card) (index_seq 0 (length frees)) frees
   403     val declarative_axioms =
   404       map2 (declarative_axiom_for_free total card)
   405            (index_seq 0 (length frees)) frees
   406     val formula =
   407       neg_t |> kodkod_formula_from_term ctxt total card complete concrete frees 
   408             |> fold_rev (curry And) declarative_axioms
   409     val univ_card = univ_card 0 0 0 bounds formula
   410   in
   411     {comment = "", settings = [], univ_card = univ_card, tuple_assigns = [],
   412      bounds = bounds, int_bounds = [], expr_assigns = [], formula = formula}
   413   end
   414 
   415 fun solve_any_kodkod_problem thy problems =
   416   let
   417     val {debug, overlord, ...} = Nitpick_Isar.default_params thy []
   418     val max_threads = 1
   419     val max_solutions = 1
   420   in
   421     case solve_any_problem debug overlord NONE max_threads max_solutions
   422                            problems of
   423       JavaNotInstalled => "unknown"
   424     | JavaTooOld => "unknown"
   425     | KodkodiNotInstalled => "unknown"
   426     | Normal ([], _, _) => "none"
   427     | Normal _ => "genuine"
   428     | TimedOut _ => "unknown"
   429     | Error (s, _) => error ("Kodkod error: " ^ s)
   430   end
   431 
   432 val default_raw_infinite = member (op =) [@{typ nat}, @{typ int}]
   433 
   434 fun minipick ctxt n t =
   435   let
   436     val thy = Proof_Context.theory_of ctxt
   437     val {total_consts, ...} = Nitpick_Isar.default_params thy []
   438     val totals =
   439       total_consts |> Option.map single |> the_default [true, false]
   440     fun problem_for (total, k) =
   441       kodkod_problem_from_term ctxt total (K k) default_raw_infinite t
   442   in
   443     (totals, 1 upto n)
   444     |-> map_product pair
   445     |> map problem_for
   446     |> solve_any_kodkod_problem (Proof_Context.theory_of ctxt)
   447   end
   448 
   449 fun minipick_expect ctxt expect n t =
   450   if getenv "KODKODI" <> "" then
   451     if minipick ctxt n t = expect then ()
   452     else error ("\"minipick_expect\" expected " ^ quote expect)
   453   else
   454     ()
   455 
   456 end;