Quot/quotient_term.ML
changeset 875 cc951743c5e2
parent 867 9e247b9505f0
child 877 09a64cb04851
--- a/Quot/quotient_term.ML	Thu Jan 14 12:23:59 2010 +0100
+++ b/Quot/quotient_term.ML	Thu Jan 14 15:25:24 2010 +0100
@@ -389,22 +389,17 @@
 
 (* Checks that two types match, for example:
      rty -> rty   matches   qty -> qty *)
-fun matches_typ thy T T' =
-  case (T, T') of
-    (TFree _, TFree _) => true
-  | (TVar _, TVar _) => true
-  | (Type (s, tys), Type (s', tys')) => (
-      if T = T' then true else
-      let
-        val rty = #rtyp (Quotient_Info.quotdata_lookup thy s')
-      in
-        if Sign.typ_instance thy (T, rty) then true else false
-      end
-      handle Not_found =>
-        if length tys <> length tys' then false else
-        (* 'andalso' is buildin syntax so it needs to be expanded *)
-        fold (fn x => fn y => x andalso y) (map2 (matches_typ thy) tys tys') (s = s')
-      )
+fun matches_typ thy rT qT =
+  if rT = qT then true else
+  case (rT, qT) of
+    (Type (rs, rtys), Type (qs, qtys)) =>
+      if rs = qs then
+        if length rtys <> length qtys then false else
+        forall (fn x => x = true) (map2 (matches_typ thy) rtys qtys)
+      else
+        (case Quotient_Info.quotdata_lookup_raw thy qs of
+          SOME quotinfo => Sign.typ_instance thy (rT, #rtyp quotinfo)
+        | NONE => false)
   | _ => false