Zulip Chat Archive

Stream: new members

Topic: boolean vs logic operations


Henning Dieterichs (Nov 25 2020 at 20:24):

Lean 3 has "∨" for props and "||" for bools (also "/\" vs "&&", "tt" vs "true" and "ff" vs "false"). What is ¬ for bools? Apparently I can mix these operators/consts as I like and lean casts them, but the cast operator scares me when I see it in the goal view. What do you recommend here? It seems like I cannot use true in pattern matching, which supports my idea for not mixing props and bools.

Johan Commelin (Nov 25 2020 at 20:24):

!

Johan Commelin (Nov 25 2020 at 20:25):

I would indeed advice to avoid the casting as much as possible

Henning Dieterichs (Nov 25 2020 at 20:25):

Lean says "invalid expression" when I use "!"

Johan Commelin (Nov 25 2020 at 20:25):

Hmm, I admit that I never use it.

Johan Commelin (Nov 25 2020 at 20:25):

bnot is the name of the function.

Rob Lewis (Nov 25 2020 at 20:26):

The notation needs an import, off the top of my head I don't know what.

Rob Lewis (Nov 25 2020 at 20:26):

mathlib data.bool suffices.

Johan Commelin (Nov 25 2020 at 20:26):

import data.bool -- apparently

variable (b : bool)

#check !b

Henning Dieterichs (Nov 25 2020 at 20:27):

thanks, import data.bool does it!

Henning Dieterichs (Nov 25 2020 at 20:27):

it is rather counterintuitive that && and || are in global scope, but ! is not

Rob Lewis (Nov 25 2020 at 20:31):

Once upon a time ! was built in syntax for something different. It probably never made its way to core Lean after that syntax was removed.

Kevin Buzzard (Nov 25 2020 at 20:43):

What is -> for bools? I couldn't find it last time I looked

Johan Commelin (Nov 25 2020 at 20:54):

!a || b :grinning:


Last updated: Dec 20 2023 at 11:08 UTC