Successfully reported this slideshow.
Upcoming SlideShare
×

# Agda であそぼ

1,018 views

Published on

Published in: Technology, Education
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

### Agda であそぼ

1. 1. Agda @erutuf13
2. 2. data : Set where @erutuf13 : -> : -> Haskell Agda Coq : ->
3. 3. • AoPa(Algebra of Programming in Agda) ( )Agda( )
4. 4. Agda . . .multS : (m n : N) -> m + m * n == m * S nmultS O _ = eqreflmultS (S m) n = eqtrans (eqsuc (plusassoc m n (m * n))) (eqtrans (eqsuc (eqplus’ (m + n) (n + m) (m * n) (pluscomm m n))) (eqtrans (eqsuc (eqsym (plusassoc n m (m * n)))) (eqsuc (eqplus (m + m * n) (m * S n) n (multS m n)))))
5. 5. Agda . . .multS : (m n : N) -> m + m * n == m * S nmultS O _ = eqreflmultS (S m) n = eqtrans (eqsuc (plusassoc m n (m * n))) (eqtrans (eqsuc (eqplus’ (m + n) (n + m) (m * n) (pluscomm m n))) (eqtrans (eqsuc (eqsym (plusassoc n m (m * n)))) (eqsuc (eqplus (m + m * n) (m * S n) n (multS m n)))))
6. 6. eqtrans : {A : Set} {n m l : A} -> n == m -> m == l -> n == l Algebraic Reasoning !
7. 7. multS (S m) n = proof S m + S m * n ==[ eqrefl ] S (m + n + m * n) ==[ eqsuc (plusassoc m n (m * n)) ] S ((m + n) + m * n) ==[ eqsuc (eqplus’ (m + n) (n + m) (m * n) (pluscomm m n)) ] S ((n + m) + m * n) ==[ eqsuc (eqsym (plusassoc n m (m * n))) ] S (n + m + m * n) ==[ eqsuc (eqplus (m + m * n) (m * S n) n (multS m n)) ] S (n + m * S n) ==[ eqrefl ] S m * S n qed
8. 8. ==
9. 9. data _IsEqualTo_ A : Set (x y : A) : Set1 where relTo : (x=y : x == y) -> x IsEqualTo yproof_ : forall A : Set x y : A -> x IsEqualTo y -> x == yproof relTo x=y = x=y_==[_]_ : forall A : Set y z : A -> (x : A) -> x == y -> y IsEqualTo z -> x IsEqualTo z_ ==[ x=y ] relTo y=z = relTo (eqtrans x=y y=z)_qed : forall A : Set -> (x : A) -> x IsEqualTo x_qed _ = relTo eqrefl proof_ < _qed = _==[_]_
10. 10. Relation.Binary.PreorderReasoning
11. 11. ( )Algebra of Programming
12. 12. ••••
13. 13. (* - )isort-der : ∃(λf → ordered? ◦ permute ⊒ fun f)
14. 14. isort-der : ∃ (λf → ordered? permute ⊒ fun f )isort-der = ( , (⊒-begin ⊒ ⟨ -monotonic-r permute-is-fold ⟩ ordered? perm ⊒ ⟨ ⊒-reﬂ ⟩ ordered? foldR combine nil ⊒ ⟨ foldR-fusion-⊒ ordered? ins-step ins-base ⟩ foldR (fun (uncurry insert)) nil ⊒ ⟨ foldR-to-foldr insert [] ⟩ fun (foldr insert []) ⊒ ■))isort : List Val -> List Valisort = proj1 isort-der
15. 15. Algebra of Programming Algebra of Programming Style ( )isort AoPA (Algebra of Programming in Agda)