src/HOL/Tools/Nitpick/nitpick_hol.ML
changeset 33743 a58893035742
parent 33706 7017aee615d6
child 33747 3aa6b9911252
equal deleted inserted replaced
33742:83ae8b7e2768 33743:a58893035742
  1107   else
  1107   else
  1108     these (Symtab.lookup table s)
  1108     these (Symtab.lookup table s)
  1109     |> map_filter (try (Refute.specialize_type thy x))
  1109     |> map_filter (try (Refute.specialize_type thy x))
  1110     |> filter (equal (Const x) o term_under_def)
  1110     |> filter (equal (Const x) o term_under_def)
  1111 
  1111 
  1112 (* term -> term *)
  1112 (* theory -> term -> term option *)
  1113 fun normalized_rhs_of thy t =
  1113 fun normalized_rhs_of thy t =
  1114   let
  1114   let
  1115     (* term -> term *)
  1115     (* term option -> term option *)
  1116     fun aux (v as Var _) t = lambda v t
  1116     fun aux (v as Var _) (SOME t) = SOME (lambda v t)
  1117       | aux (c as Const (@{const_name TYPE}, T)) t = lambda c t
  1117       | aux (c as Const (@{const_name TYPE}, T)) (SOME t) = SOME (lambda c t)
  1118       | aux _ _ = raise TERM ("Nitpick_HOL.normalized_rhs_of", [t])
  1118       | aux _ _ = NONE
  1119     val (lhs, rhs) =
  1119     val (lhs, rhs) =
  1120       case t of
  1120       case t of
  1121         Const (@{const_name "=="}, _) $ t1 $ t2 => (t1, t2)
  1121         Const (@{const_name "=="}, _) $ t1 $ t2 => (t1, t2)
  1122       | @{const Trueprop} $ (Const (@{const_name "op ="}, _) $ t1 $ t2) =>
  1122       | @{const Trueprop} $ (Const (@{const_name "op ="}, _) $ t1 $ t2) =>
  1123         (t1, t2)
  1123         (t1, t2)
  1124       | _ => raise TERM ("Nitpick_HOL.normalized_rhs_of", [t])
  1124       | _ => raise TERM ("Nitpick_HOL.normalized_rhs_of", [t])
  1125     val args = strip_comb lhs |> snd
  1125     val args = strip_comb lhs |> snd
  1126   in fold_rev aux args rhs end
  1126   in fold_rev aux args (SOME rhs) end
  1127 
  1127 
  1128 (* theory -> const_table -> styp -> term option *)
  1128 (* theory -> const_table -> styp -> term option *)
  1129 fun def_of_const thy table (x as (s, _)) =
  1129 fun def_of_const thy table (x as (s, _)) =
  1130   if is_built_in_const false x orelse original_name s <> s then
  1130   if is_built_in_const false x orelse original_name s <> s then
  1131     NONE
  1131     NONE
  1132   else
  1132   else
  1133     x |> def_props_for_const thy false table |> List.last
  1133     x |> def_props_for_const thy false table |> List.last
  1134       |> normalized_rhs_of thy |> prefix_abs_vars s |> SOME
  1134       |> normalized_rhs_of thy |> Option.map (prefix_abs_vars s)
  1135     handle List.Empty => NONE
  1135     handle List.Empty => NONE
  1136 
  1136 
  1137 datatype fixpoint_kind = Lfp | Gfp | NoFp
  1137 datatype fixpoint_kind = Lfp | Gfp | NoFp
  1138 
  1138 
  1139 (* term -> fixpoint_kind *)
  1139 (* term -> fixpoint_kind *)