A Theory of Pattern Recognition