29 Pages

scheme1

Course: CS 5541, Fall 2008
School: Minnesota
Rating:
 
 
 
 
 

Word Count: 1151

Document Preview

A Scheme: "Small" Variant of Lisp Basics Why Lisp? Learning lisp in the study of AI is like learning French if you are going to France (Charniak & McDermot) Interpreted language Prefix operator notation, with parentheses Functional style Overview Dr Scheme Characters, Atoms & Strings Functions: Math & predicates Constants: Quoting More functions: List...

Register Now

Unformatted Document Excerpt

Coursehero >> Minnesota >> Minnesota >> CS 5541

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
A Scheme: "Small" Variant of Lisp Basics Why Lisp? Learning lisp in the study of AI is like learning French if you are going to France (Charniak & McDermot) Interpreted language Prefix operator notation, with parentheses Functional style Overview Dr Scheme Characters, Atoms & Strings Functions: Math & predicates Constants: Quoting More functions: List construction Defining variables Flow of control Defining functions Dr. Scheme See web site for downloads Has different language levels: "Language" "Choose Language" "Full Scheme" Two windows Top: program editing ("definitions") window Define functions, variables, comments Bottom: interactive evaluation window: interpreted Evaluate functions, test code Characters, Atoms & Strings Characters are: A...Z, a...z, 0...9, ! % $ * + - / = ? Atom String of one or more characters with no spaces between; Examples: 123, 1xyz, fred (aka: symbol) #\ used for character constants E.g., #\A Special characters: #\newline #t, #f (true, false) Upper/lower case only distinguished in constants Strings Double quoted sequences of characters "this is a string" Math Form of function application is prefix Syntax: operator value1 value2 Expressions are parenthesized, e.g., (+ 1 2) Math operators: + - / *; other examples: Other examples: abs, sqrt, modulo, remainder Nested expressions often used: (abs (* (- 2 3) (- 0 1))) "Interactions" window > (+ 3 4) 7 > > (+ (- 6 3) 10) WARNING: Interactions window is out of sync with the definitions window. Click Execute. 13 Notation: (+ (- 6 3) 10) 13 Predicates: Functions returning boolean values Often named ending with "?" Built-in predicate examples equal? test for equality (works with lists) boolean? test for boolean type object integer? test for integer type object string=? test if two strings are equal (equal? 10 3) #f (equal? 4 4) #t (boolean? #f) #t (integer? 5) #t (string=? "abc" "ABC") #f Relational operators and functions (> op1 op2) test if op1 > op2 (< op1 op2) test if op1 < op2 (= op1 op2) numeric equality test (>= op1 op2) (<= op1 op2) (not op1) negate the boolean operand (and op1 op2) boolean conjunction (or op1 op2) boolean disjunction Quoted Symbols Not the same as double quoted characters Normally, Scheme tries to evaluate symbols as functions Often need to put a single leading quote to tell it not to evaluate It strips the quote away as evaluation `abc abc `1bigthing 1bigthing `123 123 123 123 Some Conversion Functions Convert from number to string (number->string 123) "123" (number->string 12.3) 12.3 Convert from string to number (string->number "123") 123 (string->number "12.3") 12.3 Convert from string to symbol (string->symbol "abc") abc Convert from symbol to string (symbol->string 'abc) "abc" Defining & using variables (define x 1) defines variable x to have value 1 > (define a 4) >a 4 a4 (+ a 6) 10 Lists Lists () is the empty list; `() is the quoted empty list Lists are fully parenthesized and contain lists and/or sequences of atoms/symbols Often need to quote lists to pass as parameters to functions E.g., want to test if two lists "(+ 1 2)" and "(+ 2 1)" are equal (equal? (+ 1 2) (+ 2 1)) #t Quote the lists so that they are not evaluated (equal? `(+ 1 2) `(+ 2 1)) #f Quotes just need single quote in front of list Functions Operating on lists (member op1 op2) if op1 is a list element of op2, return sublist of op2 starting with op1; else return #f (member `a `(a)) (a) (member `1 `(+ 1 2)) (1 2) (member `- `(+ 1 2)) #f (member `1 `((1 2) (2 3))) #f List construction functions-1 (list op1 op2 ...) - form a list from a sequence of items (append op1 op2 ...) put elements of lists in a new list (car op) - return the head element of a list op (cdr op) - return the tail of a list op, as a list (cons op1 op2) - make new list with op1 on front of op2 (list `a `b `c) (a b c) (append '(a) '(b)) (a b) (car `(a b)) (cdr a `(a b)) (b) (cons `a `(b c)) (a b c) Exercise-1 (list `(a) `b)) (append `(a b c) `(1 2 3)) (car (list `a `b `c)) (cdr `((a b) c)) (cdr `(a)) (cons `a `((b))) (cons `(a) `()) List construction functions-2 More list functions & predicates caar: (car (car x)) cadr: (car (cdr x)) caddr: (car (cdr (cdr x))) etc (up to 4 operators in a sequence) (null? `()) #t (null? `(a b c)) #f (null? (cdr `(a))) #t Defining list variables (define y `(a b c)) y (a b c) (define init-state `((blank 5 4) (6 1 8) (7 3 2))) (car init-state) (blank 5 4) Define-struct: Dr. Scheme Syntax: (define-struct name (field1 field2 ...)) Make new structs: make-name Get elements: name-field1, name-field2... (define-struct row (left middle right)) (define row1 (make-row `blank 1 8)) (row-left row1) blank (row-middle row1) 1 (row-right row1) 8 Conditional Evaluation Syntax: (cond [bool-condition1 expr1] [bool-condition2 expr2] ... [else default-expr] ; optional ) Semantics: Evaluates the boolean conditions from top to bottom. In the case where one of these conditions evaluates to true, the result of the "cond" is its corresponding expression. Otherwise, the result of the cond is the default-expr. (define init-state `((blank 5 4) (6 1 8) (7 3 2))) (cond [(null? init-state) init-state] [else (car init-state)] ) (blank 5 4) Functions-1: Lambda Expressions The creation of procedure objects Syntax: (lambda (op1 op2 ...opN) (expression)) Semantics: Creates a procedure that has N formal parameters or arguments; expression can have references to these parameters; the result of calling the function is the result of evaluating the expression with the particular actual parameters substituted into the formal parameters. (lambda (init-state) ; anonymous function (cond [(null? init-state) init-state] [else (car init-state)] ) ) #<procedure> > Functions-2: Supplying Parameters Syntax: (<function> op1 op2 ... opN) Semantics: <function> can be a function name, or a lambda expression giving an anonymous function. <function> is evaluated with the given N parameters. ( list ; the function `(a) ; the parameter ) ( (lambda (init-state) (cond [(null? init-state) init-state] [else (car init-state)] ) ) ; the function '(a) ; the parameter Functions-3: Name Binding Usually want to name our functions Anonymous functions can only be used once, in the text, since we don't have a name for them, we can't call them again Syntax: Similar to variables (define <function...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Minnesota - CS - 5541
Chapter 4Informed Search MethodsGoal of informed search Use problem specific knowledge to reduce search time or space Example Visual (or auditory)word recognition Dictionary contains many words Problem is constrained by the context of the con
Minnesota - CS - 5541
Three layer (two weight layer) connectionist model: 2 input, 2 hidden, and 1 output units Inputs u_x1 0 Weights w_x1_y1 w_x1_y2 w_x2_y1 w_x2_y2 0.5 -0.5 0.25 -0.75u_x2 1Hidden layer activation values a_y1 a_y2 0.25 -0.75Hidden layer output valu
Minnesota - CS - 5541
2 input (x1, x2), 2 hidden layer units (y1, y2), 1 output (z), feed forward, fully connected neural network Inputs: x1 1 x2 0Weights: x1-y1 -4.62 Hidden: Bias wts Output: Bias wt z 0.9 -3.05 y1 0 -2.6x1-y2 4.47 y2 0.87 -2.56x2-y1 4.5x2-y2 -4.
Minnesota - CS - 5541
DeltaE T 0 0 0 0.01 0.1 1 10 100 1000 10000 100000 1000000 10000000 # # # # # # # # # # #-0.5 e^(DeltaE/T) 0 0 0 0 0.01 0.61 0.95 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1-2 e^(DeltaE/T) 0 0 0 0 0 0.14 0.82 0.98 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1-20 e^(De
Minnesota - CS - 5541
Chapter 7First-Order LogicOverview First order logic Constants, connectives Variables, predicates, functions Quantifiers Using logic for sets Wumpus world Situation calculus Representing prior states of the worldSyntax and Semantics - 1
Minnesota - CS - 5541
%!PS-Adobe-2.0 %Creator: dvipsk 5.58f Copyright 1986, 1994 Radical Eye Software %Title: chapter07.dvi %Pages: 22 %PageOrder: Ascend %Orientation: Landscape %BoundingBox: 0 0 612 792 %EndComments %DVIPSCommandLine: /usr/sww/bin/dvips -o /tmp/tempsr.ps
Minnesota - CS - 5541
Chapter 9: Inference in FOL Overview Substitution, unification &amp; quantifier elimination Modus ponens in FOL Need horn clauses (incomplete) Forward/backward chaining Resolution in FOL Refutation (proof by contradiction) Conversion to CNF Gui
Minnesota - CS - 5541
%!PS-Adobe-2.0 %Creator: dvipsk 5.58f Copyright 1986, 1994 Radical Eye Software %Title: chapter11.dvi %Pages: 16 %PageOrder: Ascend %Orientation: Landscape %BoundingBox: 0 0 612 792 %EndComments %DVIPSCommandLine: /usr/sww/bin/dvips -o /tmp/tempsr.ps
Minnesota - CS - 5541
Chapter 14: Uncertainty Overview Problems: diagnosis, rational decisions Probability: prior, posterior Math: product rule, joint probability, Bayes' rule, relative likelihood Example Wumpus world Robot/sensor Conditional independence Updatin
Minnesota - CS - 5541
%!PS-Adobe-2.0 %Creator: dvipsk 5.58f Copyright 1986, 1994 Radical Eye Software %Title: chapter15b.dvi %Pages: 27 %PageOrder: Ascend %Orientation: Landscape %BoundingBox: 0 0 612 792 %EndComments %DVIPSCommandLine: /usr/sww/bin/dvips -o /tmp/tempsr.p
Duke - CPS - 097
Birds of a Feather Proposal SIGCSE 2006Proposers: Owen Astrachan Jeffrey Forbes Duke University Dept. of Computer Science Box 90129 Durham, NC 27708 Office: (919) 660-6550 Fax: (919) 660-6519 {ola,forbes}@cs.duke.edu Statement of Topic: TITLE: &quot;Inno
Duke - LECTURE - 130
9/2/2002CPS130, Lecture 2; Sums, Function Growth, L'Hospital's Rule1. Introduction To facilitate our analyses of algorithms to come, we collect and discuss here some tools we will use. In particular we discuss some important sums and also present
Duke - LECTURE - 130
9/24/2002CPS130, Lecture 9-10; Propositional Logic, Boolean Algebra, Proofs; Integers and Induction1. Introduction Much of the material to be presented this week will be a review, but it is so important that I feel this is justified. For example,
Ferris State - PROGRAMSHE - 0809
Ornamental Horticulture Technology l Associate in Applied ScienceWhy Choose Ornamental Horticulture Technology?This two-year Associate of Applied Science degree prepares students for a wide range of horticultural careers. Golf course superintendent
Auburn - AG - 1989
~Special Bulletin 89-1 July 1989PROCEEDINGS1989 Southern Conservation Tillage ConferenceTallahassee, FloridaINTEGRATED PEST MANAGEMENTInstitute of Food and Agricultural Science University o Florida fThis publication was funded by The Nati
Auburn - AG - 1989
Comparative Effects of Tillage on Winter Annual Forage ProductionDavid Lang1IntroductionProduction of winter annuals in the Southeast provides a valuable source of high quality forage (1,6). Production practices normally include disking of land su
Auburn - AG - 1989
~Special Bulletin 89-1 July 1989PROCEEDINGS1989 Southern Conservation Tillage ConferenceTallahassee, FloridaINTEGRATED PEST MANAGEMENTInstitute of Food and Agricultural Science University o Florida fThis publication was funded by The Nati
Auburn - AG - 1989
Proceedings 1989 Southern Conservation Tillage Conference Tallahassee, Florida July 12-13, 1989Published in cooperation with the Institute of Food and Agricultural ScienceG.L. Zachariah, Vice President for Agriculture J.M. Davidson, Dean f
Auburn - AG - 1987
Conservation Tillage: Today and Tomorrow Southern Region No-till ConferenceProceedingsJuly, 1987 College Station, Texas The Texas Agricultural Experiment Station, Neville P. Clarke,Director, The Texas A&amp;M University System, College Statio
Auburn - AG - 1987
Conservation Tillage Systems in Texas B.L. Harris, E.C.A. Runge, and G.K. Westmoreland1Introduction Adoption of conservation tillage systems is expanding in many areas of Texas, accelerated by continuing technological advances. Economic pressures
Auburn - AG - 1987
Economics of Conservation Tillage Research in TexasWyatte L. Harman and J. Rod Martin1Summary Cost of production and profit implications from economic analyses of conservation tillage research dif fer by regions in Texas. In the semiarid regions, s
Auburn - AG - 1987
Effect of Crop Residues on Crop Pests, Soil Water, and Soil TemperatureE.G. Krenzer Jr., R.L. Burton, F.J. Gough1Much of the wheat acreage in the Southern Great Plains is in a monoculture annual wheat production system. This is very significant whe
Auburn - AG - 1987
TABLE OF CONTENTS Invited Presentations. Conservation tillage systems in Texas . B. L. Harris, E. C . A. Runge, and G. K . W e s t m o r e l a n d Nitrogen requirements of conservation tillage systems . F. M. Hons, M . A. Locke, R. G. Lemon, and V
Auburn - AG - 1988
Special Bulletin 88-1 August 1988PROCEEDINGS1988 Southern Conservation Tillage ConferenceTupelo, Mississippi
Auburn - AG - 1988
Proceedings 1988 Southern Conservation Tillage Conference Tupelo, MississippiAugust 10-12, 1988Compiled by: James E. Hairston, Associate Professor Department of Agronomy Production by: Sherry Williams and Stephanie Pitts Department of Agro
Auburn - AG - 1988
Table of Contents Foreword J. E. Hairston and N . W. Buehring.IIIThe tillage revolution and impact of conservation mandates in the Southern Region G. B. Triplett .. Tillage selection: soil stewardship vs. financial survival D. C. Ditsc
Auburn - AG - 1985
Proceedings of the1985 Southern Region No-Till ConferenceJuly 16-17, 1985 Griffin, GeorgiaEdited byW. L. Hargrove and F. C. BoswellAgronomy Department, Georgia Agricultural Experiment Station, Experiment, GA 30212andG. W. LangdaleUS
Auburn - AG - 1985
62 Preliminary Evaluat ion of Legumes as Cover Crops for Alkaline Clay Soils T. J. Gerik, F. W. Chichester, C. L. Neely, and J. E. Morrison, JrTexas Agricultural Experiment Station and USDA-AAS, Temple, TXS i x legume species were evaluated
Auburn - AG - 1985
71 Soil Management and Fertility for No-Till ProductionK. L. Wells and J. T. TouchtonUniversity of Kentucky and Auburn UniversityN o - t i l l production of corn, soybeans, and g r a i n sorghum has increased r a p i d l y during t h e p a s t
Auburn - AG - 1985
82 Comparisons of Conventional and No-Tillage Peanut Production Practices in Central GeorgiaJ. M. Cheshire, Jr., W. L. Hargrove, C. S. Rothrock, and M. E. WalkerDepartments of Entomology, Agronomy, and Plant Pathology, University of Georgia, Geo
Auburn - AG - 1985
167 The Role of the Georgia Soil and Water Conservation Committee in P. L. 92-500, Section 208, Nonpoint Source Agricultural Pollution Control F. Graham Liles, JrGeorgia State Soil and Water Conservation CommitteeThe S t a t e Committee