Rav Shach in Mishna Torah in Arachin 4: 15-18 (and in chapter 24 law 9 of selling) brings an argument between the Rashbam, Tosphot, and Rambam. Rav Shach as is the custom starting from Rav Haim of Brisk is spending most of his efforts to understand the Rambam.
The answer is that Rav Shach has a different Gemara. It is the one where there is a difference between R Akiva and the sages about the case one sells three trees. The Gemara there agrees that to both the ground under between and around them the width of 4 yards is sold along with the trees.But if he says he is keeping the ground to the sages that is valid and to R akiva still the ground under them belongs to the new owner of the trees. The reason is all who sell sell with a good eye.
So in our case the Gemara can hold like R Akiva and that even when he says he is sanctifying the trees without teh land still the land under them comes along with them. But there is only one act of sanctification so the y are redeemed together. That is the Gemara that sees a difference between Rav papa and Rav huna hold like the sages and R Shimon that one who sanctifies does so with a grudge. evil eye. But if a Gemara would hold like R Akiva as is in fact teh law then the Gemara would say sanctifying three with no mention of ground the ground comes along both in and out of hekdesh. But the law of Rav Huna is where he mentioned both field and trees so both are redeemed separately
The issue is that the Rambam seems to decide the law in ways that at least the Gemara in Arachin would hold to be contradictory.
Rav Huna Arachin page 14a says one who sanctifies a field full of trees redeemed the trees according to their value and the field according the 50 shekels for a field of standard size. [Background: One who sanctifies a field for the Temple can redeem it himself if he gives to the Temple 50 shekels. If other kinds of objects then he redeems them according to their value but adds a 1/4 [what is called 1/5 but means 1/5 from the outside.] ]
The Gemara asks does that not disagree with the teaching that one who sanctifies trees redeems them and the field goes along with it. and the Gemara answer that Rav Huna was saying like R Akiva that one who sanctifies sanctifies with a good eye. [The Temple would get more]. That teaching is like R Shimon that one sanctifies with an unkind eye. So that the Temple would get less if redeemed.
The Gemara here clearly holds these two teachings disagree with each other.
So how is it the Rambam decides the law like both?
And in fact the Raavad says the law is not like Rav Huna but rather like Rav Papa on Arachin 14b.
There Rav Papa says one who sanctifies trees redeems the trees according to their value.
The Gemara asks Let the ground go with them to be sanctified and to go out with them to be redeemed? Answer this is where he said openly the ground does not go with them. So we see that if it would they would be sanctified together.
Rav Shach answers that The gemara on Arachin 14b clearly holds Rav Huna and Rav Papa disagree. But not that the in fact disagree. It could be that the sanctifying a field with trees makes everything go together. But sanctifying the trees alone-even if the field goes along with them, still it is not two separate acts of sanctifying. So redeeming would also be in just one act.
The Question is then where did the Rambam see this? There does not seem to be any Gemara anywhere that indicates that Rav Papa and Rav Huna agree with each other.
The answer is that Rav Shach has a different Gemara. It is the one where there is a difference between R Akiva and the sages about the case one sells three trees. The Gemara there agrees that to both the ground under between and around them the width of 4 yards is sold along with the trees.But if he says he is keeping the ground to the sages that is valid and to R akiva still the ground under them belongs to the new owner of the trees. The reason is all who sell sell with a good eye.
So in our case the Gemara can hold like R Akiva and that even when he says he is sanctifying the trees without teh land still the land under them comes along with them. But there is only one act of sanctification so the y are redeemed together. That is the Gemara that sees a difference between Rav papa and Rav huna hold like the sages and R Shimon that one who sanctifies does so with a grudge. evil eye. But if a Gemara would hold like R Akiva as is in fact teh law then the Gemara would say sanctifying three with no mention of ground the ground comes along both in and out of hekdesh. But the law of Rav Huna is where he mentioned both field and trees so both are redeemed separately