A logical calculus of analogy involving functions of order 2