Formal Semantics for Rule-Based Systems 報告者:黃怡玲 指導教授:丁德榮.

Slides:



Advertisements
Similar presentations
Design by Contract.
Advertisements

A number of MATLAB statements that allow us to control the order in which statements are executed in a program. There are two broad categories of control.
Semantics Static semantics Dynamic semantics attribute grammars
8. Introduction to Denotational Semantics. © O. Nierstrasz PS — Denotational Semantics 8.2 Roadmap Overview:  Syntax and Semantics  Semantics of Expressions.
Annoucements  Next labs 9 and 10 are paired for everyone. So don’t miss the lab.  There is a review session for the quiz on Monday, November 4, at 8:00.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages Chapter 3 : Describing Syntax and Semantics Axiomatic Semantics.
ISBN Chapter 3 Describing Syntax and Semantics.
Compiler Construction
Comp 205: Comparative Programming Languages Semantics of Imperative Programming Languages denotational semantics operational semantics logical semantics.
Chapter 6: Design of Expert Systems
Computer Science 1620 Programming & Problem Solving.
©Ian Sommerville 2000Software Engineering, 6/e, Chapter 91 Formal Specification l Techniques for the unambiguous specification of software.
Objectives You should be able to describe:
Describing Syntax and Semantics
Chapter 1 Program Design
Introduction to C Programming
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 10 Slide 1 Formal Specification.
11 Chapter 4 LOOPS AND FILES. 22 THE INCREMENT AND DECREMENT OPERATORS To increment a variable means to increase its value by one. To decrement a variable.
Fundamentals of Python: From First Programs Through Data Structures
CC0002NI – Computer Programming Computer Programming Er. Saroj Sharan Regmi Week 7.
Fundamentals of Python: First Programs
ARTIFICIAL INTELLIGENCE [INTELLIGENT AGENTS PARADIGM] Professor Janis Grundspenkis Riga Technical University Faculty of Computer Science and Information.
Managing Software Quality
Introduction to ASMs Dumitru Roman Digital Enterprise Research Institute
CS1Q Computer Systems Lecture 8
Compiler Construction Lexical Analysis. The word lexical means textual or verbal or literal. The lexical analysis implemented in the “SCANNER” module.
Programming Language Principles Lecture 26 Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Denotational Semantics.
Chapter 06 (Part I) Functions and an Introduction to Recursion.
WXGE6103 Software Engineering Process and Practice Formal Specification.
Controlling Execution Programming Right from the Start with Visual Basic.NET 1/e 8.
6/3/2016 CSI Chapter 02 1 Introduction of Flow of Control There are times when you need to vary the way your program executes based on given input.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 4 Looping.
Section 4 - Functions. All of the programs that we have studied so far have consisted of a single function, main(). However, having more than one function.
Algorithm Design.
Chapter 3 Part II Describing Syntax and Semantics.
Programming Languages and Design Lecture 3 Semantic Specifications of Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
Formal Methods in Software Engineering Credit Hours: 3+0 By: Qaisar Javaid Assistant Professor.
An Axiomatic Basis for Computer Programming Robert Stewart.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Chapter Functions 6. Modular Programming 6.1 Modular Programming Modular programming: breaking a program up into smaller, manageable functions or modules.
Agenda Perform Quiz #1 (20 minutes) Loops –Introduction / Purpose –while loops Structure / Examples involving a while loop –do/while loops Structure /
Types and Programming Languages Lecture 11 Simon Gay Department of Computing Science University of Glasgow 2006/07.
A First Book of C++: From Here To There, Third Edition2 Objectives You should be able to describe: The while Statement cin within a while Loop The for.
A FIRST BOOK OF C++ CHAPTER 5 REPETITION. OBJECTIVES In this chapter, you will learn about: The while Statement Interactive while Loops The for Statement.
A First Book of C++ Chapter 5 Repetition.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
Think Possibility 1 Iterative Constructs ITERATION / LOOPS C provides three loop structures: the for-loop, the while-loop, and the do-while-loop. Each.
1 Program Development  The creation of software involves four basic activities: establishing the requirements creating a design implementing the code.
SAFEWARE System Safety and Computers Chap18:Verification of Safety Author : Nancy G. Leveson University of Washington 1995 by Addison-Wesley Publishing.
Copyright © 2012 Pearson Education, Inc. Chapter 5: Loops.
Chapter 5 Repetition. 2 Objectives You should be able to describe: The while Statement cin within a while Loop The for Statement The do Statement Common.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Tevfik Bultan Lecture 4: Introduction to C: Control Flow.
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
OPERATORS IN C CHAPTER 3. Expressions can be built up from literals, variables and operators. The operators define how the variables and literals in the.
Control Structures I Chapter 3
Formal Specification.
CNG 140 C Programming (Lecture set 3)
CHAPTER 4 REPETITION CONTROL STRUCTURE / LOOPING
Control Structures: Part 2
Arrays, For loop While loop Do while loop
Conditions and Ifs BIS1523 – Lecture 8.
The Metacircular Evaluator
A First Book of ANSI C Fourth Edition
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
2. Second Step for Learning C++ Programming • Data Type • Char • Float
Objectives You should be able to describe: The while Statement
CSC 1051 – Data Structures and Algorithms I
LOOPS The loop is the control structure we use to specify that a statement or group of statements is to be repeatedly executed. Java provides three kinds.
Presentation transcript:

Formal Semantics for Rule-Based Systems 報告者:黃怡玲 指導教授:丁德榮

Introductin Goal:develop a formal semantics in the denotational style for rule-based productino systems A formal description of a generalized, hypothetical language for rule-based expert systems is developed as a base. Building on this base, specifying in details the variations that distinguish individual real-world systems in a usable way.

Introductin The use of production systems in the development of a KB API has been popular since they were demonstrated in the MYCIN and R1. Fast and easy development of otherwise complex or infeasible systems. Bring a new style of programming based on the paradigm of rule-based systems. Along with many shells, environments, and languages simplified many programming tasks.

Problem However the growth in rule-based environments was not supported by any theoretical model of these system. This led to significant problems in the validation and verification of rule-based systems. The development of an exact formal description of the new language is a step toward reliable validation and verification. But focus on  the specification of the shells  inference process

A Simple Rule-Based System(1/2) The semantic system is constructed around a simple but representatve system.  A formal description of just one hypothetical rule-based language;limited. A program in this hypothetical system consists of  a collection of rules  their associated declarations.

A Simple Rule-Based System(2/2) 〈 rule 〉 → IF 〈 cond 〉 〈 acts 〉 [BECAUSE 〈 exp1 〉 ] 〈 cond 〉 → 〈 identifier 〉 | 〈 relat 〉 | 〈 cond 〉 AND 〈 cond 〉 | 〈 cond 〉 OR 〈 cond 〉 | NOT 〈 cond 〉 | ( 〈 cond 〉 ) 〈 relat 〉 → 〈 expr 〉 = 〈 expr 〉 | 〈 expr 〉 < 〈 exper 〉 ……………………

Modes and Declarations To enable type checking, a declaration is required for every variable used.  A type, a mode, and an accessibility with each identifier.

Semantics-Domains(1/3) The behavior of any rule is dependent on the current state of the system, so before the semantics of rules may be defined, a representation for the state must be selected. Identifier:name, accessibility, mode, type, value

Semantics-Domains(2/3) ID = NAME ╳ ACC ╳ MODE ╳ TYPE ╳ VAL ╳ REASON NAME=String ACC={Var,Fix} MODE={Ask,Ded} TYPE={Num,Bool,Str} VAL=Real+{True,False}+String+{Undefined} Reason=String Ex. 〈 “class”, Fix, Ask, Num, 1, “user input” 〉

Semantics-Domains(3/3) Val=undefined  is Num (x) ≡ x€Realˇx=Undefined  is Bool (x) ≡ x€{True,False}ˇx=Undefined  is Str (x) ≡ x€Stringˇx=Undefined rule= ╳ ╳ 。

Semantics- Evaluation Function E defines the result of this evaluation. It is not possible for the evaluation of any expression to result in a change to the state of the system. D check that an expression or condition is being evaluated within its domain and will not result in an invalid operation. V determines which questions may be asked of the user as a precursor to the firing of a rule. V and D determine whether a rule may be considered for firing, and E makes the final determination of firability and aids in the calculation of the effects of any rule that is fired.

Semantics-Variables(1/2) Function V: 〈 expr 〉╳ State→ (setIdentifier) provides a list of those identifiers that are required for the evaluation of an expression, but are still both undefined and askable. A AND B : A may evaluate to false, knowns in B are not necessarily required; A may evaluate to true, then unknowns of B are required. The purpose of V is to determine which questions may be asked of the user as a precursor to the firing of a rule.

Semantics-Variables(2/2) V and D together determine whether a rule may even be considered for firing, and E (applied to the rule’s condition) makes the final determination of firability and aids in the calculation of the effects of any rule that is fired.

Semantics-Selection Condition, action, reason A rule may not be fired if so doing would cause an error when evaluating the actions or the reason. A system will ask just one of the questions by before reconsidering what step to take next, by reevaluating F.

Semantics- Actions An addition to D is required to ensure the validity of a deduction. The deduction of a new value for a variable is valid only if the type of that value is the same as the declared type of the variable. A multiple action is only valid if all of its components are valid. A models the result of performing a deduction, return type of A is STATE. Assign : only if the variable already exists and has the appropriate type may an assignment take place R is a string-evaluating function used to construct reasons.

Semantics-I nitial State(1/2) F: 〈 prog 〉╳ STATE ╳ PROG → STATE ╳ PROG F(empty) s,p = 〈 s,p 〉 F(IF c: 〈 cond 〉 a: 〈 acts 〉 BECAUSE r: 〈 exp1 〉 pp: 〈 prog 〉 ) s,p = F(pp) s,(p ∪ { }) F(a: m: t: n: pp: ) s,p = if €s F(pp) [s ∪ { }],p otherwise

Semantics-I nitial State(2/2) F(a: m: t: n: =e: pp: ) s,p = if €s if D t (e) {} =False F(pp) [s ∪ { }],p otherwise

THE EXECUTION CYCLE The execution cycle of a typical system, after the initial state has been constructed. SYS is a compound of four parts:  Representing the current state  The program under execution  The user input yet to be read  The output so far produced

VARIATIONS-Evaluation of Logical Expressions(1/2) Logical expressions are subject to short- circuit evaluation; the first operand of an AND or OR operation is always evaluated if the value of the first makes it necessary. A AND B- A: False, B: undefined, short- circuit evaluation would return False, full evaluation would attempt to evaluate B and cause an error.

VARIATIONS-Evaluation of Logical Expressions(2/2) Full evaluation may be specified through some simple alterations to the functions D and V. D is changed to insist that the second operand of AND or OR is valid. V determines the set of askable variables that are essential in an expression, but still undefined.

VARIATIONS-Undefined Vaiables (1/2) The function D returns false if applied to an undefined identifier. If a run-time error is the correct behavior when an undefined identifier is used, then it is sufficient to specify ┴ as the result of lookup. A result of ┴ (“bottom”) will be propagated through any functions or operators that subsequently receive it as an operand.

VARIATIONS-Undefined Vaiables (2/2) 〈 n, a, m, t, v, r 〉 €s ^ v ≠Undefined => lookup t ( i, s)=v 〈 n, a, m,Num, v, r 〉 €s ^ v =Undefined => lookup Num ( i, s)=0 〈 n, a, m, Bool, v, r 〉 €s ^ v =Undefined => lookup Bool ( i, s)=False 〈 n, a, m, Str, v, r 〉 €s ^ v=Undefined => lookup Str ( i, s)=”“

VARIATIONS- Conflict Resolution The function Run is specified to just pick one possible firable rule, or one possible askable question. Most systems give priority to the rule that was entered first. Require four simple changes:  The domain PROG must be redefined as list (RULE) instead of set (RULE)  The initial-state-generating function F must compile the PROG as a list, replacing the U operator with a ‖.  The function F should produce a list of firable rules instead of a set.  The partial definition of Step for a nonempty set of immediately firable rules must be modified to expect a list of firable rules, and always take the first.

VARIATIONS-Refirable Rules(1/2) The specification of Step shows that a rule is removed from the program once it has fired, to prevent multiple firings and to provide a guarantee of progress during execution. However, this could result in a situation in which an application of Step to a state results in no change to that state. Run may no longer be defined as the least fixed point of Step.

VARIATIONS-Refirable Rules(2/2) Better to provide an explicit definition of Run stating that Step is repeatedly applied until there are no firable rules and no askable questions. F(p) s ={} s ={} => Run = F(p) s ≠{} s ≠{} => Run =Run(Steps )

CONCLUSION It is possible to give a complete definition of every detail of the execution of a rule-based expert system program, either for reference or to enable a proof of correctness, or complete verification and validation. Furthermore, the more subtle variations between different implementations may be clearly described as differences in the semantics.