On Using Scheme to Introduce Prolog - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

On Using Scheme to Introduce Prolog

Description:

... Scheme to Introduce Prolog. Daniel E. Stevenson and Michael R. Wick. Department of Computer Science. University of Wisconsin - Eau Claire. Eau Claire, WI 54701 ... – PowerPoint PPT presentation

Number of Views:58
Avg rating:3.0/5.0
Slides: 16
Provided by: csU69
Category:

less

Transcript and Presenter's Notes

Title: On Using Scheme to Introduce Prolog


1
On Using Scheme to Introduce Prolog
  • Daniel E. Stevenson and Michael R. Wick
  • Department of Computer Science
  • University of Wisconsin - Eau Claire
  • Eau Claire, WI 54701

2
Road Map
  • Motivation
  • Reductionist Approach
  • Scheme-to-Prolog Strategy
  • The Debate
  • Experiment Design
  • Results and Observations
  • Follow-up Experiment
  • Results and Observations
  • Future Work
  • Contact Information

3
Our Motivation
  • Want to give students a concrete strategy to move
    from a blank page to a working Prolog program
  • We follow a reductionist approach to teaching
    Programming Languages
  • Includes use of translational semantics
  • Scheme is our target language
  • Simple syntax
  • Level playing field
  • Expressive power

4
A Reductionist Approach to Programming Languages
  • Focus on language building blocks
  • What is a paradigm?
  • Collection of strategic decisions involving the
    blocks
  • What is a language?
  • Collection of tactical decisions involving the
    blocks
  • Our Implementation
  • Cover basic syntax description
  • Demonstrate building blocks in Scheme
  • Implement paradigms in Scheme
  • Assignments are in other languages

5
A Prolog/Scheme Correspondence (1)
append(,L,L). append(HT,L,HNewT) -
append(T,L,NewT).
(define (append L1 L2) (cond ((null? L1)
L2) (else (car L1)
(cdr L1)
,L,L
H
T
L
HNewT
append(T,L,NewT)
(cons ))))
L2
(append )
  • Many problems in Prolog are list-processing
    problems.
  • The concepts of list processing and recursive
    definitions are similar between Scheme and Prolog
  • Prologs pattern matching plays the role of car
    and cdr in Scheme
  • Prolog rules map to Scheme cond clause

6
A Prolog/Scheme Correspondence (2)
isMember(A, AL). isMember(A, XL) -
isMember(A, L).
(define (isMember A L) (cond ((null? L)
f) (car L)
(cdr L)
A
A, A
A
L
isMember(A, L)
((eq? A ) t)
A
(else (isMember? )))
  • Many problems in Prolog are predicate problems.
  • The concepts are again similar between Scheme and
    Prolog
  • Prologs pattern matching plays the role of car
    and cdr in Scheme
  • Prolog positive rules map to Scheme cond clauses
  • Scheme adds negative cond clauses

7
A Scheme-to-Prolog Strategy
  • To Translate a Scheme Program into a Prolog
    Program
  • Write the required behavior (predicate versus
    procedure) in Scheme
  • Define the corresponding Prolog relation. If the
    Scheme program is a predicate, use the same
    number of parameters in both versions.
    Otherwise, use one additional parameter in the
    Prolog version to represent the Scheme return
    value.
  • Translate each positive clause in the Scheme
    version to Prolog.
  • If a Scheme clause requires access to the car or
    the cdr of an input parameter, use the pattern
    HT in the head of the corresponding Prolog
    definition.
  • If a Scheme clause requires two values to be
    equal, use the same variable in Prolog for each
    corresponding occurrence of the two values in
    Scheme.
  • If a Scheme clause requires the results of other
    Scheme functions, use Prologs subgoaling to
    query and name the results of these functions.

8
The Debate
  • Does our Scheme-to-Prolog strategy help or hurt?
  • Do students waste too much time in Scheme and not
    enough time learning Prolog?
  • Given Schemes relationship to mathematics, is
    there any difference in learning between using
    purely mathematical recursive definitions and
    using recursive Scheme procedures?
  • Does the use of Scheme hurt students when it
    comes to learning the backtracking concepts of
    Prolog?
  • Two Hypotheses
  • Null Hypothesis I Our use of Scheme to introduce
    students to Prolog does not impact the students
    ability to learn early Prolog.
  • Null Hypothesis II Our use of Scheme to
    introduce students to Prolog does not impact the
    students ability to learn later Prolog.

9
Experiment Design (1)
  • A total of 44 students in our Programming
    Languages course
  • Students split into control and experiment groups
  • 22 students each
  • Same CS course background
  • Six students in each group had discrete including
    brief intro to Prolog
  • Exact same average CS GPA
  • Exact same average Overall GPA
  • Both groups given one-hour lecture on logic
    programming
  • Both groups given Prolog Tutorial from Bucknell
    University
  • Control given recursive definition strategy
  • Experiment given Scheme-to-Prolog strategy

10
Experiment Design (2)
  • Students given four one-hour sessions to answer
    10 questions
  • Positives(L1, L2). L2 are the positive numbers
    from L1.
  • Max(N, L). N is the maximum number in L.
  • Palindrome(L). L is a palindrome.
  • Prefix(P, L). P is a prefix of L.
  • Last(X, L). X is the last element of L.
  • Rem(X, L1, L2). L2 is L1 with all occurrences of
    X removed.
  • NextTo(X, Y, L). X and Y are consecutive
    elements of L.
  • Replace(N1,N2,L1,L2). L2 is L1 with every
    occurrence of N1 replaced by N2.
  • Parent(P, C). P is a parent of C.
  • Ancestor(A, C). A is an ancestor of C.
  • Students also given in-class exam at completion
    of logic programming section of course
    (emphasizing backtracking)

11
Results and Observations (1)
  • Number of Students Who Answered Each Question
    Correctly
  • Total Number of Questions Answered Correctly

12
Results and Observations (2)
  • Students Scores on In-Class Exam on Logic
    Programming

13
Follow-up Experiment
  • Not a warm fuzzy
  • Are we helping our students learn new languages
    at all?
  • Final Exam
  • Give students 10 questions to implement in a new
    language
  • Give students BNF, reference manual, and tutorial
    as resources
  • Pessimistic Experiment
  • Pick language/paradigm similar to known
    (Java/C)
  • Ruby object-oriented with familiar syntax
  • Should be least difference between control and
    experiment
  • Divide into control (students after CS 330) and
    experiment (students before CS 330)
  • Comparison between two different student bodies
  • Neither reported knowledge of Ruby
  • Control GPA 3.11
  • Experiment GPA 3.09

14
Results and Observations
  • Whew!

15
Future Work Contact Information
  • Modify pre/post exams to use Haskell, ML, Snobol,
  • Test on students with deeper exposure to Scheme
  • Question-by-question analysis of pre/post exams
  • Daniel Stevenson (stevende_at_uwec.edu)
  • Michael Wick (wickmr_at_uwec.edu)
  • Department of Computer Science
  • University of Wisconsin Eau Claire
  • Eau Claire, WI 54701
Write a Comment
User Comments (0)
About PowerShow.com