{-# OPTIONS --allow-unsolved-metas #-}
open import Padova2024.EquationalReasoning
data Bool : Set where
false : Bool
true : Bool
data ℕ : Set where
zero : ℕ
succ : ℕ → ℕ
data ⊥ : Set where
¬ : Set → Set
¬ X = X → ⊥
! : Bool → Bool
! false = true
! true = false
_+_ : ℕ → ℕ → ℕ
zero + b = b
succ a + b = succ (a + b)
_·_ : ℕ → ℕ → ℕ
zero · b = zero
succ a · b = b + (a · b)
pred : ℕ → ℕ
pred zero = zero
pred (succ a) = a
equal→pwequal : {A B : Set} {f g : A → B} {x : A} → f ≡ g → f x ≡ g x
equal→pwequal p = {!!}
transport : {A : Set} {x y : A} → (F : A → Set) → x ≡ y → F x → F y
transport F refl s = s
lemma-pred-succ : (a : ℕ) → pred (succ a) ≡ a
lemma-pred-succ a = {!!}
even? : ℕ → Bool
even? zero = true
even? (succ n) = ! (even? n)
even?' : ℕ → Bool
even?' zero = true
even?' (succ zero) = false
even?' (succ (succ n)) = even?' n
lemma-even?-even?' : (a : ℕ) → even? a ≡ even?' a
lemma-even?-even?' a = {!!}
lemma-succ-pred : ((a : ℕ) → succ (pred a) ≡ a) → ⊥
lemma-succ-pred f = go (f zero)
where
go : succ zero ≡ zero → ⊥
go ()
lemma-succ-pred'' : ((a : ℕ) → succ (pred a) ≡ a) → ⊥
lemma-succ-pred'' f with f zero
... | ()
module _ (weird-assumption : (a : ℕ) → succ (pred a) ≡ a) where
lemma-succ-pred''' : ⊥
lemma-succ-pred''' with weird-assumption zero
... | ()
module _ (n : ℕ) (X : Set) (f : X → X) where
data Positive : ℕ → Set where
succs-are-positive : {n : ℕ} → Positive (succ n)
lemma-succ-pred' : (a : ℕ) → Positive a → succ (pred a) ≡ a
lemma-succ-pred' (succ a) p = refl
lemma-+-zero : (a : ℕ) → (a + zero) ≡ a
lemma-+-zero zero = refl
lemma-+-zero (succ a) = cong succ (lemma-+-zero a)
lemma-+-succ : (a b : ℕ) → (a + succ b) ≡ succ (a + b)
lemma-+-succ zero b = refl
lemma-+-succ (succ a) b = cong succ (lemma-+-succ a b)
lemma-+-commutative : (a b : ℕ) → (a + b) ≡ (b + a)
lemma-+-commutative zero b = symm (lemma-+-zero b)
lemma-+-commutative (succ a) b =
trans (symm (lemma-+-succ a b))
(trans (lemma-+-commutative a (succ b)) (symm (lemma-+-succ b a)))
lemma-+-commutative' : (a b : ℕ) → (a + b) ≡ (b + a)
lemma-+-commutative' zero b = symm (lemma-+-zero b)
lemma-+-commutative' (succ a) b = begin
succ a + b ≡⟨⟩
succ (a + b) ≡⟨ cong succ (lemma-+-commutative' a b) ⟩
succ (b + a) ≡⟨ symm (lemma-+-succ b a) ⟩
b + succ a ∎
lemma-+-associative : (a b c : ℕ) → (a + (b + c)) ≡ ((a + b) + c)
lemma-+-associative a b c = {!!}
lemma-distributive : (a b c : ℕ) → ((a + b) · c) ≡ ((a · c) + (b · c))
lemma-distributive a b c = {!!}
data Even : ℕ → Set where
base-even : Even zero
step-even : {n : ℕ} → Even n → Even (succ (succ n))
lemma-double-even : (a : ℕ) → Even (a + a)
lemma-double-even a = {!!}
data List (A : Set) : Set where
[] : List A
_∷_ : A → List A → List A
exampleList : List ℕ
exampleList = zero ∷ (succ (succ zero) ∷ (zero ∷ []))
module _ {A : Set} where
_∷ʳ_ : List A → A → List A
[] ∷ʳ y = y ∷ []
(x ∷ xs) ∷ʳ y = x ∷ (xs ∷ʳ y)
reverse : List A → List A
reverse [] = []
reverse (x ∷ xs) = reverse xs ∷ʳ x
lemma-reverse-∷ʳ : (ys : List A) (x : A) → reverse (ys ∷ʳ x) ≡ (x ∷ reverse ys)
lemma-reverse-∷ʳ ys x = {!!}
lemma-reverse-reverse : (xs : List A) → reverse (reverse xs) ≡ xs
lemma-reverse-reverse xs = {!!}
_++_ : List A → List A → List A
[] ++ ys = ys
(x ∷ xs) ++ ys = x ∷ (xs ++ ys)
data _≈_ : List A → List A → Set where
both-empty : [] ≈ []
both-same-cons : {xs ys : List A} {x y : A} → x ≡ y → xs ≈ ys → (x ∷ xs) ≈ (y ∷ ys)
≈-refl : (xs : List A) → xs ≈ xs
≈-refl [] = both-empty
≈-refl (x ∷ xs) = both-same-cons refl (≈-refl xs)
≡→≈ : {xs ys : List A} → xs ≡ ys → xs ≈ ys
≡→≈ refl = ≈-refl _
≈→≡ : {xs ys : List A} → xs ≈ ys → xs ≡ ys
≈→≡ both-empty = refl
≈→≡ (both-same-cons refl ps) = cong (_ ∷_) (≈→≡ ps)
≈→≡' : {xs ys : List A} → xs ≈ ys → xs ≡ ys
≈→≡' {[]} {[]} both-empty = refl
≈→≡' {x ∷ xs} {x ∷ ys} (both-same-cons refl ps) = cong (x ∷_) (≈→≡' ps)
data Vector (A : Set) : ℕ → Set where
[] : Vector A zero
_∷_ : {n : ℕ} → A → Vector A n → Vector A (succ n)
drop : {A : Set} {n : ℕ} (k : ℕ) → Vector A (k + n) → Vector A n
drop zero xs = xs
drop (succ k') (x ∷ xs') = drop k' xs'
take : {A : Set} {n : ℕ} (k : ℕ) → Vector A (k + n) → Vector A k
take zero xs = []
take (succ k') (x ∷ xs') = x ∷ take k' xs'
_++ᵥ_ : {A : Set} {n m : ℕ} → Vector A n → Vector A m → Vector A (n + m)
[] ++ᵥ ys = ys
(x ∷ xs') ++ᵥ ys = x ∷ (xs' ++ᵥ ys)
lemma-take-drop : {A : Set} {n : ℕ} → (k : ℕ) → (xs : Vector A (k + n)) → (take k xs ++ᵥ drop k xs) ≡ xs
lemma-take-drop = {!!}
eq? : ℕ → ℕ → Bool
eq? zero zero = true
eq? zero (succ y) = false
eq? (succ x) zero = false
eq? (succ x) (succ y) = eq? x y
lemma₁ : (x y : ℕ) → eq? x y ≡ true → x ≡ y
lemma₁ zero zero p = refl
lemma₁ (succ x) (succ y) p = cong succ (lemma₁ x y p)
lemma₂ : (x y : ℕ) → x ≡ y → eq? x y ≡ true
lemma₂ = {!!}
data _⊎_ (A B : Set) : Set where
left : A → A ⊎ B
right : B → A ⊎ B
dec : (x y : ℕ) → (x ≡ y) ⊎ (¬ (x ≡ y))
dec zero zero = left refl
dec zero (succ y) = right {!!}
dec (succ x) zero = right {!!}
dec (succ x) (succ y) with dec x y
... | left p = left (cong succ p)
... | right p = right {!!}