[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]

Duality of quantifiers

*From*:**"Costello, Roger L." <costello@mitre.org>***To*: "xml-dev@lists.xml.org" <xml-dev@lists.xml.org>*Date*: Tue, 10 Jul 2018 21:42:03 +0000

So, you’ve got an XML
document containing a bunch of integers: <Test> <x>2</x> <x>4</x> <x>5</x> <x>7</x> <x>10</x> </Test> You want to know: Is
it true that not all the integers are even? To find the answer,
you create this XPath expression:
not (every $x in /Test/* satisfies $x mod 2 eq 0) “Is
it not the case that every x in Test is even?” Alternatively,
you could have written the XPath expression this way:
some $x in /Test/* satisfies not ($x mod 2 eq 0) “Are
there some x in Test that are not even?” The
two XPath expressions are equivalent – they produce the same results. Let’s
denote the test for evenness ($x mod 2 eq 0) with p(x), where p represents the evenness test on x.
Let’s
denote the set of values being evaluated ( /Test/* ) with seq. Then
the two XPath expressions can be written:
not (every $x in seq satisfies p(x))
some $x in seq satisfies not p(x) Using
a slightly more abstract (non-XPath) notation, we can write the expressions as:
not (for all x) p(x)
(for some x) [not p(x)] The
two expressions are equivalent. “ The
equivalence of these two expressions:
not (for all x) p(x)
(for some x) [not p(x)] is
called the “ Here
are two more equivalent expressions, exhibiting the duality of quantifiers:
not (for some x) p(x)
(for all x) [not p(x)] Converting
them to XPath, we have:
not (some $x in /Test/* satisfies $x mod 2 eq 0)
every $x in /Test/* satisfies not ($x mod 2 eq 0) Both express this: “Is it the case that none of the x values are even?” Neat! /Roger |

**Follow-Ups**:**Re: [xml-dev] Duality of quantifiers***From:*Peter Flynn <peter@silmaril.ie>

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]

News |
XML in Industry |
Calendar |
XML Registry

Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS

Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS