
23 Cal.3d 274 (1979)
590 P.2d 383
152 Cal. Rptr. 528
In re JOHN DEL LEWALLEN on Habeas Corpus.
Docket No. Crim. 20212.
Supreme Court of California.
February 9, 1979.
*276 COUNSEL
Ephraim Margolin and Nicholas C. Arguimbau for Petitioner.
Robert Nicco, Public Defender (San Francisco), and Gordon H. Armstrong, Deputy Public Defender, as Amici Curiae on behalf of Petitioner.
Evelle J. Younger, Attorney General, Jack R. Winkler, Chief Assistant Attorney General, Edward P. O'Brien, Assistant Attorney General, Timothy A. Reardon and Herbert F. Wilkinson, Deputy Attorneys General, for Respondent.
OPINION
MOSK, J.
In this application for writ of habeas corpus, petitioner seeks relief from the sentence imposed after his jury 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 jury 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; *277 weapon 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. (1) (See fn. 2.) 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
(2) 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].) (3) 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].) (4a) "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 *279 because 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).
(5) 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 *280 instant 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.
(4b) 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 *281 attorney 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 by jury.
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 offered 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.
*282 The 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.
CLARK, J., Dissenting.
The majority opinion reveals a profound misunderstanding of both the trial judge's remarks and the constitutional principles applicable to plea bargaining.
A fair reading of the record clearly reveals the judge was saying: (1) Under a plea bargaining system a defendant pleads guilty in exchange for more lenient treatment than he could reasonably expect to receive upon being convicted after trial. (2) Therefore, while a defendant who pleads not guilty and is convicted after jury trial must not be penalized for exercising his constitutional rights, he is not necessarily entitled to the lenient treatment he would have received for pleading guilty. Rather, such a defendant must show that leniency is appropriate under the facts and circumstances of his case. (3) Petitioner failed to make the required showing; to the contrary, aggravating factors of substantial importance were revealed by the evidence adduced at trial.
The majority take exception to two remarks made by the trial judge. "First, in response to defense counsel's suggestion that placing petitioner 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.'" (Ante, p. 277.)
As to the first remark, the majority misconceive its significance when they simply state it was "in response to defense counsel's suggestion that placing defendant on informal probation would suffice." Defense counsel *283 not only argued that informal probation was appropriate in the circumstances of this case, but added: "I think that's pretty much standard on drunk driving cases." It was with regard to the latter assertion that the judge inquired: "You mean whether or not there's a disposition or not after a jury trial?" The point of the judge's question is that in a plea bargaining system leniency is exchanged for guilty pleas, with the result that the "standard" sentence for drunk driving entered upon a bargained for plea will be more lenient than the "standard" sentence for that offense entered upon a jury conviction. As will be demonstrated below, this disparity is constitutionally unobjectionable.
With regard to the second statement, the majority cannot deny that the judge expressly affirmed, "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 ..." However, they argue that the judge contradicted himself when he went on to say of such a defendant: "but on the other hand he's not going to have the consideration he would have had if there was a plea." There is, of course, no contradiction here. As has been stated earlier, the judge clearly meant that, although a defendant who pleads not guilty and is convicted after jury trial must not be penalized for exercising his constitutional rights, he is not necessarily entitled to the lenient treatment he would have received for pleading guilty, but must show that leniency is appropriate under the facts of his case. So understood, the judge's remarks are clearly consistent with the constitutional principles applicable to plea bargaining, as will now be shown.
In Corbitt v. New Jersey (1978) ___ U.S. ___ [58 L.Ed.2d 466, 99 S.Ct. 492], the high court considered the constitutionality of a New Jersey statute that provides for imposition of a mandatory life sentence on a defendant convicted of first degree murder after a jury trial, but that also allows a trial judge discretion to accept a plea of nolo contendere to homicide generally and then to impose life imprisonment or a lesser sentence. The defendant contended that the possibility of a sentence of less than life upon a plea of nolo contendere, combined with the absence of a similar possibility when found guilty of first degree murder by a jury, was an unconstitutional burden on his rights under the Fifth, Sixth and Fourteenth Amendments and also violated his right to equal protection under the Fourteenth Amendment. In rejecting these contentions the court restated the constitutional principles applicable to this case.
"Had Corbitt tendered a plea and had it been accepted and a term of years less than life imposed, this would simply have recognized the fact *284 that there had been a plea and that in sentencing it is constitutionally permissible to take that fact into account. The States and the Federal Government are free to abolish guilty pleas and plea bargaining; but absent such action, as the Constitution has been construed in our cases, it is not forbidden to extend a proper degree of leniency in return for guilty pleas. New Jersey has done no more than that. [¶] ... There is no doubt that those homicide defendants who are willing to plead [nolo contendere] may be treated more leniently than those who go to trial, but withholding the possibility of leniency from the latter cannot be equated with impermissible punishment as long as our cases sustaining plea bargaining remain undisturbed. Those cases, as we have said, unequivocally recognize the constitutional propriety of extending leniency in exchange for a plea of guilty and of not extending leniency to those who have not demonstrated those attributes on which leniency is based." (___ U.S. at p. ___, [58 L.Ed.2d at pp. 476-477].)
Reiterating this point, the court stated: The system of plea bargaining "permits a proper amount of leniency in return for pleas, leniency that is denied if one goes to trial. In this sense, the standard of punishment is necessarily different for those who plead and for those who go to trial. For those who plead, that fact itself is a consideration in sentencing, a consideration that is not present when one is found guilty by a jury." (Id., at p. ___, fn. 14 [58 L.Ed.2d at p. 477].)
The foregoing principles are, I submit, entirely consistent with the trial judge's statement that "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."
Moreover, the majority opinion does not tell us the trial judge prefaced the foregoing statement with the observation: "I think this case is much more serious than perhaps appears on the surface ..." Certainly the presentence report provided substantial grounds for denying petitioner the leniency granted a defendant entering a bargained-for guilty plea to the simple offense of drunk driving. First, the majority concede that petitioner's participation in a drug rehabilitation program as a condition of probation was justified by information in the presentence report that *285 he was in possession of hand-rolled cigarettes and double-crossed white pills when arrested. (Ante, p. 281, fn. 3.)
Second, as the majority concede (ante, p. 281), factors legitimately influencing sentencing may come to the court's attention during trial. In this case the judge came to the justified conclusion that, while petitioner had been acquitted of the firearm charges, his probation should be conditioned on confiscation of the firearm found in his possession and on future nonpossession of firearms.
We have not been furnished with a reporter's transcript of the trial, but the presentence report indicates that when petitioner used the hospital restroom an officer observed him remove something from his pants and drop it behind the restroom door, producing the sound of a metal object hitting the floor. The only metal object the officer found behind the door was a loaded .38 caliber derringer. According to the judge's summary of the evidence, petitioner admitted ownership of the pistol but claimed he "gave it to his cousin who had six kids and lived in Pacifica and needed it for herself and protection. He gave it to her the day after he got it, and suddenly the gun turns up at the washroom in the Emergency Hospital." The judge "recogniz[ed] fully that the jury did not convict [petitioner] on the gun charge." However, in the absence of any reasonable explanation for the pistol's presence in the hospital restroom, the judge would have been, as he said, "naive if I ignored it in imposing sentence."
Finally, the presentence report revealed that while petitioner had not run afoul of the law recently, he had a bad record. "Between the years of 1952 and 1971 the defendant has had a substantial number of arrests. In 1961, his probation was revoked and he was sentenced to State Prison for six months to ten years. In 1963, he was paroled. In 1964, he was sent back to prison for [burglary].... The defendant was paroled on March 30, 1967 and discharged on April 25, 1969."
In conclusion, as has been stated, the record amply supports the trial court's refusal to extend petitioner the leniency that would be granted to a defendant entering a bargained-for guilty plea to the simple offense of drunk driving.
The writ should be denied.
NOTES
[1]  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.
[2]  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.
[3]  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].
[4]  Petitioner asks for, and should receive upon resentencing, credit for time served.
