Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GuessLex confused by decreasing_by proof that fails on “wrong” measures #4523

Closed
nomeata opened this issue Jun 21, 2024 · 1 comment
Closed
Labels
bug Something isn't working P-low We are not planning to work on this issue

Comments

@nomeata
Copy link
Collaborator

nomeata commented Jun 21, 2024

In #4522 an innocent change broke GuessLex in the sense that the GuessLexTricky.lean test case broke, even though giving the termination measure explicitly the decreasing_by proof works (and it starts with all_goals). I’d expect GuessLex to work there.

See 390943f (if it isn’t merged already), or here:

macro_rules | `(tactic| decreasing_trivial) =>
              `(tactic| apply Nat.le_refl)
macro_rules | `(tactic| decreasing_trivial) =>
              `(tactic| apply Nat.succ_lt_succ; decreasing_trivial)
macro_rules | `(tactic| decreasing_trivial) =>
              `(tactic| apply Nat.sub_le)
macro_rules | `(tactic| decreasing_trivial) =>
              `(tactic| apply Nat.div_le_self)

syntax "search_lex " tacticSeq : tactic

macro_rules | `(tactic|search_lex $ts:tacticSeq) => `(tactic| (
    solve
    | apply Prod.Lex.right'
      · $ts
      · search_lex $ts
    | apply Prod.Lex.left
      · $ts
    | $ts
    ))

-- uncomment this to make it work
-- attribute [-simp] Nat.sub_le 

-- set_option trace.Elab.definition.wf true in
mutual
def prod (x y z : Nat) : Nat :=
  if y % 2 = 0 then eprod x y z else oprod x y z
-- termination_by (y, 1, 0)
decreasing_by
  all_goals
    simp_wf
    search_lex solve
      | decreasing_trivial
      | apply Nat.bitwise_rec_lemma; assumption

def oprod (x y z : Nat) := eprod x (y - 1) (z + x)
-- termination_by (y, 0, 1)
decreasing_by
  simp_wf
  search_lex solve -- wrapping this in try makes GuessLex work
      | decreasing_trivial
      | apply Nat.bitwise_rec_lemma; assumption

def eprod (x y z : Nat) := if y = 0 then z else prod (2 * x) (y / 2) z
-- termination_by (y, 0, 0)
decreasing_by
  simp_wf
  search_lex solve
    | decreasing_trivial
    | apply Nat.bitwise_rec_lemma; assumption

end

This isn’t high priority, but at some point I’d like to get to the bottom of this.

Versions

4.10.0-nightly-2024-06-19

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

@nomeata nomeata added bug Something isn't working low priority labels Jun 21, 2024
@leanprover-bot leanprover-bot added the P-low We are not planning to work on this issue label Aug 9, 2024
@nomeata
Copy link
Collaborator Author

nomeata commented Aug 22, 2024

It looks like this got fixed with #5016. Probably the problem was that simp_wf was unexpectedly closing a goal somewhere?

@nomeata nomeata closed this as completed Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P-low We are not planning to work on this issue
Projects
None yet
Development

No branches or pull requests

2 participants