110 likes | 231 Vues
This case study delves into functional programming languages like Scheme, Haskell, F#, and ML, as well as logic programming languages like Prolog. We discuss the inception of Scheme at MIT, its unique syntax for definitions, arithmetic, and display functions. Additionally, we explore Prolog’s role in natural language processing and theorem proving, highlighting its characteristics including facts, rules, and queries. By comparing these paradigms, we emphasize their applications and significance in modern computing.
E N D
Case Study Functional Programming Languages Logic Programming Languages
Functional Languages • There are many functional languages. • Scheme • Haskell • F# • ML • Lisp • Others
Scheme • Scheme was developed at the MIT AI Lab by Guy L. Steele and Gerald Jay Sussman who introduced it to the academic world via a series of memos • Defining Variable: (define a 10) (+ a 2)
Scheme • Printing : (display "Hello world") • To put new line: (newline) • Arithmetic Expression: (+ 4 6 7)
Scheme • Assignment Statement: (define b 10) (* b 2) (set! b 30)
Scheme (define (greet) (display "Hello, world!") (newline) ) (let ((x 1) (y 2)) (+ x y))
Logic Language • Prolog • Developed at Univ. of Aix-Marseille and Edinburgh in early to mid 1970s • Goal: natural language processing and theorem proving. • Used in Japan’s Fifth Generation Computing Project in 1981
Prolog • Prolog Syntax • Variables are uppercase • constants, predicates are lowercase • List syntax: • [1, 2, 3] • [head | tail] • Program consists of • facts, rules, and goals
Prolog • Facts female(shelley). male(bill). female(mary). male(jake). father(bill, jake). father(bill, shelley). mother(mary, jake). mother(mary, shelley).
Prolog • Rules parent(X, Y) :- mother(X, Y). parent(X, Y) :- father(X, Y). grandparent(X, Z) :- parent(X, Y), parent(Y, Z). sibling(X, Y) :- mother(M, X), mother(M, Y), father(F, X), father(F, Y). ancestor(X, X). ancestor(X, Y) :- parent(X, Z), ancestor(Z, Y)
Prolog • Queries ?- father(bill, jake). yes ?- father(X, jake). X = bill yes ?- father(bill, X). X = jake ; X = shelley yes