equal
deleted
inserted
replaced
6 |
6 |
7 signature PRIM = |
7 signature PRIM = |
8 sig |
8 sig |
9 val trace: bool ref |
9 val trace: bool ref |
10 val trace_thms: string -> thm list -> unit |
10 val trace_thms: string -> thm list -> unit |
11 val trace_cterms: string -> cterm list -> unit |
11 val trace_cterm: string -> cterm -> unit |
12 type pattern |
12 type pattern |
13 val mk_functional: theory -> term list -> {functional: term, pats: pattern list} |
13 val mk_functional: theory -> term list -> {functional: term, pats: pattern list} |
14 val wfrec_definition0: theory -> string -> term -> term -> theory * thm |
14 val wfrec_definition0: theory -> string -> term -> term -> theory * thm |
15 val post_definition: thm list -> theory * (thm * pattern list) -> |
15 val post_definition: thm list -> theory * (thm * pattern list) -> |
16 {rules: thm, |
16 {rules: thm, |
294 | check (v::rst) = |
294 | check (v::rst) = |
295 if member (op aconv) rst v then |
295 if member (op aconv) rst v then |
296 raise TFL_ERR "no_repeat_vars" |
296 raise TFL_ERR "no_repeat_vars" |
297 (quote (#1 (dest_Free v)) ^ |
297 (quote (#1 (dest_Free v)) ^ |
298 " occurs repeatedly in the pattern " ^ |
298 " occurs repeatedly in the pattern " ^ |
299 quote (Display.string_of_cterm (Thry.typecheck thy pat))) |
299 quote (Syntax.string_of_term_global thy pat)) |
300 else check rst |
300 else check rst |
301 in check (FV_multiset pat) |
301 in check (FV_multiset pat) |
302 end; |
302 end; |
303 |
303 |
304 fun dest_atom (Free p) = p |
304 fun dest_atom (Free p) = p |
910 |
910 |
911 fun trace_thms s L = |
911 fun trace_thms s L = |
912 if !trace then writeln (cat_lines (s :: map Display.string_of_thm_without_context L)) |
912 if !trace then writeln (cat_lines (s :: map Display.string_of_thm_without_context L)) |
913 else (); |
913 else (); |
914 |
914 |
915 fun trace_cterms s L = |
915 fun trace_cterm s ct = |
916 if !trace then writeln (cat_lines (s :: map Display.string_of_cterm L)) |
916 if !trace then |
917 else ();; |
917 writeln (cat_lines [s, Syntax.string_of_term_global (Thm.theory_of_cterm ct) (Thm.term_of ct)]) |
|
918 else (); |
918 |
919 |
919 |
920 |
920 fun postprocess strict {wf_tac, terminator, simplifier} theory {rules,induction,TCs} = |
921 fun postprocess strict {wf_tac, terminator, simplifier} theory {rules,induction,TCs} = |
921 let val tych = Thry.typecheck theory |
922 let val tych = Thry.typecheck theory |
922 val prove = R.prove strict; |
923 val prove = R.prove strict; |
940 * 3. replace tc by tc' in both the rules and the induction theorem. |
941 * 3. replace tc by tc' in both the rules and the induction theorem. |
941 *---------------------------------------------------------------------*) |
942 *---------------------------------------------------------------------*) |
942 |
943 |
943 fun simplify_tc tc (r,ind) = |
944 fun simplify_tc tc (r,ind) = |
944 let val tc1 = tych tc |
945 let val tc1 = tych tc |
945 val _ = trace_cterms "TC before simplification: " [tc1] |
946 val _ = trace_cterm "TC before simplification: " tc1 |
946 val tc_eq = simplifier tc1 |
947 val tc_eq = simplifier tc1 |
947 val _ = trace_thms "result: " [tc_eq] |
948 val _ = trace_thms "result: " [tc_eq] |
948 in |
949 in |
949 elim_tc (R.MATCH_MP Thms.eqT tc_eq) (r,ind) |
950 elim_tc (R.MATCH_MP Thms.eqT tc_eq) (r,ind) |
950 handle U.ERR _ => |
951 handle U.ERR _ => |