Source: https://www.lri.fr/~fiorenzi/Teaching/BDAS/TD5.pdf