315 in (map Thm.term_of cts, env) end; |
315 in (map Thm.term_of cts, env) end; |
316 |
316 |
317 fun read_def_termT freeze sg defs sT = apfst hd (read_def_termTs freeze sg defs [sT]); |
317 fun read_def_termT freeze sg defs sT = apfst hd (read_def_termTs freeze sg defs [sT]); |
318 |
318 |
319 |
319 |
320 fun read_term_sg sg (defs as (_, _, used)) s = |
320 fun read_term_sg freeze sg (defs as (_, _, used)) s = |
321 #1 (read_def_termT true sg defs (s, TVar ((variant used "'z", 0), logicS))); |
321 #1 (read_def_termT freeze sg defs (s, TVar ((variant used "'z", 0), logicS))); |
322 |
322 |
323 fun read_prop_sg sg defs s = |
323 fun read_prop_sg freeze sg defs s = |
324 #1 (read_def_termT true sg defs (s, propT)); |
324 #1 (read_def_termT freeze sg defs (s, propT)); |
325 |
325 |
326 |
326 |
327 fun cert_term_sg sg t = Thm.term_of (Thm.cterm_of sg t); |
327 fun cert_term_sg sg t = Thm.term_of (Thm.cterm_of sg t); |
328 |
328 |
329 fun cert_prop_sg sg tm = |
329 fun cert_prop_sg sg tm = |
387 in normh end; |
387 in normh end; |
388 |
388 |
389 |
389 |
390 (* dummy patterns *) |
390 (* dummy patterns *) |
391 |
391 |
|
392 local |
|
393 |
392 fun is_dummy (Const (c, _)) = c = PureThy.dummy_patternN |
394 fun is_dummy (Const (c, _)) = c = PureThy.dummy_patternN |
393 | is_dummy _ = false; |
395 | is_dummy _ = false; |
|
396 |
|
397 fun prep_dummy (i, t) = |
|
398 if is_dummy t then (i + 1, Var (("_dummy_", i), Term.fastype_of t)) else (i, t); |
|
399 |
|
400 in |
|
401 |
|
402 fun prepare_dummies tm = #2 (Term.foldl_map_aterms prep_dummy (1, tm)); |
394 |
403 |
395 fun reject_dummies ctxt tm = |
404 fun reject_dummies ctxt tm = |
396 if foldl_aterms (fn (ok, t) => ok andalso not (is_dummy t)) (true, tm) then tm |
405 if foldl_aterms (fn (ok, t) => ok andalso not (is_dummy t)) (true, tm) then tm |
397 else raise CONTEXT ("Illegal dummy pattern(s) in term", ctxt); |
406 else raise CONTEXT ("Illegal dummy pattern(s) in term", ctxt); |
398 |
407 |
399 |
408 end; |
400 fun prep_dummy (i, t) = |
|
401 if is_dummy t then (i + 1, Var (("_dummy_", i), Term.fastype_of t)) else (i, t); |
|
402 |
|
403 fun prepare_dummies tm = #2 (Term.foldl_map_aterms prep_dummy (1, tm)); |
|
404 |
409 |
405 |
410 |
406 (* read terms *) |
411 (* read terms *) |
407 |
412 |
408 fun gen_read read app is_pat (ctxt as Context {binds, defs = (types, sorts, _, used), ...}) s = |
413 fun gen_read read app is_pat (ctxt as Context {binds, defs = (types, sorts, _, used), ...}) s = |
423 |> app (if is_pat then I else norm_term ctxt) |
428 |> app (if is_pat then I else norm_term ctxt) |
424 |> app (if is_pat then prepare_dummies else (reject_dummies ctxt)) |
429 |> app (if is_pat then prepare_dummies else (reject_dummies ctxt)) |
425 end; |
430 end; |
426 |
431 |
427 val read_termTs = gen_read (read_def_termTs false) (apfst o map) false; |
432 val read_termTs = gen_read (read_def_termTs false) (apfst o map) false; |
428 val read_term = gen_read read_term_sg I false; |
433 val read_term = gen_read (read_term_sg true) I false; |
429 val read_prop = gen_read read_prop_sg I false; |
434 val read_prop = gen_read (read_prop_sg true) I false; |
430 val read_term_pat = gen_read read_term_sg I true; |
435 val read_term_pat = gen_read (read_term_sg false) I true; |
431 val read_prop_pat = gen_read read_prop_sg I true; |
436 val read_prop_pat = gen_read (read_prop_sg false) I true; |
432 |
437 |
433 |
438 |
434 (* certify terms *) |
439 (* certify terms *) |
435 |
440 |
436 fun gen_cert cert is_pat ctxt t = |
441 fun gen_cert cert is_pat ctxt t = |