# On a logical reading of \`foreach/2\` predicate

**URL:** <https://swi-prolog.discourse.group/t/on-a-logical-reading-of-foreach-2-predicate/5006>\
**Category:** Nice to know\
**Created:** [February 10, 2022, 6:48pm UTC](https://swi-prolog.discourse.group/t/on-a-logical-reading-of-foreach-2-predicate/5006 "2022-02-10T18:48:36Z")\
**Posts on this page:** 1\
**Showing post:** 15

<div class="post-metadata">

**Author:** ![chansey97](https://avatars.discourse-cdn.com/v4/letter/c/e480ec/32.png) [@chansey97](https://swi-prolog.discourse.group/u/chansey97)\
**Post date:** [June 2, 2022, 9:57pm UTC](https://swi-prolog.discourse.group/t/on-a-logical-reading-of-foreach-2-predicate/5006/15 "2022-06-02T21:57:02Z")

</div>

Recently I revisited your logical reading of forall/2 and foreach/2 and found some interesting conclusions.

1. The derivation of the forall/2

2. The derivation of the foreach/2

3. forall/2 and foreach/2 are interchangeable when `Y` is a ground value.

4. forall/2 is more efficient than foreach/2 when they are interchangeable.

---

_[View the full topic](https://swi-prolog.discourse.group/t/on-a-logical-reading-of-foreach-2-predicate/5006)._
