val str_of_isa_model: Proof.context -> isa_model -> string
val isa_model_of_nun: Proof.context -> term list -> (typ option * stringlist) list ->
nun_model -> isa_model val clean_up_isa_model: Proof.context -> isa_model -> isa_model end;
val anonymousN = "anonymous"; val irrelevantN = "irrelevant"; val unparsableN = "unparsable";
val nun_arrow_exploded = String.explode nun_arrow;
val is_ty_meta = member (op =) (String.explode "()->,");
fun next_token_lowlevel [] = (End_of_Stream, [])
| next_token_lowlevel (c :: cs) = if Char.isSpace c then
next_token_lowlevel cs elseifnot (is_ty_meta c) then letval n = find_index (Char.isSpace orf is_ty_meta) cs in
(if n = ~1 then (cs, []) else chop n cs)
|>> (cons c #> String.implode #> ident_of_str #> Ident) end elseif is_prefix (op =) nun_arrow_exploded (c :: cs) then
(Ident nun_arrow, tl cs) else
(Symbol (String.str c), cs);
val tokenize_lowlevel = let fun toks cs =
(case next_token_lowlevel cs of
(End_of_Stream, []) => []
| (tok, cs') => tok :: toks cs'); in
toks o String.explode end;
fun typ_of_nun ctxt = let fun typ_of (NType (id, tys)) = letval Ts = map typ_of tys in if id = nun_dummy then
dummyT elseif id = nun_prop then
\<^typ>\<open>bool\<close> elseif id = nun_arrow then Type (\<^type_name>\<open>fun\<close>, Ts) else
(casetry str_of_nun_tconst id of
SOME (args, s) => letval tys' = map ty_of_lowlevel_str args in Type (s, map typ_of (tys' @ tys)) end
| NONE =>
(casetry str_of_nun_tfree id of
SOME s => TFree (Proof_Context.check_tfree ctxt (flip_quote s, dummyS))
| NONE => raise Fail ("unknown type constructor: " ^ quote (str_of_ident id)))) end; in
typ_of end;
fun one_letter_of s = letval c = String.sub (Long_Name.base_name s, 0) in String.str (if Char.isAlpha c then c else #"x") end;
fun base_of_typ (Type (s, _)) = s
| base_of_typ (TFree (s, _)) = flip_quote s
| base_of_typ (TVar ((s, _), _)) = flip_quote s;
fun term_of_nun ctxt atomss = let val thy = Proof_Context.theory_of ctxt;
val typ_of = typ_of_nun ctxt;
fun nth_atom T j = letval ss = these (triple_lookup (typ_match thy) atomss T) in if j >= 0 andalso j < length ss then nth ss j else one_letter_of (base_of_typ T) ^ nat_subscript (j + 1) end;
fun term_of _ (NAtom (j, ty)) = letval T = typ_of ty in Var ((nth_atom T j, 0), T) end
| term_of bounds (NConst (id, tys0, ty)) = if id = nun_conj then
HOLogic.conj elseif id = nun_choice then Const (\<^const_name>\<open>Eps\<close>, typ_of ty) elseif id = nun_disj then
HOLogic.disj elseif id = nun_equals then Const (\<^const_name>\<open>HOL.eq\<close>, typ_of ty) elseif id = nun_false then
\<^Const>\<open>False\<close> elseif id = nun_if then Const (\<^const_name>\<open>If\<close>, typ_of ty) elseif id = nun_implies then
\<^Const>\<open>implies\<close> elseif id = nun_not then
HOLogic.Not elseif id = nun_unique then Const (\<^const_name>\<open>The\<close>, typ_of ty) elseif id = nun_unique_unsafe then Const (\<^const_name>\<open>The_unsafe\<close>, typ_of ty) elseif id = nun_true then
\<^Const>\<open>True\<close> elseifString.isPrefix nun_dollar_anon_fun_prefix id then letval j = Int.fromString (unprefix nun_dollar_anon_fun_prefix id) |> the_default ~1 in
Var ((anonymousN ^ nat_subscript (j + 1), 0), typ_of ty) end elseifString.isPrefix nun_irrelevant id then
Var ((irrelevantN ^ nat_subscript (Value.parse_int (unprefix nun_irrelevant id)), 0),
dummyT) elseif id = nun_unparsable then
Var ((unparsableN, 0), typ_of ty) else
(casetry str_of_nun_const id of
SOME (args, s) => letval tys = map ty_of_lowlevel_str args in
Sign.mk_const thy (s, map typ_of (tys @ tys0)) end
| NONE =>
(casetry str_of_nun_free id of
SOME s => Free (s, typ_of ty)
| NONE =>
(casetry str_of_nun_var id of
SOME s => Var ((s, 0), typ_of ty)
| NONE =>
(case find_index (fn bound => ident_of_const bound = id) bounds of
~1 => Var ((str_of_ident id, 0), typ_of ty) (* shouldn't happen? *)
| j => Bound j))))
| term_of bounds (NAbs (var, body)) = letval T = typ_of (safe_ty_of var) in
Abs (one_letter_of (base_of_typ T), T, term_of (var :: bounds) body) end
| term_of bounds (NApp (func, arg)) = let fun same () = term_of bounds func $ term_of bounds arg; in
(case (func, arg) of
(NConst (id, _, _), NAbs _) => if id = nun_mu then letval Abs (s, T, body) = term_of bounds arg in Const (\<^const_name>\<open>The\<close>, (T --> HOLogic.boolT) --> T)
$ Abs (s, T, HOLogic.eq_const T $ Bound 0 $ body) end else
same ()
| _ => same ()) end
| term_of _ (NMatch _) = raise Fail "unexpected match";
fun rewrite_numbers (t as \<^Const>\<open>Suc\<close> $ _) =
(casetry HOLogic.dest_nat t of
SOME n => HOLogic.mk_number \<^Type>\<open>nat\<close> n
| NONE => t)
| rewrite_numbers \<^Const_>\<open>Abs_Integ for \<^Const>\<open>Pair \<^Type>\<open>nat\<close> \<^Type>\<open>nat\<close> for t u\<close>\<close> =
HOLogic.mk_number \<^Type>\<open>int\<close> (HOLogic.dest_nat t - HOLogic.dest_nat u)
| rewrite_numbers (t $ u) = rewrite_numbers t $ rewrite_numbers u
| rewrite_numbers (Abs (s, T, t)) = Abs (s, T, rewrite_numbers t)
| rewrite_numbers t = t; in
term_of []
#> rewrite_numbers end;
(* Incomplete test: Can be led astray by references between the auxiliaries. *) fun is_auxiliary_referenced (aux, _) = exists (fn (lhs, rhs) => not (lhs aconv aux) andalso exists_subterm (curry (op aconv) aux) rhs)
term_model;
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 ist noch experimentell.