1894 (Code_Runtime.dynamic_value_strict (Pred_Result.get, put_pred_result, "Predicate_Compile_Core.put_pred_result") |
1894 (Code_Runtime.dynamic_value_strict (Pred_Result.get, put_pred_result, "Predicate_Compile_Core.put_pred_result") |
1895 thy NONE Predicate.map t' []))) ())) |
1895 thy NONE Predicate.map t' []))) ())) |
1896 handle TimeLimit.TimeOut => error "Reached timeout during execution of values" |
1896 handle TimeLimit.TimeOut => error "Reached timeout during execution of values" |
1897 in ((T, ts), statistics) end; |
1897 in ((T, ts), statistics) end; |
1898 |
1898 |
1899 fun values ctxt param_user_modes ((raw_expected, stats), comp_options) k t_compr = |
1899 fun values param_user_modes ((raw_expected, stats), comp_options) k t_compr ctxt = |
1900 let |
1900 let |
1901 val ((T, ts), statistics) = eval ctxt stats param_user_modes comp_options k t_compr |
1901 val ((T, ts), statistics) = eval ctxt stats param_user_modes comp_options k t_compr |
1902 val setT = HOLogic.mk_setT T |
1902 val setT = HOLogic.mk_setT T |
1903 val elems = HOLogic.mk_set T ts |
1903 val elems = HOLogic.mk_set T ts |
1904 val cont = Free ("dots", setT) (* FIXME proper name!? *) |
1904 val ([dots], ctxt') = |
|
1905 Proof_Context.add_fixes [(Binding.name "dots", SOME setT, Mixfix ("...", [], 1000))] ctxt |
1905 (* check expected values *) |
1906 (* check expected values *) |
|
1907 val union = Const (@{const_abbrev Set.union}, setT --> setT --> setT) |
1906 val () = |
1908 val () = |
1907 case raw_expected of |
1909 case raw_expected of |
1908 NONE => () |
1910 NONE => () |
1909 | SOME s => |
1911 | SOME s => |
1910 if eq_set (op =) (HOLogic.dest_set (Syntax.read_term ctxt s), ts) then () |
1912 if eq_set (op =) (HOLogic.dest_set (Syntax.read_term ctxt s), ts) then () |
1911 else |
1913 else |
1912 error ("expected and computed values do not match:\n" ^ |
1914 error ("expected and computed values do not match:\n" ^ |
1913 "expected values: " ^ Syntax.string_of_term ctxt (Syntax.read_term ctxt s) ^ "\n" ^ |
1915 "expected values: " ^ Syntax.string_of_term ctxt (Syntax.read_term ctxt s) ^ "\n" ^ |
1914 "computed values: " ^ Syntax.string_of_term ctxt elems ^ "\n") |
1916 "computed values: " ^ Syntax.string_of_term ctxt elems ^ "\n") |
1915 in |
1917 in |
1916 (if k = ~1 orelse length ts < k then elems |
1918 ((if k = ~1 orelse length ts < k then elems else union $ elems $ Free (dots, setT), statistics), ctxt') |
1917 else Const (@{const_abbrev Set.union}, setT --> setT --> setT) $ elems $ cont, statistics) |
|
1918 end; |
1919 end; |
1919 |
1920 |
1920 fun values_cmd print_modes param_user_modes options k raw_t state = |
1921 fun values_cmd print_modes param_user_modes options k raw_t state = |
1921 let |
1922 let |
1922 val ctxt = Toplevel.context_of state |
1923 val ctxt = Toplevel.context_of state |
1923 val t = Syntax.read_term ctxt raw_t |
1924 val t = Syntax.read_term ctxt raw_t |
1924 val (t', stats) = values ctxt param_user_modes options k t |
1925 val ((t', stats), ctxt') = values param_user_modes options k t ctxt |
1925 val ty' = Term.type_of t' |
1926 val ty' = Term.type_of t' |
1926 val ctxt' = Variable.auto_fixes t' ctxt |
1927 val ctxt'' = Variable.auto_fixes t' ctxt' |
1927 val pretty_stat = |
1928 val pretty_stat = |
1928 case stats of |
1929 case stats of |
1929 NONE => [] |
1930 NONE => [] |
1930 | SOME xs => |
1931 | SOME xs => |
1931 let |
1932 let |
1938 [Pretty.fbrk, Pretty.str "Statistics:", Pretty.fbrk, |
1939 [Pretty.fbrk, Pretty.str "Statistics:", Pretty.fbrk, |
1939 Pretty.str "total:", Pretty.brk 1, Pretty.str (string_of_int total), Pretty.fbrk] |
1940 Pretty.str "total:", Pretty.brk 1, Pretty.str (string_of_int total), Pretty.fbrk] |
1940 @ maps pretty_entry xs |
1941 @ maps pretty_entry xs |
1941 end |
1942 end |
1942 val p = Print_Mode.with_modes print_modes (fn () => |
1943 val p = Print_Mode.with_modes print_modes (fn () => |
1943 Pretty.block ([Pretty.quote (Syntax.pretty_term ctxt' t'), Pretty.fbrk, |
1944 Pretty.block ([Pretty.quote (Syntax.pretty_term ctxt'' t'), Pretty.fbrk, |
1944 Pretty.str "::", Pretty.brk 1, Pretty.quote (Syntax.pretty_typ ctxt' ty')] |
1945 Pretty.str "::", Pretty.brk 1, Pretty.quote (Syntax.pretty_typ ctxt'' ty')] |
1945 @ pretty_stat)) (); |
1946 @ pretty_stat)) (); |
1946 in Pretty.writeln p end; |
1947 in Pretty.writeln p end; |
1947 |
1948 |
1948 end; |
1949 end; |