Query Language
Queries can be expressed according to the following syntax:
Q ::= B | Q with Q | Q|Q | Q in PATH
B ::= WHERE HOW GENERALIZE? PATTERN
PATH ::= <identifier> | "<regexp>"
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
with>|>inparentheses can be used as usual to force a different precedence order
anywherecan be paired only with>=andnamecan be paired only with>=and nogeneralizea pattern is expressed using the Lambdapi syntax except with search and websearch where, for convenience,
forallis interpreted asΠ,->as→,exists x:A, tas∃ (λ x:A, t), andfun x:A => tasλ x:A, t.
The semantics of the query language is the following:
a query
Qis either a base queryB, the conjunctionQ1 with Q2of two queriesQ1andQ2, their disjunctionQ1 | Q2or the queryQ IN PATHthat behaves asQ, but only keeps the results whose path is a suffix ofPATH(that must be a valid path prefix) or matches the regular expression between double quotes ("")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
Examples:
hyp = (nat → bool) with 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 in 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
concl > plus | "*.arithmetics"searches for theorems having an hypothesis containing
plusand located in a module whose path matches*.arithmetics. The query can returnmath.arithmetics.addition.plusandmathematics.arithmetics.addition.plus
name = nat | name = NATsearches for symbols named eithernatorNAT