src/Pure/pattern.ML
changeset 17756 d4a35f82fbb4
parent 17412 e26cb20ef0cc
child 18011 685d95c793ff
equal deleted inserted replaced
17755:b0cd55afead1 17756:d4a35f82fbb4
   442 fun matches thy po = (match thy po; true) handle MATCH => false;
   442 fun matches thy po = (match thy po; true) handle MATCH => false;
   443 
   443 
   444 (* Does pat match a subterm of obj? *)
   444 (* Does pat match a subterm of obj? *)
   445 fun matches_subterm thy (pat,obj) =
   445 fun matches_subterm thy (pat,obj) =
   446   let fun msub(bounds,obj) = matches thy (pat,obj) orelse
   446   let fun msub(bounds,obj) = matches thy (pat,obj) orelse
   447             case obj of
   447             (case obj of
   448               Abs(x,T,t) => let val y = variant bounds x
   448               Abs(x,T,t) => let val y = variant bounds x
   449                                 val f = Free(":" ^ y,T)
   449                                 val f = Free(":" ^ y,T)
   450                             in msub(x::bounds,subst_bound(f,t)) end
   450                             in msub(x::bounds,subst_bound(f,t)) end
   451             | s$t => msub(bounds,s) orelse msub(bounds,t)
   451             | s$t => msub(bounds,s) orelse msub(bounds,t)
   452             | _ => false
   452             | _ => false)
   453   in msub([],obj) end;
   453   in msub([],obj) end;
   454 
   454 
   455 fun first_order(Abs(_,_,t)) = first_order t
   455 fun first_order(Abs(_,_,t)) = first_order t
   456   | first_order(t $ u) = first_order t andalso first_order u andalso
   456   | first_order(t $ u) = first_order t andalso first_order u andalso
   457                          not(is_Var t)
   457                          not(is_Var t)