More Exercises
Boolean_functions
Use the knowledge taught so far to solve the theorem:
Identity_fn_applied_twice (f: Bool/ -> Bool/) (e: (x: Bool/) -> Equal/ Bool/ (f x) x) (b : Bool/) : Equal/ Bool/ (f (f b)) b
Identity_fn_applied_twice f e b = ?Then, solve the negation_fn_applied_twice theorem, which is the same as the previous one, but changing the hypothesis to Equal (f x) (Not x)
Andb_eq_orb
Prove the following theorem (Remember that you can prove intermediate theorems separately):
Andb_eq_orb (b: Bool/) (c: Bool/) (e: Equal/ Bool/ (Andb b c) (Orb b c)) : Equal/ Bool/ b c
Andb_eq_orb b c prf = ?Binary
Consider a different representation of natural numbers using a binary system instead of unary. That is, instead of having only zero or one successor of a number, we can have:
- zero;
- twice a number;
- twice a number plus 1.
- First, write an inductive definition of this type, calling it Bin. (Remember that, in essence, the definition ofNataszeroorsucc nhas no intrinsic meaning. It only says that an element ofNatcan be azeroor asucc nifnis alsoNat. The interpretation of this as a system of values 0, 1, 2, etc., comes from how we work with this typeNat. Your definition ofBinideally will be as simple as well. It will be the functions you make onBinthat will give mathematical sense to it).
- Then write an Incrfunction to increment aBin, and aBin_to_natfunction to convert fromBintoNat.
- Write five proofs that test your increment and conversion functions. Note that incrementing a binary and then converting it should result in the same result as converting it first and then incrementing the Nat.