Documentation

CatCryptCore.Tactics.EnvSearch

EnvSearch — "loogle-lite" local declaration search over the elaborated env #

This module provides two #…Find commands that query the elaborated environment (every declaration reachable from the current imports), not the source text. This is precisely the discovery problem grep cannot solve: grep searches resolved syntax; these commands search resolved names and pretty-printed types. So questions like

are answered directly, even when the producing declaration lives in a different file, is generated, or names its type via an abbreviation that grep would miss.

Commands #

How an agent uses this #

Create (or reuse) a scratch file that imports CatCrypt.Tactic.EnvSearch together with whatever module brings the declarations of interest into scope, edit the #…Find query line, and read the resulting info diagnostic via mcp__lean-lsp__lean_diagnostic_messages. Each command emits its hits as a single multi-line logInfo, so one diagnostic carries the whole answer.

Example queries #

import CatCrypt.Tactic.EnvSearch
import CatCrypt.Crypto.SecureCompilation.ThirToComFront

-- defs/theorems whose *type* mentions `Com jasminDialect`, under `CatCrypt`:
#typeFind "Com jasminDialect" in CatCrypt

-- everything named like the front lowering:
#nameFind "thirToJasmin"

-- raise the cap and search a narrower namespace:
#typeFind "SPComp" in CatCrypt.Crypto.UOV 80

Heuristic: is n an internal / auto-generated name we want to hide? Covers the compiler-mangled and proof-helper families that swamp a raw name-substring scan without being useful search hits.

Equations
  • One or more equations did not get rendered due to their size.
Instances For

    Lowercase substring containment test.

    Equations
    Instances For

      Characters that can legitimately appear inside a (possibly dotted) Lean identifier. Anything else is a separator when we collapse qualified names to their final component.

      Equations
      Instances For

        Collapse every dotted qualified identifier in s to its final component (A.B.foofoo), leaving all other text intact. This lets #typeFind "Com jasminDialect" match a type the pretty-printer rendered fully-qualified as …VIR.Com …VIR.jasminDialect, without the caller having to open the right namespaces or spell the full path.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For

          Pretty-print a declaration's type to a single-line String, with binders and a generous width so the substring match sees a stable rendering.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For

            Format one hit as name : type.

            Equations
            Instances For

              Flatten a docstring to one line (trim each line, drop blanks, single-space join), then return a ~180-char window around the first case-insensitive occurrence of needle (starting a little before it for context). Used to render a #docFind hit on one line.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                def CatCrypt.Tactic.EnvSearch.renderResult (cmd query : String) (hits : Array String) (scanned cap : Nat) (truncated : Bool) :

                Render the accumulated hit lines (or the empty-result message) for command cmd with the given query, noting truncation if the cap was reached.

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For

                  #nameFind #

                  #nameFind "substr" (cap)? — declarations whose name contains substr (case-insensitive). Scans the whole environment (cheap, name-only); skips internal/auto-generated names; prints name : <type>. Cap default 40.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For

                    #typeFind #

                    #typeFind "typeSubstr" (in <Namespace>)? (cap)? — declarations whose pretty-printed type contains typeSubstr. A namespace prefilter keeps the (expensive) pretty-printing bounded; default prefix CatCrypt. Prints name : <type>. Cap default 40.

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For

                      #docFind — search the human-readable capability descriptions #

                      #docFind "substr" (in <Namespace>)? (cap)? — declarations whose docstring contains substr (case-insensitive). The CONCEPT search: capability descriptions live in docstrings, which #nameFind/#typeFind miss. Namespace prefilter (default CatCrypt); prints name : <snippet>. Cap default 40. Run this BEFORE building a new declaration.

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For