signature DEFS = sig datatype item_kind = Const | Type type item = item_kind * string type entry = item * typ list val item_kind_ord: item_kind ord val plain_args: typ list -> bool type context = Proof.context * (Name_Space.T * Name_Space.T) val global_context: theory -> context val space: context -> item_kind -> Name_Space.T val pretty_item: context -> item -> Pretty.T val pretty_args: Proof.context -> typ list -> Pretty.T list val pretty_entry: context -> entry -> Pretty.T type T type spec =
{def: stringoption,
description: string,
pos: Position.T,
lhs: typ list,
rhs: entry list} val all_specifications_of: T -> (item * spec list) list val specifications_of: T -> item -> spec list val dest: T ->
{restricts: (entry * string) list,
reducts: (entry * entry list) list} val dest_constdefs: T list -> T -> (string * string) list val empty: T val merge: context -> T * T -> T val define: context -> bool -> stringoption -> string -> entry -> entry list -> T -> T val get_deps: T -> item -> (typ list * entry list) list end;
structure Defs: DEFS = struct
(* specification items *)
datatype item_kind = Const | Type; type item = item_kind * string; type entry = item * typ list;
fun item_kind_ord (Const, Type) = LESS
| item_kind_ord (Type, Const) = GREATER
| item_kind_ord _ = EQUAL;
fun acyclic context (c, Ts) (d, Us) =
c <> d orelse
is_none (match_args (Ts, Us)) orelse
err context (c, Ts) (d, Us) "Circular""";
fun reduction context defs const deps = let fun reduct Us (Ts, rhs) =
(case match_args (Ts, Us) of
NONE => NONE
| SOME subst => SOME (map (apsnd (map subst)) rhs)); fun reducts (d, Us) = get_first (reduct Us) (reducts_of defs d);
val reds = map (`reducts) deps; val deps' = if forall (is_none o #1) reds then NONE else SOME (fold_rev
(fn (NONE, dp) => insert (op =) dp | (SOME dps, _) => fold (insert (op =)) dps) reds []); val _ = forall (acyclic context const) (the_default deps deps'); in deps' end;
fun restriction context defs (c, Ts) (d, Us) =
plain_args Us orelse
(case find_first (fn (Rs, _) => not (disjoint_args (Rs, Us))) (restricts_of defs d) of
SOME (Rs, description) =>
err context (c, Ts) (d, Us) "Malformed"
("\n(restriction " ^ prt context (d, Rs) ^ " from " ^ quote description ^ ")")
| NONE => true);
in
fun normalize context = let fun check_def defs (c, {reducts, ...}: def) =
reducts |> forall (fn (Ts, deps) => forall (restriction context defs (c, Ts)) deps); fun check_defs defs = Itemtab.forall (check_def defs) defs;
fun norm_update (c, {reducts, ...}: def) (changed, defs) = let val reducts' = reducts |> map (fn (Ts, deps) =>
(Ts, perhaps (reduction context defs (c, Ts)) deps)); in if reducts = reducts' then (changed, defs) else (true, defs |> map_def c (fn (specs, restricts, _) => (specs, restricts, reducts'))) end; fun norm_loop defs =
(case Itemtab.fold norm_update defs (false, defs) of
(true, defs') => norm_loop defs'
| (false, _) => defs); in norm_loop #> tap check_defs end;
fun dependencies context (c, args) restr deps =
map_def c (fn (specs, restricts, reducts) => let val restricts' = Library.merge (op =) (restricts, restr); val reducts' = insert (op =) (args, deps) reducts; in (specs, restricts', reducts') end)
#> normalize context;
end;
(* merge *)
fun merge context (Defs defs1, Defs defs2) = let fun add_deps (c, args) restr deps defs = if AList.defined (op =) (reducts_of defs c) args then defs else dependencies context (c, args) restr deps defs; fun add_def (c, {restricts, reducts, ...}: def) =
fold (fn (args, deps) => add_deps (c, args) restricts deps) reducts; in
Defs (Itemtab.join (join_specs context) (defs1, defs2)
|> normalize context |> Itemtab.fold add_def defs2) end;
(* define *)
fun define context unchecked def description (c, args) deps (Defs defs) = let val pos = Position.thread_data (); val restr = if plain_args args orelse
(case args of [Term.Type (_, rec_args)] => plain_args rec_args | _ => false) then [] else [(args, description)]; val spec =
(serial (), {def = def, description = description, pos = pos, lhs = args, rhs = deps}); val defs' = defs |> update_specs context c spec; in Defs (defs' |> (if unchecked then I else dependencies context (c, args) restr deps)) end;
fun get_deps (Defs defs) c = reducts_of defs c;
end;
Messung V0.5 in Prozent
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.12Angebot
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-09-27)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.