Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add existential and universal quantifier #736

Merged
merged 7 commits into from
Jan 19, 2024
Merged

Add existential and universal quantifier #736

merged 7 commits into from
Jan 19, 2024

Conversation

nwagner84
Copy link
Member

@nwagner84 nwagner84 commented Dec 17, 2023

This PR adds the existential and universal quantifier to a matcher expression.

The universal quantifier (, ALL) requires that all fields (or subfields) must satisfy the given predicate. The following expressions matches only records, where for all fields 065R the predicate (there exists a subfield 7 which is equal to "Tg1") evaluates to true.

$ pica filter -s 'ALL 065R.7 == "Tg1"' DUMP.dat.gz
$ pica filter -s '∀065R.7 == "Tg1"' DUMP.dat.gz

The universal quantifier can also be used in a subfield matcher expression:

$ pica filter -s '010@{ ALL a == "ger" }' DUMP.dat.gz
$ pica filter -s '010@{ ∀a == "ger" }' DUMP.dat.gz

Because the universal quantifier evaluates to true, if the set of fields (or subfields) is empty, it might be necessary to and a precondition to ensure the existence of at least one element.

$ pica filter -s '[email protected]? && ALL [email protected] == "ger"' DUMP.dat.gz

Notes

  • By default all expressions use implicitly the existential quantifier (, ANY)
  • The scope of a quantifier starts with the next field (or subfield) matcher and ends after this matcher.

@nwagner84 nwagner84 self-assigned this Dec 17, 2023
@nwagner84 nwagner84 changed the title Add universal and existential quantifiers Add universal and existential quantifier Dec 17, 2023
@nwagner84 nwagner84 changed the title Add universal and existential quantifier Add universal quantifier Dec 18, 2023
@nwagner84 nwagner84 added the C-enhancement Category: enhancement label Dec 18, 2023
@nwagner84 nwagner84 changed the title Add universal quantifier Add existential and universal quantifier Jan 5, 2024
@nwagner84 nwagner84 merged commit fc3e324 into main Jan 19, 2024
27 checks passed
@nwagner84 nwagner84 deleted the quantifier branch January 19, 2024 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant