a
This commit is contained in:
parent
32ed3d6920
commit
fceaaa8f83
5 changed files with 56 additions and 5 deletions
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
|
@ -1,4 +1,6 @@
|
||||||
{
|
{
|
||||||
|
"editor.fontFamily": "'Roboto Mono', 'Droid Sans Mono', 'monospace', monospace, 'Droid Sans Fallback'",
|
||||||
|
"editor.fontSize": 15,
|
||||||
"vim.insertModeKeyBindings": [
|
"vim.insertModeKeyBindings": [
|
||||||
{ "before": ["k", "j"], "after": ["<Esc>"] }
|
{ "before": ["k", "j"], "after": ["<Esc>"] }
|
||||||
]
|
]
|
||||||
|
|
|
@ -41,7 +41,9 @@
|
||||||
# };
|
# };
|
||||||
# };
|
# };
|
||||||
|
|
||||||
agda-mode = pkgs.vscode-utils.extensionFromVscodeMarketplace {
|
neovim = pkgs.neovim;
|
||||||
|
|
||||||
|
vscode-agda-mode = pkgs.vscode-utils.extensionFromVscodeMarketplace {
|
||||||
name = "agda-mode";
|
name = "agda-mode";
|
||||||
publisher = "banacorn";
|
publisher = "banacorn";
|
||||||
version = "0.2.19";
|
version = "0.2.19";
|
||||||
|
@ -50,7 +52,7 @@
|
||||||
combinedExtensionsDrv = pkgs.buildEnv {
|
combinedExtensionsDrv = pkgs.buildEnv {
|
||||||
name = "vscodium-extensions";
|
name = "vscodium-extensions";
|
||||||
paths = [
|
paths = [
|
||||||
agda-mode
|
vscode-agda-mode
|
||||||
pkgs.vscode-extensions.vscodevim.vim
|
pkgs.vscode-extensions.vscodevim.vim
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
@ -70,6 +72,7 @@
|
||||||
agda
|
agda
|
||||||
vscodium
|
vscodium
|
||||||
fix-whitespace
|
fix-whitespace
|
||||||
|
neovim
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
1
questions.txt
Normal file
1
questions.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
_<_ why is one constructor allowed to only have one
|
11
src/Homework2.agda
Normal file
11
src/Homework2.agda
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
open import Relation.Binary.PropositionalEquality
|
||||||
|
open ≡-Reasoning
|
||||||
|
open import Data.Nat
|
||||||
|
open import Data.Nat.Properties
|
||||||
|
|
||||||
|
module Homework2 where
|
||||||
|
|
||||||
|
data Bin : Set where
|
||||||
|
O : Bin
|
||||||
|
_I : Bin → Bin
|
||||||
|
_II : Bin → Bin
|
|
@ -891,10 +891,33 @@ Show multiplication distributes over addition, that is,
|
||||||
for all naturals `m`, `n`, and `p`.
|
for all naturals `m`, `n`, and `p`.
|
||||||
|
|
||||||
```
|
```
|
||||||
-- Your code goes here
|
|
||||||
*-distrib-+ : ∀ (m n p : ℕ) → (m + n) * p ≡ m * p + n * p
|
*-distrib-+ : ∀ (m n p : ℕ) → (m + n) * p ≡ m * p + n * p
|
||||||
*-distrib-+ zero n p = {! begin (zero + n) * p ≡ zero * p + n * p ∎ !}
|
*-distrib-+ zero n p =
|
||||||
*-distrib-+ (suc m) n p = {! !}
|
begin
|
||||||
|
(zero + n) * p
|
||||||
|
≡⟨ cong (_* p) (+-comm zero n) ⟩
|
||||||
|
(n + zero) * p
|
||||||
|
≡⟨ cong (_* p) (+-identityʳ n) ⟩
|
||||||
|
n * p
|
||||||
|
∎
|
||||||
|
*-distrib-+ (suc m) n p =
|
||||||
|
begin
|
||||||
|
(suc m + n) * p
|
||||||
|
≡⟨ cong (_* p) (+-comm (suc m) n) ⟩
|
||||||
|
(n + suc m) * p
|
||||||
|
≡⟨ cong (_* p) (+-suc n m) ⟩
|
||||||
|
suc (n + m) * p
|
||||||
|
≡⟨ cong (_* p) (cong suc (+-comm n m)) ⟩
|
||||||
|
suc (m + n) * p
|
||||||
|
≡⟨⟩
|
||||||
|
p + (m + n) * p
|
||||||
|
≡⟨ cong (p +_) (*-distrib-+ m n p) ⟩
|
||||||
|
p + (m * p + n * p)
|
||||||
|
≡⟨ sym (+-assoc p (m * p) (n * p)) ⟩
|
||||||
|
p + m * p + n * p
|
||||||
|
≡⟨⟩
|
||||||
|
suc m * p + n * p
|
||||||
|
∎
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@ -908,6 +931,17 @@ for all naturals `m`, `n`, and `p`.
|
||||||
|
|
||||||
```
|
```
|
||||||
-- Your code goes here
|
-- Your code goes here
|
||||||
|
*-assoc : ∀ (m n p : ℕ) → (m * n) * p ≡ m * (n * p)
|
||||||
|
*-assoc zero n p =
|
||||||
|
begin
|
||||||
|
(zero * n) * p
|
||||||
|
∎
|
||||||
|
*-assoc (suc m) n p =
|
||||||
|
begin
|
||||||
|
(suc m * n) * p
|
||||||
|
≡⟨ ⟩
|
||||||
|
|
||||||
|
∎
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue