@@ -249,10 +249,12 @@ standard library.
249
249
250
250
Functions over booleans can be defined in the same way as above :
251
251
252
- > negb : (b : Bool) -> Bool
253
- > negb True = False
254
- > negb False = True
255
- >
252
+ ```idris
253
+ not : (b : Bool) -> Bool
254
+ not True = False
255
+ not False = True
256
+ ```
257
+
256
258
> andb : (b1 : Bool) -> (b2 : Bool) -> Bool
257
259
> andb True b2 = b2
258
260
> andb False b2 = False
@@ -286,15 +288,17 @@ We can also introduce some familiar syntax for the boolean operations we have
286
288
just defined . The \idr{syntax} command defines a new symbolic notation for an
287
289
existing definition , and \idr{infixl} specifies left -associative fixity .
288
290
289
- > infixl 4 /\, \/
290
- >
291
- > (/\) : Bool -> Bool -> Bool
292
- > (/\) = andb
293
- >
294
- > (\/) : Bool -> Bool -> Bool
295
- > (\/) = orb
296
- >
297
- > testOrb5 : False \/ False \/ True = True
291
+ ```idris
292
+ infixl 4 &&, ||
293
+
294
+ (&&) : Bool -> Bool -> Bool
295
+ (&&) = andb
296
+
297
+ (||) : Bool -> Bool -> Bool
298
+ (||) = orb
299
+ ```
300
+
301
+ > testOrb5 : False || False || True = True
298
302
> testOrb5 = Refl
299
303
>
300
304
@@ -355,27 +359,27 @@ Every expression in Idris has a type, describing what sort of thing it computes.
355
359
The \idr{:type} (or \idr{:t}) REPL command asks Idris to print the type of an
356
360
expression.
357
361
358
- For example , the type of \idr{negb True } is \idr{Bool}.
362
+ For example , the type of \idr{not True } is \idr{Bool}.
359
363
360
364
```idris
361
365
λΠ> :type True
362
366
True : Bool
363
- λΠ> :t negb True
364
- negb True : Bool
367
+ λΠ> :t not True
368
+ not True : Bool
365
369
```
366
370
367
371
\todo[inline]{Confirm the "function types " wording.}
368
372
369
- Functions like \idr{negb } itself are also data values, just like \idr{True} and
373
+ Functions like \idr{not } itself are also data values, just like \idr{True} and
370
374
\idr{False}. Their types are called \glspl{function type }, and they are written
371
375
with arrows .
372
376
373
377
```idris
374
- λΠ> :t negb
375
- negb : Bool -> Bool
378
+ λΠ> :t not
379
+ not : Bool -> Bool
376
380
```
377
381
378
- The type of \idr{negb }, written \idr{Bool -> Bool} and pronounced "\idr{Bool}
382
+ The type of \idr{not }, written \idr{Bool -> Bool} and pronounced "\idr{Bool}
379
383
arrow \idr{Bool}," can be read, "Given an input of type \idr{Bool}, this
380
384
function produces an output of type \idr{Bool}." Similarly, the type of
381
385
\idr{andb}, written \idr{Bool -> Bool -> Bool}, can be read, "Given two inputs,
@@ -499,7 +503,7 @@ simpler definition that is a bit easier to work with:
499
503
> ||| Determine whether a number is odd .
500
504
> ||| @n a number
501
505
> oddb : (n : Nat) -> Bool
502
- > oddb n = negb (evenb n )
506
+ > oddb n = not (evenb n )
503
507
>
504
508
> testOddb1 : oddb 1 = True
505
509
> testOddb1 = Refl
@@ -886,9 +890,9 @@ For example, we use it next to prove that boolean negation is involutive --
886
890
i.e., that negation is its own inverse .
887
891
888
892
> ||| A proof that boolean negation is involutive.
889
- > negb_involutive : (b : Bool) -> negb ( negb b ) = b
890
- > negb_involutive True = Refl
891
- > negb_involutive False = Refl
893
+ > not_involutive : (b : Bool) -> not ( not b ) = b
894
+ > not_involutive True = Refl
895
+ > not_involutive False = Refl
892
896
>
893
897
894
898
Note that the case splitting here doesn't introduce any variables because none
@@ -898,7 +902,7 @@ any names.
898
902
It is sometimes useful to case split on more than one parameter , generating yet
899
903
more proof obligations. For example :
900
904
901
- > andb_commutative : (b, c : Bool) -> andb b c = andb c b
905
+ > andb_commutative : (b, c : Bool) -> b && c = c && b
902
906
> andb_commutative True True = Refl
903
907
> andb_commutative True False = Refl
904
908
> andb_commutative False True = Refl
@@ -908,15 +912,15 @@ more proof obligations. For example:
908
912
In more complex proofs , it is often better to lift subgoals to lemmas:
909
913
910
914
911
- > andb_commutative'_rhs_1 : (c : Bool) -> c = andb c True
915
+ > andb_commutative'_rhs_1 : (c : Bool) -> c = c && True
912
916
> andb_commutative'_rhs_1 True = Refl
913
917
> andb_commutative'_rhs_1 False = Refl
914
918
>
915
- > andb_commutative'_rhs_2 : (c : Bool) -> False = andb c False
919
+ > andb_commutative'_rhs_2 : (c : Bool) -> False = c && False
916
920
> andb_commutative'_rhs_2 True = Refl
917
921
> andb_commutative'_rhs_2 False = Refl
918
922
>
919
- > andb_commutative' : (b, c : Bool) -> andb b c = andb c b
923
+ > andb_commutative' : (b, c : Bool) -> b && c = c && b
920
924
> andb_commutative' True = andb_commutative'_rhs_1
921
925
> andb_commutative' False = andb_commutative'_rhs_2
922
926
>
@@ -926,7 +930,7 @@ In more complex proofs, it is often better to lift subgoals to lemmas:
926
930
927
931
Prove the following claim , lift cases (and subcases ) to lemmas when case split.
928
932
929
- > andb_true_elim_2 : (b, c : Bool) -> (andb b c = True) -> c = True
933
+ > andb_true_elim_2 : (b, c : Bool) -> (b && c = True) -> c = True
930
934
> andb_true_elim_2 b c prf = ?andb_true_elim_2_rhs
931
935
>
932
936
@@ -988,7 +992,7 @@ boolean functions.
988
992
989
993
Now state and prove a theorem \idr{negation_fn_applied_twice} similar to the
990
994
previous one but where the second hypothesis says that the function \idr{f} has
991
- the property that \idr{f x = negb x }.
995
+ the property that \idr{f x = not x }.
992
996
993
997
>
994
998
> -- FILL IN HERE
@@ -1003,7 +1007,7 @@ Prove the following theorem. (You may want to first prove a subsidiary lemma or
1003
1007
two. Alternatively, remember that you do not have to introduce all hypotheses at
1004
1008
the same time.)
1005
1009
1006
- > andb_eq_orb : (b, c : Bool) -> (andb b c = orb b c) -> b = c
1010
+ > andb_eq_orb : (b, c : Bool) -> (b && c = b || c) -> b = c
1007
1011
> andb_eq_orb b c prf = ?andb_eq_orb_rhs
1008
1012
1009
1013
$\square$
0 commit comments