On the representation and recognition of temporal patterns of activities in smart environments