@@ -7,9 +7,9 @@ permalink : /TSPL/2019/Assignment1/
77module Assignment1 where
88```
99
10- ## YOUR NAME AND EMAIL GOES HERE
10+ # YOUR NAME AND EMAIL GOES HERE
1111
12- ## Introduction
12+ # Introduction
1313
1414You must do _ all_ the exercises labelled "(recommended)".
1515
@@ -28,7 +28,7 @@ Please ensure your files execute correctly under Agda!
2828
2929
3030
31- ## Good Scholarly Practice.
31+ # Good Scholarly Practice.
3232
3333Please remember the University requirement as
3434regards all assessed work. Details about this can be found at:
@@ -43,7 +43,7 @@ yourself, or your group in the case of group practicals).
4343
4444
4545
46- ## Imports
46+ # Imports
4747
4848``` agda
4949import Relation.Binary.PropositionalEquality as Eq
@@ -55,24 +55,24 @@ open import Data.Nat.Properties using (+-assoc; +-identityʳ; +-suc; +-comm;
5555open import plfa.part1.Relations using (_<_; z<s; s<s; zero; suc; even; odd)
5656```
5757
58- ## Naturals
58+ # Naturals
5959
60- #### Exercise ` seven ` (practice) {#seven}
60+ ### Exercise ` seven ` (practice) {#seven}
6161
6262Write out ` 7 ` in longhand.
6363
6464
65- #### Exercise ` +-example ` (practice) {#plus-example}
65+ ### Exercise ` +-example ` (practice) {#plus-example}
6666
6767Compute ` 3 + 4 ` , writing out your reasoning as a chain of equations.
6868
6969
70- #### Exercise ` *-example ` (practice) {#times-example}
70+ ### Exercise ` *-example ` (practice) {#times-example}
7171
7272Compute ` 3 * 4 ` , writing out your reasoning as a chain of equations.
7373
7474
75- #### Exercise ` _^_ ` (recommended) {#power}
75+ ### Exercise ` _^_ ` (recommended) {#power}
7676
7777Define exponentiation, which is given by the following equations.
7878
@@ -82,12 +82,12 @@ Define exponentiation, which is given by the following equations.
8282Check that ` 3 ^ 4 ` is ` 81 ` .
8383
8484
85- #### Exercise ` ∸-examples ` (recommended) {#monus-examples}
85+ ### Exercise ` ∸-examples ` (recommended) {#monus-examples}
8686
8787Compute ` 5 ∸ 3 ` and ` 3 ∸ 5 ` , writing out your reasoning as a chain of equations.
8888
8989
90- #### Exercise ` Bin ` (stretch) {#Bin}
90+ ### Exercise ` Bin ` (stretch) {#Bin}
9191
9292A more efficient representation of natural numbers uses a binary
9393rather than a unary system. We represent a number as a bitstring.
@@ -134,9 +134,9 @@ For the former, choose the bitstring to have no leading zeros if it
134134represents a positive natural, and represent zero by ` x0 nil ` .
135135Confirm that these both give the correct answer for zero through four.
136136
137- ## Induction
137+ # Induction
138138
139- #### Exercise ` operators ` (practice) {#operators}
139+ ### Exercise ` operators ` (practice) {#operators}
140140
141141Give another example of a pair of operators that have an identity
142142and are associative, commutative, and distribute over one another.
@@ -145,14 +145,14 @@ Give an example of an operator that has an identity and is
145145associative but is not commutative.
146146
147147
148- #### Exercise ` finite-+-assoc ` (stretch) {#finite-plus-assoc}
148+ ### Exercise ` finite-+-assoc ` (stretch) {#finite-plus-assoc}
149149
150150Write out what is known about associativity of addition on each of the first four
151151days using a finite story of creation, as
152152[ earlier] [ plfa.Naturals#finite-creation ]
153153
154154
155- #### Exercise ` +-swap ` (recommended) {#plus-swap}
155+ ### Exercise ` +-swap ` (recommended) {#plus-swap}
156156
157157Show
158158
@@ -166,23 +166,23 @@ the following function from the standard library:
166166 sym : ∀ {m n : ℕ} → m ≡ n → n ≡ m
167167
168168
169- #### Exercise ` *-distrib-+ ` (recommended) {#times-distrib-plus}
169+ ### Exercise ` *-distrib-+ ` (recommended) {#times-distrib-plus}
170170
171171Show multiplication distributes over addition, that is,
172172
173173 (m + n) * p ≡ m * p + n * p
174174
175175for all naturals ` m ` , ` n ` , and ` p ` .
176176
177- #### Exercise ` *-assoc ` (recommended) {#times-assoc}
177+ ### Exercise ` *-assoc ` (recommended) {#times-assoc}
178178
179179Show multiplication is associative, that is,
180180
181181 (m * n) * p ≡ m * (n * p)
182182
183183for all naturals ` m ` , ` n ` , and ` p ` .
184184
185- #### Exercise ` *-comm ` (practice) {#times-comm}
185+ ### Exercise ` *-comm ` (practice) {#times-comm}
186186
187187Show multiplication is commutative, that is,
188188
@@ -191,23 +191,23 @@ Show multiplication is commutative, that is,
191191for all naturals ` m ` and ` n ` . As with commutativity of addition,
192192you will need to formulate and prove suitable lemmas.
193193
194- #### Exercise ` 0∸n≡0 ` (practice) {#zero-monus}
194+ ### Exercise ` 0∸n≡0 ` (practice) {#zero-monus}
195195
196196Show
197197
198198 zero ∸ n ≡ zero
199199
200200for all naturals ` n ` . Did your proof require induction?
201201
202- #### Exercise ` ∸-+-assoc ` (practice) {#monus-plus-assoc}
202+ ### Exercise ` ∸-+-assoc ` (practice) {#monus-plus-assoc}
203203
204204Show that monus associates with addition, that is,
205205
206206 m ∸ n ∸ p ≡ m ∸ (n + p)
207207
208208for all naturals ` m ` , ` n ` , and ` p ` .
209209
210- #### Exercise ` Bin-laws ` (stretch) {#Bin-laws}
210+ ### Exercise ` Bin-laws ` (stretch) {#Bin-laws}
211211
212212Recall that
213213Exercise [ Bin] [ plfa.Naturals#Bin ]
@@ -228,32 +228,32 @@ over bitstrings.
228228For each law: if it holds, prove; if not, give a counterexample.
229229
230230
231- ## Relations
231+ # Relations
232232
233233
234- #### Exercise ` orderings ` (practice) {#orderings}
234+ ### Exercise ` orderings ` (practice) {#orderings}
235235
236236Give an example of a preorder that is not a partial order.
237237
238238Give an example of a partial order that is not a preorder.
239239
240240
241- #### Exercise ` ≤-antisym-cases ` (practice) {#leq-antisym-cases}
241+ ### Exercise ` ≤-antisym-cases ` (practice) {#leq-antisym-cases}
242242
243243The above proof omits cases where one argument is ` z≤n ` and one
244244argument is ` s≤s ` . Why is it ok to omit them?
245245
246246
247- #### Exercise ` *-mono-≤ ` (stretch)
247+ ### Exercise ` *-mono-≤ ` (stretch)
248248
249249Show that multiplication is monotonic with regard to inequality.
250250
251251
252- #### Exercise ` <-trans ` (recommended) {#less-trans}
252+ ### Exercise ` <-trans ` (recommended) {#less-trans}
253253
254254Show that strict inequality is transitive.
255255
256- #### Exercise ` trichotomy ` (practice) {#trichotomy}
256+ ### Exercise ` trichotomy ` (practice) {#trichotomy}
257257
258258Show that strict inequality satisfies a weak version of trichotomy, in
259259the sense that for any ` m ` and ` n ` that one of the following holds:
@@ -266,26 +266,26 @@ similar to that used for totality.
266266(We will show that the three cases are exclusive after we introduce
267267[ negation] [ plfa.Negation ] .)
268268
269- #### Exercise ` +-mono-< ` {#plus-mono-less}
269+ ### Exercise ` +-mono-< ` {#plus-mono-less}
270270
271271Show that addition is monotonic with respect to strict inequality.
272272As with inequality, some additional definitions may be required.
273273
274- #### Exercise ` ≤-iff-< ` (recommended) {#leq-iff-less}
274+ ### Exercise ` ≤-iff-< ` (recommended) {#leq-iff-less}
275275
276276Show that ` suc m ≤ n ` implies ` m < n ` , and conversely.
277277
278- #### Exercise ` <-trans-revisited ` (practice) {#less-trans-revisited}
278+ ### Exercise ` <-trans-revisited ` (practice) {#less-trans-revisited}
279279
280280Give an alternative proof that strict inequality is transitive,
281281using the relating between strict inequality and inequality and
282282the fact that inequality is transitive.
283283
284- #### Exercise ` o+o≡e ` (stretch) {#odd-plus-odd}
284+ ### Exercise ` o+o≡e ` (stretch) {#odd-plus-odd}
285285
286286Show that the sum of two odd numbers is even.
287287
288- #### Exercise ` Bin-predicates ` (stretch) {#Bin-predicates}
288+ ### Exercise ` Bin-predicates ` (stretch) {#Bin-predicates}
289289
290290Recall that
291291Exercise [ Bin] [ plfa.Naturals#Bin ]
0 commit comments