Using Strategies for Assessment of Functional Programming Exercises

Similar documents
Using Strategies for Assessment of Programming Exercises

Projects and technical details

Shell CSCE 314 TAMU. Higher Order Functions

CSCE 314 Programming Languages

CITS3211 FUNCTIONAL PROGRAMMING

Topic 5: Higher Order Functions

Topic 5: Higher Order Functions

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages. Lambda calculus

Talen en Compilers. Jurriaan Hage , period 2. November 13, Department of Information and Computing Sciences Utrecht University

Abstract register machines Lecture 23 Tuesday, April 19, 2016

Generic Programming for Domain Reasoners

5. Introduction to the Lambda Calculus. Oscar Nierstrasz

Project Compiler. CS031 TA Help Session November 28, 2011

Exam Datastrukturer. DIT960 / DIT961, VT-18 Göteborgs Universitet, CSE

λ calculus is inconsistent

Exercise 1 ( = 24 points)

Introduction to the Lambda Calculus

CS 4110 Programming Languages & Logics. Lecture 27 Recursive Types

Last class. CS Principles of Programming Languages. Introduction. Outline

CS 4110 Programming Languages & Logics. Lecture 28 Recursive Types

Pure Lambda Calculus. Lecture 17

Lecture 5: Lazy Evaluation and Infinite Data Structures

Fundamentals and lambda calculus. Deian Stefan (adopted from my & Edward Yang s CSE242 slides)

11/6/17. Outline. FP Foundations, Scheme. Imperative Languages. Functional Programming. Mathematical Foundations. Mathematical Foundations

CMSC330 Fall 2016 Midterm #2 2:00pm/3:30pm

A Quick Overview. CAS 701 Class Presentation 18 November Department of Computing & Software McMaster University. Church s Lambda Calculus

Exercise 1 ( = 18 points)

> module Lambda where > import Data.List -- I need some standard list functions

Fundamentals and lambda calculus

CS 4110 Programming Languages & Logics. Lecture 17 Programming in the λ-calculus

Explicit Recursion in Generic Haskell

n Closed book n You are allowed 5 cheat pages n Practice problems available in Course Materials n Check grades in Rainbow grades

Recursive Definitions, Fixed Points and the Combinator

1 Scope, Bound and Free Occurrences, Closed Terms

Types and Programming Languages. Lecture 5. Extensions of simple types

Exercise 1 (2+2+2 points)

CS 6110 S14 Lecture 1 Introduction 24 January 2014

CMSC 330: Organization of Programming Languages. Lambda Calculus

COMP 4161 NICTA Advanced Course. Advanced Topics in Software Verification. Toby Murray, June Andronick, Gerwin Klein

One of a number of approaches to a mathematical challenge at the time (1930): Constructibility

Lecture 4: Higher Order Functions

Introduction to Lambda Calculus. Lecture 7 CS /08/09

CSCE 314 TAMU Fall CSCE 314: Programming Languages Dr. Flemming Andersen. Haskell Basics

CSCI B522 Lecture 11 Naming and Scope 8 Oct, 2009

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages

Introduction to Lambda Calculus. Lecture 5 CS 565 1/24/08

Haske k ll An introduction to Functional functional programming using Haskell Purely Lazy Example: QuickSort in Java Example: QuickSort in Haskell

ECE264 Fall 2013 Exam 1, September 24, 2013

Program Calculus Calculational Programming

Continuation Passing Style. Continuation Passing Style

CS 209 Functional Programming

Structural polymorphism in Generic Haskell

Constraint-based Analysis. Harry Xu CS 253/INF 212 Spring 2013

An introduction introduction to functional functional programming programming using usin Haskell

Concepts of programming languages

SEMANTIC ANALYSIS TYPES AND DECLARATIONS

Topic 6: Partial Application, Function Composition and Type Classes

Topic 6: Partial Application, Function Composition and Type Classes

Functional Programming

CMSC 330: Organization of Programming Languages

Programming Language Concepts: Lecture 19

CMSC 330: Organization of Programming Languages. Lambda Calculus

Problem 1. Remove consecutive duplicates (6 points, 11 mintues)

Type Systems Winter Semester 2006

Lecture 9: More Lambda Calculus / Types

- M ::= v (M M) λv. M - Impure versions add constants, but not necessary! - Turing-complete. - true = λ u. λ v. u. - false = λ u. λ v.

Contract Inference for the Ask-Elle Programming Tutor

CSE 3302 Programming Languages Lecture 8: Functional Programming

Programming Language Features. CMSC 330: Organization of Programming Languages. Turing Completeness. Turing Machine.

CMSC 330: Organization of Programming Languages

Computational Linguistics: Syntax-Semantics

CMSC330. Objects, Functional Programming, and lambda calculus

Basic Foundations of Isabelle/HOL

Exercise 1 ( = 22 points)

Introduction to lambda calculus Part 3

Polymorphic Contexts FP-Dag 2015

Optimising Functional Programming Languages. Max Bolingbroke, Cambridge University CPRG Lectures 2010

Type-indexed functions in Generic Haskell

Simply-Typed Lambda Calculus

INFOB3TC Solutions for the Exam

CSCC24 Functional Programming Scheme Part 2

Lambda expressions, functions and binding

Solutions and grading standards

Foundations. Yu Zhang. Acknowledgement: modified from Stanford CS242

Programming Languages Lecture 14: Sum, Product, Recursive Types

Lambda Calculus. Variables and Functions. cs3723 1

CMSC 330: Organization of Programming Languages

CIS 500 Software Foundations Fall September 25

Lambda Calculus. Concepts in Programming Languages Recitation 6:

Homework. Lecture 7: Parsers & Lambda Calculus. Rewrite Grammar. Problems

CSCE 314 Programming Languages

Introduction to Denotational Semantics. Brutus Is An Honorable Man. Class Likes/Dislikes Survey. Dueling Semantics

Accurate Step Counting

The Arrow Calculus (Functional Pearl)

CMSC330 Spring 2017 Midterm 2

Programming Languages 3. Definition and Proof by Induction

PRINCIPLES OF COMPILER DESIGN UNIT I INTRODUCTION TO COMPILERS

Programming Languages Fall Prof. Liang Huang

G Programming Languages - Fall 2012

INFOB3TC Solutions for Exam 1

Transcription:

Using Strategies for Assessment of Functional Programming Exercises Ir. Alex Gerdes Joint work with prof. dr. Johan Jeuring and dr. Bastiaan Heeren Open Universiteit Nederland School of Computer Science 21 November 2009

Assessment of programming exercises Every year, thousands of computer science students learn to program It is important to assess the students abilities and to provide timely feedback Traditionally, a teacher assesses programming exercises Assessing is tedious, time consuming, and error prone work Many assessment tools have been developed to assist teachers Most tools are based on testing

Disadvantages of test-based assessment Test-based assessment tools try to determine correctness by comparing the output of a student program to the expected results. Test-based assessment has a number of disadvantages: 1. Coverage: how do you know you have tested enough? 2. Testing is a dynamic process and therefore vulnerable to bugs 3. Inability to assess design features, such as good programming practices 4. Testing cannot reveal which algorithm has been used

Example A small exercise, typical for learning how to program in Haskell, is to write a function that converts a list of binary numbers to its decimal representation: frombin [1, 0, 1, 0, 1, 0] 42 The following definition that implements this function: frombin :: [Int] Int frombin = frombin 2 frombin n [ ] = 0 frombin n (x : xs) = x n (length (x : xs) 1) + frombin n xs

Example Test-based assessment tools will most likely accept the solution. However, it contains a number of imperfections: The length calculation is inefficient It takes time quadratic in the size of the input list Argument n is constant and should be abstracted We found these imperfections frequently in a set of student solutions. frombin :: [Int] Int frombin = frombin 2 frombin n [ ] = 0 frombin n (x : xs) = x n (length (x : xs) 1) + frombin n xs

Our solution (1/2) We propose to use strategies in combination with program transformations based on the λ-calculus, to assess programming exercises A programming strategy is derived from a set of model solutions We generate a set of equivalent solutions based on a programming strategy Strategies do not generate all equivalent solutions We increase the number of accepted correct solutions by normalisation After normalisation, we compare solutions syntactically

Our solution (2/2) We assess the following features: Correctness Design Our approach has the following advantages: If a program is determined to be equivalent, it is guaranteed to be correct We can recognise and report imperfections We can determine which algorithm has been implemented Strategy-based assessment is carried out statically. A disadvantage of our approach is that we cannot prove a student to be incorrect.

Example assessment We applied our tool to student solutions from a lab assignment in a first-year FP-course at Utrecht University In total we received 94 student solutions We were not involved in any aspect of the assignment The students had to implement the frombin function.

Model solutions (1/2) There are a number of model solutions, which differ quite a bit from one another. All of them use recommended programming techniques: frombin = foldl ((+) (2 )) 0 frombin xs = frombin (length xs 1) xs where frombin [ ] = 0 frombin l (x : xs) = x 2 l + frombin (l 1) xs frombin = sum zipwith ( ) (iterate ( 2) 1) reverse

Model solutions (2/2) The last model solution we consider is simple, but inefficient: frombin [ ] = 0 frombin (x : xs) = x 2 length xs + frombin xs The length of the list is calculated in each recursive call. A teacher can: Accept or reject this solution Turn the model solution into a buggy strategy and report to the student why their solution is rejected

Example We can recognise many different equivalent solutions from a model solution. For example, the following student solution: frombin = frombasen 2 frombasen b n = frombasen b (reverse n) where frombasen [ ] = 0 frombasen b (c : cs) = c + b (frombasen b cs) is recognised from this model solution: frombin = foldl ((+) (2 )) 0

Categories We have partitioned the set of student programs into four categories by hand: Good. A proper solution with respect to the features Modified. Some students have augmented their solution with sanity checks. We have removed the checks by hand Imperfect. An imperfect program is a program that is rejected because we want to report the imperfection Incorrect. A few student programs were incorrect

Results 72 programs fall into the good and modified (9) categories; our assessment tool recognises 64 programs (89%) The acceptance rate can be increased by adding more model solutions All of the incorrect and imperfect programs were rejected Some programs that were rejected with reason had gotten full grades from the assistant We can tell which model solution a student has used: 18 students used the foldl model solution 2 used tupling 2 the inner product solution 40 solutions were based on explicit recursion

Details of our approach

Strategies A strategy is a well-defined plan for solving a particular problem A programming strategy is implemented as a context-free grammar with refinement rules as symbols We have developed a library with an embedded domain-specific language for specifying strategies Strategies can also be used to detect common mistakes. These are called buggy strategies Programming strategies can be automatically derived from model solutions

Standard strategies We have defined a set of standard programming strategies Standard strategies generate many syntactically different solutions from a single model solution The automatically derived programming strategies are defined in terms of these standard strategies. For example, using the strategy for function composition: f g = λx f (g x) We can recognise both composition itself, and its definition: frombin = foldl ((+) (2 )) 0 frombin = foldl (λx y 2 x + y) 0

Program transformations Strategies from model solutions are rather strict and may reject equivalent but only slightly different programs Some of these differences cannot or should not be captured in a strategy, such as inlining a helper-function We use program transformations, which are based on the λ-calculus, to ignore such differences We use η- and β-reduction, and α-conversion Additionally, we perform preprocessing rewrite steps such as inlining In general, comparing two lambda terms for equality is undecidable. However, we did not encounter any problems

Future work Use programming strategies to generate semantically rich feedback. However, program transformations complicate this generation. We want to investigate how we can alleviate this problem Investigate how well our approach works for developing programs in programming languages like Java or C++ Investigate how we can extend our approach with testing, property checking, or static contract checking

Epilogue Strategies can be successfully used for programming exercise assessment We can guarantee a student solution to be equivalent to a model solution We are able to recognise many different student programs from a limited set of model solutions Using only 4 model solutions we managed to recognise and characterise 89% of the correct solutions Information about our research: http://ideas.cs.uu.nl E-mail: alex.gerdes@ou.nl