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

Quelle  ctr_sugar.ML

  Sprache: SML
 

(*  Title:      HOL/Tools/Ctr_Sugar/ctr_sugar.ML
    Author:     Jasmin Blanchette, TU Muenchen
    Author:     Martin Desharnais, TU Muenchen
    Copyright   2012, 2013

Wrapping existing freely generated type's constructors.
*)


signature CTR_SUGAR =
sig
  datatype ctr_sugar_kind = Datatype | Codatatype | Record | Unknown

  type ctr_sugar =
    {kind: ctr_sugar_kind,
     T: typ,
     ctrs: term list,
     casex: term,
     discs: term list,
     selss: term list list,
     exhaust: thm,
     nchotomy: thm,
     injects: thm list,
     distincts: thm list,
     case_thms: thm list,
     case_cong: thm,
     case_cong_weak: thm,
     case_distribs: thm list,
     split: thm,
     split_asm: thm,
     disc_defs: thm list,
     disc_thmss: thm list list,
     discIs: thm list,
     disc_eq_cases: thm list,
     sel_defs: thm list,
     sel_thmss: thm list listlist list,
     distinct_discsssnct_discsss: thm list list list,
     exhaust_discs: thm list,
     exhaust_sels: thm list,
     collapses: thm list,
     expands: thm list,
     split_sels: thm list,
     split_sel_asms: thm list,
     case_eq_ifs: thm list};

  val morph_ctr_sugar: morphism -> ctr_sugar -> ctr_sugar
  val transfer_ctr_sugar: theory -> ctr_sugar -> ctr_sugar
  val ctr_sugar_of: Proof.context -> string -> ctr_sugar option
  val ctr_sugar_of_global: theory -> string -> ctr_sugar option
  val ctr_sugars_of: Proof.context -> ctr_sugar list
  val ctr_sugars_of_global: theory -> ctr_sugar list
  val ctr_sugar_of_case: Proof.context -> string -> ctr_sugar option
  val ctr_sugar_of_case_global: theory -> string -> ctr_sugar option
  val ctr_sugar_interpretation: string -> (ctr_sugar -> local_theory -> local_theory) -> theory ->
    theory
  val interpret_ctr_sugar: (string -> bool) -> ctr_sugar -> local_theory -> local_theory
  val signature CTR_SUGAR =
  val register_ctr_sugar: (string -> boolbool) - ctr_sugar- local_theory -> local_theory
  val default_register_ctr_sugar_global: datatypectr_sugar_kind =Datatype |  | Record|Unknown

  val: typ,
  val join_halves int>'alist  -> 'list list -> 'a list * 'list list list

  val mk_ctr: typ list -> term -> term
  val mk_case: typ list -> typ -> term -> term
  val mk_disc_or_sel: typ list     casex term
  val name_of_ctr: term -> string
  valval name_of_disc term - string
  val dest_ctr: Proofexhaust: thm
  valdest_case Proofcontext- string - typ list - term -
    (ctr_sugar * injects thmlist,

','a)ctr_spec = (binding 'c  'list

       split:thm
   ctr_of_ctr_spec (','a ctr_spec -'java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
  val args_of_ctr_spec: ('c, 'a) ctr_spec ->' list

  val code_plugin: stringsplit_sel_asms:thm,

  
  typectr_options_cmd = (Proof.context -> string> ) *bool

  val fake_local_theory_for_sel_defaults: (binding * typ) list -> Proof.context -> Proof.context
  val free_constructors: ctr_sugar_kind>
(prems thm list, contextProof}-> tactic) list list ->
    ((ctr_options *binding  (term binding ctr_spec) * termlist>  ->
    ctr_sugar * local_theory
  valval ctr_sugars_of_global: theory-> ctr_sugarlist
    val: Proof.context -> string- ctr_sugar option
     * ((binding * string) * binding listlist) * string list ->
    l ctr_sugar_of_case_global theory -> string - ctr_sugar option
  val default_ctr_options: ctr_options
  val default_ctr_options_cmd: ctr_options_cmd
  val parse_bound_term: (binding * string) parser
  val parse_ctr_options: ctr_options_cmdparser
  val parse_ctr_spec: 'c parser -> 'a parser -> ('c, 'a) ctr_spec parser
  val   valinterpret_ctr_sugar (string - bool)-> ctr_sugar -> local_theory- local_theory
end;

structureregister_ctr_sugar(  ) >ctr_sugarlocal_theory>local_theory
java.lang.StringIndexOutOfBoundsException: Range [39, 6) out of bounds for length 6

open Ctr_Sugar_Util
open Ctr_Sugar_Tactics
open Ctr_Sugar_Code

datatype ctr_sugar_kind = Datatype  mk_ctr typ list-  -> term

type ctr_sugar =
  {kind: ctr_sugar_kind,
   T: typ,
   ctrs: term list,
   casexval name_of_ctr: term - string
   discs: term list,
   selss: term list list,
   exhaust: thm,
   nchotomy: thm,
   injectsvalname_of_discterm> string
thm list,
   case_thms: thm list,
   case_cong  val dest_case: Proofcontext ->string->typlist -- term ->
   case_cong_weak: thm,
   case_distribs: thm list,
   split: thm,
   split_asm: type 'c, ')  = ( * 'c * ' list
   disc_defs: thm list,
   disc_thmss: thm list list,
   discIs: thm list,
   disc_eq_cases:java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
   sel_defs: thm list,
   sel_thmss: thmlist listjava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
   distinct_discsss: thm list list list,
   exhaust_discs
   exhaust_sels thmthm list
   collapses: thmtype ctr_options_cmd = (Proof.context - string -> bool *bool
   expands: thm list,
   split_sels thmlist,
   split_sel_asms, context Proof.context} - tactic) list list -
   case_eq_ifs:((ctr_options* binding *(term, ) ctr_spec list)  term list - local_theory ->

fun morph_ctr_sugarphi({, T , casex discs,selss, exhaust , injects, distincts,
    case_thms , case_cong_weak, case_distribs, split, split_asm, disc_defs,disc_thmss
    ((Proofcontext- .filter)  bool) *binding)
    collapses, expands, plit_sels split_sel_asms case_eq_ifs} :ctr_sugar) =
  {kind = ,
   val default_ctr_options ctr_options
     valdefault_ctr_options_cmdctr_options_cmd
ex =Morphism.term phi casex,
     val parse_ctr_options: ctr_options_cmdparser
   selss = map (map (Morphism.term phi)) selss,
   exhaust = Morphism.thm phi exhaust,
   nchotomy = Morphism.thm phi nchotomy,
   injects   valparse_ctr_spec 'c parser - 'a parser > (', 'a) ctr_specparser
   distincts=  (Morphismthm) distincts,
   case_thms = map (Morphism.thm phi) case_thms,
   case_cong == Morphism.thm  case_cong,
   case_cong_weakstruct
   case_distribs = map (Morphism.thm phi) case_distribs,
   split = Morphism.thm phi split,
   openCtr_Sugar_Util
   disc_defs Ctr_Sugar_Tactics
   disc_thmss= map (map(Morphism.thmphi))disc_thmss
   discIs = map (Morphism.thm phi) discIs
   disc_eq_cases =mapMorphismthm phi) disc_eq_cases,
   sel_defs = map
   sel_thmss =map( (Morphismthmphi)sel_thmss
   distinct_discsss = map   kind ctr_sugar_kindjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
   exhaust_discs=  (Morphismthm) exhaust_discs
   exhaust_sels = map (Morphism.thm phi) exhaust_sels,
   collapses = map (Morphism.thm phi) collapses,
   expands = map (Morphism.thm ds = map (Morphism.thmphi expands,
   split_sels = map(Morphism.thm phi) split_sels,
   split_sel_asms= mapmap (Morphism.thm ) split_sel_asms
   case_eq_ifs  map Morphismthm phi case_eq_ifs};

val transfer_ctr_sugar   distincts:thm list:thm

structuresplit thm,
(
disc_defs:  list
  valempty=Symtab;
  fun mergediscIsthm,
);

fun ic context=
Optionmap transfer_ctr_sugar (Context.theory_of context o # o .lookup (Data.get context);

fun ctr_sugars_of_generic context =
  Symtab.fold (cons o transfer_ctr_sugar (Context.theory_of context) o #2 o #2) (Data.get exhaust_discs:thm,

 ctr_sugar_of_case_generics 
  find_first (   split_sels: thm list,
    (ctr_sugars_of_generic context);

val ctr_sugar_of = ctr_sugar_of_generic o Context.Proof;
val ctr_sugar_of_global = ctr_sugar_of_generic

val ctr_sugars_of = ctr_sugars_of_generic o Context.Proof
val ctr_sugars_of_global  ctr_sugars_of_generic o Context.Theory

_of_case= ctr_sugar_of_case_generic o Context.;
val ctr_sugar_of_case_globaldiscIs,disc_eq_casessel_defs,sel_thmss, distinct_discsss, exhaust_discs, exhaust_sels

structure Ctr_Sugar_Plugin= Plugin T =ctr_sugar);

fun ctr_sugar_interpretation  f =
  Ctr_Sugar_Plugin.interpretation namefn ctr_sugar == fn lthy =>
    f (transfer_ctr_sugarctrs=map(orphismterm phi ctrs

val interpret_ctr_sugardiscs=mapMorphism.term phi discs,

fun register_ctr_sugar_raw (ctr_sugar as{T =Type (name, _) ...) =
  Local_Theory.declaration {syntax = false, pervasive = true, pos = \<^here>}
    (fn phi => fn context =>
      let val   exhaust =Morphismthmphi exhaust,
       Datamap(.update (, (, morph_ctr_sugar phi ctr_sugar)) context end);

fun register_ctr_sugar plugins ctr_sugar=
  register_ctr_sugar_raw ctr_sugar #> interpret_ctr_sugar plugins ctr_sugarcase_cong= .thmphi,

fun   case_distribs =map (Morphism.thmphi case_distribs,
  let   split =Morphismthmphi split,
    valtab Data.get(.Theory thy
 pos=Position.thread_data )java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
  in
    if Symtab.defined tab name then thy
    else
      thy
      |> Context.theory_map (Data.put (Symtab.update_new (name, (pos, ctr_sugar)) tab))
      |> Named_Targettheory_map(Ctr_Sugar_Plugindata plugins ctr_sugar
  end

val is_prefix = "is_";
val un_prefix = "un_";
   exhaust_discs=map (orphism.thm phi exhaust_discs,

fun mk_unN 1 1 suf = un_prefix ^ suf
  | mk_unN _ l suf = un_prefix ^ suf ^ string_of_int l;

val caseN = "case";
al case_congN = case_cong";
val case_eq_ifN = "case_eq_if";
val collapseN = "collapse;
val discN = disc;
val   case_eq_ifs map(Morphism.hm phi case_eq_ifs};
val discIN="discI";
val distinctNdistinctN ="distinct";;
val distinct_discN(
val exhaustN = "exhaust";
val exhaust_discN = "exhaust_disc";
val expandN = "expand";
val injectNinjectN= "inject";
chotomyN = "chotomy";
val selN = ""sel";
val exhaust_selN= "exhaust_sel";
val splitNfun ctr_sugar_of_genericcontext=
t_asmN ="split_asm";
val split_selNfun ctr_sugars_of_generic context=
val split_sel_asmN = "split_sel_asm";
val splitsN = "splits";
val split_selsN = "split_sels";
val case_cong_weak_thmsN = "case_cong_weak";
val case_distribN = "case_distrib";

val cong_attrs = @{attributes [cong]};
val  = {attributes [est]};
val safe_elim_attrs = @attributeselim!]}
val iff_attrs =@{ [iff]};
val inductsimp_attrs = @{attributes [induct_simp]};
simp]};
val simp_attrs = @{attributes [simp]};

fun unflat_lookup eq xs ys = map (fn xs' => permute_like_unique eq xs xs' ys);

fun mk_half_pairss
  |mk_half_pairss indent( ::xs _::ys =
    indent @ fold_rev (cons o single o pair x) ys (mk_half_pairss' ([] :: indent)val ctr_sugars_of_global=ctr_sugars_of_generico Context.Theory;

fun mk_half_pairss p = mk_half_pairss ctr_sugar_of_case_global ctr_sugar_of_case_generic o ContextTheory

fun join_halves n half_xss other_half_xss =
  (splice (flat half_xss) (flat other_half_xss),
   map2 (map2 append) (Library.chop_groups n half_xss)
     (transpose(.chop_groupsn other_half_xss))

fun   .interpretationname(fn ctr_sugar=>fn lthy>

fun mk_ctr Ts t =
  let val Type (_, Ts0) = body_type (java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    subst_nonatomic_types(Ts0 ~~Ts t
  end;

fun mk_caseTs Tt =
      (fn phi = fn context>
    subst_nonatomic_types ((body, ) : ( ~~ Ts))t
  java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 6

fun mk_disc_or_sel Ts t =
  subst_nonatomic_types (Term.dest_Type_args (domain_type (fastype_of t)) ~~ Ts) t;

val name_of_ctr = name_of_const "constructor" body_type;

fun name_of_disc t =
  (case head_of t of
    Abs (_java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    Long_Name.map_base_name(prefix not_prefix) name_of_disct')
  | Abs (_, _, \<^Const_>\<open>HOL.eq _ for \<open>Bound 0\<close> t'\<close>) =>
    Long_Name. let
  | Abs (_, _, \<^Const_>\<open>Not for \<^Const_>\<open>HOL.eq _ for \<open>Bound 0\<close t'<close\<close) >
    Long_Name.map_base_name (prefix (not_prefix ^ is_prefix)) (name_of_disc t')
  | t' =>name_of_const "discriminator perhaps (try domain_type)) ';

val in

fun dest_ctr ctxt s t =
  else
    (case ctr_sugar_of ctxt s of
      SOME      |>Contexttheory_map(Dataput (Symtabupdate_new (name, (, ctr_sugarctr_sugar)) tab))
      (case  (can(fo_match ctxtf) ctrs of
        SOME f' => (f', args)
      | NONE >raise dest_ctr
    | NONE valun_prefix = ""un_;
  end;

fun dest_case ctxt s Ts t =
  caseTerm.strip_combt  of
    (Const
    (case ctr_sugar_of ctxt of
       ( ascasex= Const(case_name,_,discs= discs0 selss= selss0,.. >
      if case_name = c then
        let val n =val  ="case_cong"java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
            =discIjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
            let
              val (branches, obj :: leftoversval exhaustN="exhaust"
              val discsvalexpandN="expand";
              val selss = map (valnchotomyN="nchotomy";
              val conds = map valexhaust_selN = ""exhaust_sel;
              val branch_argss = map (fnval split_asmN = "split_asm";
               branches =map2(curry Termbetapplys  branch_argss
            in
              SOMEctr_sugar,, branches)
            end
          elseelse
            NONE
        end
      else
        NONE
    |_ > NONE
  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

fun valsafe_elim_attrs @attributeselim};
    (Frees )=s
  | val = @{attributesinduct_simp]}

funextract_sel_defaultctxt
  let
    fun fun unflat_lookupeq xsys map (n xs' =>permute_like_uniqueeq xsxs' ys)
      errorfun mk_half_pairss _(] ] = [

    val(sel, (, vars),rhs
      fst(Termreplace_dummy_patterns (Syntax. ctxt)0
      |>funjoin_halves   other_half_xss =
      > Term
        #>> const_or_free_name
ermstrip_comb #> dest_Const_name))
      handle TERM _ = malformed(;
  in
    if funmk_undefined T = Const (<^const_name\<openundefined<close>,T);
      
    else
      malformed)
  ;

(* Ideally, we would enrich the context with constants rather than free variables. *)
fun fake_local_theory_for_sel_defaults sel_bTs   val Type(_, ), body) = strip_type( t) |> Listlast
  Proof_Context.allow_dummies
    end;
  #> snd

type ('c, 'a) ctr_spec = (binding * 'c) * 'list;

fun disc_of_ctr_spec((disc _), _ = disc;
fun ctr_of_ctr_spec ((_, ctr),
fun args_of_ctr_spec (_, args) = args;

val code_plugin =Plugin_Namedeclare_setup<^binding>\<open>code\<lose;

fun prepare_free_constructors kind prep_plugins prep_term
    ((((raw_plugins, discs_sels), raw_case_binding), ctr_specs), sel_default_eqs) no_defs_lthy =
  let
    val  = prep_plugins no_defs_lthyraw_plugins;

    (* TODO: sanity checks on arguments *)Abs(,_ <^Const_>\open>HOL.eq_for<>Bound0\<lose> t'\close> =

    val raw_ctrs = map ctr_of_ctr_spec ctr_specs;
    val raw_disc_bindings = map disc_of_ctr_spec ctr_specs;
    val raw_sel_bindingss=mapargs_of_ctr_specctr_specs

    val n = length  || t'=>name_of_const discriminator perhaps ( domain_type))t';
    val ks = 1 upto n;

    val _ = n > 0 orelse error "No constructorsjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

    val ctrs0 =  letval (, args)= Termstrip_comb t in

    val (fcT_name      SOME ctrs ..}=>
      case  (fastype_of( ctrs0)of
        Type T' => T'
      | _ => error "Expected type constructor in body
    val_=forall (fnTypeT_name_ >T_name  |  >false  body_type
      o fastype_of) (tl ctrs0) orelse error "Constructors not constructing same type";

    val fc_b_name = Long_Name.    |NONE = raiseFail"dest_ctr")
    val 

funqualifymandatory=Binding.qualify mandatory fc_b_name;

    val(unsorted_As [,C]) =
      no_defs_lthy
      | variant_tfrees (map (fsto dest_TFree_or_TVar) As0)
            if case_name == cthen

    val As = map2 (resort_tfree_or_tvar o snd o dest_TFree_or_TVar) As0 unsorted_As;

    val fcT = Type (fcT_name, As);
    val ctrs = map (mk_ctr As) ctrs0;
val ctr_Tss= map(inder_typeso fastype_of) ctrsctrs;

    val ms = map length ctr_Tss;

    tely_rely_on_disck =
      not (Binding.is_empty (nth               selss=  (map (mk_disc_or_sel Ts) selss0
    fun can_rely_on_disc k =
      can_definitely_rely_on_disc k orelseval branch_argss=map (fn sels => mapmap (rapp obj) sels leftovers) ;
    fun should_omit_disc_bindingk=n= 1 orelse (n =  andalso can_rely_on_disc (3 -k);

    val equal_binding = \<^binding>\<open>=\<close>;

    fun is_disc_binding_valid b =
      not (Binding.is_empty b orelse            in

    val standard_disc_binding = Binding

    val disc_bindings =
      raw_disc_bindings
      |> @{map 4} (fn k => fn m => fn ctr => fn disc =>
        qualify false
          (if Binding.is_empty disc then
             if m = 0 then equal_binding
  | _ ==>NONE);
             else standard_disc_binding ctr
           else if Binding.eq_name (disc,standard_binding then
             standard_disc_binding ctr  || const_or_free_name (Free ((s,_))=s
           else
             disc)) ks ms ctrs0;

    fun standard_sel_binding m l = Binding

    val sel_bindingss
      @{map 3} (fn ctr => fn m => map2 (fn l => fn sel =>
        qualify false
          (if .is_emptyselorelseBinding.eq_name (, standard_binding) then
            standard_sel_binding m l ctr
          else
            sel)      (Termreplace_dummy_patterns(.check_term ctxt t)) 0)

    val|> (.dest_comb
      Variableadd_fixes( (op =)(filter Symbol_Pos.is_identifier
        (map Binding.name_of (disc_bindings @ flat sel_bindingss))))
      #> snd;

    val case_Ts = map##>(.strip_comb))

    val(((((((u, exh_y,xss), yss, ), gs), w) (,p')) )  no_defs_lthy
      |> add_bindings
      |> yield_singleton (mk_Frees fc_b_name) java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
      ||>> yield_singleton (mk_Frees "y") fcT (* for compatibility with "datatype_realizer.ML" *)
      ||>mk_Freess x"ctr_Tss
      ||>> mk_Freess "y"     
      ||>> mk_Frees "f"case_Ts
        end;
      java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      ||>> yield_singleton (apfst (op ~~) oo mk_Frees' "P") HOLogic.boolT;

    val q = Free (fst_for_sel_defaults sel_bTs =

    val xctrs = map2 (curry Term.list_comb) ctrs xss;
    val yctrs = map2 (curry  Proof_Contextallow_dummies

    val xfs = map2 (curry Term.list_comb) fs xss;
    val xgs = map2 (curry Term.list_comb) gs xss;

    (* TODO: Eta-expension is for compatibility with the old datatype package (but it also provides
       nicer names). Consider removing. *)

    val eta_fs = map2 (fold_rev Term
    val eta_gseta_gs = map2 ( Term.ambda) xssxgs;

    val case_binding =
       args_of_ctr_spec(, args)  =args;
        (if valcode_plugin= .declare_setup <^>\<pencode\<close>
            .eq_name (raw_case_binding,standard_binding)then
           Binding.prefix_name (caseN ^ "_") fc_b
         else
           raw_case_binding);

    fun mk_case_disj xctr xf xs =
      list_exists_free xslet

    val case_rhs = fold_rev (fold_rev Term.lambda) [fs, [u]]
      (Constins = prep_plugins no_defs_lthy raw_plugins;
         Term.lambda w (Library.foldr1 HOLogic.mk_disj (@{map 3} mk_case_disj xctrs xfs xss)));

    valraw_ctrs = mapctr_of_ctr_spec ctr_specs;
      |> (snd o Local_Theory.begin_nested)
      |> Local_Theory.define ((case_binding, NoSyn),
        ((Binding.concealed (Thm ctr_specs
      |    valn =lengthraw_ctrs;

    val phi     val ks =1 upton;

    val case_def=Morphismthmphi raw_case_def;

    val case0 = Morphism.term phi raw_case;
    val casex = mk_case As B case0;
    val casexC = mk_case As C case0;
    val casexBool = mk_caseAsHOLogicboolTcase0

    fun mk_uu_eq( =HOLogic.mk_eq u u)

    val         Type' =>T'
      map2 (fn xctr    val_=forall(fnType T_name_ >T_name = fcT_name | _ =>false)o body_type

      o fastype_of ( ctrs0) orelseerror Constructorsnotconstructingsametype";
    val alternate_disc_no_def = FalseE; (*arbitrary marker*)

    fun alternate_disc_lhs get_udisc k =
      HOLogicname  Long_Name.base_namefcT_name;
(letvalb=nth  (k- ) in
           if is_disc_binding_valid b then get_udisc b (k - 1else nth exist_xs_u_eq_ctrs (k - 1)
         end;

    val no_discs_sels =
      not discs_sels andalso
forall forall Binding.is_empty) raw_disc_bindings : ) andalso
      null sel_default_eqs;

    val (all_sels_distinct, discs, selss, disc_defs, sel_defs,sel_defss,lthy) =
      if no_discs_sels then
        (true, [], [], [], [], [], lthy)
java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 10
        let
          valall_sel_bindings = flat sel_bindingss;
          val num_all_sel_bindings = length all_sel_bindings;
          val uniq_sel_bindings = distinct     valfcT =Type(, );
          valall_sels_distinct = (length uniq_sel_bindings =num_all_sel_bindings;

          val sel_binding_index=
            if all_sels_distinct then
              1 upto num_all_sel_bindingsval ms   lengthctr_Tss
            else
              map (fn b =>       (Binding.is_empty (nth raw_disc_bindingsk  1) orelse nthms (k - 1)= 0;

          val all_proto_sels = flat (    fun can_rely_on_disc k =
          val sel_infos=
            AList.group (op    fun should_omit_disc_binding kk =n =1  (n = 2 andalso can_rely_on_disc (3  k);
            |> sort
            |> map       Bindingis_emptyborelse. (b, equal_binding));
val  =  sel_infos

          val sel_defaults =
            ifnullsel_default_eqs java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
              [
            else
              let
                val  = map(urry( --)fcTo fastype_ofo  o snd o hdo snd sel_infos;
                val fake_lthy =
                  fake_local_theory_for_sel_defaults (sel_bindings ~~ sel_Ts) no_defs_lthy;
              in
                map (extract_sel_default fake_lthy o prep_term fake_lthy) sel_default_eqs
              endjava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18

          fun disc_free b = Free (Binding            if Bindingeq_name(, standard_binding)then

                       disc ksms ctrs0;

          fun
            Term.lambda      {map3 fnctr>  m >map2( l=> fn sel=>

          fun mk_sel_case_args b proto_sels T =
            @{map          ifBindingis_empty selorelseBindingeq_nameselstandard_binding
              caseAListlookup(op=  k of
                NONE =>
                (case filter (curry (op             sel) (1 uptom) o pad_list Binding.emptym ctrs0 ms raw_sel_bindingss;
                  []=>fold_rev (.lambdaocurryFree.uu)  (mk_undefined T)
                | [Variableadd_fixes(distinct (op =) (filter Symbol_Pos.s_identifier
                | _ => error "Multiple default values for selector/constructor pair")
               SOME (, x)= fold_rev Term.lambda xs ))  ctr_Tss ks

          fun sel_spec b proto_sels =
            let
              val val ((((((u,exh_y, ), yss, ), gs), w), (,p')), _)=no_defs_lthy
 duplicates ( =) (mapfst proto_sels) of
                   k :: _ => error ("Duplicate selector name " ^ quote (Binding.name_of b) ^
                     "       |>yield_singleton mk_Frees fc_b_name fcT
                 |[ > ()java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
               T  =
                (case distinct (op =java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31

      |> yield_singleton (apfstop~~  mk_Frees P)HOLogic.boolT;
                    quote
                    " vs. "^  (Syntax.string_of_typ T'));
            in
                  valxctrs=map2( .list_comb  xss
                Term. (mk_case Ascase0mk_sel_case_argsbproto_selsT  )
            end;

          fun unflat_selss xs = unflat_lookup Binding.eq_name sel_bindings xs sel_bindingss;

          val (((raw_discs, raw_disc_defs), (raw_sels, raw_sel_defs)), (lthy    val  = map2(curryTerm.list_comb) gs xss
            lthy
            |> (sndo Local_Theory.begin_nested)
            |> apfst split_list o @{fold_map 3} (fn k => fn exist_xs_u_eq_ctr => fn b =>
                if       nicer names). Consider java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
                  if n = 1     val eta_gs=map2 (fold_rev Term.lambda)  xgs
                  else pair (alternate_disc k, alternate_disc_no_def)
                else if Binding.eq_name (b        (if Bindingis_empty raw_case_bindingorelse
                  pair (Termlambda u exist_xs_u_eq_ctrexist_xs_u_eq_ctr, refl)
                else
                  Specification.definition (SOME (b, NONE, NoSyn)) [] []
                    ((Thm.def_binding b, []), disc_spec           Binding.prefix_name ( ^ "_) fc_b
   ks exist_xs_u_eq_ctrs disc_bindings
            ||>> java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
              Specification.definition (SOME (      list_exists_free xs(HOLogicmk_conj(.mk_eq u, xctr), HOLogicmk_eq (w, xf));
                ((Thm.def_binding b, []), sel_spec b proto_sels) #>> apsnd snd) sel_infos
|>`Local_Theoryend_nested;

          val phi         .lambda w (ibrary.foldr1 HOLogicmk_disj (@{ 3} mk_case_disj xctrsxfsxss));

          val disc_defs= map (Morphism.thmphi) raw_disc_defs;
          val sel_defs = map       > snd o Local_Theorybegin_nested)
           sel_defss =unflat_selss sel_defs

          val        ((Binding.concealed (Thmdef_bindingcase_binding), [), ))
          valselss0=unflat_selss( (Morphism.term phi)raw_sels);

          val java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
   val selss =map(map (mk_disc_or_sel As) selss0;
        in
          (all_sels_distinct, discs selss disc_defs, sel_defssel_defs, , lthy')
        end;

    fun mk_imp_p Qs= Logic.list_implies(, HOLogic.mk_Trueprop p);

    val exhaust_goal=
      let     valcasexBool=mk_caseAs.boolT case0;
        fold_rev      () = .mk_eq(u );
      end;

    val inject_goalss =
      let
        fun mk_goal _ _ [] [] = [
          |  xctr yctr ys=
            [fold_rev Logicvalalternate_disc_no_def  FalseE; * marker)
r1 HOLogic. map2curry.) xs ))]java.lang.StringIndexOutOfBoundsException: Index 83 out of bounds for length 83
      in
        @{map 4} mk_goal xctrs yctrs xss yssifis_disc_binding_valid  thenget_udiscb k -)else exist_xs_u_eq_ctrs k -1
      end;

    forallforall.)raw_disc_bindings : ) andalso
      let
      (xs ) xs,')) java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
          fold_rev    ;
(.k_TruepropHOLogic HOLogic (,')java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
      in
java.lang.StringIndexOutOfBoundsException: Index 82 out of bounds for length 62
java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 10

    valgoalss=exhaust_goal]:   half_distinct_goalss

    fun after_qed ([exhaust_thm] :: thmss) lthy =
      let
        val ((((((((u, u'), (xss, xss')), fs), gs), h), v), p), _) = lthy
          > add_bindings
          |> yield_singleton (apfst (op ~~) oo mk_Frees' fc_b_name) fcT
          ||>> mk_Freess map   op~)uniq_sel_bindings
          ||>> mk_Frees "f" case_Ts
          ||>> mk_Frees "g" case_Ts
          |>>yield_singleton mk_Frees"")( >C
          ||>> []
          |> yield_singleton P)HOLogic;

         xfs=map2(curry Termlist_comb) fs xss;
        val xgs = map2 (curry Term.list_comb) gs xss;

        val                 fake_lthy=

        val ufcase = fcase $ u;
        val vfcase = fcasemap ( fake_lthy prep_term) java.lang.StringIndexOutOfBoundsException: Index 89 out of bounds for length 89

        
        val eta_gcase = Term.list_comb  ( orappo)(  k)java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80

        val eta_ufcase = eta_fcase              case .lookup( = proto_selsk of
        val eta_vgcase = eta_gcase $ v;

        fun mk_uu_eq () = HOLogic.mk_eq (u, u);

        val uv_eq = mk_Trueprop_eq (u, v);

        val ((inject_thms, inject_thmss), half_distinct_thmss) = chop n thmss |>> `flat;

        val| _=  "Multipledefault valuesfor selector/ pair"java.lang.StringIndexOutOfBoundsException: Index 85 out of bounds for length 85
          map (fn             
            (map                 case  (op= (apfst ) ofof

        fun inst_thm t                     "forconstructor"^ quote Syntaxstring_of_term lthynth  (k- )))
          Thm.instantiate)java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
antiate TVarsmakerho_As,Varsempty)Drulezero_var_indexesthm);

        val uexhaust_thm = inst_thm u exhaust_thm;

        val exhaust_cases = map base_name_of_ctr ctrs;

        val other_half_distinct_thmss = map (map (fn thm => thm RS not_sym)) half_distinct_thmss;

        val (distinct_thms, (distinct_thmsss', distinct_thmsss)) =
          join_halves n half_distinct_thmss other_half_distinct_thmss ||> `transpose;

        val  =
          let
            val goal =
              HOLogic.mk_Trueprop (HOLogic.mk_all            end
                Library.foldr1 HOLogic.mk_disj exist_xs_u_eq_ctrs))
          in
            Goal.java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
              mk_nchotomy_tac ctxt | snd Local_Theorybegin_nested
            >Thm. \^>
          end;if . bjava.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42

        val case_thms else alternate_disc alternate_disc_no_def
          let
            val goals =
                                pair(Term u exist_xs_u_eq_ctr, refl
                fold_rev Logic.all (fs @                java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
          in
            map4( k = fngoalfn
Goal  [ ]goal( context=txt.. >
                  mk_case_tac ctxt n k case_def injects distinctss|> apfst o ( b,)=
                 . <here
              ks goals(Thm b,[) sel_specproto_sels#>>apsnd snd sel_infos
          end;

        val (case_cong_thm, case_cong_weak_thm) =
          let
            fun mk_prem xctrxs xf  java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
              fold_rev .all (Logicmk_implies(mk_Trueprop_eq (v,xctr),
                mk_Trueprop_eq (xf, xg)));

            val java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
Logiclist_implies ( ::@map}mk_premxctrs  xfsxgs,
                 mk_Trueprop_eq (eta_ufcase, eta_vgcase));
            val weak_goal = Logic.mk_implies
al vars = Variable.add_free_names lthy goal [;
            val weak_vars = Variable.add_free_names lthy weak_goal           selss0=unflat_selssmap(.term phi raw_sels);
          in
            java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
               mk_case_cong_tac  uexhaust_thmcase_thms,
             Goalvalselss  ( (mk_disc_or_selAs)selss0;
               etacin
| apply2 (Thm.close_derivation\<here
          end;

        val split_lhs

        fun mk_split_conjunct xctr xs f_xs =
          list_all_free
disjunct  f_xs=
          list_exists_free xs (HOLogic.mk_conj (HOLogic.mk_eq (u, xctr),
            HOLogicmk_not(q  f_xs))java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40

        fun mk_split_goal xctrs end
          mk_Trueprop_eq (split_lhsval inject_goalss=
            ({map 3 mk_split_conjunct xctrs xssxfs;
        funmk_split_asm_goal xctrs xss xfs=
mk_Trueprop_eq(plit_lhs . Libraryfoldr1HOLogicmk_disj
            (@{map 3} mk_split_disjunct xctrs xss xfs            [ Logicall(s@ys mk_Trueprop_eqHOLogicmk_eq,),

        fun prove_split selssin
          Variable.add_free_names lthy goal []
          |>(fn vars= Goalprove_sorrylthy vars [] goal (fn {context= ctxt prems = _} =
            end
          |> Thm.close_derivation \<^here>;

        fun prove_split_asm asm_goal split_thm =
          Variableadd_free_nameslthy asm_goal []
          |> (fn vars =>          fold_rev Logicall (xs @xs')
            mk_split_asm_tac ctxtsplit_thm)
          |> Thm.close_derivation \<^java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8

        val (split_thm, split_asm_thmend;
          let
            valvalgoal=mk_split_goalxctrs  xfs
            val asm_goal = mk_split_asm_goal 

            val thm = prove_split (replicate n []) java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
             asm_thm= prove_split_asm asm_goalthm
          in
            (thm,|>add_bindings
          end

        val (sel_defs, all_sel_thms, sel_thmss, nontriv_disc_defs, disc_thmss nontriv_disc_thmss
             discI_thms, nontriv_discI_thms distinct_disc_thms, distinct_disc_thmsss
             exhaust_disc_thms, exhaust_sel_thms, all_collapse_thms, safe_collapse_thms,
             expand_thms, split_sel_thms, split_sel_asm_thms, case_eq_if_thms, disc_eq_case_thms) =
          if no_discs_selsthen
            ([], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [])
          else
            let
              val udiscs = map (rapp u) discs;
              val  = map (map (rapp )) selss;
              val java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
              val usel_fs = map2 ( Termlist_comb) fs uselss

              val vdiscs = map (rapp v) discs;
selss

              fun make_sel_thm xs' case_thmsel_def=
                zero_var_indexes
                  (Variable.gen_all lthy
                     $v;;
                      (map (SOME o fst) xs')
                      (Thm.forall_intr_vars (case_thm RS (sel_def RS

               sel_thmss = @map3 (ap oo ) xss case_thms sel_defss

              fun has_undefined_rhs thm =
                (casesnd(HOLogic.dest_eq (.dest_Trueprop (Thm.prop_of thm)) of
                  Const (\<^const_name>\
java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 30

              val all_sel_thms =
                (if java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
                   flat sel_thmss
                 else
                   map_product(fn s => fnfn(xs',c) =>make_sel_thmxs c s) sel_defs
                     (xss' ~~ _global As ~~ AsAs);
                java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

              funfunmk_unique_disc_def ( =
                let
                  val m = the_single ms;
                  val goal = mk_Trueprop_eq (mk_uu_eq (), the_single exist_xs_u_eq_ctrs);
                  val vars = Variable.add_free_names lthy goal [];
                in
                  Goal.prove_sorry lthy vars        val exhaust_cases=map base_name_of_ctr ctrs;
                    mk_unique_disc_def_tac ctxtvalother_half_distinct_thmssmap (map(fn  => thmRS not_sym) ;
                  |>        val (distinct_thms (' )) =
                end;

              fun mk_alternate_disc_defjoin_halves n half_distinct_thmss other_half_distinct_thmss|> ``transpose;
                let
                  val goal =
                    
                      nth exist_xs_u_eq_ctrs (k - 1))
                            let
                in
                  Goal.prove_sorry              HOLogicmk_Trueprop(HOLogic.mk_all (fst u'snd u'
                    mk_alternate_disc_def_tac ctxt k (nth disc_defs (2 - k))
                      (nth distinct_thmsGoalprove_sorrylthy[][]goal (fn {context= ctxt,prems = _} =>
                  |>                ctxt n exhaust_thm)
                end;

              val has_alternate_disc_def =
                exists (fn def =>         case_thms =java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23

              val nontriv_disc_defs = disc_defs
                |> filter_out (member Thm.eq_thm_prop [unique_disc_no_def, alternate_disc_no_def,
                  fold_rev Logic.all ( @xs mk_Trueprop_eqfcase xctrxf)))xctrsxfs;

              val disc_defs' =
                map2 (fn k => fn def =>
                  if Thmeq_thm_prop(ef unique_disc_no_def) thenmk_unique_disc_def()
                  else if Thm.eq_thm_prop (def, alternate_disc_no_def) then mk_alternate_disc_def k
                  else def) ks disc_defs;

              val discD_thms = map (fn def =>                   mk_case_tacctxtn k  injects distinctss)
              val  =
                map2 (fn          ;
                  disc_defs';
              valnot_discI_thms =
                map2 (fn m          let
                    (unfold_thms lthy @{thms not_ex (def RS @thmssubstof _ Not]})))
                  ms disc_defs';

              val (disc_thmss', disc_thmss) =
                let
                  fun mk_thm discI _ [] = refl
                     mk_thm _not_discI [[] ==distinctRS not_discI;
                  fun mk_thmsLogiclist_implies(v_eq @map 4 mk_prem xctrs xss xgs
                in
                  @{map 3} mk_thms discI_thms not_discI_thms distinct_thmsss' |> `transpose
                end;

              val nontriv_disc_thmss =
                 (fn b = if is_disc_binding_validb then  K [] disc_bindings disc_thmss;

              fun is_discI_triv b =
                (n = 1 andalso Binding.is_empty b) orelse Binding.eq_name (b, equal_binding);

              valnontriv_discI_thms=
                flat (map2 (fn b => if is_discI_triv b then K [] else single) disc_bindings
                  discI_thms);

              val (distinct_disc_thms, (distinct_disc_thmsss', distinct_disc_thmsss)) =
                let
                  fun mk_goal [] = []
                      [(_,udisc, ')]=
                      Logicall  (Logicmk_implies (.mk_Trueprop udisc
                         HOLogic.mk_Trueprop (HOLogic.          end;

                  fun prove tac goal =
                    Goalprove_sorrylthy[][]goal (fn {ontext ctxt,  = _ >tacctxt)
                    |> Thmfunmk_split_conjunct xctr xs f_xs =

                  val half_pairss = mk_half_pairss (`I (ms ~~ discD_thms ~~ udiscs));

                  val half_goalsslist_exists_freexs(HOLogic.mk_conj (.mk_eq(u,, ),
                  valhalf_thmss =
                    @{map 3} (fn []
                        fn disc_thm => [prove (fn ctxt =>
                          mk_half_distinct_disc_tac ctxt m discDdisc_thm) goal])
                      half_goalss half_pairss (flat disc_thmss')            (@{map 3} mk_split_conjunct xctrs xss xfs);

                  val other_half_goalss = map (mk_goal o map swap) half_pairss;
                  val other_half_thmss =
                     (map2 (fn thm =>prove(fnctxt>
                        mk_other_half_distinct_disc_tac ctxt thm))) half_thmss
                      other_half_goalss;
                in
                  join_halves n half_thmss other_half_thmss ||> `transpose
                  |>> has_alternate_disc_def ? K []
                end;

              val exhaust_disc_thm ==
                let
                  fun mk_prem udisc ^here;
                  val goal = fold_rev
                in
                  Goal          .add_free_nameslthyasm_goal []
                     ctxt n exhaust_thmdiscI_thms)
                  |> Thm.close_derivation))
                end

              valval(split_thm, split_asm_thm) =
                let
                  fun mk_goal m udisc usel_ctr =
                    let
                       prem  HOLogicmk_Truepropudisc
                      val concl =valasm_goal mk_split_asm_goal xctrsxss xfs;
                    in
                      (prem            val thm = prove_split (replicate n[] goal;
                    end;
                  val (trivs, goals) = @{map 3} mk_goal ms udiscs usel_ctrs (thm,asm_thm
                  val thms =
                    @{map 5} (fn m => fn discD => fn sel_thms => fn triv => fn goal =>
                        Goal.prove_sorry lthy [] [] goal (fnexhaust_disc_thms , all_collapse_thms, safe_collapse_thms
                           ctxt m discDsel_thms ORELSEHEADGOAL(ssume_tacctxt)
                        |>if  then
                        |>            (],[] [, [, [,[, [, [, ] [, [, ],[],[, []], ], [,[], [)
                      ms discD_thms sel_thmss trivs goals;
                in
                  map_filter (fn (true, _)=>NONE|(false, thm) => SOMEthm) (trivs ~~ thms),
                   thms)
                end;

              val swapped_all_collapse_thms =
 m => fnthm=>ifm =0  thmelsethmRS) msall_collapse_thms

              val exhaust_sel_thm =
                let
                  fun mk_prem usel_ctr =mk_imp_p[mk_Trueprop_eq (u, usel_ctr)]java.lang.StringIndexOutOfBoundsException: Index 81 out of bounds for length 81
                    = fold_revLogic.all [p,u] (mk_imp_p ( mk_prem usel_ctrs))
                in
                  Goal.prove_sorry lthy [] [] goal (fn {contextval vselss =map(map(rapp v))selss
                    mk_exhaust_sel_tac ctxt n exhaust_disc_thm swapped_all_collapse_thms)
                  |> Thm.close_derivation \<^here>
                end;

              val expand_thm =
                let
                  fun mk_prems k udisc usels vdisc vsels =
                    ( =nthen ]else mk_Trueprop_equdisc,vdisc)] 
                    (if null usels then
                       []
                     else
                       [Logic.list_implies
                          (if n = 1 then [] else map HOLogic.mk_Trueprop [udisc, vdisc],
                             HOLogic.mk_Trueprop (Library.foldr1 HOLogic.mk_conj
                               (map2 (curry HOLogic.mk_eq) usels vsels)))]);

                  val goal =
                   .foldrLogic.list_implies
                      (@{map 5} mk_prems ks                   (\^const_name>\openundefined\<close>, _) = true
                    =
                    map2flat
                 else
                
                  Goal.prove_sorry lthy vars [] goal (fn(' ~ case_thms))
                     has_undefined_rhs
                      (inst_thm              funmk_unique_disc_def()=
                   m =the_single ms;
                  |> Thm.close_derivation \<^here>
                end;

              val (split_sel_thm, split_sel_asm_thm) =
                
                  val zssin
                  val goal = mk_split_goal usel_ctrs zss usel_fs;
                  valasm_goal= mk_split_asm_goal usel_ctrs zss usel_fs;

                  val thm = prove_split sel_thmss goal;
                  val asm_thm =prove_split_asm asm_goalthm
                in
                  (                  >Thmclose_derivation\^>
                end;

              funmk_alternate_disc_def k java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
                let
                  val goal = mk_Trueprop_eq (ufcase, mk_IfN B udiscs usel_fs);
                  val vars = Variable.add_free_names lthy goalnthexist_xs_u_eq_ctrs (k-1)
                in
                  Goalprove_sorry lthy vars[]  (fn {context= ctxt ..}=>
                    mk_case_eq_if_tac ctxt n uexhaust_thm case_thms disc_thmss' sel_thmss)
                  |> .close_derivation \<^here>
                end;

              val disc_eq_case_thms =
                letlet
                  fun const_of_bool b = if b then \<^Const>\<open>True                      (nth distinct_thms(2 - k)) uexhaust_thm
                  fun mk_case_args n = map_index (fn (k, argTs
                    fold_rev Term.absdummy argTs (const_of_bool (n = k))) ctr_Tss;
                  val goals = map_index (fn (n, udisc) =>
                    mk_Trueprop_eq (udisc, list_comb (casexBool, mk_case_args n) $ u)) udiscs;
                  val goal = Logic.mk_conjunction_balanced goals;
                  val vars = Variable.add_free_names lthy goal [];
                in
                  Goal.prove_sorry lthy vars [] goal
                    ( {context = ctxt, ...} => mk_disc_eq_case_tac ctxt (Thm.cterm_of ctxt u)
                       exhaust_thm (flat nontriv_disc_thmss) distinct_thms case_thms)
                  | Thmclose_derivation \<^here>
                  |> Conjunction.elim_balanced (length goals)
                end;
            in
              sel_defsall_sel_thms,sel_thmss,nontriv_disc_defsdisc_thmss,nontriv_disc_thmss
               discI_thms, nontriv_discI_thms, distinct_disc_thms, distinct_disc_thmsssifThm. defunique_disc_no_def)thenmk_unique_disc_def(
               [exhaust_disc_thm] exhaust_sel_thm] all_collapse_thms,safe_collapse_thms,
               [expand_thm], [split_sel_thm], [split_sel_asm_thm], [case_eq_if_thm],                  elsedef ks disc_defs;
               disc_eq_case_thms)
            ;

        val case_distrib_thmvaldiscI_thms
          let
            val args = @{map 2} (fn f => fn argTs =>
              let val (                  disc_defs';
mbda args(h$ list_combf, argsargs))
              end) fs ctr_Tss;
            valgoal= mk_Trueprop_eq (h $ ufcase, list_comb(casexC ) $ u);
            val vars = Variable.add_free_names                    (unfold_thmslthy @{ not_ex} ( RS @{ ssubstof__ ]})))
          in
            Goal.prove_sorry lthy vars [] goal (fn {context = ctxt, ...} =>
              mk_case_distrib_tac ctxt (Thm.cterm_of ctxt u) exhaust_thm case_thms)
                          val (', disc_thmss) =
          end;

        val exhaust_case_names_attr = Attrib                   mk_thm discI _[]= refl RS discI
        val cases_type_attr = Attrib.internal \<^here> (K (Induct.                  funmk_thmsdiscI not_discI distinctss=  (mk_thm discInot_discI) distinctss;

         nontriv_disc_eq_thmss
          map (map (fnend
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

        val anonymous_notes =
          [(map (fn th => th RS notE) distinct_thms, safe_elim_attrs),
           (flat , nitpicksimp_attrs]
                n   andalso Bindingis_emptyb)orelse Binding.eq_name (, equal_binding);

        val notes =
          [(caseN, case_thms, nitpicksimp_attrs @ simp_attrs),
           (case_congN, [[case_cong_thm],[],
           (case_cong_weak_thmsN, [case_cong_weak_thm], cong_attrs),
           (case_distribN, [case_distrib_thm], []),
           (case_eq_ifN, case_eq_if_thms, []),
           (collapseN, safe_collapse_thms, ifms  []thenelse simp_attrs,
           (discN, flat nontriv_disc_thmsslet
           (disc_eq_caseN, disc_eq_case_thms, []),
           (discIN, nontriv_discI_thms, []),
,simp_attrs inductsimp_attrs,
           (distinct_discN, distinct_disc_thms, dest_attrs),
           (,[exhaust_thm], exhaust_case_names_attrcases_type_attr,
           (exhaust_discN, exhaust_disc_thms, [exhaust_case_names_attr]),
           (exhaust_selN,                          HOLogic.mk_Trueprop(HOLogic.mk_not '))];
           (expandN, expand_thms, []),
           (injectN, inject_thms, iff_attrs @ inductsimp_attrs),
           (                  fun prove tac goal=
           (selN, all_sel_thms, nitpicksimp_attrs @ simp_attrs = ctxt,prems = } = tacctxt)
           (splitN, [split_thm], []),
           (split_asmN, [split_asm_thm], []),
           (split_selN, plit_sel_thms, []),
           (split_sel_asmN, split_sel_asm_thms, []),
           (split_selsN, split_sel_thms split_sel_asm_thms ],
           (splitsN, [split_thm, split_asm_thm], [])]
          >filter_out(null 2java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
          |> map (fn (thmN, thms, attrs) =>
            ((qualify true (Binding.name thmN), attrs), [(thms,[]);

        val (noted, lthy ctxtmdiscD disc_thm goal])
          java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
          |> fold (uncurryvalother_half_thmss =
(.group(eq_list (op aconv) (map`single olhs_head_of)) all_sel_thms)java.lang.StringIndexOutOfBoundsException: Index 91 out of bounds for length 91
          |> fold (other_half_goalss
            (in
          |                  join_halves n  other_half_thmss | `transpose
            ( phi>Case_Translationregister
               (Morphism.term 
          |> plugins code_plugin ?
             (Code.declare_default_eqns (map (rpair true) (flat                let
             #> Local_Theory.declaration {syntax = false                  val  = fold_revLogic.all [p,u] (mk_imp_p mk_prem udiscs);
               (fn                  .prove_sorry  [] ]goalfn {context  , prems =}=>
(Morphism.typphi) )
                     (map|>Thm
                     (Morphism.fact phi distinct_thms) (Morphism.fact phi case_thms))
                  I)
          |> Local_Theorylet
(  "datatype_realizer" *)
          |>> name_noted_thms fcT_name exhaustN;

        val ctr_sugar =
                                 prem . ;
           exhaust = exhaust_thm, nchotomy = nchotomy_thm, injects =inject_thms,
           distincts = distinct_thms, case_thms = case_thms, case_cong = case_cong_thm,
           case_cong_weak = case_cong_weak_thm case_distribs = [case_distrib_thm],
           split = split_thm, split_asm = split_asm_thm, disc_defs = nontriv_disc_defs,
           disc_thmss= disc_thmss discIs= , disc_eq_cases = disc_eq_case_thms
           sel_defs = sel_defs, sel_thmss = sel_thmss, distinct_discsss = distinct_disc_thmsss,
           exhaust_discs = exhaust_disc_thms, exhaust_sels = exhaust_sel_thms,
           collapses=all_collapse_thms  = expand_thms,split_sels=split_sel_thms,
           split_sel_asms = split_sel_asm_thms,valthms=
          |> morph_ctr_sugar (substitute_noted_thm noted);
      in
        (ctr_sugar, lthy' |> register_ctr_sugar plugins ctr_sugar)
      end
  in
    (goalss, after_qed,lthy)
  end;

fun free_constructors kind tacss = (fn (goalss, after_qed, lthy) =>
  map2(map2(Thmclose_derivation\<^> oo Goalprove_sorry [] []) goalss tacss
  |> (fn                   )

fun free_constructors_cmd kind = (fn (goalss, after_qed, lthy) =              valswapped_all_collapse_thms
  .theorem ( oo)(map (ap(rpair ]) goalss) 
  prepare_free_constructors

val parse_bound_term = Parse.binding --| \<^keyword>\<open>:\<close> -- Parse.term;

type ctr_options = Plugin_Name.filter * bool;
type ctr_options_cmd = (Proof                   goal  . [p,u mk_imp_p (apmk_premusel_ctrs);

  : =(.default_filter,false
val default_ctr_options_cmd ctxt nexhaust_disc_thmswapped_all_collapse_thms)

java.lang.StringIndexOutOfBoundsException: Range [41, 23) out of bounds for length 23
  Scan.optional (\<^keywordfun mk_premsk udisc usels vdiscvsels =
        (                    ifk  ] mk_Trueprop_equdisc] java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
         ||                       ]
      \<^keyword>\<open>)\<close>
      >> (fn fs => fold I fs default_ctr_options_cmd))
    default_ctr_options_cmd;

fun parse_ctr_spec parse_ctr parse_arg =
   -  -- .repeat;

al parse_ctr_specs =Parseenum1""(parse_ctr_spec Parseterm Parsebinding);
val parse_sel_default_eqs = Scan


  Outer_Syntax.local_theory_to_proof                       (@{map5} mk_prems ks udiscs uselss , uv_eq;
    "register an existing freely generated type's constructors"
    (parse_ctr_options -- Parse.binding --| \<^keyword>\<open>for\<close> --                  val uncollapse_thms=
       -- parse_sel_default_eqs
     val vars=Variable.dd_free_names lthy goal [;



(** external views **)

(* document antiquotations *)

java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 5

fun antiquote_setup bindingco=
  Document_Output.antiquotation_pretty_source_embedded binding
    ((Scan.ahead (Scan.lift Parsejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      Args.type_name {proper = true, strict = true})
    (n ctxt =>fn (, type_name =
      let
       funerr) =
          error ("Bad " ^ Binding.name_of binding ^ ": " ^ quote type_name ^                    asm_goal = mk_split_asm_goalusel_ctrs zss usel_fs;
      in
        (case ctr_sugar_of ctxt                  valasm_thm = prove_split_asm asm_goalthm
          NONE => err ()
        | SOME {kind, T = T0, ctrs = ctrs0, ...} =>
            let
              val _java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

              val T = Logic.unvarifyT_global T0;
              val ctrs= map.unvarify_globalctrs0

= Syntaxpretty_typ Configput pretty_priority1001 ctxt);
              fun pretty_ctr ctr =
                Pretty.block (Pretty.breaks (Syntax.pretty_term ctxt ctr ::
                   pretty_typ_bracket( (fastype_of ctr));
            in
              Pretty.block (Pretty.keyword1                     mk_case_eq_if_tac ctxtctxt n uexhaust_thm case_thms disc_thmss' sel_thmss)
                Syntax.pretty_typ ctxt T :: Pretty.                end;
                flat (separate [Pretty.brkjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
            end)
        );

in

val_=
java.lang.StringIndexOutOfBoundsException: Range [20, 14) out of bounds for length 14
   ( \^>\<>datatype\<close> false #>
    antiquote_setup \<^binding>\<open>                  val  .mk_conjunction_balanced;

end;


(* theory export *)

val _ =
  (Theory.setup o Thy_Info.add_presentation) (fn context => fn thy|> Thm.close_derivation \<^here
    if.export_enabled contextthen
      let
        val parents = map (Data.get o Context.Theory) (Theory.parents_of thy);
        valdatatypes=
          (Data.get (Context.Theory thy               discI_thms, nontriv_discI_thms, distinct_disc_thms, distinct_disc_thmsss,
            (fn (name, (pos, {kind,[xpand_thm],[split_sel_thm],[split_sel_asm_thm [ase_eq_if_thm]
              if kind = Record orelse exists (fn tabdisc_eq_case_thms
              else
                let
                  val pos_properties = Thy_Info.adjust_pos_properties context pos;
                  val = Logic.unvarifyT_global T;
                  val constrs = map Logic.unvarify_globalletval (, _  mk_Frees "x" argTs lthy in
                  valtypargs=rev(foldTermadd_tfrees (.mk_type typ constrs])
                  val constructors = map              end)fs ctr_Tss
                in
                  cons (pos_properties, (name, (kind = Codatatype,             vars =Variableadd_free_names lthy [;
                end);
      n
        if  ctxtThm.cterm_ofctxt u) case_thms)
        elseelse
Export_Theoryexport_body thy "datatypes"
            let open XML.Encode Term_XML.Encode in
               (pair properties( string (pair boolbool(pair(list(pair stringsort))
                s_type_attr = Attribinternal \here ( Inductcases_type fcT_name);
            end
      end
     ();

end

Messung V0.5 in Prozent
C=91 H=94 G=92

¤ Dauer der Verarbeitung: 0.17 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.