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
anywhere
can be paired only with>=
andname
can be paired only with>=
and nogeneralize
a 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
Q
is either a base queryB
, the conjunctionQ1,Q2
of two queriesQ1
andQ2
, their disjunctionQ1;Q2
or the queryQ|PATH
that behaves asQ
, but only keeps the results whose path is a suffix ofPATH
(that must be a valid path prefix)a base query
name = ID
looks for symbols with nameID
in the library. The identifierID
must not be qualified.a base query
WHERE HOW GENERALIZE? PATTERN
looks in the library for occurrences of the patternPATTERN
up to normalization rules and, ifgeneralize
is 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 > y
withy < x
).WHERE
restricts the set of occurrences we are interested in as follow:anywhere
matches without restrictionsrule
matches only in rewriting ruleslhs
/rhs
matches only in the left-hand-side/right-hand-side of rewriting rulestype
matches only in the type of symbolsspine
matches 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/implicationsconcl
matches only in the conclusion of the type of symbols, i.e. what is left skipping all universal quantifications/implicationshyp
matches 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
HOW
further 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) , hyp >= (list nat)
searches for theorem that have an hypothesisnat → bool
and such thatlist nat
occurs in some (other) hypothesis. The query can returnfilter_nat_list: list nat → (nat → bool) → list nat
concl > plus | math.arithmetics
searches for theorems having an hypothesis containingplus
and located in a module whose path is a suffix ofmath.arithmetics
. The query can returnplus_O : ∀x: nat. plus x O = x
whereplus_O
has fully qualified namemath.arithmetics.addition.plus
name = nat ; name = NAT
searches for symbols named eithernat
orNAT