Functional Programming Functional Programming and Theorem Proving and Theorem Proving for Undergraduates for Undergraduates A Progress Report A Progress Report Carl Carl Eastlund Eastlund and Matthias and Matthias Felleisen Felleisen Northeastern University Northeastern University Rex Page Rex Page University of Oklahoma University of Oklahoma Functional Programming and Theorem Proving for Undergraduates 1 1 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
History History � Before 2003 � Traditional SE at OU (2-course sequence, 4 th yr) � Process Design Testing/Validation 60% 20% 20% � � 2003-2005 � SE course using ACL2 (FDPE 2005 report) � Process Design Testing/Validation 30% 35% 35% � � Successful despite crude programming env � 2006 - present � SE course with Dracula/ACL2 environment � 1 st year course at NU using Dracula/ACL2 Functional Programming and Theorem Proving for Undergraduates 2 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
Mantra Mantra Engineering is the application of � Before 2003 principles of science and mathematics � Traditional SE at OU (2-course sequence, 4 th yr) � Process Design Testing/Validation to the design of useful things 60% 20% 20% � � 2003-2005 � SE course using ACL2 (FDPE 2005 report) � Process Design Testing/Validation 30% 35% 35% � � Successful despite crude programming env � 2006 - present � SE course with Dracula/ACL2 environment � 1 st year course at NU using Dracula/ACL2 Functional Programming and Theorem Proving for Undergraduates 3 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
ACL2 ;; sqr : Int -> Int (defun sqr (x) (* x x)) ;; All squares are nonnegative. (defthm sqr>=0 (implies (integerp x) (>= (sqr x) 0))) Functional Programming and Theorem Proving for Undergraduates 4 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
ACL2 Functional Programming & Theorem Proving for Undergrads - FDPE 2008 5 Rex Page / Carl Eastlund / Matthias Felleisen
ACL2 Functional Programming & Theorem Proving for Undergrads - FDPE 2008 6 Rex Page / Carl Eastlund / Matthias Felleisen
ACL2 Functional Programming & Theorem Proving for Undergrads - FDPE 2008 7 Rex Page / Carl Eastlund / Matthias Felleisen
Dracula Functional Programming and Theorem Proving for Undergraduates 8 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
Dracula Functional Programming and Theorem Proving for Undergraduates 9 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
Dracula Functional Programming and Theorem Proving for Undergraduates 10 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
Dracula Functional Programming and Theorem Proving for Undergraduates 11 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
Dracula Functional Programming and Theorem Proving for Undergraduates 12 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
Dracula Functional Programming and Theorem Proving for Undergraduates 13 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
Dracula Functional Programming and Theorem Proving for Undergraduates 14 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
Dracula Functional Programming and Theorem Proving for Undergraduates 15 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
Dracula Functional Programming and Theorem Proving for Undergraduates 16 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
Dracula Functional Programming and Theorem Proving for Undergraduates 17 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
Dracula ;; sqr : Int -> Int (defun sqr (x) (* x x)) ;; All squares are nonnegative. (defthm sqr>=0 (implies (integerp x) (>= (sqr x) 0))) Functional Programming and Theorem Proving for Undergraduates 18 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
Dracula ;; sqr : Int -> Int (defun sqr (x) x) ;; All squares are nonnegative. (defthm sqr>=0 (implies (integerp x) (>= (sqr x) 0))) Functional Programming and Theorem Proving for Undergraduates 19 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
Dracula Functional Programming and Theorem Proving for Undergraduates 20 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
Program Design � How to Design Programs code: ;; sqr : Int -> Int (define (sqr x) (* x x)) ;; Unit tests: (check-expect (sqr 0) 0) (check-expect (sqr 2) 4) Functional Programming and Theorem Proving for Undergraduates 21 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
Program Design � Dracula code: Dracula code: ;; sqr : Int -> Int (defun sqr (x) (* x x)) ;; Unit tests: (check-expect (sqr 0) 0) (check-expect (sqr 2) 4) Functional Programming and Theorem Proving for Undergraduates 22 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
Unit Tests � Dracula code: Dracula code: ;; sqr : Int -> Int (defun sqr (x) (* x x)) ;; Unit tests: (==> assert-event) (check-expect (sqr 0) 0) (check-expect (sqr 2) 4) Functional Programming and Theorem Proving for Undergraduates 23 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
Unit Tests Functional Programming and Theorem Proving for Undergraduates 24 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
Unit Tests Functional Programming and Theorem Proving for Undergraduates 25 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
Beyond Unit Tests ;; sqr : Int -> Int (defun sqr (x) (+ x x)) ;; Unit tests: (check-expect (sqr 0) 0) (check-expect (sqr 2) 4) Functional Programming and Theorem Proving for Undergraduates 26 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
Beyond Unit Tests Functional Programming and Theorem Proving for Undergraduates 27 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
DoubleCheck ;; ACL2 theorem: (defthm name (implies (and precondition ... ) postcondition ))) ;; DoubleCheck property: (defproperty name ( x [:where precondition] [:value distribution] ... ) postcondition ) Functional Programming and Theorem Proving for Undergraduates 28 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
DoubleCheck ;; ACL2 theorem: (defthm sqr>=0 (implies (integerp x) (>= (sqr x) 0))) ;; DoubleCheck property: (defproperty sqr>=0 (x) (implies (integerp x) (>= (sqr x) 0))) Functional Programming and Theorem Proving for Undergraduates 29 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
DoubleCheck ;; ACL2 theorem: (defthm sqr>=0 (implies (integerp x) (>= (sqr x) 0))) ;; DoubleCheck property: (defproperty sqr>=0 (x :where (integerp x)) (>= (sqr x) 0)) Functional Programming and Theorem Proving for Undergraduates 30 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
DoubleCheck ;; ACL2 theorem: (defthm sqr>=0 (implies (integerp x) (>= (sqr x) 0))) ;; DoubleCheck property: (defproperty sqr>=0 (x :where (integerp x) :value (random-integer)) (>= (sqr x) 0)) Functional Programming and Theorem Proving for Undergraduates 31 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
DoubleCheck ;; Simple distributions: (random-string) (random-integer) ;; Parameterized distributions: (random-between low high ) (random-list-of dist [:size size] ) ;; Write new distributions: (defrandom name ( arg ... ) expr ) Functional Programming and Theorem Proving for Undergraduates 32 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
DoubleCheck ;; ACL2 theorem: (defthm sqr>=0 (implies (integerp x) (>= (sqr x) 0))) ;; DoubleCheck property:(==> defthm) (defproperty sqr>=0 (x :where (integerp x) :value (random-integer)) (>= (sqr x) 0)) Functional Programming and Theorem Proving for Undergraduates 33 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
DoubleCheck ;; ACL2 theorem: (defthm sqr>=0 (implies (integerp x) (>= (sqr x) 0))) ;; Ideal syntax (future work): (defproperty sqr>=0 (implies (integerp x) (>= (sqr x) 0))) Functional Programming and Theorem Proving for Undergraduates 34 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
DoubleCheck Functional Programming and Theorem Proving for Undergraduates 35 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
DoubleCheck Functional Programming and Theorem Proving for Undergraduates 36 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
DoubleCheck Functional Programming and Theorem Proving for Undergraduates 37 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
DoubleCheck ;; sqr : Int -> Int (defun sqr (x) (+ x x)) ;; Unit tests: (check-expect (sqr 0) 0) (check-expect (sqr 2) 4) (check-expect (sqr -30) 900) Functional Programming and Theorem Proving for Undergraduates 38 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
DoubleCheck ;; sqr : Int -> Int (defun sqr (x) (* x x)) ;; Unit tests: (check-expect (sqr 0) 0) (check-expect (sqr 2) 4) (check-expect (sqr -30) 900) Functional Programming and Theorem Proving for Undergraduates 39 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
DoubleCheck Functional Programming and Theorem Proving for Undergraduates 40 FDPE 2008 - Rex Page / Carl Eastlund / Matthias Felleisen
Recommend
More recommend