Query Language
Queries can be expressed according to the following syntax:
Q ::= B | Q,Q | Q;Q | Q|PATH
B ::= WHERE HOW GENERALIZE? PATTERN
PATH ::= << string >>
WHERE ::= name | anywhere | rule | lhs | rhs | type | concl | hyp | spine
HOW ::= > | = | >= | ≥
GENERALIZE ::= generalize
PATTERN ::= << term possibly containing placeholders _ (for terms) and V# (for variable occurrences >>
where
the precedence order is
,>;>|parentheses can be used as usual to force a different precedence order
anywherecan be paired only with>=andnamecan be paired only with>=and nogeneralizea pattern should be wrapped in parentheses, unless it is atomic (e.g. an identifier or a placeholder)
The semantics of the query language is the following:
a query
Qis either a base queryB, the conjunctionQ1,Q2of two queriesQ1andQ2, their disjunctionQ1;Q2or the queryQ|PATHthat behaves asQ, but only keeps the results whose path is a suffix ofPATH(that must be a valid path prefix)a base query
name = IDlooks for symbols with nameIDin the library. The identifierIDmust not be qualified.a base query
WHERE HOW GENERALIZE? PATTERNlooks in the library for occurrences of the patternPATTERNup to normalization rules and, ifgeneralizeis specified, also up to generalization of the pattern. The normalization rules are library specific and are employed during indexing. They can be used, for example, to remove the clutter associated to encodings, to align concepts by mapping symbols to cross-library standard ones, or to standardize the shape of statements to improve recall (e.g. replacing occurrence ofx > ywithy < x).WHERErestricts the set of occurrences we are interested in as follow:anywherematches without restrictionsrulematches only in rewriting ruleslhs/rhsmatches only in the left-hand-side/right-hand-side of rewriting rulestypematches only in the type of symbolsspinematches only in the spine of the type of symbols, i.e. what is left of the type skipping zero or more (but not all) universal quantifications/implicationsconclmatches only in the conclusion of the type of symbols, i.e. what is left skipping all universal quantifications/implicationshypmatches only in the hypotheses of the type of symbols, i.e. in the type of an universal quantification/in the right left of an implication that occur in the spine
HOWfurther restricts the set of occurrences we are interested in as follows, where positions have already been restricted byWHERE:>=and≥matches without restrictions=the pattern must match the whole position>the pattern must match a strict subterm of the position
Note that for commodity, forall and -> can be used inside the query instead of the Unicode characters Π and → respectively.
Examples:
hyp = (nat → bool) , hyp >= (list nat)searches for theorem that have an hypothesisnat → booland such thatlist natoccurs in some (other) hypothesis. The query can returnfilter_nat_list: list nat → (nat → bool) → list nat
concl > plus | math.arithmeticssearches for theorems having an hypothesis containingplusand located in a module whose path is a suffix ofmath.arithmetics. The query can returnplus_O : ∀x: nat. plus x O = xwhereplus_Ohas fully qualified namemath.arithmetics.addition.plus
name = nat ; name = NATsearches for symbols named eithernatorNAT