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

qify should use divisibility hypotheses on nats #7480

Closed
timotree3 opened this issue Oct 3, 2023 · 1 comment
Closed

qify should use divisibility hypotheses on nats #7480

timotree3 opened this issue Oct 3, 2023 · 1 comment
Labels
t-meta Tactics, attributes or user commands

Comments

@timotree3
Copy link
Collaborator

Right now, qify seems to be able to use divisibility hypotheses on ints but not nats. It would be nice if it worked for both.

import Mathlib.Tactic.Qify

example (n m : ℕ) (h : m ∣ n): n / m * m = n := by
  qify [h]
  -- oops! h wasn't used. goal is:
  -- ⊢ ↑(↑n / ↑m) * ↑m = ↑n
  sorry

example (n m : ℕ) (h : m ∣ n): n / m * m = n := by
  rw [← Int.ofNat_dvd] at h
  qify [h]
  -- yay! h was used. goal is:
  -- ⊢ ↑n / ↑m * ↑m = ↑n
  sorry
@timotree3 timotree3 added the t-meta Tactics, attributes or user commands label Oct 3, 2023
@timotree3
Copy link
Collaborator Author

In turns out this is a confluence issue in the simp set that qify uses:

import Mathlib.Algebra.CharZero.Lemmas
import Mathlib.Tactic.Qify

example (n m : ℕ) (h : m ∣ n): n / m * m = n := by
  -- qify [h] is equivalent to the following simp here:
  simp (config := { decide := false }) only [Mathlib.Tactic.Zify.nat_cast_eq, Nat.cast_mul, Int.ofNat_ediv,
    Mathlib.Tactic.Qify.int_cast_eq, Int.cast_mul, Int.cast_ofNat]
  -- oops! h wasn't used. goal is:
  -- ⊢ ↑(↑n / ↑m) * ↑m = ↑n
  sorry

example (n m : ℕ) (h : m ∣ n): n / m * m = n := by
  -- if we remove a lemma, it works!
  simp (config := { decide := false }) only [Mathlib.Tactic.Zify.nat_cast_eq, Nat.cast_mul, --Int.ofNat_ediv,
    Mathlib.Tactic.Qify.int_cast_eq, Int.cast_mul, h, Nat.cast_div_charZero, Int.cast_ofNat]
  -- yay! h was used. goal is:
  -- ⊢ ↑n / ↑m * ↑m = ↑n
  sorry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t-meta Tactics, attributes or user commands
Projects
None yet
1 participant