From b57df919446d10191bfb67dcb0085923831e4bd6 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 11 Nov 2026 10:22:29 +0000 Subject: [PATCH 1/2] Run the equivalence chapter's Racket example at render time The truth-table check was a plain fence, and the #t and #f it returns were typed in the prose (#131). Both checks are now {racket} chunks, so the page shows Racket's answers. Part of #131. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01FWgYrEUFVHj2qKjKncHg77 --- .../_racket-equivalence_rem.qmd | 14 +++++++++++--- chapters/equivalence-negation.qmd | 2 ++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/chapters/_subfiles/equivalence-negation/_racket-equivalence_rem.qmd b/chapters/_subfiles/equivalence-negation/_racket-equivalence_rem.qmd index 7d3ebf7cf..0b5c3a750 100644 --- a/chapters/_subfiles/equivalence-negation/_racket-equivalence_rem.qmd +++ b/chapters/_subfiles/equivalence-negation/_racket-equivalence_rem.qmd @@ -6,14 +6,22 @@ so a program can check an equivalence. In Racket, `for*/and` runs its body for every combination of `p` and `q`, and returns `#f` as soon as the body returns `#f`, and `#t` if it never does: -```racket +```{racket} +#| code-fold: false (for*/and ([p '(#t #f)] [q '(#t #f)]) (equal? (or p (and p q)) p)) ``` -This returns `#t`, as @exr-absorption found. +The result agrees with @exr-absorption. Replacing the body with `(equal? (not (and p q)) (and (not p) (not q)))` -returns `#f`, as @exr-not-and found. +asks the question of @exr-not-and, and the answer agrees with that exercise too: + +```{racket} +#| code-fold: false +(for*/and ([p '(#t #f)] + [q '(#t #f)]) + (equal? (not (and p q)) (and (not p) (not q)))) +``` ::: diff --git a/chapters/equivalence-negation.qmd b/chapters/equivalence-negation.qmd index 81d177049..70a6eda0c 100644 --- a/chapters/equivalence-negation.qmd +++ b/chapters/equivalence-negation.qmd @@ -13,6 +13,8 @@ format: {{< include ../latex-macros/macros.qmd >}} +{{< include _subfiles/_racket-setup.qmd >}} + ::: {.callout-note appearance='simple' collapse=true} ## Source From 87a1d643c6d512e9d9ba5067c6f8f120edc6f310 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 12 Nov 2026 09:22:38 +0000 Subject: [PATCH 2/2] Introduce the second equivalence check like the first The second check typed out the whole body the chunk below it runs, and stated that its answer agreed with the exercise before the chunk showed the answer. Say what the loop checks, show the chunk, and then compare its result with the exercise, as the first check does. Raised by the cross-harness read of #150. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01FWgYrEUFVHj2qKjKncHg77 --- .../equivalence-negation/_racket-equivalence_rem.qmd | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/chapters/_subfiles/equivalence-negation/_racket-equivalence_rem.qmd b/chapters/_subfiles/equivalence-negation/_racket-equivalence_rem.qmd index 0b5c3a750..31451c84d 100644 --- a/chapters/_subfiles/equivalence-negation/_racket-equivalence_rem.qmd +++ b/chapters/_subfiles/equivalence-negation/_racket-equivalence_rem.qmd @@ -14,8 +14,7 @@ and returns `#f` as soon as the body returns `#f`, and `#t` if it never does: ``` The result agrees with @exr-absorption. -Replacing the body with `(equal? (not (and p q)) (and (not p) (not q)))` -asks the question of @exr-not-and, and the answer agrees with that exercise too: +With a new body, the same loop checks whether the two statements of @exr-not-and are equivalent: ```{racket} #| code-fold: false @@ -24,4 +23,6 @@ asks the question of @exr-not-and, and the answer agrees with that exercise too: (equal? (not (and p q)) (and (not p) (not q)))) ``` +This result agrees with @exr-not-and. + :::