PROFESSOR:  Okay.
	The midterm, I'll put up a solution set for that, now that everybody has taken it.  The first part about the, yeah the TV serial, hopefully, is a sort of straight up reading the design recipe, can be one of 4 things, figure out how to represent those 4 things in Racket.  Process it, have a COND with 4 branches, pull outfields if there are any.  Think about what type it is, whether you want to make recursive call or not, and hopefully, they're meant to pop out of that.  Doesn't seem that way, but I think you follow those step-by-step, it should be, should be there.  The data structure is similar to list, some nodes have extra information beyond one number at X object.  Some nodes have only the next object, something like that, there were 2 base cases instead of just one, but yeah. 
	I'll put a solution set out for that.
	PROFESSOR:  My computer calendar is screwed up, says it November 16th, no way that can be true, right?  Okay, thank you.
	And then hopefully the trees, couple examples of, the grammars both reading a grammar and being able to write a grammar.  One reason there's the question about, can your grammar generate plus plus minus 2 or whatever I asked.  Hopefully the answer is no, the reason I put that there, if you you're like oh, my gosh any grammar could generate that, you have a chance to go back and fix it.  Okay.
	I'll post a -- a, section on, that.  Solution on that.
	Yeah, so -- and ASH you e-mailed earlier saying did I post any lectures to watch -- the answer is no.  Getting other stuff ready, didn't get to it.  So.... 
	 So that true false question is worth 0 points and just there to give you a chance to realize you might have made a mistake.  Sometimes people submit grammar that's do admit something like that.  So I'm trying to get more correct answers by explicitly saying, show you can write this and make sure you can't derive that.  
	So I didn't flip a lecture, I might tonight, I'll ask in a couple hours, maybe I'll flop a lecture, maybe stop in 2 hours and give video that I would talk about in the last section.  I'm willing to talk about it, but if you want to take off and do stuff, there's a lecture for that third part.  We'll talk about that when we get there.  And I will try, actually get ahead of game and have things (Inaudible) shows up.
	So, and usually for this week in the class, there are 3, the 3 top, the 3 hours that I give in class, -- the way I'm do anything class, so -- 2 of the topic are working with prologue.  So introducing prologue and doing a little more and one topic talking more about, the whom work and tying it in with how, interpreter for Racket would work.  Or interpreter for Q one and Q 2.  I'm not sure for this class what is the best order to do those things in.
	To start with, talking about the homework immediately or sort of defer that, wait until we're a little bit, do some of the new stuff about prologue while brains are fresh and then talk about that, what we already talked about or thought about -- anybody have any votes?  I'd like to talk about the, if I'd like to talk about it -- what I want to talk about the homework problem makes more sense if you look at it, if you've not had a chance to yet.
	Who would prefer to talk about the homework first and who would prefer to talk about prologue first and then come back and talk about the homework?  -- fine to have no opinion on this.
	Homework 7, I think it is, Q one and Q 2.
	 one question, people had a chance to look for it?  -- posted it on discussion board, have not made a Dropbox, did post on discussion board saying it was there.  If you subscribe to the discussion board, hopefully you saw it.
	Yeah, possible people have not looked at it yet.  No.  No.  No.  It will be due, in, it will be due at our next class.  After the break.  My philosophy on the Thanksgiving break, I don't expect you to work -- I treat Thanksgiving break, as far as work, I expect as any other weekend.  In particular, many, first of all we all need time to decompress at this time of the semester, and, the, you might get a little work in, but often you have family visiting, it's hard to find the time to work and get a couple hours a day or something.  So, the homework that's posted there, is meant to be, for my in-class section, thinking of as being due before we leave for the break, but you can work on it over the break and over the break I'll try to put up last 2 homework so you can get ahead. 
If you want to get a jump on the last 2 homework.
	Anyway.  Okay.
	Let's go -- for you guys I'll go ahead.  I'd like to have the test cases this Friday.  Again, some of you have work weeks that are not so minimal.  You can only do the work on weekends or something like that, here is what I might do.  I might say those test cases are due, try to get them done this week if you can.  I'll have them do 7 days from today and we won't be meeting, but, if you can't do it this week, try to do it this weekend.  And just start thinking about the homework before, right before it's due.  So -- how many people have, had a chance to read the homework?  -- 
	Yeah, there is no class meeting next week.
	It is, a Radford University holiday, we have the whole week off for Thanksgiving, starting on Monday and including Monday.  Yeah.  
	I'd rather have a few days off in the middle of the semester and shorter Thanksgiving weekend, but we get nothing off the semester until now.
	Yeah.
	Okay.  How many people are able to have a chance to look at the homework already?  Maybe you can raise your hand in the chat -- that works.  Yeah, okay.  The reason I'm asking, should we take a 10 minute pause and let people read the homework before talking about that a bit?  -- okay, I'll pace the URL for the homework -- and, so, it's not too bad, let's look at -- there we are.
	I'm not sharing this but I can show -- thing -- so last time we talked about yeah I figured some people would, that's been staggered, exam was previous week but I understand why it might pile up.  -- da-da-da -- what we did, the homework, let me go ahead and -- it's not so much talking about the homework that I wanted to do.
	I want to talk about some of the provided files a little more.  Talk about some of the code and how it works already.  I want to talk about how the test cases were setup.
	-- yeah, the final exam will be similar to the one we took writing, some code, doing some trees or something like that.  It will be, I'll emphasize, doing the second half of the -- you know recursive, tail recursive functions and some of those definitions and how to, convert tail recursive and trees and parsing that we talked about.
	Exam was sort of, we stopped the material on exam, couple weeks back -- yeah.
	Let's go ahead and I'll pause and take 10 minutes to look over homework?  Again, final, concentrate on later ha half, half, inherently cumulative.  We have exam one is design recipe and that and parse trees.
	 Looking on writing, applying designer, making tree structures, which is what we're doing.  So -- I don't know if you want to call that comprehensive, will be stuff after the first exam but you need to know everything we covered on the first exam.
	Okay, let's take -- 10 minutes, if you've already read it, go off and go running outside or do whatever you like, 10 minutes to look -- at homework.
	Including looks at the files --
	So I give you starting implementation and you're adding on to that.
	So, -- if you want to see, do you remember load those files and have them available to you and come back at 6:10 p.m.
	If you want to chat, I'm hear, I'll pause audio.
	
	[Break Time].
	PROFESSOR:  Okay.  So mentioning the homework quick, we talked about language Q 0.  And we saw examples of it.  That's there.  We went through some code, both in Racket and in Java of, how to, the data definitions an went through, examples of data, went through, particular functions, how does the function 2 string work and how does the function eval work and those are straightforward function that's follow the design recipe.  Take in expr and we have union type for expr whether in Racket or Java.  So we saw, examples of how the code looking for that.  How does 2 string look, and how does -- eval look and follow the design of the template straight up.
	Parse was a little different, right?  Parse doesn't follow the template.  Because what does parse handle?  What type does it take in.
	What did do you give to parse?  Yeah, give it a flat screen, don't give union type, give it a string, it returns an union type, but the expr itself is -- the, parse takes in a string.  So it doesn't, technically doesn't follow data definition, because it's returning an expr and really almost constructing initial expr, it does sort of have some similarities to data definition, but technically not following template for expr.
	Okay.  So we already saw those and talked about those.
	Looking at this homework, I'll point out that Q one -- just saying, let's add a couple extra things to our homework, new type of binary operator and these are both unexcited.  They're meant to help you familiarize yourself with code and add to it and see how it's currently setup.  It's, sort of thing you can do, not understanding code, just by being good at copy and pasting the appropriate parts.
	But had helps you familiar what the classes are, where they're setup and where the stet cases are.
	For, this is.... right here, go ahead, I'm saying all previous types of expr we still have them and new, bin OP all previous types we have and one more Mod.  You're talking about homework 7?  Number one?  Grammar?  Yeah.
	I only put the new parts in.
	Okay.  What was I saying?  Q one is sort of take what's there, copy and paste it, modify it a bit.  Not too, but it gets you familiar with thousand things work and Q 2, need to be understanding what we're doing and not too bad, give very detailed, or exactly what you need to do -- and everything you need to do, sort of follows largely from the template.  So -- but, you need to understand what you're doing, not quite as straightforward.  Not hey I can cut and paste without really understanding the code, okay.  But it's not bad.
	That's set aside, a few comments on what to make.  I don't, confuse the -- or -- expr -- with what evals to.
	The expr, the tree, parse tree, that's an object and, I'm sorry, I was talking to other students and students coming in, they said, point to, to say here is a string, parse is going to return a tree, what tree will it return?  What they did instead, they looked what the answer was, that, what a that program was going to evaluate to, which was not what parse does, parse gives back tree.  They were confusing parse with eval and trying to do it at once, parsing strange in evaluation stage.
	You can think, we only have a couple of functions on parse trees, we have e-mail and 2 string.  But, you can imagine I can make more, I can make another function called -- find all, -- find all undefined variables.
	I can make something that's, sort of a pretty print.  I can make something that says count how many Q words in the entire program, it takes in parse tree and tells that.  Tell me, what is the most deeply nested expression in the tree.  There are tools out there for professional developers, plug ins that say do you have, (Inaudible) too complicated.  Nested to too deeply, straightforward to do that.  A lot of things we can do with the parse tree, evaluate is the one we're most interested in, but lots of orange things we want to do along the way.
	Okay.
	What else I'm saying about this, Q 0, Q one, think about your internal representations.  -- discussion board, post, if there are odd questions you're not sure about, my grammar I'm being a little bit IFFY about spaces, because I'm provided code that works with punctuation, somebody asked in the homework when it talks about new IF 0 expr --(Inaudible) do we need a space between the expr and outside.  We need the space between else and expr, -- it turns out I give you parsing tool, if you say else and immediately follow with parentheses, we read else as one word and stop there.  Just like in Java, that's how Java works.  And just like in Java if you say else 5, to open a space between the else and 5, that would be a problem and it would be a problem the way the scanner is I give you to work for. 
Do you need spaces in certain situations, you don't necessarily -- the parsing tools I gave you are rich enough, if you want to assume there are spaces great, you only need to handle correct programs.
	You don't need to worry, about what if I give parse string -- I'm only going to give you string for that grammar, that's all you need to test for.
	Okay.
	If you want to do more, it can be good defensive program, if case you make a mistake yourself -- but you don't need to do that.
	What else Q 2, I want to sort of say, total, total I what to do, I've known from past years, people still don't do it, they skip things, and went through in the end, here is exactly, step for step what you need to do.
	Put it this way, do we live in a world with correct inputs.  Coming from user we definitely need to scan that and check those for validity.  Things coming from within our own program we assume are correct.
	And the real world, yes.  Things that come from user, that's input validation, that's user input validation, that's its own thing.  If you want to add your own (Inaudible) checks, again, other programs, on your team, like future (Inaudible) makes a lot of mistakes, -- all the time.  Program at 3 a.m., I don't know why he does that, that's how he is.
	So -- looks under Q 2, there's extra whole set the bull lets, all that is, spelling out in great deal tail what you already asked you to do.  Okay.  And today we'll talk about, law of Racket in a few minutes.  Will tile into what Q 2 is doing somewhat.  I want to talk he have briefly about the provided test cases.  Should we look at provided test cases in Racket or Java, want to talk about how to setup the cases, straightforward but different from how we did test cases so far.  Should we look at test case code in Racket?  Java?  
	No answers means I'll flip a coin here.
	A lit post-it note.  Nobody typing anything yet.  Written R on one side, jr on another.
	Tear off the -- sticky part.
	I'm being fair here, throwing up in the air and it says -- R, look at Racket test cases.
	Good choice you all.
	I provided you a file.  Windows may not be working -- none of my Racket -- is working -- it's still going.  There we are.  Okay.  
	Expr test Q 0 file -- yeah.  So one thing, and this I've been meaning to change -- there's a check equal instead of check expect the reason for that, is -- these file are in the full Racket, they're not in student language.  I guess these are advanced student, this one here -- okay.
	Put advance student, require rack unit.  And there's up line 3 of this, so looking at this file, expr test Q 0.  And my test case is for expr, Q 0.  And, the actual unit test tool, the check-expect is beginner level and does funny stuff.
	-- not what you quite want to use --so use check equal and why, because it can pass as a function.  So -- kind of comment there at the top why doing that, and that's exactly what I wanted to mention and talk about.  So first of all, I'm going to look at this expr test Q 0 file and line 15, 16, 17, and these are strings.  Not really expressions.
	Right?  They're strings.  And need to make the parse tree for them.  So -- some level, I'm going to go ahead and call string to expr.  That will be some of the test cases, here is one test case, string 39 -- simple one.
	String to expr, which I also call parse -- string to expr, 4 add 3, should give me bin expr tree, shallow bin expr tree and can I make more complicated things.  What are things I want to check, string to expr, I want to check when I have that -- notice here -- I take the same string, rather than type this make bin expr of these 3 fields, I call string to expr of the strings, these Q 0 raw strings are nice.  Once parsing function works, string to expr, hey, I find it a little easier to type string to expr and give me the raw Q, give me the Q 0 program as a string rather than all the make bin expr.
	Especially as trees get more complicated.
	String, some point I want to call eval on that parse tree, take the string and make parse tree eval on it, I should get 7.
	Third thing, take that string, parse it, string to expr, now I have parse tree and from that tree call 2 string on it, what string do I expect to get back, 4 add 3.  So really if you look at these test cases, lines 25, 26, 27, what information do I use?  I have string that I use several times.  I want to know, the tree that it generates an what it evals to.  Okay?  So -- I want to do that, I want to have a lot of different programs.  I put 5 up in lines 15-20.  Lots of programs.  You can look at that string online, 18, the, parse tree for that is kind of boring parse tree.  Paren expr, containing paren expr etc..., it's easier to write that string than it is to go ahead and, write out the tree.
	So what did I do?  I'm lazy, I want to make many different tests.
	I did things like this -- okay, now looking at lines, 53, 54, 55, here are my test cases.  I'm going to give you -- come back do it, it's a list containing list of length 3, here is list of length 3, list containing the string, parse tree and what should it evaluate to.
	I try to 2 of those reversed.  It takes a string, takes, evaluates   and optionally the parse tree.  I want to get.  So looking at line 54, string is that open paren 3 add 4, evaluates to 7 and third thing, make bin expr, 3, 4 and string add.
	That comma is important.  It proceeds, connected, make bin expr.
	And I'll have, somewhere in there is link about talking about back quote and what I'm doing.  I'm note going to emphasize that.  String is not right after the 7, it's really the thing, immediately before that.  Make bin expr.
	Okay.  So I went ahead and made these test cases.
	And some times I'm going to be lazy this 3 add 4 add 3 mul 4, I can make the bin expr for that is complicated and made one or 2 complicated parse trees, I want more test cases for eval.  But I'm not for 2 string, I'm not going to spell out parse tree.
	I made I list, of programs, things they evaluate to and sometimes the tree I want generated.  Those are my test cases.
	Up here, line 49 -- define test to be the following list -- and, this is, the beginning of line 53, don't worry or stress about this -- this is a list, so the back tick is making a literal list, I don't need to say list or cons, say open parens, the first curly bracket is test cases and square brackets is each test case, 2 things or 3 things, line 56, where I only have 2 things.
	How did I test it?  I'm going to go down and, if I look at line 105 -- okay.  And this is a for each loop and a little like map and filter.  Actually let me go ahead and look at line 112.  That's more interesting one.
	For each loop some function and then test.  This is high order function, loop construct built in, you give me a list and I'll feed each one of elements inside this list, I'll feed to this function, one at a time.  And do it for all of them.
	And what did I do?  What does it function do?  It calls check equal, like check-expect.  It calls check-expect on -- it says, take first -- so, tests was that whole list of things that have 2 or 3 items -- hey for each one of these call that lambda expression.  All lambda expression pass this list of length 2 from line 56.  Okay.
	Looks back, each T is going to be that list of length 2 or 3.  I'm going to take the check equal and, the expected result is the first of T, the string and what am I going to do?  Take first of T, string to expr, parse tree and call expr to string to get the string back.  So take the string, put in parse tree and take that parse tree and call to string on it.  I expect to get back the same string I started with.
	That's, expr to string and string to expr are inverses.
	So I gave you a list, all I care about is the string, the first item, and check the first item equal to, taking the first item, making a tree out of it and calling 2 string on that tree, do that for each of those.  If check equal fails it reports an error.
	Steven's question, if it passes everything it's silent.  If everything works fine, print nothing.  If a test fails, then we have a problem.  So I'll press run here and goes and nothing happens.
	If I go back, and change, like enter bug in code and, and, change something here -- change -- say online, 56, change that expected result, 19, change to 18.  If I run that, I do get an error.  It doesn't show up in separate window like check-expect.  It prints to standard error.  Which is in red in the bottom thing.
	And now, there's a, get 19, expected 18.  What's going on.
	Okay.
	So, it's actually catching the errors, if there is an error, check equal will fail, let me change that 18 back to 19 before I forget.
	Okay.
	Yeah, so -- this is me trying to make my life easy, how do I check 2 string, I go ahead and Steven the answer is no.  Because we're doing this other harness here.  If you want to do your own check equal, yeah, tell exactly which line of check equal that fails.
	I'm saying, I have so many program that's I want to make, I give you some tests for Q one and there's another 20 of them here, I'll give you a string and what I ox expect to evaluate to.  One of things I test, I take that string, make a tree out of it, and take that tree and call 2 string on it and see if it's the same as the string I got in.  Rather than write check-expect for all of those, all I wrote was the string inside that list and went through and did that little loop, online 112, 113, 114, what's drawback?  When you get an error, you see the ox inspected output and actual output.  But didn't tell which line.  Failure happened in line 112.  That's all it knows.
	So --it doesn't actually tell you exactly -- exactly that -- hopefully by looking at this expected output and actual output, you'll be able to tell which of the test cases, you can double check by just running that one thing and see if it got back what you wanted.  So -- yeah, if you don't want to use the test harness, go and write a check replace, each of these lines, 53 through 82 and write check-expect on each one, check equal.  So that's trade off we're making.
	Although you know, it occurs to me -- I believe check equal you can give it the actual output, expected output.  You can actually give it a third thing, which is a string, string what the test case S sometimes people name each test case, I'm not sure, I'll double check and look up documentation of check equal.
	You with probably Jimmy it, so you pass some string to the, third argument for check equal, that includes, the, exact test case that failed.  Yes.
	So -- I have to look into that.  But that should be possible.  Yes.
	Okay.  By the way, what's -- what's the only thing I didn't explain about lines 112-114?  You know about lambda, I mentioned for each, that runs lambda on everything in the list -- talked about first, we talked about taking that first element of the list, which is a string making a participation tree, taking that parse tree and calling expr to string, what is string to P tokens, first of all that should be string to Q tokens.  This is a function that says, hey, -- so, what is problem about saying I'll take a string, make a parse tree, take 2 string and see if I get the same thing back.  That almost works, one annoying situation it doesn't quite work though.  I'll draw your attention to line 18.
	-- big old parentheses expr, I can make this into a tree, I can call 2 string on tree, what string will I get back when I call 2 string on a tree, I'll probably not have some of these spaces in there.  Depending how 2 string works for paren that size expression.  Or alternately, maybe I'll have lots of spaces in there.  Even though, they weren't required for the input.  Similar to some of the other things, places were spaces were required but not optional.  That would move up.  Add spices, 3 and closed paren.  4 add 3, those already change the parse tree I want to get.  Parsers are less enough it makes parse tree ignore those spaces.
	-- so what did I do?  I made a little helper function.  I want to compare 2 strings if they're equal, ignoring spaces.  Okay, looking at punctuation it has.  Okay.  Punctuation it has.
	Change P to Q in all of this.
	-- so I have this function that takes string and turns into list of tokens.
	I use the same sort of standard object you can look in the project and so on, and goes through and makes a list.  It turns out, this uses named let.  This is available in advance student, not beginning, see named let -- advanced student.
	It's a way of writing a little function here.  That looks back on itself.  Really inner function they call recursively, but okay regardless, you don't need to know about that, you don't need to touch this function, you just might be wonder, check 2 if these 2 are equal, but don't check the strings exactly.  Go ahead and get rid of all the white space?  How, take the string and turn into a list of tokens.
	Yeah.
	Okay.  That's just if you're wondering about it.  Yes,  end of file.
	And stuff there you don't know about, you can go ahead and look at the documentation for it and so on.
	That's my test, hey here is easy way to test, test cases for every language, for every string that was a Q 0 program, called parse and 2 string, those should be, opposites, should get the same string back, go ahead and do that.  How about eval, look at lib lines, 18-120.  I have full reach loop.  Go through test.  Each test was list of 2 or 3, and here is what I do.  Grab the first thing in the test, which was the string, call string to expr on that getting parse tree, call eval on the parse tree and check if that's equal to the second thing in that test case.  If not report an error.  Otherwise -- keep ongoing.  We do that for everything in test.
	Okay.  That's why when you go through here, -- it's going to take that string, first, I look at, the square brackets, that's individual test, first element of that list, is a string, called parse and call eval, I better get 12.  And that's what check equal does in line 118.
	So -- see first, turns out there is a function called second, third, fourth, fifth, 6th, 7th, all the way to tenth in Racket.
	First, the part of data definition of cons, second through tenth are derived from calls first and rest.
	-- okay.  So that was, -- check that eval is correct, like line 117.
	Test the internal representations, I want to, if test fails, go ahead and take that third one, parse tree and see if equal to result of calling string to expr on the string, first item.
	That's pretty straightforward.
	What's the only interesting thing there, remember I was lazy and decided I don't want to include every single parse tree, because some are verbose, typed out by hand the parse tree.  I took tests.  I call for each thing on this list.  This list is not all of test.  It is what?  -- hey call filter -- and I'm going to say hey here is test, filter is high order function that we talked about -- I'm going to give you a list, I'm going to give you a little bit of code that says, should I keep an item of the list.  It goes through this list and keeps all the ones that satisfy the condition, whose length is at least 3.  What is the test case having length of 3 mean?  There's one of these.
	Keep all the ones provided the parse tree, and that is what I go ahead and pass to this test expression here.
	You need to know any of this?  No.  Can you -- yes, this is stuff you can understand and we talked about these things, I just want to talk about, saying, you know, this is a pretty routine in the real world as well.  I'm writing this code.  I can write a bunch of unit test cases but sometimes I can take code shortcuts to the test cases.  Take a string, parse it, 2 string and get the same string back.  So you write your own test harness -- which is what we're doing here.
	Okay.
	What else?  -- does all of that, the downside is we went to the 5 advanced student language to get those test cases, working different than check-expect.
	And the reason I did that, so I can call it, check-expect.  If you don't call it at top level, doesn't work.  It's meant for beginning students to put in the soft level test.  I cannot have it embedded in the middle of some other function, which I'm doing here.
	Check equal, doesn't return anything, so we're in a different world in advance student -- okay.  Anything else I want to talk about here?  I think this is -- now, you can look at this and say I'm going to add more lines to this list called test.  I'm going to add to lines 53 through 85 or 84, sure that's fine.
	But, if something goes wrong, need to change something, we're doing okay, you should be able to look at it and figure out how it's working -- but I'm not going to test you on that.
	Any other questions?  I -- I'll put up list on lecture page about this use of back quote as shortcut to make lists.
	Here is cool thing about back quote, it made a list of lists.  Once -- here -- I can go ahead and say -- quote -- 3, 4, 5, that makes list containing 3, 4, 5, it's nice, I don't need to call the list function, I do it myself.  In I have nested list it becomes especially handy.
	There we are.  I typed in some big wacky thing, I could have, this is evaluated to, I could have typed exactly that, list containing, list containing, list containing, list of 3, 4, hello, 99 and second thing on this list was -- this here -- list with the symbol another, symbol nested and more lists -- etc..., 7 and 9.
	Back quote or tick mark, quote is nice convenient way to make lists.  In fact, Racket is descended from what language?  -- I mentioned this before.
	Racket is descendent from -- from scheme, scheme is simplified sort of lisp, what does lisp processor stand for?  -- why?  They bake into the syntax this quote operator, there's easy way to make lists, nested lists and that's cool.
	The lisp is saying look at this source code.  This whole thing is list of, 2 things inside it.  Symbol require and a string.  And go ahead and look at this list here.
	Hey, the list containing, you know -- everything here is actual code.  If I want to turn code into data.  Maybe writing an interpreter, throw a tick mark in front of it and now you have internal parse tree.  You didn't make structs like we are, internal parse tree, list of lists an we'll figure out from how long the list is -- you know -- we'll see in a moment, the Racket lisp has nice easy syntax that makes this nice representation.  Anyway -- that's all kind of cool.
	Here is one problem though, because, when I made this list here, above, I included the word like another or nested or list, that's cool, they became symbols and embedded there.  What if I have a variable X that I want to embedded in the middle of my list?  -- well, I can go, if I go here, and you know throw in that.  Well, I get the symbol, don't get the thing that I want.
	--use pi, get symbol pi, no, I want 3.14.  Again, mention as cool thing -- okay, in addition to tick mark we'll make back tick or, un-quasi coat.  You think about the back tech, if you put a -- comma in front of something it will unquote that part of it.  So most of this list is quoted.  And nested and list --
	Another and nested and list, they're all being quoted but pi is not being quoted to it gets evaluates and see 3.14 occurring in the middle of the list.  I can unquote more things as well.  Unquote 99, turns out numbers will quote to themselves.
	I can say square root of one hundred here -- and now in the middle of my list -- I call the square root function that built most of this list was literal.  Every now -- and unquote that had got something there.  Does this remind web developers of anything.  You have literal stuff and in the middle you want to do computation?  -- PHP.
	You tend to have stuff that is -- literally stuff that's print that had turns into print statements.  And you enter PHP block -- actual, (Inaudible) and then code that gets runned and finish question, angle bracket and into quoted mode.
	I'll say quick -- the bad thing about that, is, length of list -- one hundred -- here is, length of that list is one.
	-- in PHP you can't do this.  Once unquoted this whole expression has that comma so unquoted there.  So I can have a code list.  But why do I, list one hundred, yeah I want to be able to say this.  Okay.  In fact -- have a bunch of netted lists -- no, I too many parens.
	I can go ahead in the back, I can quote as much as I want and I can even quasi quote -- and, play around with this and try things, but you can't do that in PHP.  When you enter PHP mode, you can't, inside a little section exit PHP mode that's surrounded by PHP mode environment.  You have to smush to top level, (Inaudible) you can't net them.  While this back quote quasi quote nest, pretty cool.
	How did I use that?  In test cases because here one actual string, quotes to itself.  12 quotes to itself.
	I didn't want a list containing the symbol make bin expr.  I want to call the function.  That's why I have this comma here, I'm actually unquoting this part of it.  Getting actual tree structure stuck in there.  So -- okay.
	Again, you don't need to know that.  That's pretty dang cool and all the Lincoln lecture notes about -- further reading and examples of quote and unquote and quasi quote if you want to go off and have fun.
	Go ahead, take a break -- and be back in 5 minutes --
	[Break Time].
	PROFESSOR:  Back quote, if you look at lecture page now, if you want to pursue it.
	Add test cases to that test harness, but that's how it all works.  Just using ideas we've done.
	Some examples of high order function and filters, give me list, give me function that says what I want to keep and give results just what I want to keep out of original list.  -- had parse tree as part of test, if it didn't, don't do any check equals on it.
	Okay.
	How are we all doing?  -- is everyone comatose, if you are, raise your hand and say AYE.  Yeah.
	So -- what I want to do next, finish up with one thing, looking at Racket.  I want to give you the law of Racket.
	That is, the syntax and semantics.  Okay.  So yeah, what is Racket?  -- well, little asterisk here -- or at least -- typing -- okay.  Least a little bit of Racket we used for all of our work.
	Okay.  I'm, I think I missed something there.  But, yeah, what is Racket?  But the, syntax and semantics of expressions.  So in Racket, notice, by the way you can tie this back to the homework.  In the homework we're sitting there and saying, in Q 0, express is num, bin expr and giver the syntax for it.  Okay.
	So I'm going to do the same sort of thing here, I'm going to be, not give official context free grammar -- but in Racket, what can expressions be?  What sort of things can we type into Racket and get an answer back?  -- bottom window.
	Symbol, yes, -- hello -- that's an expression and evaluates to itself and there are other simple expressions.  Yeah the Boolean true.  Literal true.  Yeah the number 43.
	-- string, hello, hello.  Maybe.  Okay.
	It turns out these are all immediate values, they're not, you don't have to do anything, the answer is right there.
	So one possible thing, in Racket expression can be, is a value.
	-- EG, literal numbers, strings, Booleans, symbols.  Anything else?  -- all right.  Hash tables, lists.  Okay.
	Whatever.  But the interesting thing is, those are all literal values and what is the semantics if you see a value how do you figure out what its answer is?  The answer is you don't.  What does 43 evaluate to?  43.  Really, when I type in 43 and hit enter, part of Racket is read anything characters I type, parsing them together and making internal representation and print it's right back out.  Some sense the, the, thing this 43 evaluates to is the number 43.
	What is expr -- it evaluate to?  It evaluates to itself.
	Okay.
	So -- value, I can have syntax, syntax for number and string.  Basically, values -- syntax say, you look up syntax for that, and seminar ticks, what does eval do, it evaluates to itself.
	What else can we do, different type of expression that doesn't evaluate to exactly what you type in?  -- I mean, yeah I mean, what is this lower, text editor and typed character 4 and character 3 and that's all the program got is these characters, took characters and turned into, hey it's int and bit pattern aside.  It read, reading a string and parsing that.  Yeah.
	And, if you give it characters that are like, double tick mark, HI double tick mark, it reads that, or tick mark 43 tick mark and reads those characters and says I'll make an internal string object.  Your Java program is a file of chair Rick attorneys, there are only characters in that file.  First thing Java does is read that textile and convert it into the internal representation of a program.  Including all literals, numbers, characters 4, 3, 2, same thing here.
	All we have is text file, source code.  Yeah.
	Well, it's doing parsing.  -- I just like you are parsing code we went through, we said look at the first token, if it's an open paren, we'll start parsing one way, if it's a square bracket do some other parsing.  If it's a double tick mark, we'll parse it some other way.
	Yeah.
	Yeah, your Java program there's a parse tree for your Java program, every Java program has a parse tree.  It's about as big as your program want only huge if your program is huge.
	 what is something that -- here we are, got an answer -- pi, yes, type in PI, I get this thing here, if I gone ahead and said define Harland's friend and I'll go ahead and define that to be, come back to this -- Kitty-Kitty, type in bar land's friend, it comes back with whatever that it (Inaudible) here is another thing that can be an expression.
	If you see an identifier, that's a valid expression, what are semantics?  Look up the corresponding (typing) okay.  Look up corresponding defined, bound to -- I should go ahead and say separately down here, some things that are not expressions, but still have syntax/semantics.  One of things define, followed by identifier, followed by expression.
	Semantics, evaluate the expr, and, remember -- bind the (typing) -- okay, remember that value for the future -- we call that remembered value, the binding.
	Evaluate the expression, expr, -- whenever you evaluate something, what do you get back?  You get back either a number, string, Boolean, symbol, hash table, list or whatever type.  You get back a primitive value.  I should not say primitive, you get back value.  Including lambda expression, including potentially struct, any of answer is value.
	Values are special because they're also what you get when you evaluate an expression, you always get back a value.
	In particular, see identifier like PI or Harland's friend.  You get back the result of whatever this thing evaluated to.  So in particular, define RAWR to be -- according to the rules I've written, RAWR, what is RAWR, we get back 5, RAWR is down to 5, it still says 5, how many times did we call the addition function?  The answer is just once.  Why?  When we typed in this, what did we do?  We evaluated it, getting the answer 5 and then all we remember is 5.  We didn't care about how we got 5, if you see RAWR -- remember it's 5.
	Okay.
	So, we have these semantics here for what does define do.
	It includes expr.  Okay.  So Racket, expect can be literal value, identifier and what else can be an expr?  Yeah, plus 2, 3.  What's general syntax what it can be?  It can be open paren followed by expr, followed by expr, followed by expr, followed by closed paren.  We can give the full, we know how to do this, it's going to be one or more expr, oops -- and we know thousand give a grammar for one or more expr -- okay.
	If you see an open paren, literal open par reason followed by expressions followed by closing paren, what is are semantics for that.  See plus, 2, 3.
	What is plus?  By the way.  Plus is identifier.  What is plus bound to?  Addition function.  Unfortunately Racket doesn't know how to print addition function well, so it prints it out as plus.  Really, identifier, we looked up what it was, addition function and printed it back out here in this interactive window.  So -- evaluate each of he have expr 0.  Expr one -- expr N, let's call the results val 0, value 0, value 1, VN.
	And this is what Racket has been doing all along and hopefully makes sense and providing clarity and I'll point out, this is ha we're doing for language Q, we're doing exactly the same thing, expressions and how to evaluate them.
	Okay -- okay.  If you see open paren and follow a bunch of expressions an close paren, evaluate each of those expression, the 0 better be a function.  What do we do with that function?  We go ahead and -- the answer is -- take the body of the function -- and replace its parameters with V one, VN, and evaluate that -- sort of, replace -- substitute --
	Parameters with V one through VN and evaluate that.
	That's the answer.
	Let's take example of this one.  I'm going to do here, say, hey define foo to be -- foo of AB, to be -- (typing) 2 times A plus B.
	  the way we saw this in syntactic sugar, how does this define, actually, how does it relate to this define here?  -- is the real define has open paren define, and followed by identifier.  So what does it line 36 really turn into again?  -- talked about this.
	Really turns into define, what identifier are we going to attach a value to?  In line 36?  foo, yeah, sorry, didn't mean to cut that option off, foo is the new name, so plus and (Inaudible) are already bound to things the only new identifier we're attaching value to now, is the value, the word -- foo.  And turns into this thing here -- so line 36, syntactic sugar for what we have here, see foo replace with that.  What happened if I call foo of you know, square root of 10, 3, and square root of one hundred.
	You can probably figure out, foo times first pin put.
	Input plus the second input.  2 times 6, hopefully that's 106.  Sorry, 2 times 3 plus 10, which is 16, yeah.  So -- I can see why we get that, go to that aud you had now and see where these rule are going in.
	Stepper the thing on the left, thing highlighted in green turns into the thing highlighted in white.
	Let me get this window a little smaller.
	Sorry.  Turns into the thing highlighted in purple.  It says I see something that is open paren, expression, expression, expression closed paren, first evaluate each of those 3 expressions.
	Evaluate foo, so recursively, turn off camera?  Okay -- yeah.
	Thanks.
	Making sure that's out of way.
	-- okay, moving down helped.
	Okay.  Racket comes along and says I see open paren something something something closed paren, evaluate each of those expressions recursively, if I see foo, go up and replace it with whatever it was defined as.  That's why the green part turns to purple.  I looked up identifier and literally put in what it was defined as.
	Okay.  Next step -- it's skip over the fact 3 evaluated to 3, even stepper doesn't show that so simple.  And square root of one hundred, do that, it goes off recursively, calls internal code and so on and comes back with 10.
	Then what does it do?  It says, okay, look back at notes, where is main window -- non stepper window -- can't show it right now -- notes, in the other window I was writing, evaluate each of those 3 expressions.  The first one had better been expression or we get error, it was, it was lambda value.  The answer is going to be the body of this lambda but with A and B replaced with 3 and 10.  And that's why we go from the green part to you were p the part.  It's the body of the lambda, replace A with 3 and replace 3 with 10.
	Then evaluate that.
	How do we evaluate that?  We are open paren, expression, expression, expression, evaluate each of those 3.  The first thing plus is symbol, look it up,  that's defined as internal addition function.  This recursively evaluates to 10, 10 evaluates to itself.  Internally there's lambda expression for the plus, wherever parameters were replace with 6, 10 respectively and get your answer, that's where we get 16 coming out.  So there are several steps going on.  If you see in stepper, reach step 5 out of 6.  There was really, 6 steps.  Turning foo of 3 square root of one hundred into the result 16.
	There we go.
	There's my Racket -- computer is acting funny.  System is a little off somewhere.
	Okay.
	So that is, an example of this one here, that's most complicated one, that's the one I want you to know and understand.  How does that work?  You see open paren, open paren bunch of stuff closed paren, evaluate each expr, square root of one hundred evaluate that, and get 10 back as value.  Third might be place holder, that results in lambda value.  Great, we get back, a bunch of values, hey, these better be function value, better have N parameters.  The answer is the body of that function with those N parameters replaced with V one, the particular values V one through VN substituted in.  Whatever you get there, evaluate that, and that's your answer.  That's the most valued you will hear I think.
	Racket, value, identifier, open paren, closed paren, that's a function application.
	-- applying a bunch of open paren, means apply a function in Racket.  Okay.  What else do we have in Racket?  I think you just have values, identifiers and function calls.
	There's one more thing we have, which is special cases.  COND is a little special.  And -- is a little special.
	-- and is a little like a function -- but it shortcuts.
	In particular, it does not evaluate each of these expressions first and then call the function.  It evaluates each of the expressions in order.  What is the syntax for -- and.  Open paren, and, followed by expr...., expr one, expr 2, ..., expr N -- semantics, -- evaluate expr one, if it's getting a value.  If that value (typing) otherwise return this recursively.  And actually we need a base case as well.  Grammar for...., actually base cased, and if nothing at all, returns true.
	Okay, actually I think the way full Racket works and single expr -- evaluate expr N, and return it.  Okay.  Oops.  Hold on.  So -- see what happens here and go through this in the step we're in, no.  These lines out -- and the 4, 7, false and hello -- working through the stepper -- stepper doesn't like that -- using simple one where we only have Booleans, even though we're in intermediate -- we're in intermediate student -- I'll go up here.
	Semantics of AND, let me fix that, evaluate expr one getting value, if false, return false, if it's not a Boolean, give -- throw an exception.  If it's true, return, that.
	Base case -- and if nothing at all, return true.  See if that's true in intermediate student.  Is that right.  It still, go to full Racket and with nothing at all and you get back true, you see why.
	It's doing this -- here with the base case.
	Okay.  So -- depending which language level we're in, semantics are a little different.  Student language, AND you can't get fewer than 2 arguments here, must have at least 2 arguments.  Okay, anyway.  That's semantics of AND, COND has similar semantics, I'll show on a different page here.  And then there's a few things like -- define -- still has syntax and semantics -- define struct as -- syntax of, ID, something like that.
	Really 0 or more identifiers.  And, did the constructor, getters, etc..., binding them to the names, make (typing) -- okay.
	Again, this I'm less interested in, it's the function call I'm interested in you getting.  Okay, but this I think is all -- I have not written out what we do for COND, but other than that, this is the full semantics of Racket.  Syntax and semantics, expr up here including a few special indications that evaluate specially for functions.  And only special because they shortcut.  And then, define, define struct, I guess there's, -- let-star, those are the 3 special forms we've used.  
	I won't go through the semantics of let-star, we talked about it, what does it do?  You figure out the value of each sub expression and substitute those in the body.  Look at this other page of notes that I have, I think this might be under expr page, yeah, same thing I had there, lambda is the other special form, yeah.
	And IF -- okay.
	Okay -- so yeah, that is, basically one file I can go ahead and say exactly what syntax of lambda, lambda you remember this stuff, create internal data.  I give you semantics of COND, syntax the COND, semantics are a lot like the semantics of AND.
	I'll compare this with semantics of Java.  I don't have camera going.  Get the camera back.
	Here is the book here, Java programming language, earlier edition, here is semantics and syntax of Java, good luck putting that on single page.
	It's a big long book, not a single picture in the book and it is 860 pages long.  So -- now, I can tell you why am I doing this class in Racket rather than Java, part of it, language definition, language speck does not need to be 860 pages long.  You can fit full language on single page.
	The language writing Q 0, one we get through it, up to Q 4, you'll have full fledge language, 2 or 3 pages, entire syntax, implementation of language fit on a few pages.
	Yeah, now to be fair, Racket, there's a lot of stuff in Racket I have not talked about.  There are some things complicate nd Racket as well.  Java has complicated things going on.  What does synchronize key do.  Synchronize key do.  Creating exceptions, handling exceptions, -- so there's a lot of stuff going on there in Java.  You can have language without having all of that.
	Okay.
	So -- it key is -- hey, when we go ahead and, have this, when we call a function, take the body of the function -- so, foo is bound with this thing here, this is a function who's, lambda is keyword, think of it as define struct, or make a function struct.  That, A and B are special identifiers an here is the answer here, here is the body.  Hey, when you call it, replace those parameters, those identifiers replace with actual values, substitute them in are, and evaluate that resulting body.  We substitute in, and then evaluate that result.  That's -- the interesting part.
	Are there setters in Racket.  Yes,  you can read about them.  They have exclamation point in their name.  I think I mentioned there's one keyword that goes ahead and sets local variables and another that sets fields of objects.
	Those are 2 things, Racket gives them separate names.
	Okay.
	And -- I think that's good.  In Java it uses equal sign for both, X gets 7 or foo dot, you know, num people gets 7.  And it feels like you're doing the same thing, the way they work with aud thing it's wildly different things and operations were 2 separate names.
	Something I never thought about until I saw it in another language, in scheme.  Yeah, I was raised on C, yeah assignment through field, same thing, right?  No, quite different.
	Once they gave different names I started to think why they're different and semantics.
	One enables aliasing and the other not.
	-- okay.  So that's the law of Racket.
	I have this file out here, includes both syntax, examples, and has a little bit on semantics of COND.
	And so on.  Okay.
	And we do substitution as part of one of the steps applying a function and calling a function, replace parameters with actual arguments.
	Parameters AB with the arguments 3 and 10.  So, okay.
	-- that's kind of cool.  That is Racket in, one or 2 pages.
	All of the stuff we talked about Racket.  With no, (Inaudible) that's kind of cool.
	Can't really do that in CS one with Java, can't say, after a few weeks here is the full meaning of the language much Java has too many keywords.
	Constructor is different and know static and public and, void, and yeah.  Anyway.
	Okay.
	How are we doing?  -- people totally comatose, no response, dead fingers are like 10 times, counting up to 7, keyboard fingers around the state of Virginia.  It's nice, tell you what.
	Let's, I went longer than I thought I would on some of this, take break, come back and try to do a shorter session and, I will have a flop of one hour over things giving break to look at.
	-- that we'll talk about.  It will be a flip, at the beginning when we come back in 2 week from today.  Let's take a shorter break.
	Refill my water bottle.  Break until -- 5 minutes.
	
	[Break Time] -- we'll start with prologue when we come back.
	Try to finish that off in 45 minutes or so.  See you in a second.
	[Break Time].
	Maybe the force of 2 quizzes due, if Dr. Lewis teaching that maybe get it done before the weekend, or maybe you'll be done, be able to finish by Friday or something.  Okay.
	If you recall way back when we talked about different families of languages.  There are procedural programming versus object oriented.  Versus functional,  and versus scripting language and what was bar land's takeaway point on that I can away , what features make a scripting language, what features make object-oriented, what features make language functional.
	What was my takeaway point one thing to remember about all of those categories?  Hint, there's 2 letter abbreviation that might sum it up.  BS, these distinctions are a little bit, pearl that scripting language but pearl has object system.  If you want to program using immutable in pearl you can do that and pass around high order function.
	Maybe pearl is functional language, maybe object or orient language, no conflict with these sort of things.
	Just keep anything mind, that, I think it's good to know what people expect.  Keep in mind these are not exclusive categories, not like language fits in one indicate Gore other another.  What I think is more important.  When people talk about scripting languages what feature do they mean, easy operate ability with the shell and file system and other languages an stuff like that.  Okay.  Thank you -- 
	Okay.  
	Yeah we have those different categories of languages, that don't take them all with a serious grain of salt -- at least say these are not exclusive categories in any way.  And we talked about, mentioned declarative programming and prologue being the poster child for this thing, what is, the declare I have programming, you declare what a correct answer is but not how to compute it.  And that may not have, may seem odd, let's go ahead and look at examples.  So first of all to, there are different prologue engines out there, you can download for machine and use it, there are some with nice gooey interfaces an stuff, and I'll have a few, I think in this file or next file, have some other examples, things you can download.  I'm going to use a totally text interface one called SSB, command line, -- so if you don't want to mess with installing anything go to aud and do all of the work there.
	XSB, first of all, mention how we're going use this -- our pro log, 2 phases.  There's entering the facts in the rules an making interactive query, same thing with database, first you make tables an fill with data, and then do interesting select commands to pull out interesting information from the database.  Same sort of idea here.
	Okay.  So -- here is, own the web page there's a file that has, say there's a section of data, section of rules, and data we have, a few statements entering, periods, female period, mail of Bob.  Male of Charlie.
	I can pull up terminal.  Make sure I have this here.
	We have a file, I say XSB, load that file, gives me little thing, file loaded.  And now I can make query beside that.  I can ask, male of Ethan and comes back and says yes.  Female of DEE, yes.
	Female of Ethan -- oh, wait, that was my example for --
	I wanted to say female of Bob, it will say no.  And male of Bob yes, sir, female of Bob no.  One thing about pro log all of answers are true-or-false.
	Okay.
	There's only true-or-false.  as the result.
	If that brothers you, hold on we'll have ways to talk about other things, thanks.
	All the things, predicates will either be true-or-false.
	What if I talk about something that does not exist at all.  Male of pat.  It will say no, female of pat, it says no, pat is not mentioned at all.
	I entered both male of Ethan and female of Ethan as a effect.  Does that cause problems.  No we have social construct, we might think male and female are mutually exclusive, regardless the computer, some relation called male, certain things are male.  Some relation female, certain things match female.
	I could have another query called Led Zeplin's fan, doesn't mean you can't be male.  Okay.  So.
	These are rules and then we go ahead and have, rules.
	Those are facts, male of Ethan, female of DEE, and then we have rules.
	I put rules in there and come back and say partner of Bob D, and say yes, well if I say partner of Bob and Ethan -- Charlie, partner Bob and Charlie will be false.
	Partners rule that you see on the web page that was built in.  Let me pull that, up for a second -- so here is how to read this rule.  Partner of A and B, A and B, partner of A and B is true, if -- colon dash, if -- male of A and female of B.
	Period.
	Excuse me.
	So read the comma as and, read the colon equal as IF.
	-- okay, you may not.  By the way this definition may not be a good social definition, but, we can make rules in pro log like this.  Pro log will fill them out.  That's why is said, partner of Bob comma D, yes, because male of Bob and female of D, partner of, Bob, Charlie, came back and said no, it was not the case that male of Charlie is true.  That is the use of a rule there.  We have the facts and the rules, this may not be a good social definition.  Okay.
	This might be, who is allowed to go to junior high dance in small town, something like that.  Might be defined in Supreme Court.  Okay.
	-- here is the cool thing -- partner of Bob, Z, here is all possible solutions for Z, we can have Z equal at -- that will make this a true statement.  I hit comma and enter, can you find another value of Z, yeah, Z equals D would make it true, another value?  Z equals Ethan, so yeah -- it wasn't listed in the file, but I put female as Ethan.  You don't see that in web page.  Sorry about that.  Ethan will make that true and no other Z's that make that true.  That's cool, this is interesting.  I put in, Bob of Z and shows me all the Z's that will make this true.  And I can go the other way around, -- partner of Z comma, Z -- and I can get all sorts of answers there.
	Okay.  By the way, what is -- how did it know that Z was a special variable?  Starts with capital letter.
	So -- several letters long but starts with capital letter as opposed to Alice, Bob, Charlie, it's important they start with lower case, symbols, think of them as symbols like in Racket, they're, -- if,  -- (Inaudible) you can say partner of A comma B period, here is one solution, A equals Bob, B equals Alice, and so on -- and we get a bunch of things, answers there.  -- including the answer A equals Ethan, B equals Ethan, let's look at code I have.
	And see why that is.  Why is A and B equal Ethan allowed.  Let's look at that.
	-- here you can see that I went ahead and put Ethan as male and female.  -- okay.
	So why is A qualm Ethan, B equals Ethan as an answer, think of the same as -- in algebra, think of, you have things like X plus Y equals 4.  And one solution might be X can equal 2 and Y, there are other solutions, X equals one, Y equals 3, etc..., but you know, there's no reason in algebra, you're mentioning X and Y, no reason they can't be the same, both bound to 2 and that will yield valid answer.  That's what happened here, A equals Ethan, B equals Ethan, male of Ethan was true and female of Ethan was true, so Ethan, Ethan was a solution to that, I should not say equation, say this is a constraint, when I made that query, partner of XSB, when I said partner, maybe not use letters A and B.
	Use B and W -- think of this as constraint, either true-or-false, all we have is Boolean, find me all the ways to set V and W to make this come back and true and show them all to me.
	Okay.
	With Ethan being there.
	Okay.
	That's kind of cool.  That's, interesting, I hi.  The fact I put in this variable and finds the solutions for me.  All I did, was, what is the definition of partner.  And it went ahead and solved.  This is let me say, declarative programming is about just stating what a correct answer is, and let the program solve it for you.  We just had what does it mean to be a partner and program actually found it for us.
	I didn't have any IF statements, no variables, just what is the meaning of partner.
	Okay.  And again, this may not be socially acceptable meaning here -- setting that aside.
	Here in small town that has, very restrictive junior high there's probably a lot of drinking going on, this might be after the prom.
	I went ahead and, in the database I had, things here, we'll come back and talk about that -- and we'll see, more useful programs going on.
	So, and I'll talk about why I'm choosing to talk about pro log in particular.  Okay . we'll have this drinks database.
	And so I'll put in certain facts, drinks of (inaudible) comma begin, martini, soda, and so on.
	-- in fact I put on -- fut in few more examples of that.
	So I have a bunch of people here --and so now here is my question, Biff give me, I want to find out every drink that Charlie likes.  What would I type in, every drink that Charlie likes -- what should I type?  -- how do I find out who Bob can be a partner with.
	Exact same idea we use up there.  Yeah, I can say drinks of Charlie, comma, maybe call it DR to remind me it's a drink.  Period needed remember that finishes query.
	And it will come back and solve for all the ways to make that, it could be water, soda, whiskey and March tiny, and no other solutions.
	If I ask that and Charlie comma DR period.  If I hit enter, I don't say comma and enter, if I just hit enter now it will stop.  Yeah, there were more but sounds good.  Yes, I made you happy I guess.
	I want to find all of the whiskey drinkers in the group.
	What do I type?  Somebody besides Steven.
	Steven O.
	Want to find all the whiskey drinkers.
	By the way it needs to be lower case and drinks plural to match up.  Yeah, drinks of, maybe see P for person -- and whiskey/come back, just Charlie, only one that likes whiskey.  	Now interesting one -- I want to go and want to find out -- I want to make new query, called drinking buddy, that takes in 2 people and a drink.  Might take something like Bob and Charlie, and, martini, and come back and say yes or no, these are drinking buddies who can use that drink.  Bob, Charlie and martini.  How do I make a rule that does that?  It's now making a rule.  Go back and see what the rule looks like for the partners, for example, I want to make a rule about drinking buddies, if there are 2 people, 2 people and a drink, that both people like.  If you look at what we did for the, for the previous one with the, partner -- I setup a rule and used variables for the 2 parameters.
	Here I have 3 things, rather than call them ABC, call them P one, P 2 and drink.  When do P one and P 2 both like drink?  Who wants to finish off the right-hand side?  -- 
	Part of the right-hand side, if not all of it.
	Partner A comma B, what was that true?  -- oh, when this was true, and, this was true.  Okay.  That was that rule there.  Similar to drinks with.  When is, P one, P 2, when are those valid?  
	So I don't want to call drinks with.  I don't want to make recursive call, want to talk about underlying relation, which is just drinks.  Exactly, drinks.  This is true, person one drinks, drink DR, and comma, drinks person 2 DR.  Go ahead.
	Okay.  So drinks with, yeah.  Person one, person 2, DR and go ahead and quit and start XSB -- and by the way, mentioned on notes page if in XSB, first thing I want to do is load database, knowledge dais, it will vary from one system to another.  Say square bracket, and then the name of the file without the, so I have file called LECT 34, in square brackets and then a period.  This is weird, they load that file there.  And tells you, we went ahead and, compiled and (Inaudible) great.  Now try -- drinks with of, and what are people that make it true?  -- martini Charlie and Chris, martini and it says yes.
	While drinks with, Charlie, Ethan, martini, that was yes too, why was that?  Oh, -- I don't have Ethan drinking martini.  Let me try -- actually try drinks with -- Charlie, Chris, and water.  Don't say I have them both like water.  Charlie likes water.  Chris likes, have I done something wrong here, I'm thinking I have, but I don't see it.
	Charlie, let me find people -- Alice, okay, try Alice and Charlie -- they like martinis but they don't both like whiskey.  Alice and Charlie, martini and whiskey.  -- by the way if you download your own prolog thing it might have gooey and easier way to reload the file, I encourage you to try different things.
	Okay.
	Drinks with and now we have, Alice and Charlie, whiskey, drinks with Charlie, Alice, that's suppose it be like that?  -- are they all returning true?  What's going on?  -- Alice and martini should not have been.  What's the rule?  I think I got it wrong.  Oh.  Da.  Anybody see my mistake?  -- I typed D 4 instead of DR for drink.
	Gosh, what was that, I didn't mean to do that -- but now it's going to work.
	And I'll come back in a second, what it was doing and why it's passing with that.
	Charlie and who was it again?  -- Alice.
	Drinks with Charlie, Alice, and whiskey.  Was no.  Okay.  okay.  And in fact, we can also find, Charlie and Alice want to drink together and want to chip in single bottle.  What are all of the things they might try, Charlie, Alice, X, they can buy a bottle of water, bottle of martini and those are the only 2 choices for drinks with.
	Okay.
	So, great, we can try that, putting variables in different places.
	Next question -- I want a new version of drinks with, this version of drinks with took in 3 inputs, 2 people and drink type and by the way, sometimes they'll refer to this in error message as drinks with slash 3, meaning it takes in 3 inputs.
	I want version ever drinks with that only takes in 2 people and says yes or no, are these 2 people drinking buddies.  Is there some drink they can find.  Okay.
	How will I do that?  Person one, person 2, and I'm not going to have a drink.  I'm not going to tell prolog what to match up with.  One person, 2 person are they compatible as drinking buddies, the right-hand side is just the same, in order for this to be true, there needs to be some DR that makes this true.  Hey prolog if you find DR that makes right hand true then left-hand side is true.
	Here is variable on the right-hand side but never mentioned on left-hand side.  Links, connecting, involves with person one and involved with person 2 a and now go ahead and try this and, drinks with, and pass it, I can still use that 3 verse before, but now here is version that only take twos inputs, Alice and Charlie, they can be drinking buddies.  Who can be drinking buddies with Alice?  -- Alice, Charlie, Ethan, Alice, Alice, Charlie, Chris, and that's all.
	Those are all the correct answers.  Now there's a separate question that came up.  Why are some of these answers repeat and why is Charlie repeated twice?  -- turns out listed twice, prolog found 2 ways for them to be drinking buddies.  I typed in comma, comma give me another solution, I don't like that solution, giver me another one.  It gave, Charlie as answer twice because there's 2 ways Charlie can be a drinking buddy.
	So there are 2 drinks that were in common.  By the way what about Alice?  Can Alice be her on drinking buddy, I guess she can according to my own definition, but that's kind of sad.  Drinks with Alice, comma at list, why is that true, set DR to be water and then we have the fact that, drinks of, so if I have P one as Alice, P 2 as Alice and DR as water.  Is that true.  Drinks of a Alice Water is true and drinks of Alice water is true, so the whole thing is true.
	Okay.
	And again, just like in algebra, no reason why X and why could not have been both equal to 2 in solving constraint.  I want won't call equation because no equal sign going on.  Constraint we're trying to satisfy.  Somebody drinking buddy with Alice.  We want to add one more rule.  This is now -- a lit bill, sort of minor detail here.  If you want to say, one more constraint, I want this and this to be true and want P one to be different than P 2.  Not equal, in prolog is backslash equals.
	Nor forward slash equals, but backslash equals.
	And that gets rid of somebody (Inaudible) again, going back to what is declarative programming, we say what is the rules for drinking buddy and the system actually goes an find it's.  But we need to make sure we get our rule right.  Right, right.  Drinking buddies you can't be drinking buddy with yourself, that's just being an alcoholic.  Okay.
	Okay, that's, another example of the rule here.  And notice by the way it's fine to have drinks with, these are overloaded methods, version has 3 and 2 inputs, may as well be named entirely different things, entirely unrelated to each other.
	Okay.  Questions?  Thoughts.
	Here is task for you, write party of 3, I want 3 people, every pair of which.  3 people who can, each person can be a drinking buddy with both of the other 2.  But not saying there's one drink they're all happy with.  I just want, say it's 3 people and any 2 of them can share a drink.
	Any 2 of them have some drink in common.
	How would I write that?  -- party of 3.
	After this, I'll make a few more comments an we can go home.  How is that for incentive.  I guess it was not good incentive, all thinking about it.
	Sure, you can try on your own and then put in chat window or start in the chat window, whenever you like.  Give people -- one hundred more seconds.
	Party ever 3, come up with a rule -- for 3 people, 2 of which are drinking buddies.
	One more minute.
	Okay, so, where were we?  Okay, party of 3, party of 3, how many inputs will there be to this?  How many inputs to party of 3, 3 people, name them P one, P   2, P 3.
	Just, so -- yeah, I want to go ahead and say, are there 3 people all drinking buddies with each other.  There may not be a drink they all have in common as long as every 2 have a drink in common.  How can I do this?  -- I want person one and person 2 to have a drink in common, so, drinks P 1, something drink 1 maybe?  And person 2, also, drink A.
	And person 2 has to like drink A as well.
	Can now, P 1 and P 2 have something in common, I need P 2 and P 3 to have something in common.  But doesn't have to be the same drink, it can be drink B, and finally I need, who else needs to have a -- P 2 and P 3, P 1 and P 2 have a drink in common.
	P 2 and P 3 have a drink in common and I need person 3 and person one -- have some drink in common, I'll call them drinks A, B, C, don't need to be the same drink.
	Okay.  So this will go ahead and give me party of 3, 3 people and come back and be true if it, it's going to try and solve for all of the variables involved.  In I say party of 3 and give it whatever, Alice, Ethan and Bob, it will try and solve for, is there a DA, DB, DC, drink ABC to make these all true.  If we find that, then this will be true.  If I said party of 3, Bob XY, don't say find values of X and Y such that, XY and drink A drink B drink C, such that will all be true.
	X would have to be the same as P 2 and Y the same as P 3, really the, whether I have vary able in extra query going on or just extra variable on the right-hand side is all the same to prolog, it just says, look for each of the variables an try to solve them to make this whole thing true.  The whole right-hand side true.  If I make the right-hand side true, then the left-hand side, I'll say it's true as well.
	-- okay.
	By the way, is there faster or shorter way or better way the writing party of 3.  Hint?  Yes.
	-- hint, it's given the fact we already wrote about 2 people being a drinking buddy.  We already had that code written.  Right?  -- in fact as programming, we should reuse existing code.  Yeah, so one thing is I have a bug in this.
	And, I want to make sure person one, person 2, person 3 are now all, no 2 are the same.  I need all 3 to be different.  Yeah.  In fact, -- here is a better solution.  Okay.  I want to go ahead and have P one, P 2 be drinking buddies, P 2, P 3 drinking buddies, P one and P 3 drinking buddies, this actually (Inaudible) we already talk care of different people at pair wise and I think that's enough for all 3 of these true.
	Then P one, P 2, can't be the same person, I think this is better solution, incorporates this bug we fixed here, when we started repeating code, yeah we actually had things, needed to say things like P one not equal to P 2 -- P 2 and so on.
	That's another example, why you don't want to repeat code, you're repeating bugs that were already fixed and reintroduce them, when he sort of, yeah I can do that when we repeat code, blah-blah-blah this made you think, that's repeated code -- they're both solutions, both correct, second one better from a programming, like cleaner code.
	Okay, that's, prolog, define for functions.  Even though only getting Booleans back, interesting we can do this stuff, and yeah, -- separate thought that occurred to me, how do you use this language, how used in real life, instead of saying sequel and showing how to do queries on tables, how do you use in real life, I can write program that (Inaudible) pi but still useful.  This file that has all of the facts really is, I'm going to finish up with several observations.
	Knowledge base, they're saying we have facts an rules an (Inaudible) above what database has, we have rules built into it.  So -- one thing I'd like to, mention is that -- some of these facts, female of D, I'll go ahead and add another one, female of -- grace, go ahead and like this -- this is true if, remember this is, this holds in right-hand side holds.
	Right-hand side always holds.
	So this would be another way of righting female of D.  -- writing female of D, and might be guessing where I'm going with this.  There are facts an rules, in prolog there are other rules, if you see something that looks like fact here, period, that's syntactic sugar for this.  By the way, I guess it could be syntactic sugar for this, right, true and true and true.  That's kind of silly, don't need it say true and true and true, say once, as a matter of fact it's good enough to say 0 times.
	Everything on the right-hand side, they'll call it true.  The way AND works, AND of nothing at all is true.  We talked about previous hour, semantics of AND, base case AND with nothing at all ends up being true.  Same idea.  So really, this is the sin tam tick sugar, female of grace period, -- it depends on nothing on the ride hand side.  So I lied a little bit prolog does not distinguish between rules an facts they're all rules.
	Some rules are trivially true.  This one here.
	-- okay.
	One more, I'm going to put in another rule here.  I think, drinking part -- I think -- Ethan only likes water and that sounds, I wonder if Ethan used to drink more, and what if he falls off wagon -- how about this rule here, Ethan, drinks of Ethan   X is true, if -- I don't have, on the right-hand side -- drinks of Ethan X, this is, what is this saying, this saying X is variable, is drinks of Ethan comma whiskey, set X to whiskey and see if we satisfy right-hand side, yes we can.  If I add this rule here, drinks of Ethan whiskey and martini an Margarita, poor Ethan, he has problems here.
	So -- yeah, you can go ahead and do this, and -- that's fine, again, really right-hand side doesn't need anything at all.  I could just write it as here.
	So that's usually how prolog writes this line.  One more thing, about this, this variable named X, I'm only using it in one place, not using in anywhere where else, unlike rules here.
	P 1 got used in a couple plagues, here and here, linking the fact when this is true, depending on P 1 is related to when this can be true.  And DR occurred in this rule and that rule.
	If variable only occurs in one rule doesn't link to anything else at all, that a little weird, -- and almost like you see the X and looking, if I had things on right-hand side, you search through them, where is X mentioned.  If X is not mentioned at all.  Their special variable in prologue called underscore, underscore is variable that isn't matching anywhere else.  Okay.  So -- and also kind of nice, says, doesn't matter what that S you don't need to give it a name and see if it matches somewhere else.  It just underscores.
	Drinks of Ethan and anything.
	Okay.  Same as drinks Ethan X, don't mention X anywhere else, idiomatic to use this underscore variable.  See next time, underscore is Smith special -- because if you use X 3 times, they're all talking about the same X and related to each other.
	If you use underscore each time, each is separate I don't care that matching anything.
	Underscore is wild card not variable, just matches everything.
	Okay.
	I think that's all I wanted to say about prolog right now.  Any questions at the moment?  -- we'll get out 10 minutes early here, homework is due end of Thanksgiving break, we are not meet meeting for class next time.  Get the test cases in by, when we would have class next week.
	I'm trying to get it done by Friday.
	Try to get it done, work on homework, send e-mail, post discussion on discuss board, -- and that way if you want to take Thanksgiving break off, you can, I'll post the last couple homework over the Thanksgiving break if you want to work ahead.
	I'll have one video for us to watch, at least 2, at least one, probably 2 to flip to, watch ahead next time and try to put prologue questions out there as well.  Next homework we'll continue the Q language and have a few prolog questions on it.
	Okay.  So I think we're good.  We'll meet in 2 weeks and you'll have, the BARE essential test cases done one week from tonight.  --this really is water, by the way, just so you know.  It's not GIN.
	See you all next week.
	-- good night.
	>>>  I hope it get exam, put that as high priority to the other stuff.  Once in-class turns in test cases for homework 7, get those back to them quickly.