Let f:A->B and g:B->C and let H be a subset of C, then (g(f))^-1(H) = f^-1(g^-1(H)).
Proof. Let x be a member of (g(f))^-1(H), then since H is a subset of C and (g(f)):A -> B, then x is a member of A, and there exists a z in H such that g(f)(x) = z. Thus, f(x) = g^-1(z) and x = f^-1(g^-1(z)), so that x is a member of f^-1(g^-1(H)). This gives (g(f))^-1(H) is a subset of f^-1(g^-1(H)).
Now let x be a member of f^-1(g^-1(H)). By definition, there exists z in H such that z = g(f(x)). Thus, x = (g(f))^-1(z) and since z is a member of H, x is a member of (g(f))^-1(H). This gives us that f^-1(g^-1(H)) is a subset of (g(f))^-1(H).
Since each side is a subset of the other, the two sets are equal; QED