Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,23 @@ 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.
Replacing the body with `(equal? (not (and p q)) (and (not p) (not q)))`
returns `#f`, as @exr-not-and found.
The result agrees with @exr-absorption.
With a new body, the same loop checks whether the two statements of @exr-not-and are equivalent:

```{racket}
#| code-fold: false
(for*/and ([p '(#t #f)]
[q '(#t #f)])
(equal? (not (and p q)) (and (not p) (not q))))
```

This result agrees with @exr-not-and.

:::
2 changes: 2 additions & 0 deletions chapters/equivalence-negation.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ format:

{{< include ../latex-macros/macros.qmd >}}

{{< include _subfiles/_racket-setup.qmd >}}

::: {.callout-note appearance='simple' collapse=true}
## Source

Expand Down
Loading