ufmg-smite / lean-smt

Tactics for discharging Lean goals into SMT solvers.
Apache License 2.0
84 stars 18 forks source link

Certifying transformations and local definitions #34

Open Vtec234 opened 2 years ago

Vtec234 commented 2 years ago

With #32, the smt tactic is becoming robust enough that I can translate some fairly complex expressions (e.g. exponentiation by squaring in $GF(2^8)$ with internals declared). Unfortunately, the current preprocessing approach (concretize) is lacking and falls over on these expressions, so I cannot define the entire circuit. This is to record the problems and propose a general approach. The approach is basically that of Blot et al. in snipe, with some new ideas.

Problems in concretize:

For the snipe approach, we need a representation of "local copies" of definitions which can be transformed and eventually consumed by smt. The equational variant foo.def : ∀ x y z, foo x y z = foo_body x y z that snipe uses seems quite workable. We should ensure it is fully abstract, i.e. that the equality is not over a function, by adding as many binders as possible (3.2 in snipe). This is roughly like the unfold equational theorems that Lean core uses.

We can then use certifying transformations which operate on this representation. The starting set I am going to implement is:

Other ones (that I will not do unless I find them necessary) include #27, ADTs, pattern matching, etc.

One thing to note is that having a bunch of blah.def equations which are expected to be of a certain form is a bit hacky. Fundamentally, the issue is how to transfer information between tactics. It might be nice to eventually provide an smt tactic mode which stores this information instead of relying on the local context. The syntax could be

smt =>
  extract_def foo
  monomorphize [blah] at foo
  extract_def [bar] at foo 
  solve