83 (* dtype_spec list -> typ -> dtype_spec option *) |
83 (* dtype_spec list -> typ -> dtype_spec option *) |
84 fun datatype_spec (dtypes : dtype_spec list) T = |
84 fun datatype_spec (dtypes : dtype_spec list) T = |
85 List.find (equal T o #typ) dtypes |
85 List.find (equal T o #typ) dtypes |
86 |
86 |
87 (* dtype_spec list -> styp -> constr_spec *) |
87 (* dtype_spec list -> styp -> constr_spec *) |
88 fun constr_spec [] x = raise TERM ("NitpickScope.constr_spec", [Const x]) |
88 fun constr_spec [] x = raise TERM ("Nitpick_Scope.constr_spec", [Const x]) |
89 | constr_spec ({constrs, ...} :: dtypes : dtype_spec list) (x as (s, T)) = |
89 | constr_spec ({constrs, ...} :: dtypes : dtype_spec list) (x as (s, T)) = |
90 case List.find (equal (s, body_type T) o (apsnd body_type o #const)) |
90 case List.find (equal (s, body_type T) o (apsnd body_type o #const)) |
91 constrs of |
91 constrs of |
92 SOME c => c |
92 SOME c => c |
93 | NONE => constr_spec dtypes x |
93 | NONE => constr_spec dtypes x |
113 | NONE => Typtab.lookup ofs dummyT |> the_default 0 |
113 | NONE => Typtab.lookup ofs dummyT |> the_default 0 |
114 |
114 |
115 (* scope -> typ -> int * int *) |
115 (* scope -> typ -> int * int *) |
116 fun spec_of_type ({card_assigns, ofs, ...} : scope) T = |
116 fun spec_of_type ({card_assigns, ofs, ...} : scope) T = |
117 (card_of_type card_assigns T |
117 (card_of_type card_assigns T |
118 handle TYPE ("NitpickHOL.card_of_type", _, _) => ~1, offset_of_type ofs T) |
118 handle TYPE ("Nitpick_HOL.card_of_type", _, _) => ~1, offset_of_type ofs T) |
119 |
119 |
120 (* (string -> string) -> scope |
120 (* (string -> string) -> scope |
121 -> string list * string list * string list * string list * string list *) |
121 -> string list * string list * string list * string list * string list *) |
122 fun quintuple_for_scope quote ({ext_ctxt as {thy, ctxt, ...}, card_assigns, |
122 fun quintuple_for_scope quote ({ext_ctxt as {thy, ctxt, ...}, card_assigns, |
123 bisim_depth, datatypes, ...} : scope) = |
123 bisim_depth, datatypes, ...} : scope) = |
203 |
203 |
204 (* (''a * ''a -> bool) -> (''a option * int list) list -> ''a -> int list *) |
204 (* (''a * ''a -> bool) -> (''a option * int list) list -> ''a -> int list *) |
205 fun lookup_ints_assign eq asgns key = |
205 fun lookup_ints_assign eq asgns key = |
206 case triple_lookup eq asgns key of |
206 case triple_lookup eq asgns key of |
207 SOME ks => ks |
207 SOME ks => ks |
208 | NONE => raise ARG ("NitpickScope.lookup_ints_assign", "") |
208 | NONE => raise ARG ("Nitpick_Scope.lookup_ints_assign", "") |
209 (* theory -> (typ option * int list) list -> typ -> int list *) |
209 (* theory -> (typ option * int list) list -> typ -> int list *) |
210 fun lookup_type_ints_assign thy asgns T = |
210 fun lookup_type_ints_assign thy asgns T = |
211 map (curry Int.max 1) (lookup_ints_assign (type_match thy) asgns T) |
211 map (curry Int.max 1) (lookup_ints_assign (type_match thy) asgns T) |
212 handle ARG ("NitpickScope.lookup_ints_assign", _) => |
212 handle ARG ("Nitpick_Scope.lookup_ints_assign", _) => |
213 raise TYPE ("NitpickScope.lookup_type_ints_assign", [T], []) |
213 raise TYPE ("Nitpick_Scope.lookup_type_ints_assign", [T], []) |
214 (* theory -> (styp option * int list) list -> styp -> int list *) |
214 (* theory -> (styp option * int list) list -> styp -> int list *) |
215 fun lookup_const_ints_assign thy asgns x = |
215 fun lookup_const_ints_assign thy asgns x = |
216 lookup_ints_assign (const_match thy) asgns x |
216 lookup_ints_assign (const_match thy) asgns x |
217 handle ARG ("NitpickScope.lookup_ints_assign", _) => |
217 handle ARG ("Nitpick_Scope.lookup_ints_assign", _) => |
218 raise TERM ("NitpickScope.lookup_const_ints_assign", [Const x]) |
218 raise TERM ("Nitpick_Scope.lookup_const_ints_assign", [Const x]) |
219 |
219 |
220 (* theory -> (styp option * int list) list -> styp -> row option *) |
220 (* theory -> (styp option * int list) list -> styp -> row option *) |
221 fun row_for_constr thy maxes_asgns constr = |
221 fun row_for_constr thy maxes_asgns constr = |
222 SOME (Max constr, lookup_const_ints_assign thy maxes_asgns constr) |
222 SOME (Max constr, lookup_const_ints_assign thy maxes_asgns constr) |
223 handle TERM ("lookup_const_ints_assign", _) => NONE |
223 handle TERM ("lookup_const_ints_assign", _) => NONE |
313 |> Integer.sum |
313 |> Integer.sum |
314 in |
314 in |
315 max < k |
315 max < k |
316 orelse (forall (not_equal 0) precise_cards andalso doms_card () < k) |
316 orelse (forall (not_equal 0) precise_cards andalso doms_card () < k) |
317 end |
317 end |
318 handle TYPE ("NitpickHOL.card_of_type", _, _) => false |
318 handle TYPE ("Nitpick_HOL.card_of_type", _, _) => false |
319 |
319 |
320 (* theory -> scope_desc -> bool *) |
320 (* theory -> scope_desc -> bool *) |
321 fun is_surely_inconsistent_scope_description thy (desc as (card_asgns, _)) = |
321 fun is_surely_inconsistent_scope_description thy (desc as (card_asgns, _)) = |
322 exists (is_surely_inconsistent_card_assign thy desc) card_asgns |
322 exists (is_surely_inconsistent_card_assign thy desc) card_asgns |
323 |
323 |