1925 fun pair_for_prop t = |
1925 fun pair_for_prop t = |
1926 case term_under_def t of |
1926 case term_under_def t of |
1927 Const (s, _) => (s, t) |
1927 Const (s, _) => (s, t) |
1928 | t' => raise TERM ("Nitpick_HOL.pair_for_prop", [t, t']) |
1928 | t' => raise TERM ("Nitpick_HOL.pair_for_prop", [t, t']) |
1929 |
1929 |
1930 fun def_table_for get ctxt subst = |
1930 fun def_table_for ts subst = |
1931 ctxt |> get |> map (pair_for_prop o subst_atomic subst) |
1931 ts |> map (pair_for_prop o subst_atomic subst) |
1932 |> AList.group (op =) |> Symtab.make |
1932 |> AList.group (op =) |> Symtab.make |
1933 |
1933 |
1934 fun const_def_tables ctxt subst ts = |
1934 fun const_def_tables ctxt subst ts = |
1935 (def_table_for (map prop_of o Nitpick_Unfolds.get) ctxt subst, |
1935 (def_table_for |
|
1936 (map prop_of (rev (Named_Theorems.get ctxt @{named_theorems nitpick_unfold}))) subst, |
1936 fold (fn (s, t) => Symtab.map_default (s, []) (cons t)) |
1937 fold (fn (s, t) => Symtab.map_default (s, []) (cons t)) |
1937 (map pair_for_prop ts) Symtab.empty) |
1938 (map pair_for_prop ts) Symtab.empty) |
1938 |
1939 |
1939 fun paired_with_consts t = map (rpair t) (Term.add_const_names t []) |
1940 fun paired_with_consts t = map (rpair t) (Term.add_const_names t []) |
1940 |
1941 |
1941 fun const_nondef_table ts = |
1942 fun const_nondef_table ts = |
1942 fold (append o paired_with_consts) ts [] |> AList.group (op =) |> Symtab.make |
1943 fold (append o paired_with_consts) ts [] |> AList.group (op =) |> Symtab.make |
1943 |
1944 |
1944 fun const_simp_table ctxt = |
1945 fun const_simp_table ctxt = |
1945 def_table_for (map_filter (equationalize_term ctxt "nitpick_simp" o prop_of) |
1946 def_table_for (map_filter (equationalize_term ctxt "nitpick_simp" o prop_of) |
1946 o Nitpick_Simps.get) ctxt |
1947 (rev (Named_Theorems.get ctxt @{named_theorems nitpick_simp}))) |
1947 |
1948 |
1948 fun const_psimp_table ctxt = |
1949 fun const_psimp_table ctxt = |
1949 def_table_for (map_filter (equationalize_term ctxt "nitpick_psimp" o prop_of) |
1950 def_table_for (map_filter (equationalize_term ctxt "nitpick_psimp" o prop_of) |
1950 o Nitpick_Psimps.get) ctxt |
1951 (rev (Named_Theorems.get ctxt @{named_theorems nitpick_psimp}))) |
1951 |
1952 |
1952 fun const_choice_spec_table ctxt subst = |
1953 fun const_choice_spec_table ctxt subst = |
1953 map (subst_atomic subst o prop_of) (Nitpick_Choice_Specs.get ctxt) |
1954 map (subst_atomic subst o prop_of) |
|
1955 (rev (Named_Theorems.get ctxt @{named_theorems nitpick_choice_spec})) |
1954 |> const_nondef_table |
1956 |> const_nondef_table |
1955 |
1957 |
1956 fun inductive_intro_table ctxt subst def_tables = |
1958 fun inductive_intro_table ctxt subst def_tables = |
1957 let val thy = Proof_Context.theory_of ctxt in |
1959 let val thy = Proof_Context.theory_of ctxt in |
1958 def_table_for |
1960 def_table_for |
1959 (maps (map (unfold_mutually_inductive_preds thy def_tables o prop_of) |
1961 (maps (map (unfold_mutually_inductive_preds thy def_tables o prop_of) |
1960 o snd o snd) |
1962 o snd o snd) |
1961 o filter (fn (cat, _) => cat = Spec_Rules.Inductive orelse |
1963 (filter (fn (cat, _) => cat = Spec_Rules.Inductive orelse |
1962 cat = Spec_Rules.Co_Inductive) |
1964 cat = Spec_Rules.Co_Inductive) (Spec_Rules.get ctxt))) subst |
1963 o Spec_Rules.get) ctxt subst |
|
1964 end |
1965 end |
1965 |
1966 |
1966 fun ground_theorem_table thy = |
1967 fun ground_theorem_table thy = |
1967 fold ((fn @{const Trueprop} $ t1 => |
1968 fold ((fn @{const Trueprop} $ t1 => |
1968 is_ground_term t1 ? Inttab.map_default (hash_term t1, []) (cons t1) |
1969 is_ground_term t1 ? Inttab.map_default (hash_term t1, []) (cons t1) |