Lesson 4 of 15

Booleans

Booleans in Lean

Lean's Bool type has two values: true and false (lowercase, unlike Haskell).

Logical operators:

  • && — and
  • || — or
  • ! — not (prefix)

Comparison operators return Bool:

  • ==, != — equality
  • <, >, <=, >= — comparisons
#eval true && false    -- false
#eval true || false    -- true
#eval !true            -- false
#eval 5 > 3            -- true
#eval 10 == 10         -- true

Your Turn

Evaluate:

  1. true && true
  2. false || true
  3. !false
  4. 7 < 3
Lean loading...
Loading...
Click "Run" to execute your code.