| author | huffman | 
| Tue, 27 Mar 2012 20:19:23 +0200 | |
| changeset 47167 | 099397de21e3 | 
| parent 46961 | 5c6955f487e5 | 
| child 49170 | 03bee3a6a1b7 | 
| permissions | -rw-r--r-- | 
| 31723 
f5cafe803b55
discontinued ancient tradition to suffix certain ML module names with "_package"
 haftmann parents: 
30860diff
changeset | 1 | (* Title: HOL/Tools/inductive_set.ML | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 2 | Author: Stefan Berghofer, TU Muenchen | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 3 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 4 | Wrapper for defining inductive sets using package for inductive predicates, | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 5 | including infrastructure for converting between predicates and sets. | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 6 | *) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 7 | |
| 31723 
f5cafe803b55
discontinued ancient tradition to suffix certain ML module names with "_package"
 haftmann parents: 
30860diff
changeset | 8 | signature INDUCTIVE_SET = | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 9 | sig | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 10 | val to_set_att: thm list -> attribute | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 11 | val to_pred_att: thm list -> attribute | 
| 32306 
19f55947d4d5
removed debug messages; exported to_pred in InductiveSet; added further display function; adjusted mode analysis
 bulwahn parents: 
32287diff
changeset | 12 | val to_pred : thm list -> Context.generic -> thm -> thm | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 13 | val pred_set_conv_att: attribute | 
| 24815 
f7093e90f36c
tuned internal interfaces: flags record, added kind for results;
 wenzelm parents: 
24745diff
changeset | 14 | val add_inductive_i: | 
| 31723 
f5cafe803b55
discontinued ancient tradition to suffix certain ML module names with "_package"
 haftmann parents: 
30860diff
changeset | 15 | Inductive.inductive_flags -> | 
| 29581 | 16 | ((binding * typ) * mixfix) list -> | 
| 28084 
a05ca48ef263
type Attrib.binding abbreviates Name.binding without attributes;
 wenzelm parents: 
28083diff
changeset | 17 | (string * typ) list -> | 
| 
a05ca48ef263
type Attrib.binding abbreviates Name.binding without attributes;
 wenzelm parents: 
28083diff
changeset | 18 | (Attrib.binding * term) list -> thm list -> | 
| 31723 
f5cafe803b55
discontinued ancient tradition to suffix certain ML module names with "_package"
 haftmann parents: 
30860diff
changeset | 19 | local_theory -> Inductive.inductive_result * local_theory | 
| 28084 
a05ca48ef263
type Attrib.binding abbreviates Name.binding without attributes;
 wenzelm parents: 
28083diff
changeset | 20 | val add_inductive: bool -> bool -> | 
| 29581 | 21 | (binding * string option * mixfix) list -> | 
| 22 | (binding * string option * mixfix) list -> | |
| 28084 
a05ca48ef263
type Attrib.binding abbreviates Name.binding without attributes;
 wenzelm parents: 
28083diff
changeset | 23 | (Attrib.binding * string) list -> (Facts.ref * Attrib.src list) list -> | 
| 31723 
f5cafe803b55
discontinued ancient tradition to suffix certain ML module names with "_package"
 haftmann parents: 
30860diff
changeset | 24 | bool -> local_theory -> Inductive.inductive_result * local_theory | 
| 45384 
dffa657f0aa2
clarified attribute "mono_set": pure declaration, proper export in ML;
 wenzelm parents: 
45375diff
changeset | 25 | val mono_add: attribute | 
| 
dffa657f0aa2
clarified attribute "mono_set": pure declaration, proper export in ML;
 wenzelm parents: 
45375diff
changeset | 26 | val mono_del: attribute | 
| 28723 | 27 | val codegen_preproc: theory -> thm list -> thm list | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 28 | val setup: theory -> theory | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 29 | end; | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 30 | |
| 31723 
f5cafe803b55
discontinued ancient tradition to suffix certain ML module names with "_package"
 haftmann parents: 
30860diff
changeset | 31 | structure Inductive_Set: INDUCTIVE_SET = | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 32 | struct | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 33 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 34 | (**** simplify {(x1, ..., xn). (x1, ..., xn) : S} to S ****)
 | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 35 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 36 | val collect_mem_simproc = | 
| 38715 
6513ea67d95d
renamed Simplifier.simproc(_i) to Simplifier.simproc_global(_i) to emphasize that this is not the real thing;
 wenzelm parents: 
38665diff
changeset | 37 |   Simplifier.simproc_global @{theory Set} "Collect_mem" ["Collect t"] (fn thy => fn ss =>
 | 
| 35364 | 38 |     fn S as Const (@{const_name Collect}, Type ("fun", [_, T])) $ t =>
 | 
| 34903 | 39 | let val (u, _, ps) = HOLogic.strip_psplits t | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 40 | in case u of | 
| 37677 | 41 |            (c as Const (@{const_name Set.member}, _)) $ q $ S' =>
 | 
| 32342 
3fabf5b5fc83
path-sensitive tuple combinators carry a "p"(ath) prefix; combinators for standard right-fold tuples
 haftmann parents: 
32287diff
changeset | 42 | (case try (HOLogic.strip_ptuple ps) q of | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 43 | NONE => NONE | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 44 | | SOME ts => | 
| 42083 
e1209fc7ecdc
added Term.is_open and Term.is_dependent convenience, to cover common situations of loose bounds;
 wenzelm parents: 
41489diff
changeset | 45 | if not (Term.is_open S') andalso | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 46 | ts = map Bound (length ps downto 0) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 47 | then | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 48 | let val simp = full_simp_tac (Simplifier.inherit_context ss | 
| 37136 | 49 |                       (HOL_basic_ss addsimps [@{thm split_paired_all}, @{thm split_conv}])) 1
 | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 50 | in | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 51 | SOME (Goal.prove (Simplifier.the_context ss) [] [] | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 52 |                         (Const ("==", T --> T --> propT) $ S $ S')
 | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 53 | (K (EVERY | 
| 24815 
f7093e90f36c
tuned internal interfaces: flags record, added kind for results;
 wenzelm parents: 
24745diff
changeset | 54 |                           [rtac eq_reflection 1, rtac @{thm subset_antisym} 1,
 | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 55 | rtac subsetI 1, dtac CollectD 1, simp, | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 56 | rtac subsetI 1, rtac CollectI 1, simp]))) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 57 | end | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 58 | else NONE) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 59 | | _ => NONE | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 60 | end | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 61 | | _ => NONE); | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 62 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 63 | (***********************************************************************************) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 64 | (* simplifies (%x y. (x, y) : S & P x y) to (%x y. (x, y) : S Int {(x, y). P x y}) *)
 | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 65 | (* and        (%x y. (x, y) : S | P x y) to (%x y. (x, y) : S Un {(x, y). P x y})  *)
 | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 66 | (* used for converting "strong" (co)induction rules *) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 67 | (***********************************************************************************) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 68 | |
| 23849 
2a0e24c74593
strong_ind_simproc now only rewrites arguments of inductive predicates.
 berghofe parents: 
23764diff
changeset | 69 | val anyt = Free ("t", TFree ("'t", []));
 | 
| 
2a0e24c74593
strong_ind_simproc now only rewrites arguments of inductive predicates.
 berghofe parents: 
23764diff
changeset | 70 | |
| 
2a0e24c74593
strong_ind_simproc now only rewrites arguments of inductive predicates.
 berghofe parents: 
23764diff
changeset | 71 | fun strong_ind_simproc tab = | 
| 38715 
6513ea67d95d
renamed Simplifier.simproc(_i) to Simplifier.simproc_global(_i) to emphasize that this is not the real thing;
 wenzelm parents: 
38665diff
changeset | 72 |   Simplifier.simproc_global_i @{theory HOL} "strong_ind" [anyt] (fn thy => fn ss => fn t =>
 | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 73 | let | 
| 23849 
2a0e24c74593
strong_ind_simproc now only rewrites arguments of inductive predicates.
 berghofe parents: 
23764diff
changeset | 74 | fun close p t f = | 
| 
2a0e24c74593
strong_ind_simproc now only rewrites arguments of inductive predicates.
 berghofe parents: 
23764diff
changeset | 75 | let val vs = Term.add_vars t [] | 
| 
2a0e24c74593
strong_ind_simproc now only rewrites arguments of inductive predicates.
 berghofe parents: 
23764diff
changeset | 76 | in Drule.instantiate' [] (rev (map (SOME o cterm_of thy o Var) vs)) | 
| 27330 | 77 | (p (fold (Logic.all o Var) vs t) f) | 
| 23849 
2a0e24c74593
strong_ind_simproc now only rewrites arguments of inductive predicates.
 berghofe parents: 
23764diff
changeset | 78 | end; | 
| 38795 
848be46708dc
formerly unnamed infix conjunction and disjunction now named HOL.conj and HOL.disj
 haftmann parents: 
38715diff
changeset | 79 |       fun mkop @{const_name HOL.conj} T x =
 | 
| 35364 | 80 |             SOME (Const (@{const_name Lattices.inf}, T --> T --> T), x)
 | 
| 38795 
848be46708dc
formerly unnamed infix conjunction and disjunction now named HOL.conj and HOL.disj
 haftmann parents: 
38715diff
changeset | 81 |         | mkop @{const_name HOL.disj} T x =
 | 
| 35364 | 82 |             SOME (Const (@{const_name Lattices.sup}, T --> T --> T), x)
 | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 83 | | mkop _ _ _ = NONE; | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 84 | fun mk_collect p T t = | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 85 | let val U = HOLogic.dest_setT T | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 86 | in HOLogic.Collect_const U $ | 
| 32342 
3fabf5b5fc83
path-sensitive tuple combinators carry a "p"(ath) prefix; combinators for standard right-fold tuples
 haftmann parents: 
32287diff
changeset | 87 | HOLogic.mk_psplits (HOLogic.flat_tuple_paths p) U HOLogic.boolT t | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 88 | end; | 
| 37677 | 89 |       fun decomp (Const (s, _) $ ((m as Const (@{const_name Set.member},
 | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 90 | Type (_, [_, Type (_, [T, _])]))) $ p $ S) $ u) = | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 91 | mkop s T (m, p, S, mk_collect p T (head_of u)) | 
| 37677 | 92 |         | decomp (Const (s, _) $ u $ ((m as Const (@{const_name Set.member},
 | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 93 | Type (_, [_, Type (_, [T, _])]))) $ p $ S)) = | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 94 | mkop s T (m, p, mk_collect p T (head_of u), S) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 95 | | decomp _ = NONE; | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 96 | val simp = full_simp_tac (Simplifier.inherit_context ss | 
| 37136 | 97 |         (HOL_basic_ss addsimps [mem_Collect_eq, @{thm split_conv}])) 1;
 | 
| 23849 
2a0e24c74593
strong_ind_simproc now only rewrites arguments of inductive predicates.
 berghofe parents: 
23764diff
changeset | 98 | fun mk_rew t = (case strip_abs_vars t of | 
| 
2a0e24c74593
strong_ind_simproc now only rewrites arguments of inductive predicates.
 berghofe parents: 
23764diff
changeset | 99 | [] => NONE | 
| 
2a0e24c74593
strong_ind_simproc now only rewrites arguments of inductive predicates.
 berghofe parents: 
23764diff
changeset | 100 | | xs => (case decomp (strip_abs_body t) of | 
| 
2a0e24c74593
strong_ind_simproc now only rewrites arguments of inductive predicates.
 berghofe parents: 
23764diff
changeset | 101 | NONE => NONE | 
| 
2a0e24c74593
strong_ind_simproc now only rewrites arguments of inductive predicates.
 berghofe parents: 
23764diff
changeset | 102 | | SOME (bop, (m, p, S, S')) => | 
| 
2a0e24c74593
strong_ind_simproc now only rewrites arguments of inductive predicates.
 berghofe parents: 
23764diff
changeset | 103 | SOME (close (Goal.prove (Simplifier.the_context ss) [] []) | 
| 46219 
426ed18eba43
discontinued old-style Term.list_abs in favour of plain Term.abs;
 wenzelm parents: 
45979diff
changeset | 104 | (Logic.mk_equals (t, fold_rev Term.abs xs (m $ p $ (bop $ S $ S')))) | 
| 23849 
2a0e24c74593
strong_ind_simproc now only rewrites arguments of inductive predicates.
 berghofe parents: 
23764diff
changeset | 105 | (K (EVERY | 
| 
2a0e24c74593
strong_ind_simproc now only rewrites arguments of inductive predicates.
 berghofe parents: 
23764diff
changeset | 106 | [rtac eq_reflection 1, REPEAT (rtac ext 1), rtac iffI 1, | 
| 
2a0e24c74593
strong_ind_simproc now only rewrites arguments of inductive predicates.
 berghofe parents: 
23764diff
changeset | 107 | EVERY [etac conjE 1, rtac IntI 1, simp, simp, | 
| 
2a0e24c74593
strong_ind_simproc now only rewrites arguments of inductive predicates.
 berghofe parents: 
23764diff
changeset | 108 | etac IntE 1, rtac conjI 1, simp, simp] ORELSE | 
| 
2a0e24c74593
strong_ind_simproc now only rewrites arguments of inductive predicates.
 berghofe parents: 
23764diff
changeset | 109 | EVERY [etac disjE 1, rtac UnI1 1, simp, rtac UnI2 1, simp, | 
| 
2a0e24c74593
strong_ind_simproc now only rewrites arguments of inductive predicates.
 berghofe parents: 
23764diff
changeset | 110 | etac UnE 1, rtac disjI1 1, simp, rtac disjI2 1, simp]]))) | 
| 
2a0e24c74593
strong_ind_simproc now only rewrites arguments of inductive predicates.
 berghofe parents: 
23764diff
changeset | 111 | handle ERROR _ => NONE)) | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 112 | in | 
| 23849 
2a0e24c74593
strong_ind_simproc now only rewrites arguments of inductive predicates.
 berghofe parents: 
23764diff
changeset | 113 | case strip_comb t of | 
| 
2a0e24c74593
strong_ind_simproc now only rewrites arguments of inductive predicates.
 berghofe parents: 
23764diff
changeset | 114 | (h as Const (name, _), ts) => (case Symtab.lookup tab name of | 
| 
2a0e24c74593
strong_ind_simproc now only rewrites arguments of inductive predicates.
 berghofe parents: 
23764diff
changeset | 115 | SOME _ => | 
| 
2a0e24c74593
strong_ind_simproc now only rewrites arguments of inductive predicates.
 berghofe parents: 
23764diff
changeset | 116 | let val rews = map mk_rew ts | 
| 
2a0e24c74593
strong_ind_simproc now only rewrites arguments of inductive predicates.
 berghofe parents: 
23764diff
changeset | 117 | in | 
| 
2a0e24c74593
strong_ind_simproc now only rewrites arguments of inductive predicates.
 berghofe parents: 
23764diff
changeset | 118 | if forall is_none rews then NONE | 
| 36945 | 119 | else SOME (fold (fn th1 => fn th2 => Thm.combination th2 th1) | 
| 120 | (map2 (fn SOME r => K r | NONE => Thm.reflexive o cterm_of thy) | |
| 121 | rews ts) (Thm.reflexive (cterm_of thy h))) | |
| 23849 
2a0e24c74593
strong_ind_simproc now only rewrites arguments of inductive predicates.
 berghofe parents: 
23764diff
changeset | 122 | end | 
| 
2a0e24c74593
strong_ind_simproc now only rewrites arguments of inductive predicates.
 berghofe parents: 
23764diff
changeset | 123 | | NONE => NONE) | 
| 
2a0e24c74593
strong_ind_simproc now only rewrites arguments of inductive predicates.
 berghofe parents: 
23764diff
changeset | 124 | | _ => NONE | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 125 | end); | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 126 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 127 | (* only eta contract terms occurring as arguments of functions satisfying p *) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 128 | fun eta_contract p = | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 129 | let | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 130 | fun eta b (Abs (a, T, body)) = | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 131 | (case eta b body of | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 132 | body' as (f $ Bound 0) => | 
| 42083 
e1209fc7ecdc
added Term.is_open and Term.is_dependent convenience, to cover common situations of loose bounds;
 wenzelm parents: 
41489diff
changeset | 133 | if Term.is_dependent f orelse not b then Abs (a, T, body') | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 134 | else incr_boundvars ~1 f | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 135 | | body' => Abs (a, T, body')) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 136 | | eta b (t $ u) = eta b t $ eta (p (head_of t)) u | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 137 | | eta b t = t | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 138 | in eta false end; | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 139 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 140 | fun eta_contract_thm p = | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 141 | Conv.fconv_rule (Conv.then_conv (Thm.beta_conversion true, fn ct => | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 142 | Thm.transitive (Thm.eta_conversion ct) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 143 | (Thm.symmetric (Thm.eta_conversion | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 144 | (cterm_of (theory_of_cterm ct) (eta_contract p (term_of ct))))))); | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 145 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 146 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 147 | (***********************************************************) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 148 | (* rules for converting between predicate and set notation *) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 149 | (* *) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 150 | (* rules for converting predicates to sets have the form *) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 151 | (* P (%x y. (x, y) : s) = (%x y. (x, y) : S s) *) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 152 | (* *) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 153 | (* rules for converting sets to predicates have the form *) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 154 | (* S {(x, y). p x y} = {(x, y). P p x y}                   *)
 | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 155 | (* *) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 156 | (* where s and p are parameters *) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 157 | (***********************************************************) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 158 | |
| 33519 | 159 | structure PredSetConvData = Generic_Data | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 160 | ( | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 161 | type T = | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 162 |     {(* rules for converting predicates to sets *)
 | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 163 | to_set_simps: thm list, | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 164 | (* rules for converting sets to predicates *) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 165 | to_pred_simps: thm list, | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 166 | (* arities of functions of type t set => ... => u set *) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 167 | set_arities: (typ * (int list list option list * int list list option)) list Symtab.table, | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 168 | (* arities of functions of type (t => ... => bool) => u => ... => bool *) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 169 | pred_arities: (typ * (int list list option list * int list list option)) list Symtab.table}; | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 170 |   val empty = {to_set_simps = [], to_pred_simps = [],
 | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 171 | set_arities = Symtab.empty, pred_arities = Symtab.empty}; | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 172 | val extend = I; | 
| 33519 | 173 | fun merge | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 174 |     ({to_set_simps = to_set_simps1, to_pred_simps = to_pred_simps1,
 | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 175 | set_arities = set_arities1, pred_arities = pred_arities1}, | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 176 |      {to_set_simps = to_set_simps2, to_pred_simps = to_pred_simps2,
 | 
| 29288 | 177 | set_arities = set_arities2, pred_arities = pred_arities2}) : T = | 
| 24039 
273698405054
renamed Drule.add/del/merge_rules to Thm.add/del/merge_thms;
 wenzelm parents: 
23849diff
changeset | 178 |     {to_set_simps = Thm.merge_thms (to_set_simps1, to_set_simps2),
 | 
| 
273698405054
renamed Drule.add/del/merge_rules to Thm.add/del/merge_thms;
 wenzelm parents: 
23849diff
changeset | 179 | to_pred_simps = Thm.merge_thms (to_pred_simps1, to_pred_simps2), | 
| 41472 
f6ab14e61604
misc tuning and comments based on review of Theory_Data, Proof_Data, Generic_Data usage;
 wenzelm parents: 
38864diff
changeset | 180 | set_arities = Symtab.merge_list (op =) (set_arities1, set_arities2), | 
| 
f6ab14e61604
misc tuning and comments based on review of Theory_Data, Proof_Data, Generic_Data usage;
 wenzelm parents: 
38864diff
changeset | 181 | pred_arities = Symtab.merge_list (op =) (pred_arities1, pred_arities2)}; | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 182 | ); | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 183 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 184 | fun name_type_of (Free p) = SOME p | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 185 | | name_type_of (Const p) = SOME p | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 186 | | name_type_of _ = NONE; | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 187 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 188 | fun map_type f (Free (s, T)) = Free (s, f T) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 189 | | map_type f (Var (ixn, T)) = Var (ixn, f T) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 190 | | map_type f _ = error "map_type"; | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 191 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 192 | fun find_most_specific is_inst f eq xs T = | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 193 | find_first (fn U => is_inst (T, f U) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 194 | andalso forall (fn U' => eq (f U, f U') orelse not | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 195 | (is_inst (T, f U') andalso is_inst (f U', f U))) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 196 | xs) xs; | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 197 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 198 | fun lookup_arity thy arities (s, T) = case Symtab.lookup arities s of | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 199 | NONE => NONE | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 200 | | SOME xs => find_most_specific (Sign.typ_instance thy) fst (op =) xs T; | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 201 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 202 | fun lookup_rule thy f rules = find_most_specific | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 203 | (swap #> Pattern.matches thy) (f #> fst) (op aconv) rules; | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 204 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 205 | fun infer_arities thy arities (optf, t) fs = case strip_comb t of | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 206 | (Abs (s, T, u), []) => infer_arities thy arities (NONE, u) fs | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 207 | | (Abs _, _) => infer_arities thy arities (NONE, Envir.beta_norm t) fs | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 208 | | (u, ts) => (case Option.map (lookup_arity thy arities) (name_type_of u) of | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 209 | SOME (SOME (_, (arity, _))) => | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 210 | (fold (infer_arities thy arities) (arity ~~ List.take (ts, length arity)) fs | 
| 43278 | 211 | handle General.Subscript => error "infer_arities: bad term") | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 212 | | _ => fold (infer_arities thy arities) (map (pair NONE) ts) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 213 | (case optf of | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 214 | NONE => fs | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 215 | | SOME f => AList.update op = (u, the_default f | 
| 33049 
c38f02fdf35d
curried inter as canonical list operation (beware of argument order)
 haftmann parents: 
33038diff
changeset | 216 | (Option.map (fn g => inter (op =) g f) (AList.lookup op = fs u))) fs)); | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 217 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 218 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 219 | (**************************************************************) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 220 | (* derive the to_pred equation from the to_set equation *) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 221 | (* *) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 222 | (* 1. instantiate each set parameter with {(x, y). p x y}     *)
 | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 223 | (* 2. apply %P. {(x, y). P x y} to both sides of the equation *)
 | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 224 | (* 3. simplify *) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 225 | (**************************************************************) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 226 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 227 | fun mk_to_pred_inst thy fs = | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 228 | map (fn (x, ps) => | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 229 | let | 
| 46828 
b1d15637381a
to_pred/set attributes now properly handle variables of type "... => T set"
 berghofe parents: 
46219diff
changeset | 230 | val (Ts, T) = strip_type (fastype_of x); | 
| 
b1d15637381a
to_pred/set attributes now properly handle variables of type "... => T set"
 berghofe parents: 
46219diff
changeset | 231 | val U = HOLogic.dest_setT T; | 
| 
b1d15637381a
to_pred/set attributes now properly handle variables of type "... => T set"
 berghofe parents: 
46219diff
changeset | 232 | val x' = map_type | 
| 
b1d15637381a
to_pred/set attributes now properly handle variables of type "... => T set"
 berghofe parents: 
46219diff
changeset | 233 | (K (Ts @ HOLogic.strip_ptupleT ps U ---> HOLogic.boolT)) x; | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 234 | in | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 235 | (cterm_of thy x, | 
| 46828 
b1d15637381a
to_pred/set attributes now properly handle variables of type "... => T set"
 berghofe parents: 
46219diff
changeset | 236 | cterm_of thy (fold_rev (Term.abs o pair "x") Ts | 
| 
b1d15637381a
to_pred/set attributes now properly handle variables of type "... => T set"
 berghofe parents: 
46219diff
changeset | 237 | (HOLogic.Collect_const U $ | 
| 
b1d15637381a
to_pred/set attributes now properly handle variables of type "... => T set"
 berghofe parents: 
46219diff
changeset | 238 | HOLogic.mk_psplits ps U HOLogic.boolT | 
| 
b1d15637381a
to_pred/set attributes now properly handle variables of type "... => T set"
 berghofe parents: 
46219diff
changeset | 239 | (list_comb (x', map Bound (length Ts - 1 downto 0)))))) | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 240 | end) fs; | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 241 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 242 | fun mk_to_pred_eq p fs optfs' T thm = | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 243 | let | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 244 | val thy = theory_of_thm thm; | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 245 | val insts = mk_to_pred_inst thy fs; | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 246 | val thm' = Thm.instantiate ([], insts) thm; | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 247 | val thm'' = (case optfs' of | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 248 | NONE => thm' RS sym | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 249 | | SOME fs' => | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 250 | let | 
| 45979 | 251 | val U = HOLogic.dest_setT (body_type T); | 
| 32342 
3fabf5b5fc83
path-sensitive tuple combinators carry a "p"(ath) prefix; combinators for standard right-fold tuples
 haftmann parents: 
32287diff
changeset | 252 | val Ts = HOLogic.strip_ptupleT fs' U; | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 253 | (* FIXME: should cterm_instantiate increment indexes? *) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 254 | val arg_cong' = Thm.incr_indexes (Thm.maxidx_of thm + 1) arg_cong; | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 255 | val (arg_cong_f, _) = arg_cong' |> cprop_of |> Drule.strip_imp_concl |> | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 256 | Thm.dest_comb |> snd |> Drule.strip_comb |> snd |> hd |> Thm.dest_comb | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 257 | in | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 258 | thm' RS (Drule.cterm_instantiate [(arg_cong_f, | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 259 |               cterm_of thy (Abs ("P", Ts ---> HOLogic.boolT,
 | 
| 32342 
3fabf5b5fc83
path-sensitive tuple combinators carry a "p"(ath) prefix; combinators for standard right-fold tuples
 haftmann parents: 
32287diff
changeset | 260 | HOLogic.Collect_const U $ HOLogic.mk_psplits fs' U | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 261 | HOLogic.boolT (Bound 0))))] arg_cong' RS sym) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 262 | end) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 263 | in | 
| 37136 | 264 |     Simplifier.simplify (HOL_basic_ss addsimps [mem_Collect_eq, @{thm split_conv}]
 | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 265 | addsimprocs [collect_mem_simproc]) thm'' |> | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 266 | zero_var_indexes |> eta_contract_thm (equal p) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 267 | end; | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 268 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 269 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 270 | (**** declare rules for converting predicates to sets ****) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 271 | |
| 26047 
d27b89c95b29
Instead of raising an exception, pred_set_conv now ignores conversion
 berghofe parents: 
25978diff
changeset | 272 | fun add ctxt thm (tab as {to_set_simps, to_pred_simps, set_arities, pred_arities}) =
 | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 273 | case prop_of thm of | 
| 38864 
4abe644fcea5
formerly unnamed infix equality now named HOL.eq
 haftmann parents: 
38795diff
changeset | 274 |     Const (@{const_name Trueprop}, _) $ (Const (@{const_name HOL.eq}, Type (_, [T, _])) $ lhs $ rhs) =>
 | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 275 | (case body_type T of | 
| 35364 | 276 |          @{typ bool} =>
 | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 277 | let | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 278 | val thy = Context.theory_of ctxt; | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 279 | fun factors_of t fs = case strip_abs_body t of | 
| 37677 | 280 |                  Const (@{const_name Set.member}, _) $ u $ S =>
 | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 281 | if is_Free S orelse is_Var S then | 
| 32287 
65d5c5b30747
cleaned up abstract tuple operations and named them consistently
 haftmann parents: 
32135diff
changeset | 282 | let val ps = HOLogic.flat_tuple_paths u | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 283 | in (SOME ps, (S, ps) :: fs) end | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 284 | else (NONE, fs) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 285 | | _ => (NONE, fs); | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 286 | val (h, ts) = strip_comb lhs | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 287 | val (pfs, fs) = fold_map factors_of ts []; | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 288 | val ((h', ts'), fs') = (case rhs of | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 289 | Abs _ => (case strip_abs_body rhs of | 
| 37677 | 290 |                      Const (@{const_name Set.member}, _) $ u $ S =>
 | 
| 32287 
65d5c5b30747
cleaned up abstract tuple operations and named them consistently
 haftmann parents: 
32135diff
changeset | 291 | (strip_comb S, SOME (HOLogic.flat_tuple_paths u)) | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 292 | | _ => error "member symbol on right-hand side expected") | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 293 | | _ => (strip_comb rhs, NONE)) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 294 | in | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 295 | case (name_type_of h, name_type_of h') of | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 296 | (SOME (s, T), SOME (s', T')) => | 
| 26047 
d27b89c95b29
Instead of raising an exception, pred_set_conv now ignores conversion
 berghofe parents: 
25978diff
changeset | 297 | if exists (fn (U, _) => | 
| 
d27b89c95b29
Instead of raising an exception, pred_set_conv now ignores conversion
 berghofe parents: 
25978diff
changeset | 298 | Sign.typ_instance thy (T', U) andalso | 
| 
d27b89c95b29
Instead of raising an exception, pred_set_conv now ignores conversion
 berghofe parents: 
25978diff
changeset | 299 | Sign.typ_instance thy (U, T')) | 
| 
d27b89c95b29
Instead of raising an exception, pred_set_conv now ignores conversion
 berghofe parents: 
25978diff
changeset | 300 | (Symtab.lookup_list set_arities s') | 
| 
d27b89c95b29
Instead of raising an exception, pred_set_conv now ignores conversion
 berghofe parents: 
25978diff
changeset | 301 | then | 
| 
d27b89c95b29
Instead of raising an exception, pred_set_conv now ignores conversion
 berghofe parents: 
25978diff
changeset | 302 |                    (warning ("Ignoring conversion rule for operator " ^ s'); tab)
 | 
| 
d27b89c95b29
Instead of raising an exception, pred_set_conv now ignores conversion
 berghofe parents: 
25978diff
changeset | 303 | else | 
| 
d27b89c95b29
Instead of raising an exception, pred_set_conv now ignores conversion
 berghofe parents: 
25978diff
changeset | 304 |                    {to_set_simps = thm :: to_set_simps,
 | 
| 
d27b89c95b29
Instead of raising an exception, pred_set_conv now ignores conversion
 berghofe parents: 
25978diff
changeset | 305 | to_pred_simps = | 
| 
d27b89c95b29
Instead of raising an exception, pred_set_conv now ignores conversion
 berghofe parents: 
25978diff
changeset | 306 | mk_to_pred_eq h fs fs' T' thm :: to_pred_simps, | 
| 
d27b89c95b29
Instead of raising an exception, pred_set_conv now ignores conversion
 berghofe parents: 
25978diff
changeset | 307 | set_arities = Symtab.insert_list op = (s', | 
| 
d27b89c95b29
Instead of raising an exception, pred_set_conv now ignores conversion
 berghofe parents: 
25978diff
changeset | 308 | (T', (map (AList.lookup op = fs) ts', fs'))) set_arities, | 
| 
d27b89c95b29
Instead of raising an exception, pred_set_conv now ignores conversion
 berghofe parents: 
25978diff
changeset | 309 | pred_arities = Symtab.insert_list op = (s, | 
| 
d27b89c95b29
Instead of raising an exception, pred_set_conv now ignores conversion
 berghofe parents: 
25978diff
changeset | 310 | (T, (pfs, fs'))) pred_arities} | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 311 | | _ => error "set / predicate constant expected" | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 312 | end | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 313 | | _ => error "equation between predicates expected") | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 314 | | _ => error "equation expected"; | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 315 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 316 | val pred_set_conv_att = Thm.declaration_attribute | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 317 | (fn thm => fn ctxt => PredSetConvData.map (add ctxt thm) ctxt); | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 318 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 319 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 320 | (**** convert theorem in set notation to predicate notation ****) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 321 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 322 | fun is_pred tab t = | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 323 | case Option.map (Symtab.lookup tab o fst) (name_type_of t) of | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 324 | SOME (SOME _) => true | _ => false; | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 325 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 326 | fun to_pred_simproc rules = | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 327 | let val rules' = map mk_meta_eq rules | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 328 | in | 
| 38715 
6513ea67d95d
renamed Simplifier.simproc(_i) to Simplifier.simproc_global(_i) to emphasize that this is not the real thing;
 wenzelm parents: 
38665diff
changeset | 329 |     Simplifier.simproc_global_i @{theory HOL} "to_pred" [anyt]
 | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 330 | (fn thy => K (lookup_rule thy (prop_of #> Logic.dest_equals) rules')) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 331 | end; | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 332 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 333 | fun to_pred_proc thy rules t = case lookup_rule thy I rules t of | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 334 | NONE => NONE | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 335 | | SOME (lhs, rhs) => | 
| 32035 | 336 | SOME (Envir.subst_term | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 337 | (Pattern.match thy (lhs, t) (Vartab.empty, Vartab.empty)) rhs); | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 338 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 339 | fun to_pred thms ctxt thm = | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 340 | let | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 341 | val thy = Context.theory_of ctxt; | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 342 |     val {to_pred_simps, set_arities, pred_arities, ...} =
 | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 343 | fold (add ctxt) thms (PredSetConvData.get ctxt); | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 344 | val fs = filter (is_Var o fst) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 345 | (infer_arities thy set_arities (NONE, prop_of thm) []); | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 346 |     (* instantiate each set parameter with {(x, y). p x y} *)
 | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 347 | val insts = mk_to_pred_inst thy fs | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 348 | in | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 349 | thm |> | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 350 | Thm.instantiate ([], insts) |> | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 351 | Simplifier.full_simplify (HOL_basic_ss addsimprocs | 
| 37136 | 352 |       [to_pred_simproc (mem_Collect_eq :: @{thm split_conv} :: to_pred_simps)]) |>
 | 
| 25416 
1d8ebaf5f211
to_pred and to_set now save induction and case rule tags.
 berghofe parents: 
25016diff
changeset | 353 | eta_contract_thm (is_pred pred_arities) |> | 
| 33368 | 354 | Rule_Cases.save thm | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 355 | end; | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 356 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 357 | val to_pred_att = Thm.rule_attribute o to_pred; | 
| 45979 | 358 | |
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 359 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 360 | (**** convert theorem in predicate notation to set notation ****) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 361 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 362 | fun to_set thms ctxt thm = | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 363 | let | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 364 | val thy = Context.theory_of ctxt; | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 365 |     val {to_set_simps, pred_arities, ...} =
 | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 366 | fold (add ctxt) thms (PredSetConvData.get ctxt); | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 367 | val fs = filter (is_Var o fst) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 368 | (infer_arities thy pred_arities (NONE, prop_of thm) []); | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 369 | (* instantiate each predicate parameter with %x y. (x, y) : s *) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 370 | val insts = map (fn (x, ps) => | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 371 | let | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 372 | val Ts = binder_types (fastype_of x); | 
| 46828 
b1d15637381a
to_pred/set attributes now properly handle variables of type "... => T set"
 berghofe parents: 
46219diff
changeset | 373 | val l = length Ts; | 
| 
b1d15637381a
to_pred/set attributes now properly handle variables of type "... => T set"
 berghofe parents: 
46219diff
changeset | 374 | val k = length ps; | 
| 
b1d15637381a
to_pred/set attributes now properly handle variables of type "... => T set"
 berghofe parents: 
46219diff
changeset | 375 | val (Rs, Us) = chop (l - k - 1) Ts; | 
| 
b1d15637381a
to_pred/set attributes now properly handle variables of type "... => T set"
 berghofe parents: 
46219diff
changeset | 376 | val T = HOLogic.mk_ptupleT ps Us; | 
| 
b1d15637381a
to_pred/set attributes now properly handle variables of type "... => T set"
 berghofe parents: 
46219diff
changeset | 377 | val x' = map_type (K (Rs ---> HOLogic.mk_setT T)) x | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 378 | in | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 379 | (cterm_of thy x, | 
| 46219 
426ed18eba43
discontinued old-style Term.list_abs in favour of plain Term.abs;
 wenzelm parents: 
45979diff
changeset | 380 | cterm_of thy (fold_rev (Term.abs o pair "x") Ts | 
| 46828 
b1d15637381a
to_pred/set attributes now properly handle variables of type "... => T set"
 berghofe parents: 
46219diff
changeset | 381 | (HOLogic.mk_mem (HOLogic.mk_ptuple ps T (map Bound (k downto 0)), | 
| 
b1d15637381a
to_pred/set attributes now properly handle variables of type "... => T set"
 berghofe parents: 
46219diff
changeset | 382 | list_comb (x', map Bound (l - 1 downto k + 1)))))) | 
| 46219 
426ed18eba43
discontinued old-style Term.list_abs in favour of plain Term.abs;
 wenzelm parents: 
45979diff
changeset | 383 | end) fs; | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 384 | in | 
| 25416 
1d8ebaf5f211
to_pred and to_set now save induction and case rule tags.
 berghofe parents: 
25016diff
changeset | 385 | thm |> | 
| 
1d8ebaf5f211
to_pred and to_set now save induction and case rule tags.
 berghofe parents: 
25016diff
changeset | 386 | Thm.instantiate ([], insts) |> | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 387 | Simplifier.full_simplify (HOL_basic_ss addsimps to_set_simps | 
| 25487 | 388 | addsimprocs [strong_ind_simproc pred_arities, collect_mem_simproc]) |> | 
| 33368 | 389 | Rule_Cases.save thm | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 390 | end; | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 391 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 392 | val to_set_att = Thm.rule_attribute o to_set; | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 393 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 394 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 395 | (**** preprocessor for code generator ****) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 396 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 397 | fun codegen_preproc thy = | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 398 | let | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 399 |     val {to_pred_simps, set_arities, pred_arities, ...} =
 | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 400 | PredSetConvData.get (Context.Theory thy); | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 401 | fun preproc thm = | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 402 | if exists_Const (fn (s, _) => case Symtab.lookup set_arities s of | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 403 | NONE => false | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 404 | | SOME arities => exists (fn (_, (xs, _)) => | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 405 | forall is_none xs) arities) (prop_of thm) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 406 | then | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 407 | thm |> | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 408 | Simplifier.full_simplify (HOL_basic_ss addsimprocs | 
| 37136 | 409 |           [to_pred_simproc (mem_Collect_eq :: @{thm split_conv} :: to_pred_simps)]) |>
 | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 410 | eta_contract_thm (is_pred pred_arities) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 411 | else thm | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 412 | in map preproc end; | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 413 | |
| 45177 
189c81779a68
removing old code generator setup for inductive sets in the inductive set package
 bulwahn parents: 
44045diff
changeset | 414 | fun code_ind_att optmod = to_pred_att []; | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 415 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 416 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 417 | (**** definition of inductive sets ****) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 418 | |
| 29389 | 419 | fun add_ind_set_def | 
| 33669 | 420 |     {quiet_mode, verbose, alt_name, coind, no_elim, no_ind, skip_mono, fork_mono}
 | 
| 33458 
ae1f5d89b082
proper naming convention lthy: local_theory, but ctxt: Proof.context for arbitrary context;
 wenzelm parents: 
33368diff
changeset | 421 | cs intros monos params cnames_syn lthy = | 
| 
ae1f5d89b082
proper naming convention lthy: local_theory, but ctxt: Proof.context for arbitrary context;
 wenzelm parents: 
33368diff
changeset | 422 | let | 
| 42361 | 423 | val thy = Proof_Context.theory_of lthy; | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 424 |     val {set_arities, pred_arities, to_pred_simps, ...} =
 | 
| 33458 
ae1f5d89b082
proper naming convention lthy: local_theory, but ctxt: Proof.context for arbitrary context;
 wenzelm parents: 
33368diff
changeset | 425 | PredSetConvData.get (Context.Proof lthy); | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 426 | fun infer (Abs (_, _, t)) = infer t | 
| 37677 | 427 |       | infer (Const (@{const_name Set.member}, _) $ t $ u) =
 | 
| 32287 
65d5c5b30747
cleaned up abstract tuple operations and named them consistently
 haftmann parents: 
32135diff
changeset | 428 | infer_arities thy set_arities (SOME (HOLogic.flat_tuple_paths t), u) | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 429 | | infer (t $ u) = infer t #> infer u | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 430 | | infer _ = I; | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 431 | val new_arities = filter_out | 
| 45979 | 432 | (fn (x as Free (_, T), _) => member (op =) params x andalso length (binder_types T) > 0 | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 433 | | _ => false) (fold (snd #> infer) intros []); | 
| 33278 | 434 | val params' = map (fn x => | 
| 435 | (case AList.lookup op = new_arities x of | |
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 436 | SOME fs => | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 437 | let | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 438 | val T = HOLogic.dest_setT (fastype_of x); | 
| 32342 
3fabf5b5fc83
path-sensitive tuple combinators carry a "p"(ath) prefix; combinators for standard right-fold tuples
 haftmann parents: 
32287diff
changeset | 439 | val Ts = HOLogic.strip_ptupleT fs T; | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 440 | val x' = map_type (K (Ts ---> HOLogic.boolT)) x | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 441 | in | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 442 | (x, (x', | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 443 | (HOLogic.Collect_const T $ | 
| 32342 
3fabf5b5fc83
path-sensitive tuple combinators carry a "p"(ath) prefix; combinators for standard right-fold tuples
 haftmann parents: 
32287diff
changeset | 444 | HOLogic.mk_psplits fs T HOLogic.boolT x', | 
| 46219 
426ed18eba43
discontinued old-style Term.list_abs in favour of plain Term.abs;
 wenzelm parents: 
45979diff
changeset | 445 | fold_rev (Term.abs o pair "x") Ts | 
| 
426ed18eba43
discontinued old-style Term.list_abs in favour of plain Term.abs;
 wenzelm parents: 
45979diff
changeset | 446 | (HOLogic.mk_mem | 
| 
426ed18eba43
discontinued old-style Term.list_abs in favour of plain Term.abs;
 wenzelm parents: 
45979diff
changeset | 447 | (HOLogic.mk_ptuple fs T (map Bound (length fs downto 0)), x))))) | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 448 | end | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 449 | | NONE => (x, (x, (x, x))))) params; | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 450 | val (params1, (params2, params3)) = | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 451 | params' |> map snd |> split_list ||> split_list; | 
| 30860 
e5f9477aed50
Added check whether argument types of inductive set agree with types of declared
 berghofe parents: 
30528diff
changeset | 452 | val paramTs = map fastype_of params; | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 453 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 454 | (* equations for converting sets to predicates *) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 455 | val ((cs', cs_info), eqns) = cs |> map (fn c as Free (s, T) => | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 456 | let | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 457 | val fs = the_default [] (AList.lookup op = new_arities c); | 
| 45979 | 458 | val (Us, U) = strip_type T |> apsnd HOLogic.dest_setT; | 
| 30860 
e5f9477aed50
Added check whether argument types of inductive set agree with types of declared
 berghofe parents: 
30528diff
changeset | 459 | val _ = Us = paramTs orelse error (Pretty.string_of (Pretty.chunks | 
| 
e5f9477aed50
Added check whether argument types of inductive set agree with types of declared
 berghofe parents: 
30528diff
changeset | 460 | [Pretty.str "Argument types", | 
| 33458 
ae1f5d89b082
proper naming convention lthy: local_theory, but ctxt: Proof.context for arbitrary context;
 wenzelm parents: 
33368diff
changeset | 461 | Pretty.block (Pretty.commas (map (Syntax.pretty_typ lthy) Us)), | 
| 30860 
e5f9477aed50
Added check whether argument types of inductive set agree with types of declared
 berghofe parents: 
30528diff
changeset | 462 |            Pretty.str ("of " ^ s ^ " do not agree with types"),
 | 
| 33458 
ae1f5d89b082
proper naming convention lthy: local_theory, but ctxt: Proof.context for arbitrary context;
 wenzelm parents: 
33368diff
changeset | 463 | Pretty.block (Pretty.commas (map (Syntax.pretty_typ lthy) paramTs)), | 
| 30860 
e5f9477aed50
Added check whether argument types of inductive set agree with types of declared
 berghofe parents: 
30528diff
changeset | 464 | Pretty.str "of declared parameters"])); | 
| 32342 
3fabf5b5fc83
path-sensitive tuple combinators carry a "p"(ath) prefix; combinators for standard right-fold tuples
 haftmann parents: 
32287diff
changeset | 465 | val Ts = HOLogic.strip_ptupleT fs U; | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 466 | val c' = Free (s ^ "p", | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 467 | map fastype_of params1 @ Ts ---> HOLogic.boolT) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 468 | in | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 469 | ((c', (fs, U, Ts)), | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 470 | (list_comb (c, params2), | 
| 32342 
3fabf5b5fc83
path-sensitive tuple combinators carry a "p"(ath) prefix; combinators for standard right-fold tuples
 haftmann parents: 
32287diff
changeset | 471 | HOLogic.Collect_const U $ HOLogic.mk_psplits fs U HOLogic.boolT | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 472 | (list_comb (c', params1)))) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 473 | end) |> split_list |>> split_list; | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 474 | val eqns' = eqns @ | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 475 | map (prop_of #> HOLogic.dest_Trueprop #> HOLogic.dest_eq) | 
| 37136 | 476 |         (mem_Collect_eq :: @{thm split_conv} :: to_pred_simps);
 | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 477 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 478 | (* predicate version of the introduction rules *) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 479 | val intros' = | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 480 | map (fn (name_atts, t) => (name_atts, | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 481 | t |> | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 482 | map_aterms (fn u => | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 483 | (case AList.lookup op = params' u of | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 484 | SOME (_, (u', _)) => u' | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 485 | | NONE => u)) |> | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 486 | Pattern.rewrite_term thy [] [to_pred_proc thy eqns'] |> | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 487 | eta_contract (member op = cs' orf is_pred pred_arities))) intros; | 
| 30345 | 488 | val cnames_syn' = map (fn (b, _) => (Binding.suffix_name "p" b, NoSyn)) cnames_syn; | 
| 33458 
ae1f5d89b082
proper naming convention lthy: local_theory, but ctxt: Proof.context for arbitrary context;
 wenzelm parents: 
33368diff
changeset | 489 | val monos' = map (to_pred [] (Context.Proof lthy)) monos; | 
| 38665 
e92223c886f8
introducing simplification equations for inductive sets; added data structure for storing equations; rewriting retrieval of simplification equation for inductive predicates and sets
 bulwahn parents: 
37863diff
changeset | 490 |     val ({preds, intrs, elims, raw_induct, eqs, ...}, lthy1) =
 | 
| 31723 
f5cafe803b55
discontinued ancient tradition to suffix certain ML module names with "_package"
 haftmann parents: 
30860diff
changeset | 491 | Inductive.add_ind_def | 
| 33669 | 492 |         {quiet_mode = quiet_mode, verbose = verbose, alt_name = Binding.empty,
 | 
| 29389 | 493 | coind = coind, no_elim = no_elim, no_ind = no_ind, | 
| 494 | skip_mono = skip_mono, fork_mono = fork_mono} | |
| 33458 
ae1f5d89b082
proper naming convention lthy: local_theory, but ctxt: Proof.context for arbitrary context;
 wenzelm parents: 
33368diff
changeset | 495 | cs' intros' monos' params1 cnames_syn' lthy; | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 496 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 497 | (* define inductive sets using previously defined predicates *) | 
| 33458 
ae1f5d89b082
proper naming convention lthy: local_theory, but ctxt: Proof.context for arbitrary context;
 wenzelm parents: 
33368diff
changeset | 498 | val (defs, lthy2) = lthy1 | 
| 33671 | 499 | |> Local_Theory.conceal (* FIXME ?? *) | 
| 33766 
c679f05600cd
adapted Local_Theory.define -- eliminated odd thm kind;
 wenzelm parents: 
33671diff
changeset | 500 | |> fold_map Local_Theory.define | 
| 46909 | 501 | (map (fn (((c, syn), (fs, U, _)), p) => ((c, syn), ((Thm.def_binding c, []), | 
| 33278 | 502 | fold_rev lambda params (HOLogic.Collect_const U $ | 
| 503 | HOLogic.mk_psplits fs U HOLogic.boolT (list_comb (p, params3)))))) | |
| 504 | (cnames_syn ~~ cs_info ~~ preds)) | |
| 33671 | 505 | ||> Local_Theory.restore_naming lthy1; | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 506 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 507 | (* prove theorems for converting predicate to set notation *) | 
| 33458 
ae1f5d89b082
proper naming convention lthy: local_theory, but ctxt: Proof.context for arbitrary context;
 wenzelm parents: 
33368diff
changeset | 508 | val lthy3 = fold | 
| 
ae1f5d89b082
proper naming convention lthy: local_theory, but ctxt: Proof.context for arbitrary context;
 wenzelm parents: 
33368diff
changeset | 509 | (fn (((p, c as Free (s, _)), (fs, U, Ts)), (_, (_, def))) => fn lthy => | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 510 | let val conv_thm = | 
| 33458 
ae1f5d89b082
proper naming convention lthy: local_theory, but ctxt: Proof.context for arbitrary context;
 wenzelm parents: 
33368diff
changeset | 511 | Goal.prove lthy (map (fst o dest_Free) params) [] | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 512 | (HOLogic.mk_Trueprop (HOLogic.mk_eq | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 513 | (list_comb (p, params3), | 
| 46219 
426ed18eba43
discontinued old-style Term.list_abs in favour of plain Term.abs;
 wenzelm parents: 
45979diff
changeset | 514 | fold_rev (Term.abs o pair "x") Ts | 
| 
426ed18eba43
discontinued old-style Term.list_abs in favour of plain Term.abs;
 wenzelm parents: 
45979diff
changeset | 515 | (HOLogic.mk_mem (HOLogic.mk_ptuple fs U (map Bound (length fs downto 0)), | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 516 | list_comb (c, params)))))) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 517 | (K (REPEAT (rtac ext 1) THEN simp_tac (HOL_basic_ss addsimps | 
| 37136 | 518 |               [def, mem_Collect_eq, @{thm split_conv}]) 1))
 | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 519 | in | 
| 33671 | 520 | lthy |> Local_Theory.note ((Binding.name (s ^ "p_" ^ s ^ "_eq"), | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 521 | [Attrib.internal (K pred_set_conv_att)]), | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 522 | [conv_thm]) |> snd | 
| 33458 
ae1f5d89b082
proper naming convention lthy: local_theory, but ctxt: Proof.context for arbitrary context;
 wenzelm parents: 
33368diff
changeset | 523 | end) (preds ~~ cs ~~ cs_info ~~ defs) lthy2; | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 524 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 525 | (* convert theorems to set notation *) | 
| 28083 
103d9282a946
explicit type Name.binding for higher-specification elements;
 wenzelm parents: 
27330diff
changeset | 526 | val rec_name = | 
| 28965 | 527 | if Binding.is_empty alt_name then | 
| 30223 
24d975352879
renamed Binding.name_pos to Binding.make, renamed Binding.base_name to Binding.name_of, renamed Binding.map_base to Binding.map_name, added mandatory flag to Binding.qualify;
 wenzelm parents: 
30089diff
changeset | 528 | Binding.name (space_implode "_" (map (Binding.name_of o fst) cnames_syn)) | 
| 28083 
103d9282a946
explicit type Name.binding for higher-specification elements;
 wenzelm parents: 
27330diff
changeset | 529 | else alt_name; | 
| 33671 | 530 | val cnames = map (Local_Theory.full_name lthy3 o #1) cnames_syn; (* FIXME *) | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 531 | val (intr_names, intr_atts) = split_list (map fst intros); | 
| 33458 
ae1f5d89b082
proper naming convention lthy: local_theory, but ctxt: Proof.context for arbitrary context;
 wenzelm parents: 
33368diff
changeset | 532 | val raw_induct' = to_set [] (Context.Proof lthy3) raw_induct; | 
| 37734 
489ac1ecb9f1
added the new command inductive_cases to derive simplification equations for inductive predicates; added binding simps for general simplification equation
 bulwahn parents: 
37677diff
changeset | 533 | val (intrs', elims', eqs', induct, inducts, lthy4) = | 
| 35757 
c2884bec5463
adding Spec_Rules to definitional package inductive and inductive_set
 bulwahn parents: 
35646diff
changeset | 534 | Inductive.declare_rules rec_name coind no_ind cnames (map fst defs) | 
| 33459 | 535 | (map (to_set [] (Context.Proof lthy3)) intrs) intr_names intr_atts | 
| 536 | (map (fn th => (to_set [] (Context.Proof lthy3) th, | |
| 44045 
2814ff2a6e3e
infrastructure for attaching names to hypothesis in cases; realised via the same tag mechanism as case names
 nipkow parents: 
43278diff
changeset | 537 | map (fst o fst) (fst (Rule_Cases.get th)), | 
| 34986 
7f7939c9370f
Added "constraints" tag / attribute for specifying the number of equality
 berghofe parents: 
34903diff
changeset | 538 | Rule_Cases.get_constraints th)) elims) | 
| 38665 
e92223c886f8
introducing simplification equations for inductive sets; added data structure for storing equations; rewriting retrieval of simplification equation for inductive predicates and sets
 bulwahn parents: 
37863diff
changeset | 539 | (map (to_set [] (Context.Proof lthy3)) eqs) raw_induct' lthy3; | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 540 | in | 
| 35646 | 541 |     ({intrs = intrs', elims = elims', induct = induct, inducts = inducts,
 | 
| 37734 
489ac1ecb9f1
added the new command inductive_cases to derive simplification equations for inductive predicates; added binding simps for general simplification equation
 bulwahn parents: 
37677diff
changeset | 542 | raw_induct = raw_induct', preds = map fst defs, eqs = eqs'}, | 
| 33458 
ae1f5d89b082
proper naming convention lthy: local_theory, but ctxt: Proof.context for arbitrary context;
 wenzelm parents: 
33368diff
changeset | 543 | lthy4) | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 544 | end; | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 545 | |
| 31723 
f5cafe803b55
discontinued ancient tradition to suffix certain ML module names with "_package"
 haftmann parents: 
30860diff
changeset | 546 | val add_inductive_i = Inductive.gen_add_inductive_i add_ind_set_def; | 
| 
f5cafe803b55
discontinued ancient tradition to suffix certain ML module names with "_package"
 haftmann parents: 
30860diff
changeset | 547 | val add_inductive = Inductive.gen_add_inductive add_ind_set_def; | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 548 | |
| 45384 
dffa657f0aa2
clarified attribute "mono_set": pure declaration, proper export in ML;
 wenzelm parents: 
45375diff
changeset | 549 | fun mono_att att = | 
| 
dffa657f0aa2
clarified attribute "mono_set": pure declaration, proper export in ML;
 wenzelm parents: 
45375diff
changeset | 550 | Thm.declaration_attribute (fn thm => fn context => | 
| 
dffa657f0aa2
clarified attribute "mono_set": pure declaration, proper export in ML;
 wenzelm parents: 
45375diff
changeset | 551 | Thm.attribute_declaration att (to_pred [] context thm) context); | 
| 45375 
7fe19930dfc9
more explicit representation of rule_attribute vs. declaration_attribute vs. mixed_attribute;
 wenzelm parents: 
45177diff
changeset | 552 | |
| 45384 
dffa657f0aa2
clarified attribute "mono_set": pure declaration, proper export in ML;
 wenzelm parents: 
45375diff
changeset | 553 | val mono_add = mono_att Inductive.mono_add; | 
| 
dffa657f0aa2
clarified attribute "mono_set": pure declaration, proper export in ML;
 wenzelm parents: 
45375diff
changeset | 554 | val mono_del = mono_att Inductive.mono_del; | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 555 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 556 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 557 | (** package setup **) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 558 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 559 | (* setup theory *) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 560 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 561 | val setup = | 
| 30528 | 562 |   Attrib.setup @{binding pred_set_conv} (Scan.succeed pred_set_conv_att)
 | 
| 563 | "declare rules for converting between predicate and set notation" #> | |
| 33458 
ae1f5d89b082
proper naming convention lthy: local_theory, but ctxt: Proof.context for arbitrary context;
 wenzelm parents: 
33368diff
changeset | 564 |   Attrib.setup @{binding to_set} (Attrib.thms >> to_set_att)
 | 
| 
ae1f5d89b082
proper naming convention lthy: local_theory, but ctxt: Proof.context for arbitrary context;
 wenzelm parents: 
33368diff
changeset | 565 | "convert rule to set notation" #> | 
| 
ae1f5d89b082
proper naming convention lthy: local_theory, but ctxt: Proof.context for arbitrary context;
 wenzelm parents: 
33368diff
changeset | 566 |   Attrib.setup @{binding to_pred} (Attrib.thms >> to_pred_att)
 | 
| 
ae1f5d89b082
proper naming convention lthy: local_theory, but ctxt: Proof.context for arbitrary context;
 wenzelm parents: 
33368diff
changeset | 567 | "convert rule to predicate notation" #> | 
| 45384 
dffa657f0aa2
clarified attribute "mono_set": pure declaration, proper export in ML;
 wenzelm parents: 
45375diff
changeset | 568 |   Attrib.setup @{binding mono_set} (Attrib.add_del mono_add mono_del)
 | 
| 30528 | 569 | "declaration of monotonicity rule for set operators" #> | 
| 42795 
66fcc9882784
clarified map_simpset versus Simplifier.map_simpset_global;
 wenzelm parents: 
42361diff
changeset | 570 | Simplifier.map_simpset_global (fn ss => ss addsimprocs [collect_mem_simproc]); | 
| 30528 | 571 | |
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 572 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 573 | (* outer syntax *) | 
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 574 | |
| 31723 
f5cafe803b55
discontinued ancient tradition to suffix certain ML module names with "_package"
 haftmann parents: 
30860diff
changeset | 575 | val ind_set_decl = Inductive.gen_ind_decl add_ind_set_def; | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 576 | |
| 24867 | 577 | val _ = | 
| 46961 
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
 wenzelm parents: 
46909diff
changeset | 578 |   Outer_Syntax.local_theory' @{command_spec "inductive_set"} "define inductive sets"
 | 
| 33458 
ae1f5d89b082
proper naming convention lthy: local_theory, but ctxt: Proof.context for arbitrary context;
 wenzelm parents: 
33368diff
changeset | 579 | (ind_set_decl false); | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 580 | |
| 24867 | 581 | val _ = | 
| 46961 
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
 wenzelm parents: 
46909diff
changeset | 582 |   Outer_Syntax.local_theory' @{command_spec "coinductive_set"} "define coinductive sets"
 | 
| 33458 
ae1f5d89b082
proper naming convention lthy: local_theory, but ctxt: Proof.context for arbitrary context;
 wenzelm parents: 
33368diff
changeset | 583 | (ind_set_decl true); | 
| 23764 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 584 | |
| 
15f81c5d5330
New wrapper for defining inductive sets with new inductive
 berghofe parents: diff
changeset | 585 | end; |