Zulip Chat Archive

Stream: lean4

Topic: Can aesop take a simp-list


Bhavik Mehta (Sep 05 2023 at 23:10):

I find myself using aesop fairly often, and noticing that when it gets stuck I can add or remove one or two simp lemmas to make it succeed - is it possible to give aesop a list of lemmas to add/remove from the simp call (ie if I give it [a,-b,←c] then instead of calling simp it'd call simp [a,-b,←c]), like we can with norm_num? I'm aware of aesop (add simp a), but I can't get it to work to remove lemmas or reverse them.
(Tangentially, might it be sensible for ext to be one of the things aesop should try?)

Jannis Limperg (Sep 06 2023 at 00:12):

You can erase Aesop rules:

import Aesop

@[irreducible]
def foo := 42

@[aesop simp]
theorem foo_def : foo = 42 := by unfold foo; rfl

example : foo = 42 := by
  aesop (erase foo_def) -- fails
  aesop

The ←c syntax for reversing a lemma is currently not supported. Could be added with some effort.

ext sounds like a sensible candidate for the global rule set.

Bhavik Mehta (Sep 06 2023 at 05:46):

Ah, I was misunderstanding the syntax for erase - I tried (erase simp foo_def) - thanks for the clarification

Jannis Limperg (Sep 06 2023 at 15:50):

If you got it wrong, that probably means the docs are not great. I'll take a look. :)

Jireh Loreaux (Sep 13 2023 at 22:08):

This is a slightly different question, but is it possible to avoid using a lemma tagged @[simp] in an aesop call?

Alex Keizer (Sep 14 2023 at 13:16):

A particular lemma tagged @[simp], or do you want it to not use any simp-lemmas at all?

Jireh Loreaux (Sep 14 2023 at 17:06):

A particular lemma. But either option would be interesting.

James Gallicchio (Sep 14 2023 at 17:49):

how's that different from erasing a lemma? :thinking:

Jireh Loreaux (Sep 14 2023 at 18:05):

I thought aesop can only erase @[aesop simp] lemmas, not @[simp] lemmas. Am I wrong?

James Gallicchio (Sep 14 2023 at 18:08):

Ohhhhh maybe

Jannis Limperg (Sep 18 2023 at 09:43):

Digging up this thread after the holidays, sorry. Apparently I did implement this:

import Aesop

@[simp]
def A := True

example : A := by
  fail_if_success aesop (erase A) (options := { terminal := true })
  aesop

Jireh Loreaux (Sep 26 2023 at 21:11):

@Jannis Limperg I don't think so: that fail_if_success succeeds, but for the wrong reason.

import Aesop

@[simp]
def A := True

example : A := by
  aesop (erase A) (options := { terminal := true }) -- aesop: 'A' is not registered (with the given features) in any rule set.

Jireh Loreaux (Sep 26 2023 at 21:12):

Do you want me to create an issue on the aesop repo for this?

Jannis Limperg (Sep 26 2023 at 21:13):

Ah! Sorry, I'll look into it. No issue necessary (but do remind me if I forget).

Jannis Limperg (Oct 02 2023 at 17:17):

This is now fixed on Aesop master.

Jireh Loreaux (Oct 02 2023 at 17:30):

Thanks!

Jireh Loreaux (Oct 02 2023 at 17:36):

#7461 is the mathlib bump

Jannis Limperg (Oct 02 2023 at 17:57):

Aesop master currently has some other commits that'll (very mildly) break mathlib. #7462 avoids this breakage.

Patrick Massot (Oct 02 2023 at 17:58):

I borsed that but it would be nice to have a better fix where aesop still works there.

Jannis Limperg (Oct 02 2023 at 18:03):

Thanks! The issue with these goals is that they contain an equational hypothesis w that, when rewritten left to right, makes the goal unprovable. Aesop runs simp_all and so potentially rewrites with w. New Aesop still proves the goals when w is cleared. Old Aesop proved the goal in the presence of w because the simp lemmas were applied in a different order, so the correct simp lemma would fire before w. I consider such proofs inherently brittle (there's no guarantee anywhere about the order in which simp lemmas are tried), so I think it's good to replace them.

Patrick Massot (Oct 02 2023 at 18:06):

I understand but I thought that aesop was meant to be strictly stronger than simp. Of course, deep down, I know that there is never any such ordering between automation tactic...

Jannis Limperg (Oct 02 2023 at 18:16):

That's fair. I can't guarantee this property, but I'll see if I can avoid this specific discrepancy.

Jannis Limperg (Oct 03 2023 at 11:56):

Fixed on Aesop master.


Last updated: Dec 20 2023 at 11:08 UTC