TFL/tfl.ML
changeset 19046 bc5c6c9b114e
parent 18972 2905d1805e1e
child 19349 36e537f89585
equal deleted inserted replaced
19045:75786c2eb897 19046:bc5c6c9b114e
   314       fun single [_$_] =
   314       fun single [_$_] =
   315               mk_functional_err "recdef does not allow currying"
   315               mk_functional_err "recdef does not allow currying"
   316         | single [f] = f
   316         | single [f] = f
   317         | single fs  =
   317         | single fs  =
   318               (*multiple function names?*)
   318               (*multiple function names?*)
   319               if length (gen_distinct same_name fs) < length fs
   319               if length (distinct same_name fs) < length fs
   320               then mk_functional_err
   320               then mk_functional_err
   321                    "The function being declared appears with multiple types"
   321                    "The function being declared appears with multiple types"
   322               else mk_functional_err
   322               else mk_functional_err
   323                    (Int.toString (length fs) ^
   323                    (Int.toString (length fs) ^
   324                     " distinct function names being declared")
   324                     " distinct function names being declared")
   326 fun mk_functional thy clauses =
   326 fun mk_functional thy clauses =
   327  let val (L,R) = ListPair.unzip (map HOLogic.dest_eq clauses
   327  let val (L,R) = ListPair.unzip (map HOLogic.dest_eq clauses
   328                    handle TERM _ => raise TFL_ERR "mk_functional"
   328                    handle TERM _ => raise TFL_ERR "mk_functional"
   329                         "recursion equations must use the = relation")
   329                         "recursion equations must use the = relation")
   330      val (funcs,pats) = ListPair.unzip (map (fn (t$u) =>(t,u)) L)
   330      val (funcs,pats) = ListPair.unzip (map (fn (t$u) =>(t,u)) L)
   331      val atom = single (gen_distinct (op aconv) funcs)
   331      val atom = single (distinct (op aconv) funcs)
   332      val (fname,ftype) = dest_atom atom
   332      val (fname,ftype) = dest_atom atom
   333      val dummy = map (no_repeat_vars thy) pats
   333      val dummy = map (no_repeat_vars thy) pats
   334      val rows = ListPair.zip (map (fn x => ([]:term list,[x])) pats,
   334      val rows = ListPair.zip (map (fn x => ([]:term list,[x])) pats,
   335                               map (fn (t,i) => (t,(i,true))) (enumerate R))
   335                               map (fn (t,i) => (t,(i,true))) (enumerate R))
   336      val names = foldr add_term_names [] R
   336      val names = foldr add_term_names [] R