Are laws written logically and rigorously in law books? For example, do texts of laws specifically use "if and only if" instead of the more frequently used but less logically correct "if"? I am just giving a specific example, but there could be other subtle logical things that laws do not explicitly state. Also, bonus question, has any case in a court of law hinged on a point of logic?
Are laws written logically and rigorously?
Laws are not consistently written to any consistent stylistic standards.
Whatever legislators approve becomes the law even if the law is poorly drafted.
While some legislative bodies, such as the Joint Tax Committee of the U.S. Congress and the legislative services department of many state legislatures encourage good, or at least consistent, drafting practices, these standards are routinely ignored in the course of the legislative process.
This is particularly true in the United States, since it does not have a "House of Revision" akin to the House of Lords or the Canadian Senate, that is concerned primarily with the quality of legislative drafting, and also does not have law that are drafted by the secure majority of a Prime Minster in most parliamentary systems.
Instead, in the U.S. there is constant haggling and negotiation on a bill by bill basis at every step of the legislative process right up through a conference committee reconciling different versions of a bill that arise between two houses of a bicameral legislature. As a result, the key drafting priority is to secure support of a majority of legislators in two houses of the bicameral legislature and then avoiding a veto of the final product, and that objective is pre-eminent over the objective of good drafting.
Frequently, in the U.S., legislation is intentionally drafted ambiguously in order to secure its passage with different legislators essentially making "bets" on the courts interpreting the language which is known to be ambiguous in the manner that they prefer.
Sometimes legal language that is very precise and logical is interpreted to mean something completely different than what it literally says. For example, consider the 11th Amendment to the United States which says:
The Judicial power of the United States shall not be construed to extend to any suit in law or equity, commenced or prosecuted against one of the United States by Citizens of another State, or by Citizens or Subjects of any Foreign State.
This is an amendment to Article III, Section 2, Paragraph 1 of the United States Constitution, which says:
The judicial Power shall extend to all Cases, in Law and Equity, arising under this Constitution, the Laws of the United States, and Treaties made, or which shall be made, under their Authority;—to all Cases affecting Ambassadors, other public Ministers and Consuls;—to all Cases of admiralty and maritime Jurisdiction;—to Controversies to which the United States shall be a Party;—to Controversies between two or more States;—between a State and Citizens of another State,—between Citizens of different States,—between Citizens of the same State claiming Lands under Grants of different States, and between a State, or the Citizens thereof, and foreign States, Citizens or Subjects.
But, what the 11th Amendment actually means is that states retain sovereign immunity in most cases.
The governing principle in interpreting legislation is not logic but legislative intent. Oliver Wendell Holmes, Jr. summed up the situation famously when he said:
The life of the law has not been logic: it has been experience.
Laws are not composed or interpreted according to the usual formal logic conventions (Philosophy 105), for instance "if and only if" is not generally used, although it is used (examples). Indeed, there is a law (definition) in many jurisdictions saying that "and means or, and vice versa, if necessary".
There are many ways to interpret laws. One trend is textualism, a "hug the wording of the text" approach, which is most likely to invoke formal logic. There are other, shall we say "contextual" approaches that take into consideration what the courts believe the legislature "must have intended", wording notwithstanding. This summary of Scalia-Garner style canons of construction should give you an idea what some of the logic-like appeals that are available under textualism.
Indeed, grammar is considered more important than logic, which doesn't tell you much at all. Example: RCW 9.68A.040
(1) A person is guilty of sexual exploitation of a minor if the person...
"If" is necessary because this section defines one set of criteria for guilt of that crime, where "if and only if" would preclude there being two separate criteria.
An example of a linguistically illogical outcome is United States v. Larry G. Rowe, 414 F.3d 271, one of the cases (see also v. Pabon-Cruz, 391 F.3d 86) involving 18 USC 2251(c)'s sentencing provision, which at the time read that violators
shall be fined under this title or imprisoned not less than 10 years nor more than 20 years, and both
The court then noted that
As we observed, "the 'and both' language ... makes no sense as a matter of grammar, usage, or law..." 391 F.3d at 105. Accordingly, we held that the District Court had the discretion to sentence defendant to either a fine or a term of imprisonment of not less than ten years or both. Because this was not clear to the parties or to the District Court at the time of sentencing, we are required to vacate the sentence and remand the cause to the District Court for resentencing consistent with our opinion here and with such Sentencing Guidelines as may be applicable in the circumstances presented.
Many statutes contain what appear to be precise logical constructions. Here are some examples from Canada using "if and only if." But this is not the norm and does not necessarily confine the meaning of the statute. See Rizzo & Rizzo Shoes Ltd. (Re),  1 SCR 27, at para 21:
Today there is only one principle or approach, namely, the words of an Act are to be read in their entire context and in their grammatical and ordinary sense harmoniously with the scheme of the Act, the object of the Act, and the intention of Parliament.
Even the construction "if and only if" is often redundant, for example, in statutes that confer the power to do something on a court or another decision-maker. Section 15.1(7) of the Divorce Act says:
Notwithstanding subsection (3), a court may award an amount that is different from the amount that would be determined in accordance with the applicable guidelines on the consent of both spouses if it is satisfied that reasonable arrangements have been made for the support of the child to whom the order relates.
That doesn't say "if and only if", but reading the sentence in its grammatical and ordinary sense leads to the understanding that only if the court is thus satisfied does it have the power to award an amount that differs from the guidelines.
From a practical perspective, the text of statutes is drafted by expert legislative drafters with a goal of designing the statute to avoid litigation and to have avoid inconsistencies or deficiencies but this is merely an ideal. And readability is another primary goal of drafting. A lot of guidance can be found here.
An idealistic presentation of law as logic can be found in Hans Kelsen's The Pure Theory of Law. But even this view does not imply that the circumstances in which the condition is triggered can be rigourously defined. This is where the grey in law can be found. This grey area, or penumbra of uncertainty, is well described by HLA Hart in his writing on the "open texture" of language and law (see The Concept of Law). See also Frederick Schauer, "A Critical Guide to Vehicles in the Park"; and sometimes, a fish is not a "tangible object" (Yates v. United States, 574 U.S. 528 (2015)).