Zulip Chat Archive
Stream: new members
Topic: a+b -c = a + (b-c) in N
RedPig (Oct 19 2024 at 17:44):
I have a trivial problem which is the associative of integers. The following code actually fails. The struggle here is that is not SubNegMonoid. How do we deal with such cases where we to inherent obvious operation from . Similar question could apply to field extension type of operation where a real number is also a complex number.
import Mathlib
theorem trivial_math (a b c : ℕ) : a + b - c = a + (b - c):= by
rw [add_sub_assoc]
Scott Carnahan (Oct 19 2024 at 18:03):
If a = 1, b = 0, c = 1, then the left side is 0 and the right side is 1. This is because Nat subtraction truncates at zero.
RedPig (Oct 19 2024 at 18:13):
Scott Carnahan said:
If a = 1, b = 0, c = 1, then the left side is 0 and the right side is 1. This is because Nat subtraction truncates at zero.
I see, in order to make sense, a + (b - c) must be represented in as (b-c) could be negative. Can we have sth like to transform the type
Julian Berman (Oct 19 2024 at 18:17):
A good piece of advice from someone in a previous thread (maybe Damiano? or Henrik?) is "literally any time you put -
somewhere with Nats, either don't do that if you can afford it, or if not, then try slim_check
" -- in particular in your case:
import Mathlib
theorem trivial_math (a b c : ℕ) : a + b - c = a + (b - c):= by
slim_check
immediately finds a counterexample like the one Scott mentioned.
Kevin Buzzard (Oct 19 2024 at 23:34):
import Mathlib.Tactic
theorem trivial_math (a b c : ℕ) : (a : ℤ) + b - c = a + (b - c):= by
rw [add_sub_assoc]
Terence Tao (Oct 20 2024 at 22:39):
If you absolutely have to use natural number subtraction for some reason, then many statements can be proven using the zify
tactic to convert (assuming suitable inequalities) to integer subtraction.
Riccardo Brasca (Oct 21 2024 at 06:19):
Nowadays we have omega
that works very well.
Last updated: May 02 2025 at 03:31 UTC