230 likes | 247 Views
Characterization of Actions [Chapter 5] Representation Language [Chapter 2] Lab Assignment 2. Artificial Intelligence and Lisp #3. Part I: Working with action laws [Read Lecture Notes Chapter 5 for this, but read Chapter 2 first]. [Do .t [pour .fr .to]] =
E N D
Characterization of Actions [Chapter 5] Representation Language [Chapter 2] Lab Assignment 2 Artificial Intelligence and Lisp #3
Part I: Working with action laws[Read Lecture Notes Chapter 5 for this,but read Chapter 2 first]
[Do .t [pour .fr .to]] = [if [and [H- .t (substance-in: .to) empty] (not [H- .t (substance-in: .fr) Empty ])] [coact [H! .t (substance-in: .to) (cv (substance-in: .fr)) ] [H! .t (substance-in: .fr) Empty ]] [soact] ]] Effect law for pour action
Notation on previous slide • [H- time feature val] is a logical expression which is true if the value of feature at time-1 is val • [H time feature val] is a logical expression which is true if the value of feature at time is val • [H! time feature val] is a low-level “action” that assigns val as the value of feature at time
Use of effect law in simulator • Check whether precondition is satisfied • If so, execute the 'then' clause in the environment. • A composite action (coact) always takes one timestep. A sequence (soact) takes one timestep per component. • If precondition is not satisfied, then execute the 'else' clause. • Report success or failure, failed precondition, and culprit of the failure (so that the agent has a chance to fix the problem)
[Do .t [pour .fr .to]] = [if [and [H- .t (substance-in: .to) empty] (not [H- .t (substance-in: .fr) empty ])] [coact [H! .t (substance-in: .to) (cv (substance-in: .fr)) ] [H! .t (substance-in: .fr) empty ]] [soact] ]] Failed precondition as reported by simulator: [H- now (substance-in: g2) empty] Precondition for pour action
Operations done on the precondition • Evaluate precondition. If failed: • Instantiate variables (most of them) • Insert now for current time in simulated world • Identify which (one or more) of the conjuncts has the value false • Return both entire instantiated precondition, and failed conjuncts • More complicated operation if the precondition is more complicated
Agent's response to failed precondition: alternatives • Recall:[H- now (substance-in: g2) empty] • Simplest: Look up reaction in table - but based on what? • Associate reaction(s) with pattern: • [H- now (substance-in: .g) empty] • [H- now (substance-in: .g) .c] • Check postconditions of all available actions to find one with desired effect: • dispose[H! .t (substance-in: .e) empty] • Find sequence of actions (a plan) whose combined effect will be the desired one.
Operations on action expressions • Consist of expressions for precondition and for effect which are treated separately • Evaluation of precondition • Partial evaluation of precondition • Effect is ~ postcondition • Match partially evaluated precondition with postcondition/effect of another action • Send expression to another agent • Save expression for later reuse (learning)
Part II: Representation formalism[Read Lecture Notes, Chapter 2 for parts II-IV] • Requirements: • Adequate expressivity: facts, scripts, action laws • Facilitate processing in computer • Readability for humans • Conciseness - avoid multiple representations • Use available standards both from mathematics and logic, and from computer world
KRF - atomic elements • Atomic entities, e.g. Plato • Strings, e.g. ”Ursus ursus” • Numbers, e.g. 451
KRF - composite elements • Composite entities, e.g. (age-of: Plato) • Sets, e.g. {Plato Socrates} • Sequences, e.g. <Caesar Augustus Nero> • Records, e.g. [dispose :e glass4] • Maplets, e.g. [: 45 empty] • Forms, e.g. (cv (age-of: Plato)) • or (+ 2 (cv (age-of: Plato)))
Composite entities vs forms • Composite entities, e.g. (age-of: Plato) • Forms, e.g. (cv (age-of: Plato)) • or (+ 2 (cv (age-of: Plato))) • Composite entities can have attributes and values • Forms are replaced by their value during evaluation - composite entities are not
KRF - records • Records, e.g. [dispose :e glass4] • More generally: • [oper arg1 arg2... :tag1 val1 • :tag2 val2 ... ] • Alternative, equivalent: • [oper :tag1 val1 :tag2 val2 ... • ^ arg1 arg2... ]
KRF - mappings • Maplets, e.g. [: 45 empty] • Used to form mappings, e.g. • {[: 21 water] • [: 28 empty] • [: 35 beer] • [: 45 empty]}
Part III: Generic Scripting Language • Used as a basis for a range of scripting languages: • Agent Scripting Language • Document Scripting Language (for texts and web pages) • Operations Scripting Language • ...
Scripting Expressions • Action expression, record, [verb a1 a2...] • Action composition using if, soact, etc. • Feature, comp.ent., (feaop: arg1 ...) • Term, form, (function arg1 arg2 ...) • Query, form, is a kind of term • Atomic propos., record, [pred a1 a2 ...] • Composite propos., form, (and p1 p2 ...) and similarly for or, not, etc.
Part IV: Entity-files • Entity-files are used in Leonardo for persistent storage of information between sessions • In principle, each entityfile is a two-level mapping: • {[: ent-1 {[: a1 val-1-1] • [: a2 val-1-2] ...}] • [: ent-2 {[: a1 val-2-1] • [: a2 val-2-2] ...}] • ... ... }
Practical representation of entityfiles ----------------------------------- -- entity-1 [: type sometype] [: a1 “value of attribute a1 for entity-1”] [: a2 (symbfun: a5)] [: (attrfun: color) {red green}] ----------------------------------- -- entity-2 [: type sometype] [: a1 “value of attribute a1 for entity-2”] @Comment Comments may be expressed in free text, or may use a specialized notations as selected by the designer. They are preserved in textual form until processed by an application program. ooooooooooooooooooooooooooooooooooo
Entityfile facilities • Each entity in the file must have a value for the type attribute. That value must again be an entity in a file, and so on. • Entityfiles can be written and read back. • Only attributes that are included in the attributes attribute of the type are written to the file • Entities not having a value for any of the attributes of their type, are not written to file • Notice the use of properties, e.g. Comment
Some additional aspects • An entity of type section can be used for partitioning an entityfile into parts separated by a =================== line • The in-categories attribute is always optional and should have a set of entities as value • The command sortfil myfile sorts the entities in a file in alphabetical order • The name of an entityfile is always the first entity in the file
Lab 2: Defining a Zoo Miniworld • Milestone 1: static structure in the zoo world • Milestone 2: defining actions in the zoo world • What to do for the lab:
What to do for the lab(your “script”) • Read lab instructions on the course webpage: page on labserver access and lab 2 definition • Start a session with your Leonardo agent • Download lab materials from labserver using commands getlabs and getlab lab2a-kb • Do the work as specified • Make a local check using check-lab command • Upload results using upload-lab command • Await final approval