### Set Logic and Intersections Defined

Any search item entered in a query can be weighted for determination as to what qualifies as a hit.

All search items indicate to the program a set of possibilities to be found. A keyword is a set of valid derivations of that word's root (morpheme). A concept set includes a list of equivalent meaning words. A special expression includes a range of strings that could be matched.

Therefore, whatever weighting applies to a search item applies to the whole set, and is referred to as "set logic".

The most usual logic in use is "AND" logic. Where no other weighting is given, it is understood that all entered search items have equal weight, and you want each one to occur in the targeted hit.

Here is an example of a typical query, where no special weighting has been assigned:

`WHERE BODY LIKE 'mayor powers duties city'`

The query equally weights each item, and searches for a sentence containing "mayor" and "powers" and "duties" and "city" anywhere within it, finding this sentence:

```In the case of absence from the CITY or the failure,
inability or refusal of both the MAYOR and mayor pro tempore
to perform the DUTIES of mayor, the city council may elect
an acting mayor pro tempore, who shall serve as mayor with
all the POWERS, privileges, and duties.```

Only those words required to qualify the sentence as a hit are located by the program, for maximum search efficiency.

In this example, there are several occurrences of the search items "mayor", "duties", and "city". It was only necessary to locate each item once to confirm validity of the hit. Such words may be found by the search program in any order.

The existence of more than one matched search item in a hit is called an intersection. Specifying two keywords in a query indicates you want both keywords to occur, or intersect, in the sentence.

A 2 item search is common, and can be thought of as 1 intersection of 2 sets.

Example:

`WHERE BODY LIKE '~alcohol ~consumption'`

In the above example, the tilde (`~`) preceding "alcohol" and preceding "consumption" enables concept expansion on both words, thereby including the set of associations listed for each word in the Thesaurus.

Where something from the concept set "alcohol" and something from the concept set "consumption" meet within a sentence, there is a hit. This default set logic finds a 1 intersection sentence:

```It shall be unlawful to USE the city swimming pool or enter
the enclosure in which it is located when a person is
INTOXICATED or under the influence of illegal drugs.```

"Use" is in the "consumption" concept set; "intoxicated" is in the "alcohol" concept set.

These two sets have herein intersected, forcing the context of the set members to be relevant to the entered query.