The present invention provides a compound having a cholinergic muscarinic M1 receptor positive allosteric modulator activity, which may be useful as a prophylactic or therapeutic drug for Alzheimer's disease, schizophrenia, pain, sleep disorder, Parkinson's disease dementia, dementia with Lewy bodies and the like. The present invention relates to a compound represented by the formula (I) or a salt thereof: wherein each symbol is as defined in the attached DESCRIPTION.