TFL/tfl.sml
changeset 8631 a10ae360b63c
parent 8622 870a58dd0ddd
child 8642 140883a538c1
equal deleted inserted replaced
8630:c3af577e7c7b 8631:a10ae360b63c
   105   end;
   105   end;
   106 
   106 
   107 
   107 
   108 
   108 
   109 (*---------------------------------------------------------------------------
   109 (*---------------------------------------------------------------------------
   110  * This datatype carries some information about the origin of a
   110  * Each pattern carries with it a tag (i,b) where
   111  * clause in a function definition.
   111  * i is the clause it came from and
   112  *---------------------------------------------------------------------------*)
   112  * b=true indicates that clause was given by the user
   113 (*
   113  * (or is an instantiation of a user supplied pattern)
   114 datatype pattern = GIVEN   of term * int
   114  * b=false --> i = ~1
   115                  | OMITTED of term * int
   115  *---------------------------------------------------------------------------*)
   116 *)
   116 
   117 (* True means the pattern was given by the user
       
   118    (or is an instantiation of a user supplied pattern)
       
   119 *)
       
   120 type pattern = term * (int * bool)
   117 type pattern = term * (int * bool)
   121 
   118 
   122 fun pattern_map f (tm,x) = (f tm, x);
   119 fun pattern_map f (tm,x) = (f tm, x);
   123 
   120 
   124 fun pattern_subst theta = pattern_map (subst_free theta);
   121 fun pattern_subst theta = pattern_map (subst_free theta);
   125 (*
   122 
   126 fun dest_pattern (GIVEN (tm,i)) = ((GIVEN,i),tm)
       
   127   | dest_pattern (OMITTED (tm,i)) = ((OMITTED,i),tm);
       
   128 *)
       
   129 val pat_of = fst;
   123 val pat_of = fst;
   130 val row_of_pat = fst o snd;
   124 val row_of_pat = fst o snd;
   131 val given = snd o snd;
   125 val given = snd o snd;
   132 
   126 
   133 (*---------------------------------------------------------------------------
   127 (*---------------------------------------------------------------------------
   341      val patts2 = U.sort(fn p1=>fn p2=> row_of_pat p1 < row_of_pat p2) patts1
   335      val patts2 = U.sort(fn p1=>fn p2=> row_of_pat p1 < row_of_pat p2) patts1
   342      val finals = map row_of_pat patts2
   336      val finals = map row_of_pat patts2
   343      val originals = map (row_of_pat o #2) rows
   337      val originals = map (row_of_pat o #2) rows
   344      val dummy = case (originals\\finals)
   338      val dummy = case (originals\\finals)
   345              of [] => ()
   339              of [] => ()
   346           | L => mk_functional_err ("The following rows are inaccessible: " ^
   340           | L => mk_functional_err
       
   341  ("The following clauses are redundant (covered by preceding clauses): " ^
   347                    commas (map Int.toString L))
   342                    commas (map Int.toString L))
   348  in {functional = Abs(Sign.base_name fname, ftype,
   343  in {functional = Abs(Sign.base_name fname, ftype,
   349 		      abstract_over (atom, 
   344 		      abstract_over (atom, 
   350 				     absfree(aname,atype, case_tm))),
   345 				     absfree(aname,atype, case_tm))),
   351      pats = patts2}
   346      pats = patts2}