Opinion
MOSK, J.In this application for writ of habeas corpus, petitioner seeks relief from the sentence imposed after his juiy trial resulted in conviction.
Petitioner was charged with misdemeanor violations of Vehicle Code section 23102, subdivision (a) (drunk driving), Penal Code section 12025 (carrying a concealed firearm), Penal Code section 12031 (carrying a loaded firearm), and Penal Code section 12021 (possession of firearm by ex-felon). The prosecution offered him a negotiated sentence to the Vehicle Code violation: 30 days in county jail, suspended; $315.50 fine, and one year informal court probation with the condition that he attend “drunk driving school.” Petitioner refused, however, to accept any plea negotiation that did not include dismissal of the remaining weapon charges, and he therefore pleaded not guilty.
Petitioner’s intransigence was vindicated: after trial by juiy he was convicted of the Vehicle Code violation and acquitted of all the remaining charges. The presentence report by the probation department and the prosecution both recommended that defendant be fined $315.50 and placed on formal departmental probation for one year. Defense counsel’s only material objection to the report and the recommendations consisted of the suggestion that informal rather than formal probation would be sufficient. The trial judge, however, sentenced petitioner to 90 days in county jail, suspended; $315.50 fine; and 3 years formal departmental probation with the following conditions: 30 days in county jail to be served on weekends; alcohol rehabilitation, drug rehabilitation, and “drunk driving school” as prescribed by the probation department; *277weapon confiscated; and petitioner to have no weapons at home, at his business, or in his automobile.
Our attention is directed to two statements by the trial court to demonstrate that sentencing was influenced by improper considerations. First, in response to defense counsel’s suggestion that placing defendant on informal probation would suffice, the trial judge responded, “You mean whether or not there’s a disposition or not after a jury trial?” Second, after sentencing the trial judge stated, “I think I want to emphasize there’s no reason in having the District Attorney attempt to negotiate matters if after the defendant refuses a negotiation he gets the same sentence as if he had accepted the negotiation. It is just a waste of everybody’s time, and what’s he got to lose. And as far as I’m concerned, if a defendant wants a jury trial and he’s convicted, he’s not going to be penalized with that, but on the other hand he’s not going to have the consideration he would have had if there was a plea.”
Petitioner also contends various trial court minute orders demonstrate that his sentence greatly exceeds those ordinarily imposed in California for equivalent criminal conduct.
We must decide whether petitioner has established that the trial court’s exercise of its sentencing function was improperly influenced by his refusal of the proffered plea bargain and insistence on his right to trial. We conclude that he has carried his burden; accordingly, the sentence must be vacated and the case remanded for resentencing.1
I
In habeas corpus procedure the return to the order to show cause must allege facts tending to establish the legality of the petitioner’s detention; it is thus analogous to the complaint in civil actions. (Pen. Code, § 1500; In re Saunders (1970) 2 Cal.3d 1033, 1047 [88 Cal.Rptr. 633, 472 P.2d 921]; In re Masching (1953) 41 Cal.2d 530, 533 [261 P.2d 251]; In re Collins (1907) 151 Cal. 340 [90 P. 827, 91 P. 397].) The traverse, which may incorporate the allegations of the petition, must deny or controvert each material fact or matter alleged in the return or such fact or matter will be deemed admitted; it is therefore analogous to the answer in civil actions. *278(In re Stafford (1958) 160 Cal.App.2d 110, 113 [324 P.2d 967].) In this relatively uncomplicated manner both factual and legal issues are joined for review. (See generally Witkin, Cal. Criminal Procedure (1963) § 825, at pp. 790-791.)
It is important to note that review on habeas corpus, unlike an appeal, is not limited to the trial record. In the instant case, however, the People offer nothing more in support of their claim that petitioner’s confinement is lawful than a general denial of his allegation that the judge improperly considered his election to stand trial rather than to accept the proffered plea bargain. By alleging only a conclusionary statement of ultimate fact in their return, the People have indicated a willingness to rely on the record. Furthermore, the People do not dispute petitioner’s assertion that the sentence herein substantially exceeds that imposed in this jurisdiction on other first offenders, nor do they question the accuracy of the documentary evidence submitted by petitioner as exhibits to his petition. There being no disputed factual questions as to matters outside the trial record, the merits of petitioner’s claim can be reached without ordering an evidentiary hearing.2
II
It is well settled that to punish a person for exercising a constitutional right is “a due process violation of the most basic sort.” (Bordenkircher v. Hayes (1978) 434 U.S. 357, 363 [54 L.Ed.2d 604, 610, 98 S.Ct. 663, 668].) The constitutional right to trial by jury in criminal prosecutions is fundamental to our system of justice (U.S. Const., 6th Amend.; Cal. Const., art. I, § 16; People v. Superior Court (1967) 67 Cal.2d 929, 932 [64 Cal.Rptr. 327, 434 P.2d 623, 25 A.L.R.3d 1143]); thus, we have stated that “only the most compelling reasons can justify any interference, however slight, with an accused’s prerogative to personally decide whether to stand trial or to waive his rights by pleading guilty.” (People v. Hill (1974) 12 Cal.3d 731, 768 [117 Cal.Rptr. 393, 528 P.2d 1].) “A court may not offer any inducement in return for a plea of guilty or nolo contendere. It may not treat a defendant more leniently *279because he foregoes his right to trial or more harshly because he exercises that right.” (People v. Superior Court (Felmann) (1976) 59 Cal.App.3d 270, 276 [130 Cal.Rptr. 548].)
The People concede that the refusal of an accused to negotiate a plea with the prosecution must not influence the sentence imposed by the court after trial. Appellate courts in California and in other jurisdictions have vacated sentences when the trial court has apparently used its sentencing power, either more severely or more leniently than the norm, in order to expedite the resolution of criminal matters. (See, e.g., People v. Morales (1967) 252 Cal.App.2d 537 [60 Cal.Rptr. 671]; United States v. Wiley (7th Cir. 1960) 278 F.2d 500; United States v. Stockwell (9th Cir. 1973) 472 F.2d 1186; United States v. Tateo (S.D.N.Y. 1963) 214 F.Supp. 560; Johnson v. State (1975) 274 Md. 536 [336 A.2d 113]; Letters v. Commonwealth (1963) 346 Mass. 403 [193 N.E.2d 578].) Such cases are consistent with United States v. Jackson (1968) 390 U.S. 570 [20 L.Ed.2d 138, 88 S.Ct. 1209] (holding unconstitutional the federal Kidnaping Act (18 U.S.C. § 1201(a)) because it provided the death penalty for a conviction after a plea of not guilty, and a maximum sentence of life imprisonment after a guilty plea), and North Carolina v. Pearce (1969) 395 U.S. 711 [23 L.Ed.2d 656, 89 S.Ct. 2072] (prohibiting trial courts from imposing greater sentences on conviction after retrial of defendants who had successfully appealed and overturned their previous convictions).
The trial judge’s rhetorical query at sentencing—“You mean whether or not there’s a disposition or not after a jury trial?”—clearly reveals that he gave consideration to petitioner’s election to plead not guilty in imposing sentence. That a defendant pleads not guilty is completely irrelevant at sentencing; if a judge bases a sentence, or any aspect thereof, on the fact that such a plea is entered, error has been committed and the sentence cannot stand.
The People insist that the total comments of the trial judge were ambiguous and the . ambiguity must be resolved in favor of holding there was regularity in the judicial proceedings. We find, however, that the colloquy here is remarkably similar to that in People v. Morales, supra, 252 Cal.App.2d 537. There the Court of Appeal, in reversing, emphasized that “by increasing the penalty in the case of a defendant who chooses to rely on the presumption of innocence, to put the state to the test of proving its case, and to assert his right to a jury trial, one is in effect penalizing a defendant who asserts rights to which he is entitled.” (Id., p. 546.) In Morales the sentencing judge spoke much like the judge in the *280instant case: “I have no objection, in fact I feel all the inmates should be free to come in and present any defense that they may have .... They have the same rights as anyone else in that regard, but I don’t think it’s fair for an inmate, or anyone else, to come to Court and demand a jury trial, demand the services of the public defender, obtain what I thought was a first class and able defense, when there really isn’t any defense to this case, and there was no effort to put on a defense because there couldn’t be, and I don’t think this is right.” (Id., p. 542, fn. 4; italics added.) The judge in Morales declared his defendant had the same rights as anyone else, but—and he then proceeded to qualify those rights.
In the instant case, the judge reacted in precisely that manner. Said he, “as far as I’m concerned, if a defendant wants a jury trial and he’s convicted, he’s not going to be penalized with that, but on the other hand he’s not going to have the consideration he would have had if there was a plea.” (Italics added.) It is clear the judge declared that petitioner had a right to a jury trial—but under these circumstances he would not get the consideration he would otherwise have, that is, he would be treated differently because he asserted his constitutional rights.
The People would have us interpret the trial court’s remark, “he’s not going to have the consideration he would have had if there was a plea,” as meaning that a defendant convicted after a plea of not guilty has no “vested right” in the sentence offered by the prosecution before trial. In other words, the convicted defendant is not entitled to the consideration, as that word is used in the law of contracts, offered him in exchange for a plea of guilty. We conclude that when the judge’s statements are viewed as a whole, there can be no rational interpretation other than that he was basing petitioner’s sentence at least in part on the fact that he declined the prosecution’s plea bargain and demanded a trial by jury. The People are correct, however, in asserting that a defendant is not entitled, as a matter of law, to the same sentence he would have received had he pleaded guilty.
Though it is subject to occasional abuse and frequent criticism, plea bargaining has been recognized as an accepted practice in American criminal courts which, if administered properly, contributes to the expeditious administration of justice. (People v. West (1970) 3 Cal.3d 595, 604 [91 Cal.Rptr. 385, 477 P.2d 409]; see also People v. Williams (1969) 269 Cal.App.2d 879, 884 [75 Cal.Rptr. 348].) The statutory framework for plea negotiation is set forth in several-sections of the Penal Code. (Pen. Code, §§ 1192.1-1192.5.) The legislative scheme contemplates a district *281attorney negotiating with the accused and the trial judge approving or disapproving the ultimate agreement.
Just as a trial judge is precluded from offering an accused in return for a guilty plea a more lenient sentence than he would impose after trial (Pen. Code, § 1192.5; People v. Superior Court (Felmann), supra, 59 Cal.App.3d 270, 276), so he is precluded from imposing a more severe sentence because the accused elects to proceed to trial. Trial courts may not thus chill the exercise of the constitutional right to trial byjuiy.
We emphasize, however, that a trial court’s discretion in imposing sentence is in no way limited by the terms of any negotiated pleas or sentences offered the defendant by the prosecution. The imposition of sentence within the legislatively prescribed limits is exclusively a judicial function. (People v. Navarro (1972) 7 Cal.3d 248, 258 [102 Cal.Rptr. 137, 497 P.2d 481].) When granting probation, as in the instant case, courts have broad discretion to impose conditions directed toward rehabilitation of the offender and safety of the public. (In re Bushman (1970) 1 Cal.3d 767, 776 [83 Cal.Rptr. 375, 463 P.2d 727].) Legitimate facts may come to the court’s attention either through the personal observations of the judge during trial (see, e.g., United States v. Grayson (1978) 438 U.S. 41 [57 L.Ed.2d 582, 98 S.Ct. 2610]), or through the presentence report by the probation department, to induce the court to impose a sentence in excess of any recommended by the prosecution.3
Thus it is clear that under appropriate circumstances a defendant may receive a more severe sentence following trial than he would have received had he pleaded guilty; the trial itself may reveal more adverse information about him than was previously known. A court may not, however, impose a sentence that conflicts with a defendant’s exercise of his constitutional right to a jury trial. (See In re Manino (1971) 14 Cal.App.3d 953, 967 [92 Cal.Rptr. 880, 45 A.L.R.3d 996].) The comments of the judge reveal that is what occurred here.
*282The writ is granted, the judgment is vacated, and petitioner is remanded to the Municipal Court of the City and County of San Francisco for resentencing in accordance with the views expressed herein.4
Bird, C. J., Tobriner, J., Richardson, J., Manuel, J., and Newman, J., concurred.
Because of our disposition, we find it unnecessary to reach petitioner’s other contentions, i.e., that his sentence was based upon information to which he had no opportunity to respond, and that the sentence imposed violates the constitutional prohibition against cruel and unusual punishment.
We emphasize our disapproval of the practice of setting out in a return to an order to show cause mere general denials of a habeas corpus petition’s allegations. Because the issuance of an order to show cause reflects the issuing court’s determination that the petition states facts which, if true, entitle the petitioner to relief (Pen. Code, § 1476; In re Hochberg (1970) 2 Cal.3d 870, 873, fn. 2 [87 Cal.Rptr. 681, 471 P.2d 1]), the respondent should recite the facts upon which the denial of petitioner’s allegations is based, and, where appropriate, should provide such documentary evidence, affidavits, or other materials as will enable the court to determine which issues are truly disputed.
The record in the instant case illustrates how the presentence report may include additional information relevant to sentencing. According to the report, when petitioner was arrested he had hand-rolled cigarettes and double-crossed white pills in his possession. Petitioner did not object to consideration of this information at sentencing; therefore, the trial court justifiably included participation in a drug rehabilitation program as a condition of his probation. (See People v. Escobar (1953) 122 Cal.App.2d 15, 20 [264 P.2d 571].)
However, the sentencing judge may not consider the gun charge of which defendant was acquitted. This was made clear in People v. Lent (1975) 15 Cal.3d 481 [124 Cal.Rptr. 905, 541 P.2d 545],
Petitioner asks for, and should receive upon resentencing, credit for time served.