Zulip Chat Archive
Stream: mathlib4
Topic: Precisely one of these holds
Michael Rothgang (Jan 08 2024 at 16:12):
What's the idiomatic mathlib spelling for "exactly one of these conditions holds"?
(Case in point is #9343: the result is "either condition A xor condition B holds". The current solution is a lemma iff , which is slightly cumbersome to prove.)
Yury G. Kudryashov (Jan 08 2024 at 18:54):
See docs#Xor'
Yury G. Kudryashov (Jan 08 2024 at 18:55):
IMHO, we should define an instance of docs#Xor for docs#Prop and docs#Bool, then use the ^^^
notation.
Yaël Dillies (Jan 08 2024 at 19:04):
No, you should use docs#symmDiff instead
Johan Commelin (Jan 08 2024 at 19:08):
I'm not sure... We also don't use and instead of and ...
Eric Rodriguez (Jan 08 2024 at 19:36):
we can make some nice notation for symmdiff. I'm surprised we haven't ran into this much before; I think many, many of the Or
s written in mathlib right now are of this form
Adam Topaz (Jan 08 2024 at 19:51):
Personally I think we should set something up similar to docs#List.TFAE for this.
Johan Commelin (Jan 08 2024 at 19:53):
X1OTFIT
= "exactly one of the following is true"
Adam Topaz (Jan 08 2024 at 19:53):
List.ExactlyOne
Yury G. Kudryashov (Jan 08 2024 at 20:09):
We can have both a List
and a binary version. I think that the operation on Prop
should be called xor
in theorem names. I don't care which notation does it use.
Michael Rothgang (Jan 08 2024 at 20:25):
Thanks for all the pointers! I've gone with Xor for now - if there's consensus to use otherwise or a reviewer objects, this can be changed easily.
Wrenna Robson (Jan 09 2024 at 12:07):
I think it probably shouldn't use ^^^
because we have a different symbol for "Boolean and" and ∧, right?
Wrenna Robson (Jan 09 2024 at 12:09):
Unfortunately this operation is quite an overloaded one, semantically. But I think @Yaël Dillies is right: ∆
is good.
Wrenna Robson (Jan 09 2024 at 12:11):
It is worth thinking about what you'd actually do with such statements, mind. And
and Or
decompose easily enough.
Eric Wieser (Jan 09 2024 at 12:34):
∆
is no good for the n-ary statement
Wrenna Robson (Jan 09 2024 at 12:42):
good point
Wrenna Robson (Jan 09 2024 at 12:44):
But then, again, it isn't clear to me (from a structural point of view) how you should use such a proposition.
For A_i, I suppose what you have is a) a proof of A_1 or A_2.. or A_n, and b) a proof that A_i -> not (A_j) for i \ne j.
Wrenna Robson (Jan 09 2024 at 12:45):
It's a little bit like being pairwise disjoint, actually.
Wrenna Robson (Jan 09 2024 at 12:45):
That is probably the analogous n-ary statement on sets.
Wrenna Robson (Jan 09 2024 at 12:46):
What you probably want is a symbol for "at most one of these is true", which is that. And then or covers "at least one of these is true".
Wrenna Robson (Jan 09 2024 at 12:47):
Any two of them imply False.
Kevin Buzzard (Jan 09 2024 at 13:13):
Eric Wieser said:
∆
is no good for the n-ary statement
I guess ∆
is great for "an odd number of these statements are true" :-)
Wrenna Robson (Jan 09 2024 at 13:21):
example (ι : Type*) (p : ι → Prop) : Prop := Pairwise (fun i j => ¬ (p i) ∨ ¬ (p j)) ∧ ∃ i, p i
Wrenna Robson (Jan 09 2024 at 13:22):
Something like this?
Wrenna Robson (Jan 09 2024 at 13:23):
example (ι : Type*) (p : ι → Prop) : Prop := Pairwise (Or on (Not ∘ p)) ∧ ∃ i, p i
or this, if you want to be cute.
Eric Wieser (Jan 09 2024 at 13:26):
∃! i, p i
seems like the obvious spelling
Wrenna Robson (Jan 09 2024 at 13:28):
Yes I was about to say, if you want to bundle everything together, that is the one.
Wrenna Robson (Jan 09 2024 at 13:28):
But in practice I think you will, I'm prepared to say 99% of the time, prove that by proving the left and the right there.
Wrenna Robson (Jan 09 2024 at 13:29):
Incidentally, where is ∃!
defined? Docs search isn't giving me it.
Wrenna Robson (Jan 09 2024 at 13:30):
nvm got it.
ExistsUnique p = ∃ (x : α), p x ∧ ∀ (y : α), p y → y = x
Wrenna Robson (Jan 09 2024 at 13:31):
Not sure if that's easier or harder to work with in practice.
Wrenna Robson (Jan 09 2024 at 13:32):
like I can imagine in some cases wanting to split the proof of "at most one" and "at least one", and here, you show "at most one" and then "any others are that one"
Yaël Dillies (Jan 09 2024 at 16:09):
Wrenna Robson said:
It's a little bit like being pairwise disjoint, actually.
It is exactly being a partition of True
.
Yury G. Kudryashov (Jan 09 2024 at 20:33):
BTW, do we have (∃! b : Bool, p b) <-> Xor' (p true) (p false)
?
Last updated: May 02 2025 at 03:31 UTC