“Maar hoe moet het dan?”
Onderzoek naar feedback in interactieve leeromgevingen bij de Faculteit Informatica
Johan Jeuring
Met bijdragen van Alex Gerdes, Bastiaan Heeren, Josje Lodder, Harrie Passier, Sylvia Stuurman
Software technology for learning and teaching
The software technology group has worked on interactive learning environments since 2005:
I The logic tutor
I Feedback in mathematical learning environments I Ask-Elle: a programming tutor for Haskell
Main ideas behind
Ask-Elle
I A teacher specifies model solutions for an exercise, and possibly adapts the feedback
I Ask-Elle compares possibly partial student solutions against model solutions
I As long as a student follows a model solution, Ask-Elle can give hints
And what if a student makes an error, or takes a step that the tutor doesn’t recognize?
You have made a, possibly incorrect, step that does not follow the strategy.
And what if a student makes an error, or takes a step that the tutor doesn’t recognize?
You have made a, possibly incorrect, step that does not follow the strategy.
Our goals
I Increase the number of recognized good programs I Report more errors, as precisely as possible
Report more errors, as precisely as possible
I Specify the propertiesa solution should satisfy I Testthe properties using QuickCheck
I Express the properties a solution should satisfy as a contract
I Usecontract inferenceto infer contracts for user-defined functions
I Usecontract checkingto report property violations as precisely as possible
The problem
Write a function that sorts a list sort :: Ord a => [a] -> [a]
For example:
Data.List> sort [1,2,1,3,2,4] [1,1,2,2,3,4]
Sorting: a model solution
sort=foldr insert[ ]
insert x[ ] = [x] insert x(y:ys)|x6y =x:y:ys
An error in sorting
sort0 =foldr insert0[ ] insert0x[ ] = [x]
insert0x(y:ys)|x6y =y:x:ys
Sorting: a property
propSort xs=isNonDesc(sort0 xs)
isNonDesc(x:y:xs) =x6y∧isNonDesc(y:xs) isNonDesc =True
Running QuickCheck
main=doquickCheck propSort
*Main> main
*** Failed! Falsifiable (after ...): [0,1]
Running QuickCheck
main=doquickCheck propSort
*Main> main
*** Failed! Falsifiable (after ...): [0,1]
Contracts...
A contracted sort
sortc=assert
([true]_{zs|isNonDesc zs}) (λxs→sort0 xs)
Blaming
blameSort=sortch0i[0,1]
*** Exception: contract failed: the expression ‘sort’ is to blame.
Blaming
blameSort=sortch0i[0,1]
*** Exception: contract failed: the expression ‘sort’ is to blame. But where is the error?
A more precise location
To get a more precise location for the error: replace all functions in the definition of sort by their contracted counterparts.
A contracted
insert
insertc=assert
(true_{xs|isNonDesc xs}_{xs|isNonDesc xs}) (λx→λxs→insert0 x xs)
A contracted
foldr
foldrc ca cb=assert
((ca_cb_cb)_cb _[ca]_cb)
(λf →λe→λxs→
Blaming II
blameSort=sortch0i[0,1]
*** Exception: contract failed: the expression ‘insert’ is to blame.
But wait
I In the context of the tutor, we only know the contract for
sort
I A student can implementsort in many different ways I We want toinfer the contracts for the components of a
The inferring contracts problem:
Given
I A well-typed program
I A contract for the top-level function
range
Write a function which enumerates all numbers contained in a given range.
range::Int→Int→[Int] For example, range2 5gives
Some solutions for
range
range1x y=ifx ythen[x]elsex:range1(x+1)y range2x y=ify xthen[x]elsex:range2(x+1)y range3x y=ifx6 ythenx:range3(x+1)yelse[x] range4x y=ify6 xthenx:range4(x+1)yelse[x] range5x y=ifx6 ythenx:range5(1+x)yelse[x]
-- and the 3 variants
range6x =λy→ifx ythen[x]elsex:range6(x+1)y
-- and the 7 variants
range7 =λx→λy→ifx y
then[x]
A procedure for determining equality
I A procedure for determining whether or not two programs are equal is necessarily going to have some limitations I But surely each pair ofrange programs can pass the test I How can determine many of these equalities?
I What program transformations can I specify to steer this procedure?
I need a normal form!
I Remove syntactic sugar
I Normalization by Evaluation normalizes based on types, so a function of typea→b→calways has the form
λx→λy→...
I Normal forms for integer expressions, boolean expressions, string expressions, taking into account algebraic properties of the operators
I Inlining?
letduplicate x= [x,x]inconcatMap duplicate concatMap(λx→[x,x])
The functional programming normal form problem
I High-level: how can I determine equality of (functional) programs?
I What is a normal form of a program?
I What sequence of steps do I use for determining a normal form of a program?
I How can I influence the computation of a normal form of a program?
Conclusions
Interesting problems remain to be solved for Ask-Elle: I Inferring contracts
I Normal forms of programs More info:
I J.T.Jeuring@uu.nl I General information:
http://ideas.cs.uu.nl/ I Experiment on-line: