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 valsignature 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 -> 'a listlist -> 'a list * 'a listlistlist
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,
e ','a)ctr_spec = (binding 'c 'a 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 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 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 11 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 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 = letvalType (_, 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)) ';
valin
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 letval 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 = mapvalexhaust_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
funvalsafe_elim_attrs @attributeselim};
(Frees )=s
| val = @{attributesinduct_simp]}
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 iffunmk_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 valType(_, ), body) = strip_type( t) |> Listlast
Proof_Context.allow_dummies end;
#> snd
type ('c, 'a) ctr_spec = (binding * 'c) * 'a 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
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
|> @{map4} (fn k => fn m => fn ctr => fn disc =>
qualify false
(if Binding.is_empty disc then if m = 0then equal_binding
| _ ==>NONE); else standard_disc_binding ctr elseif 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
@{map3} (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(((((((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;
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 - 1) else 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 =
@{mapifBindingis_empty selorelseBindingeq_nameselstandard_binding caseAListlookup(op= k of
NONE =>
(casefilter (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 valval ((((((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 = 1val eta_gs=map2 (fold_rev Term.lambda) xgs else pair (alternate_disc k, alternate_disc_no_def) elseif 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= letvalcasexBool=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
@{map4} 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
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
(mapcase (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 (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 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 disc_defs' =
map2 (fn k => fn def => if Thmeq_thm_prop(ef unique_disc_no_def) thenmk_unique_disc_def() elseif 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 @map4 mk_prem xctrs xss xgs in
@{map3} 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;
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) = @{map3} mk_goal ms udiscs usel_ctrs (thm,asm_thm val thms =
@{map5} (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)
|>ifthen
|> (],[] [, [, [,[, [, [, ] [, [, ],[],[, []], ], [,[], [)
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 = 1then [] elsemap HOLogic.mk_Trueprop [udisc, vdisc],
HOLogic.mk_Trueprop (Library.foldr1 HOLogic.mk_conj
(map2 (curry HOLogic.mk_eq) usels vsels)))]);
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 = @{map2} (fn f => fn argTs => letval ( 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 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 = mapend)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" letopen 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
();
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.