The entire album is explained in Kendrick's story to Pac.
In the end of Mortal Man, Kendrick reads a story to Pac about his life from the perspective of a caterpillar:
“The caterpillar is a prisoner to the streets that conceived it. It's only job is to eat or consume everything around it, in order to protect itself from this mad city. While consuming its environment the caterpillar begins to notice ways to survive. One thing it noticed is how much the world shuns him, but praises the butterfly. The butterfly represents the talent, the thoughtfulness, and the beauty within the caterpillar. But having a harsh outlook on life the caterpillar sees the butterfly as weak and figures out a way to pimp it to his own benefits Already surrounded by this mad city the caterpillar goes to work on the cocoon which institutionalizes him. He can no longer see past his own thoughts. He’s trapped When trapped inside these walls certain ideas start to take roots, such as going home, and bringing back new concepts to this mad city. The result? Wings begin to emerge, breaking the cycle of feeling stagnant. Finally free, the butterfly sheds light on situations that the caterpillar never considered, ending the eternal struggle. Although the butterfly and caterpillar are completely different, they are one and the same."
Looking at this, it recaps each song in chronological order.
“The caterpillar is a prisoner to the streets that conceived it Its only job is to eat or consume everything around it, in order to protect itself from this mad city. While consuming its environment the caterpillar begins to notice ways to survive" this part of how story recaps 'Wesley's Theory'. The song basically describes Kendrick's life pre-fame. The first line says "When I get signed, homie I'mma act a fool Hit the dance floor, strobe lights in the room Snatch your little secretary ***** for the homies" The caterpillar (Kendrick) is gaining fame by "eating everything around him" and hustling, and notices ways to survive.
-"One thing it noticed is how much the world shuns him, but praises the butterfly" this line recaps 'For Free (Interlude)'. The song starts with a chick yelling at Kendrick saying "**** you, ************, you a ho-*** ***** I don't know why you trying to go big, ***** you ain't **** Walking around like you God's gift to Earth, ***** you ain't ****" showing how the "caterpillar" is being shunned. She then ends her rant with "You won't know, you gonna lose on a good ***** My other ***** is on, you off" showing how she praises the butterfly.
-"The butterfly represents the talent, the thoughtfulness, and the beauty within the caterpillar But having a harsh outlook on life the caterpillar sees the butterfly as weak and figures out a way to pimp it to his own benefits" this part embodies the same message as 'King Kunta'. In the song Kendrick expresses how he has grown to become a big influence and a king, much like a caterpillar grows into a butterfly.
-"Already surrounded by this mad city the caterpillar goes to work on the cocoon which institutionalizes him He can no longer see past his own thoughts" this one is more apparent, it clearly recaps the song 'Institutionalized'. He says in the intro "I'm trapped inside the ghetto and I ain't proud to admit it Institutionalized, I keep runnin' back for a visit" so he is saying that he is institutionalized into the ghetto.
-"He’s trapped When trapped inside these walls certain ideas start to take roots, such as going home, and bringing back new concepts to this mad city" this line is also clear, it represents 'These Walls'. The walls in the story represent the caterpillars cocoon, but in the song they could represent Kendrick's past experiences, perhaps of something that happened in the hotel room that he continuously refers to, because when people use the phrase "if these walls could talk" they are usually reminiscing about past experiences that occurred in that very room. I also think 'u' and 'Alright' are from the perspective of the caterpillar inside the cocoon. 'These Walls' and 'u' are both very dark, while 'Alright' gets more uplifting and explains how he and his homies will be alright.
-"The result? Wings begin to emerge, breaking the cycle of feeling stagnant" this line could represent 'For Sale' as well as 'Momma'. 'For Sale' talks about Kendrick's troubles with Lucy (Lucifer), which could represent the butterfly emerging from the cocoon and dealing with troubles outside of its walls. 'Momma' explains how Kendrick returns to Compton and feels guilty for abandoning his city, which the butterfly could feel as he returns to the real world after spending so much time in the cocoon.
-"Finally free, the butterfly sheds light on situations that the caterpillar never considered, ending the eternal struggle" this line encapsulates the next three songs, 'Hood Politics', 'How Much a Dollar Cost', and 'Complexion'. Kendrick is shedding light on these important issues such as the problems in the hood, poverty, and racial issues.
-"Although the butterfly and caterpillar are completely different, they are one and the same." This last line of the story raps up the last two songs (prior to Mortal Man), 'You Ain't Gotta Lie' and 'i'. You Ain't Gotta Lie and 'i' contrast in sound, as YAGL is more chill while i is really upbeat. This could represent the differences between the caterpillar and the butterfly. This contrast helps them stand out though, much like the caterpillar and butterfly rely on each other to exist.
In the beginning, Kendrick (the caterpillar) is alone and small. In the end, Kendrick (the butterfly) has completely changed and become something large and full of life with new ideas and outlooks. To Pimp a Butterfly.