src/HOL/Tools/inductive_codegen.ML
changeset 19046 bc5c6c9b114e
parent 19025 596fb1eb7856
child 19861 620d90091788
equal deleted inserted replaced
19045:75786c2eb897 19046:bc5c6c9b114e
   175 fun print_modes modes = message ("Inferred modes:\n" ^
   175 fun print_modes modes = message ("Inferred modes:\n" ^
   176   space_implode "\n" (map (fn (s, ms) => s ^ ": " ^ commas (map
   176   space_implode "\n" (map (fn (s, ms) => s ^ ": " ^ commas (map
   177     string_of_mode ms)) modes));
   177     string_of_mode ms)) modes));
   178 
   178 
   179 val term_vs = map (fst o fst o dest_Var) o term_vars;
   179 val term_vs = map (fst o fst o dest_Var) o term_vars;
   180 val terms_vs = distinct o List.concat o (map term_vs);
   180 val terms_vs = distinct (op =) o List.concat o (map term_vs);
   181 
   181 
   182 (** collect all Vars in a term (with duplicates!) **)
   182 (** collect all Vars in a term (with duplicates!) **)
   183 fun term_vTs tm =
   183 fun term_vTs tm =
   184   fold_aterms (fn Var ((x, _), T) => cons (x, T) | _ => I) tm [];
   184   fold_aterms (fn Var ((x, _), T) => cons (x, T) | _ => I) tm [];
   185 
   185 
   439               (Pretty.block [Pretty.str "Seq.single", Pretty.brk 1, mk_tuple out_ps])
   439               (Pretty.block [Pretty.str "Seq.single", Pretty.brk 1, mk_tuple out_ps])
   440               (exists (not o is_exhaustive) out_ts'''))
   440               (exists (not o is_exhaustive) out_ts'''))
   441           end
   441           end
   442       | compile_prems out_ts vs names gr ps =
   442       | compile_prems out_ts vs names gr ps =
   443           let
   443           let
   444             val vs' = distinct (List.concat (vs :: map term_vs out_ts));
   444             val vs' = distinct (op =) (List.concat (vs :: map term_vs out_ts));
   445             val SOME (p, mode as SOME (Mode ((_, js), _))) =
   445             val SOME (p, mode as SOME (Mode ((_, js), _))) =
   446               select_mode_prem thy modes' vs' ps;
   446               select_mode_prem thy modes' vs' ps;
   447             val ps' = filter_out (equal p) ps;
   447             val ps' = filter_out (equal p) ps;
   448             val ((names', eqs), out_ts') =
   448             val ((names', eqs), out_ts') =
   449               foldl_map check_constrt ((names, []), out_ts);
   449               foldl_map check_constrt ((names, []), out_ts);