Git Product home page Git Product logo

lean-tidy's Introduction

Build Status

A library of tactics for lean. These are used in the category theory library.

Highlights include chain and tidy.

Here's the basic idea. The tidy tactic attempts to do as much as possible of the "obvious" steps in a proof. In particular, it has a long (ordered) list of tactics, and at each step it finds the first tactic that succeeds, and if there is one that succeeds, it tries again. The current list of tactics is:

[ force (reflexivity)                         >> pure "refl", 
  exact_decidable,
  propositional_goal >> assumption            >> pure "assumption",
  forwards_reasoning,
  forwards_library_reasoning,
  backwards_reasoning,
  `[ext1]                                     >> pure "ext1",
  intro_at_least_one                          >>= λ ns, pure ("intros " ++ (" ".intercalate ns)),
  automatic_induction,
  `[apply_auto_param]                         >> pure "apply_auto_param",
  `[dsimp at *]                               >> pure "dsimp at *",
  `[simp at *]                                >> pure "simp at *",
  fsplit                                      >> pure "fsplit", 
  injections_and_clear                        >> pure "injections_and_clear",
  terminal_goal >> (`[solve_by_elim])         >> pure "solve_by_elim",
  unfold_aux                                  >> pure "unfold_aux",
  run_tidy_tactics ]

A few notes:

  • Each of these is setup as a "tactic string", which returns the command a user would enter in tactic mode. Using the command tidy { trace_result := tt } outputs the entire sequence of commands used, making it easy to replace a call to tidy with a sequence of explicit calls to the underlying tactics.
  • One can also pass extra tactics using tidy { extra_tactics := [ ... ] }, although these tactics are only tried after all the built-in ones. (I'd like to make this more flexible.)
  • There's also a @tidy attribute. Putting this on a definition that returns a tactic unit or tactic string will include that tactic in the list.
  • Because tidy relies on checking whether a tactic succeeds or fails, we need to wrap some of the basic commands (like reflexivity and fsplit) with force, to verify that they actually did something, and didn't just "fail silently".
  • To make use of backwards_reasoning you need to tag lemmas with @[back]; these are then applied to the goal wherever possible. (The attribute @[back'] allows the more conservative approach that the lemma should be applied to the goal so long as all new goals can be solved directly from hypotheses.)
  • To make use of forwards_library_reasoning you need to tag lemmas with @[forward].
  • The other non-standard tactic is automatic_induction which applies induction to variety of simple types (pairs, units, etc).
  • Because ext1 is on the list, the tidy tactic tends to prove things by writing everything out in components!

I'm very happy to have examples of goals that tidy does something stupid with. I'm very happy to have suggestions of improvements to the list of tactics tidy uses, that would make it more useful in other problem domains. I'm thinking about ways to produce better output as well --- at the moment we can use tidy { trace_result := tt } to get the list of commands used, but I'd love to have, for example tidy { latex_output := tt } produce something human readable!

Not described here (yet) are rewrite_search and obviously (which is just tidy followed by rewrite_search.)

lean-tidy's People

Contributors

semorrison avatar khoek avatar minchaowu avatar timjb avatar

Watchers

Reid Barton avatar James Cloos avatar

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.