src/Pure/pattern.ML
changeset 19863 3a4ca87efdc5
parent 19776 a8c02d8b8b40
child 19880 1b0d48257caf
equal deleted inserted replaced
19862:7f29aa958b72 19863:3a4ca87efdc5
    21   val eta_contract_atom: term -> term
    21   val eta_contract_atom: term -> term
    22   val match: theory -> term * term -> Type.tyenv * Envir.tenv -> Type.tyenv * Envir.tenv
    22   val match: theory -> term * term -> Type.tyenv * Envir.tenv -> Type.tyenv * Envir.tenv
    23   val first_order_match: theory -> term * term
    23   val first_order_match: theory -> term * term
    24     -> Type.tyenv * Envir.tenv -> Type.tyenv * Envir.tenv
    24     -> Type.tyenv * Envir.tenv -> Type.tyenv * Envir.tenv
    25   val matches: theory -> term * term -> bool
    25   val matches: theory -> term * term -> bool
    26   val matches_seq: theory -> term list -> term list -> bool
       
    27   val matches_subterm: theory -> term * term -> bool
    26   val matches_subterm: theory -> term * term -> bool
    28   val unify: theory -> term * term -> Envir.env -> Envir.env
    27   val unify: theory -> term * term -> Envir.env -> Envir.env
    29   val first_order: term -> bool
    28   val first_order: term -> bool
    30   val pattern: term -> bool
    29   val pattern: term -> bool
    31   val rewrite_term: theory -> (term * term) list -> (term -> term option) list -> term -> term
    30   val rewrite_term: theory -> (term * term) list -> (term -> term option) list -> term -> term
   404   val envir' = apfst (typ_match thy (pT, oT)) envir;
   403   val envir' = apfst (typ_match thy (pT, oT)) envir;
   405 in mtch [] po envir' handle Pattern => first_order_match thy po envir' end;
   404 in mtch [] po envir' handle Pattern => first_order_match thy po envir' end;
   406 
   405 
   407 fun matches thy po = (match thy po (Vartab.empty, Vartab.empty); true) handle MATCH => false;
   406 fun matches thy po = (match thy po (Vartab.empty, Vartab.empty); true) handle MATCH => false;
   408 
   407 
   409 fun matches_seq thy ps os =
       
   410   let
       
   411     fun mtch (pat :: pats) (obj :: objs) env =
       
   412           mtch pats objs (match thy (pairself Envir.beta_norm (Envir.subst_vars env pat, obj)) env)
       
   413       | mtch [] [] env = env
       
   414       | mtch _ _ _ = raise MATCH;
       
   415   in (mtch ps os (Vartab.empty, Vartab.empty); true) handle MATCH => false end;
       
   416 
       
   417 
   408 
   418 (* Does pat match a subterm of obj? *)
   409 (* Does pat match a subterm of obj? *)
   419 fun matches_subterm thy (pat,obj) =
   410 fun matches_subterm thy (pat,obj) =
   420   let fun msub(bounds,obj) = matches thy (pat,obj) orelse
   411   let fun msub(bounds,obj) = matches thy (pat,obj) orelse
   421             (case obj of
   412             (case obj of