Librarian of Congress Daniel J. Boorstin, testifying at the trial of 10 persons arrested while protesting shorter hours at the library, said yesterday he had hoped to avoid the arrests and denied that his criticism of federal budget cuts had encouraged such demonstrations.

"Nothing that I said . . . was directed to encourage violations of the law or violations of the regulations of the Library of Congress," Boorstin said during his hour-long testimony in the D.C. Superior Court trial.

The demonstrators, in a jury trial before Judge Noel Anketell Kramer, face charges of unlawful entry. They tried to force the library to stay open March 18 after its closing time had been shifted from 9:30 p.m. to 5:30 p.m. Library officials attributed the shorter hours to the Gramm-Rudman-Hollings deficit reduction measure.

Boorstin, who initially looked flustered on the witness stand, soon relaxed and began to pepper his testimony with quips and quotations. At one point, he burst into giggles when a defense lawyer asked whether Boorstin had been contacted by the White House before deciding to call police to handle the demonstrators.

"That's a very flattering question," Boorstin said. "No, I'm not generally in touch with the White House when we make administrative decisions at the Library of Congress. I'd certainly remember it." His red bow tie bobbed as he laughed again.

Defense lawyers, beginning their case yesterday, tried to show that Boorstin and other library officials welcomed the demonstrations as a way to force Congress to appropriate more money for the library, and that they had encouraged media coverage of similar protests the two previous nights before calling in the police.

A number of defense lawyers are expected to argue that as a result of the alleged encouragement by library officials, the defendants did not think they were violating any laws and did not expect to be arrested.

Stating often that he could not recall the specifics of certain events that led up to the arrests, Boorstin said that reducing the operating hours had caused him great pain but that he had hoped library users "would accept the inconvenience" and lobby for more money through "legal means."

At one point, Boorstin told defense lawyer Nina Kraut that he could not recall telling one of the defendants, Russell Mohkiber, that "we're with you" but that the arrests had been made because the demonstrations had become "too political."

Boorstin drew one of his biggest laughs near the end of his testimony when defense lawyer Stephen Milliken asked him if he had once called the library "an opener of new openings in the land of open gates."

"Yes, that sounds very good, thank you very much," said Boorstin, a broad smile creasing his face as he clasped his hands.