Sāmkhya (or Sankhya) is the philosophical system believed to be the basis of Yoga. It is probably the oldest of the Indian philosophical systems. Elements of Sāmkhya are already found in the older sacred texts of the Upanishad, and a system already definable as Sāmkhya (but theist) is exposed in the Mahābhārata. Sāmkhya is also the reference philosophy of the Purāna and elements of it remain in most of Darshana (visions of reality), from Classical Yoga (which is based on the Sāmkhyakārikā) to the Vedānta and the Sciva schools.
The foundation of the philosophy is attributed to the Sage Kapila and the basic text of Sāmkhya as a system (Sāmkhyakārikā) was written by Īśvarakrishna, around the third or fourth century. The Sāmkhyakārikā recognizes three pranamas (means of knowledge): pratyaksa (direct sensible perception), anumana (inference) and ptavacana (authoritative testimony).
Sāmkhya literally means 'enumeration', the term alludes to one of the characteristics of the school, namely the enumeration of 25 principles (tattva). The first two are:
(1) purusha, spirit, pure consciousness; (2) prakriti, matter, the primordial nature.
Only these two first principles exist independently and are forever separated from each other. The remaining 23 principles, are evolutions of prakrti. These are, on the psychic level:
(3) buddhi, intellect; (4) ahankāra, sense of self; (5) manas, mind as an internal sense.
The senses follow:
(6) hearing; (7) touch; (8) sight; (9) taste; (10) smell.
Action options follow: (11) word; (12) pāni, literally 'hand', prehension; (13) pāda, literally 'foot', motion; (14) excretion; (15) procreation.
Then, the five subtle elements, object of the senses:
(16) sound; (17) tangible quality; (18) form-color; (19) taste; (20) smell.
Finally, the five large elements:
(21) space or ether; (22) wind or air; (23) fire; (24) water; (25) earth.
Classical Yoga, as expounded by the philosopher Patañjali, appropriates the dualistic metaphysics of the Sāmkhya, adding the concept of Īśvara and differentiating itself not so much in the doctrine but above all in the method, considering the only metaphysical knowledge not to be sufficient for the purposes of liberation and supporting the importance of other psychophysical disciplines whose origins seem to be even more ancient. In the fourth section of the text Yoga Sūtra, Kaivalya Pāda (the separation), the philosopher gives a philosophical dress to the discipline presented by referring to the doctrine of the Sāmkhya: the samādhi finally allows to recognize the separation (kaivalya) between spirit (purusha) and matter (prakriti). Patañjali thus combines two of the most ancient traditions of the Indian world, the philosophical one of the Sāmkhya and the mystical one of Yoga.
I recommend reading an interesting article, in Italian language, by Luca Pinzolo published on quadernimaterialisti.unimib.it, a website dedicated to philosophy.
SĀMKHYA-YOGA- Filosofia della natura e teoria dell’azione