Zulip Chat Archive

Stream: lean4

Topic: Object not being a structure


Gareth Ma (Oct 15 2023 at 14:34):

Hi, how do I express (and prove) that an object is not a particular structure via a counterexample?
For example,

import Mathlib.Tactic

open Nat

structure Idempotent (α : Type*) [AddGroup α] where
  f :  a : α, a = a + a

theorem NotIdempotent : ¬( a : , a = a + a) := by
  push_neg
  use 1
  linarith

/- If ℤ is Idempotent, then it has a .f field, contradicting NotIdempotent -/
example : ¬(Idempotent ) := by sorry

Kevin Buzzard (Oct 15 2023 at 14:48):

import Mathlib.Tactic

open Nat

structure Idempotent (α : Type*) [AddGroup α] : Prop where -- working around Lean 4 bug
  f :  a : α, a = a + a

theorem NotIdempotent : ¬( a : , a = a + a) := by
  push_neg
  use 1
  linarith

/- If ℤ is Idempotent, then it has a .f field, contradicting NotIdempotent -/
example : ¬(Idempotent ) := by
  rintro f
  exact NotIdempotent f

Kevin Buzzard (Oct 15 2023 at 14:49):

Is there an open Lean 4 issue for the "structure will sometimes be a Type when it should be a Prop" bug?

Gareth Ma (Oct 15 2023 at 14:54):

Ah, I didn't know it's supposed to be a Prop, thanks.

Gareth Ma (Oct 15 2023 at 14:54):

Kevin Buzzard said:

Is there an open Lean 4 issue for the "structure will sometimes be a Type when it should be a Prop" bug?

I can't find any. Also, this bug has been there since version Lean (version 4.0.0, commit ec941735c80d, Release)

Yaël Dillies (Oct 15 2023 at 15:13):

It was also there in Lean 3. It never worked, really. Maybe that's a performance concern? as in checking whether something can live in Prop could be expensive? or maybe it would unexpectedly unify universe metavariables?

Mario Carneiro (Oct 15 2023 at 15:14):

no, I think it's just not a feature that has been suggested

Mario Carneiro (Oct 15 2023 at 15:14):

I think we got as far as writing a linter for it though

Kevin Buzzard (Oct 15 2023 at 15:23):

lean4#2690

Kevin Buzzard (Oct 15 2023 at 15:24):

(let me know if you'd rather this were closed for some reason)


Last updated: Dec 20 2023 at 11:08 UTC