src/ZF/Tools/primrec_package.ML
changeset 17314 04e21a27c0ad
parent 17224 a78339014063
child 17412 e26cb20ef0cc
equal deleted inserted replaced
17313:7d97f60293ae 17314:04e21a27c0ad
    78     else if length middle > 1 then
    78     else if length middle > 1 then
    79       raise RecError "more than one non-variable in pattern"
    79       raise RecError "more than one non-variable in pattern"
    80     else case rec_fn_opt of
    80     else case rec_fn_opt of
    81         NONE => SOME (fname, ftype, ls, rs, con_info, [new_eqn])
    81         NONE => SOME (fname, ftype, ls, rs, con_info, [new_eqn])
    82       | SOME (fname', _, ls', rs', con_info': constructor_info, eqns) =>
    82       | SOME (fname', _, ls', rs', con_info': constructor_info, eqns) =>
    83           if isSome (assoc (eqns, cname)) then
    83           if AList.defined (op =) eqns cname then
    84             raise RecError "constructor already occurred as pattern"
    84             raise RecError "constructor already occurred as pattern"
    85           else if (ls <> ls') orelse (rs <> rs') then
    85           else if (ls <> ls') orelse (rs <> rs') then
    86             raise RecError "non-recursive arguments are inconsistent"
    86             raise RecError "non-recursive arguments are inconsistent"
    87           else if #big_rec_name con_info <> #big_rec_name con_info' then
    87           else if #big_rec_name con_info <> #big_rec_name con_info' then
    88              raise RecError ("Mixed datatypes for function " ^ fname)
    88              raise RecError ("Mixed datatypes for function " ^ fname)
   118 
   118 
   119     (*Translate rec equations into function arguments suitable for recursor.
   119     (*Translate rec equations into function arguments suitable for recursor.
   120       Missing cases are replaced by 0 and all cases are put into order.*)
   120       Missing cases are replaced by 0 and all cases are put into order.*)
   121     fun add_case ((cname, recursor_pair), cases) =
   121     fun add_case ((cname, recursor_pair), cases) =
   122       let val (rhs, recursor_rhs, eq) =
   122       let val (rhs, recursor_rhs, eq) =
   123             case assoc (eqns, cname) of
   123             case AList.lookup (op =) eqns cname of
   124                 NONE => (warning ("no equation for constructor " ^ cname ^
   124                 NONE => (warning ("no equation for constructor " ^ cname ^
   125                                   "\nin definition of function " ^ fname);
   125                                   "\nin definition of function " ^ fname);
   126                          (Const ("0", Ind_Syntax.iT),
   126                          (Const ("0", Ind_Syntax.iT),
   127                           #2 recursor_pair, Const ("0", Ind_Syntax.iT)))
   127                           #2 recursor_pair, Const ("0", Ind_Syntax.iT)))
   128               | SOME (rhs, cargs', eq) =>
   128               | SOME (rhs, cargs', eq) =>