sep_type_unify : hol_type -> hol_type -> (hol_type,hol_type) subst * (hol_type,hol_type) subst
type_subst (sep_type_unify ty1 ty2 |> fst) ty1 = type_subst (sep_type_unify ty1 ty2 |> snd) ty2
- let val alpha_list = Type `:'a list` in sep_type_unify alpha alpha_list end; > val it = ([{redex = “:α”, residue = “:α list”}], []): (hol_type, hol_type) Lib.subst * (hol_type, hol_type) subst - let val ty1 = Type `:'a -> 'b -> 'b` val ty2 = Type `:'a list -> 'b list -> 'a list` in sep_type_unify ty1 ty2 end; > val it = ([{redex = “:β”, residue = “:α list”}, {redex = “:α”, residue = “:α list”}], [{redex = “:β”, residue = “:α”}]): (hol_type, hol_type) Lib.subst * (hol_type, hol_type) subst
Note that in these examples, type_unify would fail due to an occurs check:
- let val ty1 = Type `:'a -> 'b -> 'b` val ty2 = Type `:'a list -> 'b list -> 'a list` in type_unify ty1 ty2 end; Exception raised at boolSyntax.type_unify: occurs check Exception- HOL_ERR {message = "occurs check", origin_function = "type_unify", origin_structure = "boolSyntax"} raised