1 / 28

Today's topics

Artificial Intelligence and Lisp Lecture 3 LiU Course TDDC65 Autumn Semester, 2010 http://www.ida.liu.se/ext/TDDC65/. Today's topics. Evaluation of terms, in two modes: - Computational evaluation - Representational evaluation Evaluation of conditions/propositions Operations on actions:

conner
Download Presentation

Today's topics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Artificial Intelligence and LispLecture 3LiU Course TDDC65Autumn Semester, 2010http://www.ida.liu.se/ext/TDDC65/

  2. Today's topics • Evaluation of terms, in two modes: • - Computational evaluation • - Representational evaluation • Evaluation of conditions/propositions • Operations on actions: • - Evaluation • - Execution

  3. Today's topics • Evaluation of terms, in two modes: • - Computational evaluation • - Representational evaluation • Examples: (+ .a 5) (father-of sven) (age (father-of sven)) • Evaluation of conditions/propositions • Example: [less-than (age (father-of sven)) 50] • Operations on actions: • - Evaluation • - Execution • Examples: [call-by-phone sven (father-of sven)] • [call-by-phone .p (father-of .p)]

  4. Computational vs representational evaluation of terms • Recall: terms formed from symbols, strings, and numbers, composed using functions and set and sequence operators • Strings always evaluate to themselves • Numbers also • Symbols evaluate to themselves computationally, and to a thing in the world representationally (modif. will follow) • Set and sequence expressions evaluate element by element • Functions evaluate using knowledgebase computationally • Functions representationally: according to facts in the world if some argument is in the world, otherwise use computational evaluation (modif. will follow)

  5. The examples • Terms: (+ .a 5) (father-of sven) (age (father-of sven)) • Proposition: [less-than (age (father-of sven)) 50] • Actions: [call-by-phone sven (father-of sven)] • [call-by-phone .p (father-of .p)] • Consider the arguments of the action expressions. • - Computational evaluation: symbols sven, lars • - Representational evaluation: these respective persons • Function 'age' maps • - Computationally: symbol to number • - Representationally: person to number • Analyze function 'father-of' similarly • Function + maps number to number in both modes

  6. Additional examples • [member sven (friends-of gunnar)] • [member sven {maria sture hubert ... }] • Notice that literals (i.e. elementary propositions) evaluate similarly to functions, but they have a truth-value • Composite propositions, formed using and, or, not, etc, also evaluate similarly to functions, with standard truth-tables • 'Numbers evaluate to themselves': a mathematician make take issue on this, and the system implementor as well, but for our purpose it is sufficient • 'Set expressions evaluate to themselves': similar observation

  7. Evaluation vs execution of actions • (More exactly, action expressions) • Evaluation of action: arguments and parameters elementwise, like for sets and sequences • Execution of (evaluated) action: computationally in simulated world, representationally in real world • A robot will do computational evaluation followed by representational execution (leads to grounding problem) • Examples: [call-by-phone sven (father-of sven)] • [call-by-phone .p (father-of .p)] • Evaluation result: [call-by-phone sven lars-erik]

  8. Execution vs statements about actions • Examples: [call-by-phone sven (father-of sven)] • [call-by-phone .p (father-of .p)] • Evaluation result: [call-by-phone sven lars-erik] • Actually in the world: representational evaluation and execution • Performed by robot: comput. evaluation, repres. execution • (modif. example as [call-by-phone sven (father-of sven)] ) • In memory: use a proposition like • [do time-4983 time-4992[call-by-phone sven lars-erik]] • In a plan: similarly (but ending time yet undetermined)

  9. Computational evaluationof terms and propositions • Possibilities: • One attached procedure for each function and predicate, without stored data (examples: plus, less-than, concat) • Make a table of argument combinations and corresponding values, for each function and predicate • For predicates: make a list of those combinations of arguments where it is true, omit the others • Representation using attribute values of one or more of the arguments, for example [are-friends lars sven] using a set-valued attribute for one or both of the arguments

  10. Correspondence between a symbol and its representational value • The following conventions are sometimes applicable: • Unique names assumption: Never two different symbols that have the same representational value in the 'world' • Closed world assumption: Each thing in the 'world' has a symbol whose representational value it is. • Called closed world assumption because... • Modified unique names assumption: make statements • [equal foo fie] • in those cases where two symbols refer to the same thing. If no such statement is in the knowledgebase, then take for granted that they refer to two different things.

  11. Composite entities • Compare the following representations, where area1 and area2 are given entities: • [has-type border-area1-area2 border] • [delimits border-area1-area2 area1] • [delimits border-area1-area2 area2] • [marked-by border-area1-area2 wooden-fence] • [marked-by (border-between area1 area2) wooden-fence] • [marked-by (border-between area1 area2)(made-by fence wood)] • where also • [subsumed-by wooden-fence fence] • [material-for wooden-fence wood]

  12. Use of composite entities • Convenient both notationally and implementationwise • May apply to specific things, e.g. area1, or to classes or other abstract entities, e.g. fence • Do not admit multiple values, but may have a set as a value. (What about occasional multiple values?) • Must use a reserved value such as nil when no actual value exists • Equality issue is important when composite entities are used. Example: lars-erik vs (father-of sven) vs ... • One may wish to use unique names assumption for atomic entities only

  13. Reification • Compare • [has-phonenumber sven "013-459120"] • [equal (phonenumber sven) "013-459120"] • [Holds (phoneof: sven) "013-459120"] • The third construct allows you to also write e.g. • [knows lars (phoneof: sven)] • The entity (phoneof: sven) is called a reification • The function the complements Holds, for forming subexpressions, as in • [equal (the (phoneof: sven)) "013-459120"] • Reifications are usually subject to a complete unique names assumption • If phone number is time dependent, then make time an additional argument of phonenumber, the, and Holds

  14. List Processing in CEL • Operations on recursively nested sequences, called lists • Functions: • (e1 <a b c>) = a • (e2 <a b c>) = b etc • (en 4 <a b c d e f g>) = d • (t1 <a b c>) = <b c> • (t2 <a b c>) = <c> • (cons a <a b c>) = <a a b c> • (concat <a b> <c d>) = <a b c d>

  15. Information aggregates • Information elements, in different approaches: • - Logic programming: propositions • - OWL: triple of entities • - KRF: an entity with its attribute values • Information aggregates are the structures that are used for organizing large numbers of information elements • In KRF: entityfiles, knowledgeblocks, agents, individuals • An entityfile is a textfile containing a sequence of entity descriptions • A knowledgeblock is a set of entityfiles • Each agent contains a number of knowledgeblocks, and may also access knowledgeblocks of other agents in the same individual, to a limited extent

  16. Lab2a addresses information aggregatesand representation issues

  17. Reading Matter for the course Leonardo Document:n Knowledge Representation (several parts) Lisp in Leo Environment Leonardo Facilities Programming Language Lisp Software for Intelligent Agents Managing Info Aggregates List Processing Logic notes Goals of AI Leonardo installation Introduction to KR framework

  18. List processing • Recursively nested sequences as the only composite expressions, with symbols, strings, numbers as elements • Functions on sequences (no side-effects!) • (e1 <a b c>) = a • (e2 <a b c>) = b • (en 4 <a b c d e f>) = d • (t1 <a b c>) = <b c> • t2, tn similarly • (cons g <a b c>) = <g a b c> • Notice: (cons (e1 .x) (t1 .x)) = x

  19. List processing • Predicates on lists • (equal <a b c> <a b c>) = true • Control operators, for example • (if (equal .a <>) .b .a) • Other necessary function • (type-of .a) • The value is either symbol, string, integer, real, sequence • Other functions can be defined in terms of these, for example • and, or, not

  20. List Processing - Recursive Functions • (length .s) == • (if [equal .s <>] 0 (+ 1 (length (t1 .s)))) • (replace .a .b .s) == • (if [equal .s .a] .b • (if [atom .s] s • (cons (replace .a .b (e1 .s)) • (replace .a .b (t1 .s)) )))

  21. Lisp Programming • Lisp uses S-expression style, all data are formed as recursively nested expressions with round parentheses • Using function names such as e1 and t1, rewrite as follows • (e1 <a b c>) (e1 (quote (a b c))) • ssv .a <red green> (setq a (quote (red green))) • (e1 .a) (e1 a) • General rule: a list (g a b c) is considered as a term with g as a function and the rest as arguments, except for a small number of special operators, such as quote, if, ... • Thisresults in the simplest possible system, but at some expense of readability. KRE / CEL is closer to the standard notation of logic and mathematics.

  22. Lisp Systems - Data Structure (red green blue)represented as nil red green blue The e1 and t1 operations follow a pointer (but they are actually called car and cdr in Lisp) The cons operation constructs a new 'yellow' cell This was the origin of the method of garbage collection.

  23. What datastructure for KRE? • One possibility: reimplement from scratch (not a very attractive idea) • Other possibility: implement "on top of" Lisp (or another similar language). This is a standard approach in the field. Lisp is used as a "high level implementation language". • Other languages that are similar to Lisp and that are well suited for the same purpose: Scheme (also S-expression style), Python.

  24. List Processing - Recursive Functions • (length .s) == • (if [equal .s <>] 0 (+ 1 (length (t1 .s)))) • (replace .a .b .s) == • (if [equal .s .a] .b • (if [atom .s] s • (cons (replace .a .b (e1 .s)) • (replace .a .b (t1 .s)) )))

  25. Information aggregates, continuedWorking with entityfiles • Commands: • crek zoo-kb create new knowledgeblock, directory Zoo • setk zoo-kb select as current knowledgeblock • crefil animals-catal create entityfile in this block • loadfil animals-catal load the textual file into session • writefil animals-catal write back textual file from session • loadk zoo-kb loadfil zoo-kb + loadfil of its 'mustload' • For lab2a, recommended to work in 'loadfil mode': text-edit the file and load it from time to time • For some purposes the 'writefil' mode is appropriate • Directory Zoo contains entityfile zoo-kb which contains info about the other entityfiles in the knowledgeblock

  26. Small Example --------------------------------------------------------- -- demofil [: type entityfile] [: latest-written "2010-09-01/07:46.+02"] [: contents <demofil Groucho>] [: changed-since-archived t] --------------------------------------------------------- -- Groucho [: type animal] [: in-species gorilla] [: sex male] [: has-age 15] ooooooooooooooooooooooooooooooooooooooooooooooooooooooooo

  27. Small Example - Type definition --------------------------------------------------------- -- ontofil [: type entityfile] [: latest-written "2010-09-01/07:38.+02"] [: contents <ontofil animal>] [: changed-since-archived t] --------------------------------------------------------- -- animal [: type Type] [: attributes {in-species sex has-age}] ooooooooooooooooooooooooooooooooooooooooooooooooooooooooo

  28. Small Example - Technical additions --------------------------------------------------------- -- demofil [: type entityfile] [: latest-written "2010-09-01/07:46.+02"] [: contents <demofil Groucho>] [: changed-since-archived t] [: nullvalued {has-purpose has-author requires mustload leos-extension has-profile overlay-on overlay-types overlay-own leos-use dont-display sections local-ents purpose author latest-archived-entity latest-rearchived}] --------------------------------------------------------- -- Groucho [: type animal] [: in-species gorilla] [: sex male] [: has-age 15] [: latest-rearchived nil] ooooooooooooooooooooooooooooooooooooooooooooooooooooooooo

More Related