108 fun cantunify sg (t, u) = error ("Non-unifiable terms:\n" ^ |
108 fun cantunify sg (t, u) = error ("Non-unifiable terms:\n" ^ |
109 Sign.string_of_term sg t ^ "\n\n" ^ Sign.string_of_term sg u); |
109 Sign.string_of_term sg t ^ "\n\n" ^ Sign.string_of_term sg u); |
110 |
110 |
111 fun decompose sg Ts (env, p as (t, u)) = |
111 fun decompose sg Ts (env, p as (t, u)) = |
112 let fun rigrig (a, T) (b, U) uT ts us = if a <> b then cantunify sg p |
112 let fun rigrig (a, T) (b, U) uT ts us = if a <> b then cantunify sg p |
113 else apsnd List.concat (foldl_map (decompose sg Ts) (uT env T U, ts ~~ us)) |
113 else apsnd flat (foldl_map (decompose sg Ts) (uT env T U, ts ~~ us)) |
114 in case pairself (strip_comb o Envir.head_norm env) p of |
114 in case pairself (strip_comb o Envir.head_norm env) p of |
115 ((Const c, ts), (Const d, us)) => rigrig c d (unifyT sg) ts us |
115 ((Const c, ts), (Const d, us)) => rigrig c d (unifyT sg) ts us |
116 | ((Free c, ts), (Free d, us)) => rigrig c d (unifyT sg) ts us |
116 | ((Free c, ts), (Free d, us)) => rigrig c d (unifyT sg) ts us |
117 | ((Bound i, ts), (Bound j, us)) => |
117 | ((Bound i, ts), (Bound j, us)) => |
118 rigrig (i, dummyT) (j, dummyT) (K o K) ts us |
118 rigrig (i, dummyT) (j, dummyT) (K o K) ts us |