data ℕ : Set where
zero : ℕ
succ : ℕ → ℕ
data ⊥ : Set where
_+_ : ℕ → ℕ → ℕ
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
data _≡_ {X : Set} : X → X → Set where
refl : {a : X} → a ≡ a
{-# BUILTIN EQUALITY _≡_ #-}
infix 3 _∎
infixr 2 _≡⟨_⟩_ _≡⟨⟩_
infix 1 begin_
trans : {A : Set} {x y z : A} → x ≡ y → y ≡ z → x ≡ z
trans p q rewrite p = q
_≡⟨_⟩_ : {A : Set} {y z : A} → (x : A) → x ≡ y → y ≡ z → x ≡ z
x ≡⟨ p ⟩ q = trans p q
_≡⟨⟩_ : {A : Set} {y : A} → (x : A) → (q : x ≡ y) → x ≡ y
x ≡⟨⟩ q = q
_∎ : {A : Set} → (x : A) → x ≡ x
x ∎ = refl
begin_ : {A : Set} {x y : A} → x ≡ y → x ≡ y
begin p = p
cong : {A B : Set} {x y : A} → (f : A → B) → x ≡ y → f x ≡ f y
cong f refl = refl
symm : {A : Set} {x y : A} → x ≡ y → y ≡ x
symm refl = refl
equal→pwequal : {A B : Set} {f g : A → B} {x : A} → f ≡ g → f x ≡ g x
equal→pwequal p rewrite p = refl
lemma-pred-succ : (a : ℕ) → pred (succ a) ≡ a
lemma-pred-succ a = {!!}
lemma-succ-pred : ((a : ℕ) → succ (pred a) ≡ a) → ⊥
lemma-succ-pred f = {!!}
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 b) 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 (cong succ (lemma-+-commutative a b)) (symm (lemma-+-succ b 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 zero b c = refl
lemma-·-distributive (succ a) b c = begin
((succ a + b) · c) ≡⟨⟩
(succ (a + b) · c) ≡⟨⟩
c + ((a + b) · c) ≡⟨ cong (_+_ c) (lemma-·-distributive a b c) ⟩
c + ((a · c) + (b · c)) ≡⟨ lemma-+-associative c (a · c) (b · c) ⟩
(c + (a · c)) + (b · c) ≡⟨⟩
(succ a · c) + (b · c) ∎
data Even : ℕ → Set where
base-even : Even zero
step-even : {n : ℕ} → Even n → Even (succ (succ n))
transport : {A : Set} {x y : A} → (F : A → Set) → x ≡ y → F x → F y
transport F refl s = s
lemma-double-even : (a : ℕ) → Even (a + a)
lemma-double-even zero = base-even
lemma-double-even (succ b) rewrite lemma-+-succ b b = step-even (lemma-double-even b)
data List (A : Set) : Set where
[] : List A
_∷_ : A → List A → List A
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 [] = refl
lemma-reverse-reverse (x ∷ xs) =
trans (lemma-reverse-∷ʳ (reverse xs) x)
(cong (λ zs → x ∷ zs) (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)
≡→≈ : {xs ys : List A} → xs ≡ ys → xs ≈ ys
≡→≈ p = {!!}
≈→≡ : {xs ys : List A} → xs ≈ ys → xs ≡ ys
≈→≡ p = {!!}
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 = {!!}
data _⊎_ (A B : Set) : Set where
left : A → A ⊎ B
right : B → A ⊎ B
_≢_ : {A : Set} → A → A → Set
x ≢ y = ((x ≡ y) → ⊥)
theorem : zero ≢ succ zero
theorem ()
module _ {A : Set} (cmp : (x : A) → (y : A) → (x ≡ y) ⊎ (x ≢ y)) where
delete : A → List A → List A
delete x [] = []
delete x (y ∷ ys) with cmp x y
... | left p = delete x ys
... | right p = y ∷ delete x ys
count-number-of-occurences : A → List A → ℕ
count-number-of-occurences x ys = {!!}