module _ where {- 0. set up agda. Here's what worked for me; please post on piazza about how it goes for you. First, If installed the Haskell Platform and then picked a directory where agda was going to go, call it (don't create it; create only its parent). stack new cd edit the stack.yaml so that the (not commented out) resolver line looks like this: resolver: lts-12.26 from inside , run: stack build Agda && stack exec -- which agda run agda like this: stack exec -- agda You will also want to set up the Emacs mode for agda: https://agda.readthedocs.io/en/v2.6.0/tools/emacs-mode.html Note that I ended up installing agda 2.4.x not 2.6 and I'm not sure if the version differences are significant or not. Because you've installed your version of agda only in one directory, you'll need to use a variation of the emacs configuration, replacing "agda-mode locate" with something like "cd ; stack exec -- agda-mode locate" Also, get a copy of the text book: https://dl.acm.org/citation.cfm?id=2841316 The book points to the IAL agda library but it points to an old version. You want the latest, which you can get here: https://github.com/cedille/ial It also seems to recommend 2.4, not 2.6. To solve the rest of these exercises, I recommend you create a file in the same directory as the IAL library you've checked out (icky, I know). I will grade your homework by putting it there to try it out. -} {- 1. Do exercises 1.1 and 1.2 in the text. -} open import bool open import eq {- Fill in the body of the isadd2 function so that `add2 b1 b2 b3 b4 = tt` if and only if the two digit binary number b1,b2 is equal to the two digit binary number b3,b4 plus 1. For example, isadd2 ff tt ff ff = tt since b1,b2 = 1, b3,b4 = 0, and 0+1 = 1, but isadd2 tt ff tt tt = ff since b1,b2 = 2, b3, b4 = 3, and 3+1 =/= 2 -} isadd2 : 𝔹 -> 𝔹 -> 𝔹 -> 𝔹 -> 𝔹 isadd2 b1 b2 b3 b4 = ? {- for UBool (possibly unknown bools) think of `TT` and `FF` as values that are completely known, but `??` as a value that might be true and might be false, but we do not know yet (think: we are waiting for the electricity to flow to this point in the ciruit) -} data MBool : Set where TT : MBool FF : MBool ?? : MBool {- there are sometimes functions that return known values when they get an unknown value, but sometimes their answer is not known yet. For example, when `Mand` sees a false, it knows the answer, no matter if the other argument is known or not. But when it gets a true in one argument and the unknown input in the other, it must propogate the unknown value. -} Mand : MBool -> MBool -> MBool Mand FF _ = FF Mand _ FF = FF Mand TT mb = mb Mand mb TT = mb Mand ?? ?? = ?? {- Implement Mor. -} Mor : MBool -> MBool -> MBool Mor mb1 mb2 = ? {- We can prove the theorems about the relationship between Mand and regular booleans if we lift from MBools to bools. -} lift : bool -> MBool lift tt = TT lift ff = FF andlift : ∀ b1 b2 → Mand (lift b1) (lift b2) ≡ lift (b1 && b2) andlift b1 b2 = ? orlift : ∀ b1 b2 → Mor (lift b1) (lift b2) ≡ lift (b1 || b2) orlift b1 b2 = ?