comp.lang.ada
 help / color / mirror / Atom feed
* quantified expression with empty array?
@ 2018-03-09 17:15 Stephen Leake
  2018-03-09 18:40 ` Jeffrey R. Carter
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Stephen Leake @ 2018-03-09 17:15 UTC (permalink / raw)


I ran across this question recently:

If I have a quantified expression:

  (for some Child of Children => Predicate (Child))

what is the value if Children'Length = 0?

ARM 2012 4.5.8 8/4, 9/4 talk about evaluating the predicates, but in this case there are no predicates to evaluate.

I wrapped this piece of code in "if Children'Length = 0 then" to be safe.

-- Stephe


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: quantified expression with empty array?
  2018-03-09 17:15 quantified expression with empty array? Stephen Leake
@ 2018-03-09 18:40 ` Jeffrey R. Carter
  2018-03-09 18:41 ` Niklas Holsti
  2018-03-09 21:08 ` Shark8
  2 siblings, 0 replies; 4+ messages in thread
From: Jeffrey R. Carter @ 2018-03-09 18:40 UTC (permalink / raw)


On 03/09/2018 06:15 PM, Stephen Leake wrote:
> I ran across this question recently:
> 
> If I have a quantified expression:
> 
>    (for some Child of Children => Predicate (Child))
> 
> what is the value if Children'Length = 0?

4.5.8(9) reads, "If the quantifier is some, the expression is True if the 
evaluation of any predicate yields True; evaluation of the quantified_expression 
stops at that point. Otherwise (every predicate has been evaluated and yielded 
False), the expression is False." As we all learned in school, a parenthetical 
expression can be discarded without changing the meaning, so this is equivalent 
to "If the quantifier is some, the expression is True if the evaluation of any 
predicate yields True; evaluation of the quantified_expression stops at that 
point. Otherwise, the expression is False."

Since no predicate evaluated to True, the expression is False.

-- 
Jeff Carter
"To Err is human, to really screw up, you need C++!"
Stéphane Richard
63

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: quantified expression with empty array?
  2018-03-09 17:15 quantified expression with empty array? Stephen Leake
  2018-03-09 18:40 ` Jeffrey R. Carter
@ 2018-03-09 18:41 ` Niklas Holsti
  2018-03-09 21:08 ` Shark8
  2 siblings, 0 replies; 4+ messages in thread
From: Niklas Holsti @ 2018-03-09 18:41 UTC (permalink / raw)


On 18-03-09 19:15 , Stephen Leake wrote:
> I ran across this question recently:
>
> If I have a quantified expression:
>
> (for some Child of Children => Predicate (Child))
>
> what is the value if Children'Length = 0?
>
> ARM 2012 4.5.8 8/4, 9/4 talk about evaluating the predicates, but in
> this case there are no predicates to evaluate.

AARM 4.5.8 adds, for a "some" expression:

9.a/3  Ramification: The expression is False if the domain contains no 
values.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: quantified expression with empty array?
  2018-03-09 17:15 quantified expression with empty array? Stephen Leake
  2018-03-09 18:40 ` Jeffrey R. Carter
  2018-03-09 18:41 ` Niklas Holsti
@ 2018-03-09 21:08 ` Shark8
  2 siblings, 0 replies; 4+ messages in thread
From: Shark8 @ 2018-03-09 21:08 UTC (permalink / raw)


On Friday, March 9, 2018 at 10:15:12 AM UTC-7, Stephen Leake wrote:
> I ran across this question recently:
> 
> If I have a quantified expression:
> 
>   (for some Child of Children => Predicate (Child))
> 
> what is the value if Children'Length = 0?
> 
> ARM 2012 4.5.8 8/4, 9/4 talk about evaluating the predicates, but in this case there are no predicates to evaluate.
> 
> I wrapped this piece of code in "if Children'Length = 0 then" to be safe.

(FOR SOME ...) is exactly equivalent to a "THERE EXISTS" in logic, therefore if the domain for the ∃x is the null-set, then the evaluation is False because the thing didn't exists.

OTOH, the (FOR ALL ...) construct is exactly equivalent to the "FOR ALL" in logic and all 0 objects of ∀x {NULL} satisfy that, the expression evaluates to True.

So just remember that FOR ALL and FOR SOME are, respectively, ∀ and ∃.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-03-09 21:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-09 17:15 quantified expression with empty array? Stephen Leake
2018-03-09 18:40 ` Jeffrey R. Carter
2018-03-09 18:41 ` Niklas Holsti
2018-03-09 21:08 ` Shark8

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox