GithubHelp home page GithubHelp logo

nomeata / loogle Goto Github PK

View Code? Open in Web Editor NEW
54.0 5.0 6.0 314 KB

Mathlib search tool

Home Page: https://loogle.lean-lang.org/

License: Apache License 2.0

Lean 71.45% Nix 0.59% HTML 4.13% Python 21.60% C 2.21% Shell 0.01%
lean4 lean

loogle's Introduction

loogle

Loogle is a search tool for Lean/Mathlib, and can be used on the web, via a zulip bot, via APIs, from VSCode or nvim extensions as a Lean command or a command line tool.

Try it at https://loogle.lean-lang.org/!

$ loogle '(List.replicate (_ + _) _ = _)'
Found 5 definitions mentioning List.replicate, HAdd.hAdd and Eq.
Of these, 3 match your patterns.

List.replicate_add
List.replicate_succ
List.replicate_succ'

Running locally

To use loogle locally:

  1. check out this repository
  2. install elan
  3. run lake exe cache get
  4. run lake exe loogle --help (or other options)

If you use loogle on a large repository like Mathlib, the startup-time will be rather large. Run lake build LoogleMathlibCache if you want to pre-compute the index for Mathlib.

CLI Usage

USAGE:
  loogle [OPTIONS] [QUERY]

OPTIONS:
  --help
  --interactive, -i     read querys from stdin
  --json, -j            print result in JSON format
  --module mod          import this module (default: Mathlib)
  --path path           search for .olean files here (default: the build time path)
  --write-index file    persists the search index to a file
  --read-index file     read the search index from a file. This file is blindly trusted!

By default, it will create an internal index upon starting, which takes a bit. You can use --write-index and --read-index to cache that, but it is your responsibility to pass the right index for the given module and search path. In the nix setup, the index is built as part of the build process.

Web service

This tool is the backend of https://loogle.lean-lang.org/. This is currently running on a virtual host with a nixos system with a ngingx reverse proxy (for SSL) in front of a small python HTTP server (see ./server.py) that uses loogle. The query processing is locked down using SECCOMP (see ./loogle_seccomp.c). It automatically tries to upgrade to the latest mathlib every 6 hours.

You can run this server locally as well, either using ./server.py after you built loogle via lake.

At the path /json?q=… (instead of /?q=…), the result is returned in JSOON format. No stability of the format is guaranteed at this point.

Zulip bot

The leanprover Zulip chat has a bot called loogle that will respond to messages with the first two hits from loogle. Just write @**loogle** query in a public stream.

It is implemented via an outgoing webhook to the above web service.

Editor integration

These are created by their respective maintainers; reach out to them if you have questions

Contact

This tool was created by Joachim Breitner <[email protected]>. Feel free to use this repository to report issues or (even better) submit PRs that resolves such issues.

loogle's People

Contributors

nomeata avatar volodeyka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

loogle's Issues

Show definitions that mention all types of none matches exactly

It would be great any description that matches all types would be shown in case of no definition matching exactly.
Example: String -> Nat -> Substring results in Found one definition mentioning Substring, String and Nat. Of these, 0 match your pattern(s).

Use a front-end framework

I believe that using a front-end framework (like NextJS or Remix) helps both the user experience and the developer experience.

Today the project lacks some useful features, such as a dropdown in the search and some CSS improvements that would help the results become more readable.

Improved type rendering

The current way Loogle renders types can become very verbose. What would be a better way?

  • Certainly [C t] instead of [inst : C t] would be good if that name isn’t mentioned.

  • How about Nat instead of (n : Nat)? if n isn’t mentioned?

    But names can be very useful find : (needle hey : String)

  • simply R instead of (R : Type u_2)? Again maybe only if the u_2 is not mentioned anywhere else?

Unfortunately, the signature syntax before : doesn’t allow unnamed arguments (Nat), and the syntax after : doesn’t allow binders without types (R).

Also, should #check use the same syntax? The documentation generator?

Ideally, the code that does all this is not loogle-specific and lives in Lean or Std.

seccomp.h not found

I'm trying to install loogle locally on my machine (running SuSE Tumbleweed). When I try lake exe loogle --help (after the lake exe cache get step), I get the error message

mstoll@xxx:~/lean4/loogle> lake exe loogle --help
info: [0/68] Compiling Seccomp c shim (.o)
error: > cc -c -o ./.lake/build/loogle_seccomp.o ./loogle_seccomp.c -I /home/mstoll/.elan/toolchains/leanprover--lean4---v4.5.0-rc1/include -fPIC
error: stderr:
./loogle_seccomp.c:3:10: fatal error: seccomp.h: No such file or directory
    3 | #include <seccomp.h>
      |          ^~~~~~~~~~~
compilation terminated.
error: external command `cc` exited with code 1

There is a file /usr/inlcude/linux/seccomp.h, but no /usr/include/seccomp.h. Commenting out line 3 of loogle_seccomp.c (which does the #include that the compiler is complaining about), I get loads of error messages pointing to missing declarations. Installing the libseccomp-devel package seems to provide a suitable seccomp.h file, but in the directory /usr/include/libseccomp/, which does not seem to be in the path searched for header files. Adding /libseccomp in suitable places helps.

Maybe at some point the presence (or whereabouts) of relevant header files can be checked (before they are needed to compile something), and a helpful message be printed if they are not there or not where they are expected?

Negative filters

A reasonable feature request is to be able to prefix filters with, say, -, and then exclude all matches.

Technically doable. Would probably call for a refactoring of the implementation that I have in the back of my head anyways.

I am just hesitant to add complexity to the surface, so at the moment, I’m gauging the demand.

Requested here:

Invisible characters

Having invisible characters in a query (such as "​") will cause no results to show up, resulting in identical looking searches with different results.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.