src/HOL/BNF/Tools/bnf_gfp_rec_sugar.ML
changeset 54976 b502f04c0442
parent 54975 451786451d04
child 54978 afc156c7e4f7
equal deleted inserted replaced
54975:451786451d04 54976:b502f04c0442
   630     val (ctr, ctr_args) = strip_comb (unfold_let rhs);
   630     val (ctr, ctr_args) = strip_comb (unfold_let rhs);
   631     val {disc, sels, ...} = the (find_first (curry (op =) ctr o #ctr) basic_ctr_specs)
   631     val {disc, sels, ...} = the (find_first (curry (op =) ctr o #ctr) basic_ctr_specs)
   632       handle Option.Option => primcorec_error_eqn "not a constructor" ctr;
   632       handle Option.Option => primcorec_error_eqn "not a constructor" ctr;
   633 
   633 
   634     val disc_concl = betapply (disc, lhs);
   634     val disc_concl = betapply (disc, lhs);
   635     val (eqn_data_disc_opt, matchedsss') = if length basic_ctr_specs = 1
   635     val (eqn_data_disc_opt, matchedsss') =
   636       then (NONE, matchedsss)
   636       if null (tl basic_ctr_specs) then
   637       else apfst SOME (dissect_coeqn_disc fun_names sequentials basic_ctr_specss eqn_pos
   637         (NONE, matchedsss)
       
   638       else
       
   639         apfst SOME (dissect_coeqn_disc fun_names sequentials basic_ctr_specss eqn_pos
   638           (SOME (abstract (List.rev fun_args) rhs)) code_rhs_opt prems disc_concl matchedsss);
   640           (SOME (abstract (List.rev fun_args) rhs)) code_rhs_opt prems disc_concl matchedsss);
   639 
   641 
   640     val sel_concls = sels ~~ ctr_args
   642     val sel_concls = sels ~~ ctr_args
   641       |> map (fn (sel, ctr_arg) => HOLogic.mk_eq (betapply (sel, lhs), ctr_arg));
   643       |> map (fn (sel, ctr_arg) => HOLogic.mk_eq (betapply (sel, lhs), ctr_arg));
   642 
   644 
  1241         val sel_thmss = map (map snd o order_list_duplicates) sel_alists;
  1243         val sel_thmss = map (map snd o order_list_duplicates) sel_alists;
  1242 
  1244 
  1243         fun prove_disc_iff ({ctr_specs, ...} : corec_spec) exhaust_thms disc_thmss'
  1245         fun prove_disc_iff ({ctr_specs, ...} : corec_spec) exhaust_thms disc_thmss'
  1244             (({fun_args = exhaust_fun_args, ...} : coeqn_data_disc) :: _) disc_thms
  1246             (({fun_args = exhaust_fun_args, ...} : coeqn_data_disc) :: _) disc_thms
  1245             ({fun_name, fun_T, fun_args, ctr_no, prems, eqn_pos, ...} : coeqn_data_disc) =
  1247             ({fun_name, fun_T, fun_args, ctr_no, prems, eqn_pos, ...} : coeqn_data_disc) =
  1246           if null exhaust_thms then
  1248           if null exhaust_thms orelse null (tl ctr_specs) then
  1247             []
  1249             []
  1248           else
  1250           else
  1249             let
  1251             let
  1250               val {disc, disc_excludess, ...} = nth ctr_specs ctr_no;
  1252               val {disc, disc_excludess, ...} = nth ctr_specs ctr_no;
  1251               val goal =
  1253               val goal =