Zulip Chat Archive

Stream: new members

Topic: How to determine if the conditions are contradictory?


tsuki hao (Jul 29 2024 at 07:00):

Dose there exist a simple tactic that can lead to a contradiction of the conditions?

import Mathlib
import LeanCopilot


theorem lean_workbook_plus_79999 (a b c d e : ) (hab : a = 13) (hbc : b = 14) (hca : c = 15) (hpc : d = 10) (hABCD : a + b = c + d) (hABCE : a + b = c + e) (hDEF : d + e = 2 * b) : e - d = 12 * Real.sqrt 2    := by

Johan Commelin (Jul 29 2024 at 07:04):

linarith works

Johan Commelin (Jul 29 2024 at 07:05):

In general, the tactic you need of course depends on the shape of your conditions

Edward van de Meent (Jul 29 2024 at 07:28):

contradiction is another good one to know about

tsuki hao (Jul 29 2024 at 08:57):

Johan Commelin said:

linarith works

Actually, when I use linarith, the formal statement is proved? But the hypothesis contradict with each other :smiling_face_with_tear:

Josha Dekker (Jul 29 2024 at 09:00):

tsuki hao said:

Johan Commelin said:

linarith works

Actually, when I use linarith, the formal statement is proved? But the hypothesis contradict with each other :smiling_face_with_tear:

If the hypotheses contradict each-other, you can prove False, which then proves anything.

tsuki hao (Jul 29 2024 at 09:01):

Edward van de Meent said:

contradiction is another good one to know about

contradiction is to negate the conclusion?But what I need is to verify if the hypothesis is contradictory?

Ruben Van de Velde (Jul 29 2024 at 09:01):

No, contradiction solves any goal if there's P and not P in the context; you may be thinking of by_contra

tsuki hao (Jul 29 2024 at 09:03):

Josha Dekker said:

tsuki hao said:

Johan Commelin said:

linarith works

Actually, when I use linarith, the formal statement is proved? But the hypothesis contradict with each other :smiling_face_with_tear:

If the hypotheses contradict each-other, you can prove False, which then proves anything.

Yeah! Then how can I prove False using some simple tactic? I want to get the state False in Lean Infoview.

Edward van de Meent (Jul 29 2024 at 09:05):

you want the goal to be False? or you want to have a hypothesis False? for the first, you can probably use apply False.elim, while for the second, you can do have hfalse: False := by ...

tsuki hao (Jul 29 2024 at 09:10):

Maybe my explanation was unclear. I want to automatically verify whether the hypotheses contradict with each other, and if they are, to derive a new condition: False.

Ralf Stephan (Jul 29 2024 at 09:18):

I would set the goal manually to False and write contradiction in the proof. If it succeeds, your conditions are contradictory.

Edward van de Meent (Jul 29 2024 at 09:22):

how about this:

import Mathlib

macro "have_contra" n:ident : tactic => `(tactic|
  try have $n :False := by (
    try contradiction;
    try linarith;
    try omega;))

theorem lean_workbook_plus_79999 (a b c d e : ) (hab : a = 13) (hbc : b = 14) (hca : c = 15)
    (hpc : d = 10) (hABCD : a + b = c + d) (hABCE : a + b = c + e) (hDEF : d + e = 2 * b) :
    e - d = 12 * Real.sqrt 2 := by
  have_contra hfalse
  sorry

example : 1 = 1 := by
  have_contra hfalse
  sorry

Ruben Van de Velde (Jul 29 2024 at 09:42):

As it happens, "automatically verify whether the hypotheses contradict with each other" is just as strong as "prove the theorem", so you can't expect a procedure that works in general

Edward van de Meent (Jul 29 2024 at 09:47):

indeed. to elaborate on why that is: if you'd like to prove that h1,h2,h3,,hnPh_1,h_2,h_3,\ldots,h_n \rightarrow P with hih_i your hypotheses and PP your goal, it suffices to show that h1,h2,h3,,hn,¬Ph_1,h_2,h_3,\ldots,h_n,\neg P is a set of contradictory hypotheses.


Last updated: May 02 2025 at 03:31 UTC