Provided is a compound having a cholinergic muscarine M1 receptor positive allosteric modulator activity. A compound represented by the formula (I): wherein each symbol is as described in the DESCRIPTION, or a salt thereof has a cholinergic muscarine M1 receptor positive allosteric modulator activity, and is 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.