Zulip Chat Archive
Stream: new members
Topic: How to use xor for boolean function?
Anthony Peterson (Mar 04 2024 at 20:09):
I am trying to migrate from Coq to Lean 4 and I'm starting by translation an existing proof that I wrote in Coq into Lean. It's just a stupid simple lemma about the Xor function, and I'm stumbling trying gain access to the definition of xor in Bool
Probably just some simple thing I'm missing. I've tried to look at the file where boolean functions are defined, but my import statement doesn't work and xor doesn't seem to be in scope by default. I'm not even sure if Lean uses scopes the same way Coq does?
import init.data.bool
#eval xor true false
Bolton Bailey (Mar 04 2024 at 20:11):
Bolton Bailey (Mar 04 2024 at 20:12):
Seems to be in Std.Data.Bool
Bolton Bailey (Mar 04 2024 at 20:12):
import Std.Data.Bool
#eval xor true false
Timo Carlin-Burns (Mar 04 2024 at 20:13):
It's a bit concerning that you've pasted import init.data.bool
. That lowercase naming convention for modules was only used in Lean 3.
Anthony Peterson (Mar 04 2024 at 20:13):
Bolton Bailey said:
import Std.Data.Bool #eval xor true false
Thanks that's what I needed. the Std.Data.Bool
Eric Wieser (Mar 04 2024 at 20:52):
Note there is also true ^^^ false
notation
Timo Carlin-Burns (Mar 04 2024 at 20:54):
Eric Wieser said:
Note there is also
true ^^^ false
notation
I tested that and there doesn't seem to be an instance of Xor Bool
.
Eric Wieser (Mar 04 2024 at 20:55):
Even with mathlib imported?
Timo Carlin-Burns (Mar 04 2024 at 20:56):
import Mathlib
#check true ^^^ false
-- failed to synthesize instance
-- HXor Bool Bool ?m.20
Last updated: May 02 2025 at 03:31 UTC