10 Pages

JNI-notes-2x2

Course: CS 2111, Fall 2009
School: Allan Hancock College
Rating:
 
 
 
 
 

Word Count: 2395

Document Preview

of School Computer Science & Engineering -- UNSW http://www.cse.unsw.edu.au/ Objectives of this presentation To explain the purpose of the Java Native Interface (JNI). To outline a procedure for producing a JNI for the C code produced by the B An Introduction to the B Method Using Native C Code with Java The Java Native Interface 2nd October 2001 c Ken Robinson 2000, 2001 Toolkit. To give a small...

Register Now

Unformatted Document Excerpt

Coursehero >> California >> Allan Hancock College >> CS 2111

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

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
of School Computer Science & Engineering -- UNSW http://www.cse.unsw.edu.au/ Objectives of this presentation To explain the purpose of the Java Native Interface (JNI). To outline a procedure for producing a JNI for the C code produced by the B An Introduction to the B Method Using Native C Code with Java The Java Native Interface 2nd October 2001 c Ken Robinson 2000, 2001 Toolkit. To give a small demonstration of an embedding of the native C code in a simple Java interface. mailto::k.robinson@unsw.edu.au 1/39 ? i P 2/39 ? i P Embedding Native C code in Java As with many programming languages it is possible to embed native C code into a Java program and use the C functions as Java methods. However, native C functions will not normally match the C functions corresponding to Java methods. The following slide illustrates the mismatch for the the implementation of The Java/Native Code Mismatch response < -- BorrowBook(user,book) C void BorrowBook(int response,int user,int book) Mismatch BorrowBook MainLibraryAPI. BorrowBook operation from The top half of the slide shows the B operation into C. and its translation The bottom half of the slide shows a possible representation of that operation as a Java method and its translation into C. There is a mismatch between the native C functions and the C code corresponding to real Java methods. JNIEXPORT void JNICALL Java LibraryJNI BorrowBook (JNIEnv env, jobject obj, jint user, jint book) C public native void BorrowBook(intuser, int book) 3/39 ? i P 4/39 ? i P The Mismatch There are number of important differences between the two C functions in the middle of the slide: What the JNI does The Java Native Interface (JNI) provides a facility for the declaration of native methods on the Java side, and a way of programming a connection between the two mismatched C functions. The following explanation will be based on the The results of the B operation are coded as a references. References aren't allowed in Java and hence there will be no way of describing these arguments in Java. MainLibraryAPI machine and its implementation. We will provide an embedding of the code generated by the B-Toolkit. The translation of the Java method has two extra arguments: one is an environment pointer, and the other is the object that owns this method. These have no counterpart in the B implementation. 5/39 ? i P 6/39 ? i P A Directory Structure The following procedure requires the building of both C and Java files and access to the C files generated by the B-Toolkit translator. For convenience, we will create a directory MainLibraryJNI.java We need to build a Java file that specifies all the native C functions that we want to use as Java native methods. In this example we use global (static) variables to implement the operation results. Another possibility would be to use an array argument and pass back results in the array. Notice that JNI at the outer level of the B development directory, and within that directory we create two directories: C and Java. Having translated the implementation of the relevant B machine, we need copies of the C files in the INI MainLibraryAPI the B-Toolkit in is the initialisation function implemented by C directory. This can be achieved simply, if there is only one MainLibraryAPI.c. to load the shared object library that implementation present, by creating soft links in the command in the C directory. Run the following Notice the call to C System.loadLibrary directory contains the compiled C functions. We will build this library in a later step. ln -s ../../CDE/C/ . 7/39 ? i P 8/39 ? i P /** GUI for the Library B development * kennys@cse.unsw.edu.au */ public class MainLibraryJNI { // global variables static int response = -1; // for register user static int newuser = -1; // for WhoBorrowed static int user = -1; // initialisation public native void INI_MainLibraryAPI(); // main operations public native void RegisterUser(); 9/39 public public public public public public public public public AcquireBook(int bookNo); ExitLibrary(int bookNo); BeginBrowseBook(int bookNo); EndBrowseBook(int bookNo); BorrowBook(int user, int bookNo); ReturnBook(int bookNo); WhoBorrowed(int bookNo); ReserveBook(int user, int bookNo); CancelBookReservation(int user, int bookNo); public native void UnCollectBook(int user, int bookNo); static { System.loadLibrary("MainLibrary"); } } native native native native native native native native native void void void void void void void void void ? i P 10/39 ? i P MainLibraryJNI.h MainLibraryJNI.java This, of course, will create should be compiled by running Understanding the B-Toolkit code We now need to move our attention to the equivalent to If you look in the javac MainLibraryJNI.java MainLibraryJNI.class MainLibraryJNI.h should then be created by running C directory and eventually MainLibraryJNI.java. build a C CDE/C directory of the B development you will find suffixes .c, .h and .g. These play the following roles: files with javah MainLibraryJNI This file should be linked into the .c: .h: .g: standard role of carrying code; defines machine parameters, constants and functions of machine; provides the instantiation of machine parameters and other constants. We will illustrate the C directory by running ln -s ../Java/MainLibraryJNI.h . in the a C directory. a .h and .g files with examples. As for all softlinks created in this process, the link should only be created once. 11/39 ? i P 12/39 ? i P MainLibraryAPI.h Perhaps the most important thing to notice are the declaration of variables extern int MainLibraryAPIP1; extern int MainLibraryAPIP2; extern int MainLibraryAPIP3; and MainLibraryAPIP1, MainLibraryAPIP2 denoting the three machine parameters of MainLibraryAPIP3 MainLibraryAPI. extern char * _MainLibraryAPI_RESPONSE []; extern char * _MainLibraryAPI_USER []; #define RESPONSE _MainLibraryAPI_RESPONSE #define USER _MainLibraryAPI_USER #define #define #define #define #define #define #define #define #define OK 1 BookInLibrary 2 LibraryFull 3 BookNotForLoan 4 BookNotOnLoan 5 BookNotAvailable 6 NotBeingBrowsed 7 InvalidReservation 8 NoNewUsers 9 ? i P 13/39 ? i P 14/39 #define #define #define #define #define #define void void void void void void void void void void void NotRegisteredUser 10 NotForCollection 11 NotReservedForUser 12 ReserveQueueFull 13 UnBorrowedBook 14 FAIL 15 void UnCollectBook(int *_response,int _user,int _book); INI_MainLibraryAPI(void); RegisterUser(int *_response,int *_newuser); AcquireBook(int *_response,int _book); ExitLibrary(int *_response,int _book); BeginBrowseBook(int *_response,int _book); EndBrowseBook(int *_response,int _book); BorrowBook(int *_response,int _user,int _book); ReturnBook(int *_response,int _book); WhoBorrowed(int *_response,int *_user,int _book); ReserveBook(int *_response,int _user,int _book); CancelBookReservation (int *_response,int _user,int _book); 15/39 ? i P 16/39 ? i P MainLibraryAPI.g Things to notice about this file: int MainLibraryAPIP1 = MainLibraryAPIPV1; int MainLibraryAPIP2 = MainLibraryAPIPV2; int MainLibraryAPIP3 = MainLibraryAPIPV3; char * _MainLibraryAPI_RESPONSE [] = { "", "OK", "BookInLibrary", "LibraryFull", "BookNotForLoan", "BookNotOnLoan", "BookNotAvailable", "NotBeingBrowsed", "InvalidReservation", "NoNewUsers", "NotRegisteredUser", "NotForCollection", "NotReservedForUser", "ReserveQueueFull", "UnBorrowedBook", "FAIL", "_RESPONSE" }; char * _MainLibraryAPI_USER [] = {"1..maxuser"}; #define user_NvarPV1 MainLibraryAPIPV1 #include "user_Nvar.g" #define LibraryDBPV1 MainLibraryAPIPV2 it contains the instantiation of machine parameters of all machines imported by the implementation of MainLibraryAPI; for all machines imported by the implementation of it includes the .g file MainLibraryAPI; as extern in the it contains the machine parameter variables of MainLibraryAPI, declared .h file. These variables are set to symbolic values, which are currently undefined. 17/39 ? i P 18/39 ? i P #define LibraryDBPV2 {"1..maxbook"} #define LibraryDBPV3 {"1..maxuser"} #include "LibraryDB.g" MainLibraryJNI.g .g files it follows that the machine parameters will not have been defined and nor will the .g files have been included for the following Given the role and usage of the machines: the top level machine, in our case any machines that are MainLibraryAPI; SEEN by any machines in the implementation. Thus, we need to build a file that the represents interface to the topmost level. This file clearly has the role of a it .g file and for want of a better name, we will call MainLibraryJNI.g. 19/39 ? i P 20/39 ? i P /** Gui for Library B development * kennys@cse.unsw.edu.au */ #define MainLibraryAPIPV1 10 #define MainLibraryAPIPV2 10 #define MainLibraryAPIPV3 5 #include "MainLibraryAPI.g" #define maxuser MainLibraryAPIPV1 #define maxlibrary MainLibraryAPIPV2 #define maxreserve MainLibraryAPIPV3 #include "LibraryDBCtx.g" #define Book_TYPEPV1 10 #include "Book_TYPE.g" #define maxbook Book_TYPEPV1 #include "Bool_TYPE.g" #include "basic_io.g" #include "file_dump.g" #include "Scalar_TYPE.g" 21/39 #include "String_TYPE.g" #include "LibraryDB_file_dump.g" ? i P 22/39 ? i P Note carefully the included files: MainLibraryJNI.c Now we can build the C file that will act as an interface between the native C functions and the C representations of the Java native methods declared in jni.h part of the JNI. stdio.h MainLibraryAPI.h MainLibraryJNI.h MainLibraryJNI.g will further include generated by B-Toolkit. generated by javah. our top-level MainLibraryJNI.java. Notice the following for each operation: .g file. The C function representing the Java method; Local variables for any results; A call of the native C function, with appropriate passing of references to result variables; jni.h jni md.h, which contains machine dependent defini- tions of various types. The use of the environment to pass any results back to the appropriate global variables. 23/39 ? i P 24/39 ? i P /** Gui for Library B development * kennys@cse.unsw.edu.au */ #include #include #include #include #include <jni.h> <stdio.h> "MainLibraryAPI.h" "MainLibraryJNI.h" "MainLibraryJNI.g" /* initialisation */ JNIEXPORT void JNICALL Java_MainLibraryJNI_INI_1MainLibraryAPI (JNIEnv *env, jobject obj) { INI_MainLibraryAPI(); } /* register user */ JNIEXPORT void JNICALL Java_MainLibraryJNI_RegisterUser (JNIEnv *env, jobject obj) { int response = 0; int newuser = 0; jclass cls = (*env)->GetObjectClass(env, obj); jfieldID fid; /* call the C method */ RegisterUser(&response, &newuser); /* set the fields to be accessed by java. */ fid = (*env)->GetStaticFieldID (env, cls, "response", "I"); (*env)->SetStaticIntField(env, cls, fid, response); fid = (*env)->GetStaticFieldID (env, cls, "newuser", "I"); (*env)->SetStaticIntField(env, cls, fid, newuser); } 25/39 ? i P 26/39 ? i P /* acquire book */ JNIEXPORT void JNICALL Java_MainLibraryJNI_AcquireBook (JNIEnv *env, jobject obj, jint book){ int response = 0; jclass cls = (*env)->GetObjectClass(env, obj); jfieldID fid; /* call the C method */ AcquireBook(&response, book); /* set the fields to be accessed by java. */ fid = (*env)->GetStaticFieldID (env, cls, "response", "I"); (*env)->SetStaticIntField(env, cls, fid, response); } /* exit library */ JNIEXPORT void JNICALL Java_MainLibraryJNI_ExitLibrary (JNIEnv *env, jobject obj, jint book){ int response = 0; jclass cls = (*env)->GetObjectClass(env, obj); jfieldID fid; /* call the C method */ ExitLibrary(&response, book); /* set the fields to be accessed by java. */ fid = (*env)->GetStaticFieldID (env, cls, "response", "I"); (*env)->SetStaticIntField(env, cls, fid, response); } 27/39 ? i P 28/39 ? i P /* BeginBrowseBook */ JNIEXPORT void JNICALL Java_MainLibraryJNI_BeginBrowseBook (JNIEnv *env, jobject obj, jint book){ int response = 0; jclass cls = (*env)->GetObjectClass(env, obj); jfieldID fid; /* call the C method */ BeginBrowseBook(&response, book); /* set the fields to be accessed by java. */ fid = (*env)->GetStaticFieldID (env, cls, "response", "I"); (*env)->SetStaticIntField(env, cls, fid, response); } /* end browse book */ JNIEXPORT void JNICALL Java_MainLibraryJNI_EndBrowseBook (JNIEnv *env, jobject obj, jint book){ int response = 0; jclass cls = (*env)->GetObjectClass(env, obj); jfieldID fid; /* call the C method */ EndBrowseBook(&response, book); /* set the fields to be accessed by java. */ fid = (*env)->GetStaticFieldID (env, cls, "response", "I"); (*env)->SetStaticIntField(env, cls, fid, response); } 29/39 ? i P 30/39 ? i P /* borrow book */ JNIEXPORT void JNICALL Java_MainLibraryJNI_BorrowBook (JNIEnv *env, jobject obj, jint user, jint book) { int response = 0; jclass cls = (*env)->GetObjectClass(env, obj); jfieldID fid; /* call the C method */ BorrowBook(&response, user, book); /* set the fields to be accessed by java. */ fid = (*env)->GetStaticFieldID (env, cls, "response", "I"); (*env)->SetStaticIntField(env, cls, fid, response); } /* return book */ JNIEXPORT void JNICALL Java_MainLibraryJNI_ReturnBook (JNIEnv *env, jobject obj, jint book){ int response = 0; jclass cls = (*env)->GetObjectClass(env, obj); jfieldID fid; /* call the C method */ ReturnBook(&response, book); /* set the fields to be accessed by java. */ fid = (*env)->GetStaticFiel...

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

Below is a small sample set of documents:

Allan Hancock College - CS - 2111
B Assignment 1Ken Robinson 28th February 2007Name of assignment: ass1 Assessment: 5 marks Submission: ~cs2111/bin/giveB ass1 CoffeeClub This assignment is intended to check that you are able to use the elementary functions of the B-Toolkit. The ass
Allan Hancock College - CS - 2111
B Assignment 2Ken Robinson 12th March 2006Name of assignment: ass2 Due date: 24th March 2006 Assessment: 5 marks max. Submission: ~cs2110/bin/giveB ass2 RailTicket1Purpose of this assignment consolidation of the notion of precondition; expans
Allan Hancock College - CS - 2111
B Assignment 3Ken Robinson 18th March 2004Name of assignment: ass3 Due date: 26th March 2004 Assessment: 5 marks max. Submission: ~cs2110/bin/giveB ass3 RailTicket1Purpose of this assignment consolidation of the notion of precondition; expans
Allan Hancock College - CS - 2111
B Assignment 2Ken Robinson 19th March 2005Name of assignment: ass2 Due date: 6th April 2005 Assessment: 5 marks max. Submission: ~cs2111/bin/giveB ass2 TravelCard1Purpose of this assignment consolidation of the notion of precondition; expansi
Allan Hancock College - CS - 2111
B Assignment 5Ken Robinson 2nd April 2004Name of assignment: ass5 Due date: 23rd April 2004 Assessment: 10 marks max. Submission: ~cs2110/bin/giveB ass5 DVDLibrary1Purpose of this assignmentPreceding assignments were concerned with invariants
Allan Hancock College - CS - 2111
B Assignment 6Ken Robinson 27th April 2004Name of assignment: ass6 Due date: May 7th 2004 Assessment: 10 marks max. Submission: ~cs2110/bin/giveB ass6 VM Note: the name of the development (VM) is unimportant1Purpose of this assignmentThis ass
Allan Hancock College - CS - 2111
B Assignment 7Ken Robinson 8th May 2004Name of assignment: ass7 Due date: 21th May 2004 Assessment: 10 marks max. Submission: ~cs2110/bin/giveB ass7 SMS Note: the name of the development (SMS) is unimportant1Purpose of this assignmentThis ass
Allan Hancock College - CS - 2111
B Assignment 8Ken Robinson 25th May 2004Name of assignment: ass7 Due date: 8th June 2004 Assessment: 8A 8 marks max. 8B 13 marks max. 8C 15 marks max. Submission: ~cs2110/bin/giveB ass8 SmallShop Note: the name of the development (SmallShop) is un
Allan Hancock College - CS - 2111
System Modelling and DesignA Simple ATM Beyond SpecificationRevision: 1.2, May 16, 2006Ken Robinson May 17, 2006c Ken Robinson 2005mailto:k.robinson@unsw.edu.auContents1 2 Objectives of this Lecture A Simplistic Model of an ATM 2.1 2.2 2.3
Allan Hancock College - CS - 2111
School of Computer Science &amp; Engineering UNSWhttp:/www.cse.unsw.edu.au/Objectives of this Lecture to introduce the concepts of renement and implementation; to introduce detail through design (renement &amp; implementations);An Introduction to the
Allan Hancock College - CS - 2111
School of Computer Science &amp; Engineering UNSWhttp:/www.cse.unsw.edu.au/Objectives of this Lecture to introduce the concepts of renement and implementation; to introduce detail through design (renement &amp; implementations);An Introduction to the
Allan Hancock College - CS - 2111
Outline Objectives of this Lecture A Simplistic Model of an ATM Refinement APPENDIX loggedin Vvar islogged VvarSystem Modelling and DesignA Simple ATM Beyond SpecificationRevision: 1.2, May 16, 2006Ken RobinsonSchool of Computer Science &amp; Engi
Allan Hancock College - CS - 2111
System Modelling and DesignA Stack Calculator: A Small Exercise in Refinement and ImplementationRevision: 1.0, May 31, 2006Ken Robinson June 8, 2006c Ken Robinson 2005mailto:k.robinson@unsw.edu.auContents1 Objectives of this Lecture 1.1 1.2
Allan Hancock College - CS - 2111
Objectives of this LectureSystem Modelling and DesignA Stack Calculator: A Small Exercise in Refinement and ImplementationRevision: 1.0, May 31, 2006Ken RobinsonSchool of Computer Science &amp; Engineering The University of New South Wales, Sydney
Allan Hancock College - CS - 2111
System Modelling and DesignMachine CompositionRevision: 1.3, August 26, 2005Ken Robinson 26th August 2005c Ken Robinson 2005mailto:k.robinson@unsw.edu.auContents1 INCLUDES 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2 Include Once Only . . . . . .
Allan Hancock College - CS - 2111
School of Computer Science &amp; Engineering - UNSWhttp:/www.cse.unsw.edu.au/Objectives of this lectureTo introduce the constructs offered by B for composing machines. To discuss the rules and restrictions imposed by the different composition constru
Allan Hancock College - CS - 2111
Name: Student Id:THE UNIVERSITY OF NEW SOUTH WALES Final ExaminationJune 2004COMP2110 Software System SpecicationTime allowed: 1.5 hours Total number of questions: 30 Questions are not necessarily of equal value. Questions must be answered in
Allan Hancock College - CS - 2111
Name: Student Id:THE UNIVERSITY OF NEW SOUTH WALES Sample ExaminationJune 2007COMP2111 System Modelling and DesignTime allowed:1 hours 20Total number of questions: Questions are Questions must be answerednot necessarilyof equal value.
Allan Hancock College - CS - 2111
System Modelling and DesignIntroduction to the B Method and B ToolkitRevision: 1.1, March 3, 2007Ken Robinson March 3, 2007c Ken Robinson 2005mailto:k.robinson@unsw.edu.auContents1 2 B Mathematical Toolkit Set Theory 2.1 2.2 3 Relations . .
Virgin Islands - SENG - 130
SENG130 S01 EXAM REVIEW Exam: Tuesday, April 24 ECS104, 2:00pm 1. HTTP Requests and Responses a. Write a GET request with 2 headers of your choice. Explain what those headers are for. Have your GET request also pass a value of user and a key o
Allan Hancock College - CS - 2111
Outline B Mathematical Toolkit Set Theory Predicate Calculus Notation The B-Toolkit A Simple Model Modelling a Coffee Club Specifying a Robust machine A Question of IdenSystem Modelling and DesignIntroduction to the B Method and B ToolkitRevision
Virgin Islands - SENG - 130
SENG130 Assignment 3: HTML, Javascript and JSP Due: Monday, April 14 by 5:30pm.1. Write a web application in JSP. Your application is a music suggestion service. If a user logs in, they should choose their a genre of music in a main navigation bar.
Allan Hancock College - CS - 2111
System Modelling and DesignIntroductionRevision: 1.3, March 3, 2007Ken Robinson March 3, 2007c Ken Robinson 2005mailto:k.robinson@unsw.edu.auContents1 Introduction 1.1 1.2 1.3 1.4 2 What is this course about? . . . . . . . . . . . . . . . .
Virgin Islands - SENG - 130
SENG130 Assignment 4: BONUS Due: Monday, April 21 by 5:30pm.1. You must design a Web Application that you think is innovative and different that what sites are currently offering. You must create a proof of concept of this site including the followi
Allan Hancock College - CS - 2111
Outline Introduction Software ModellingSystem Modelling and DesignIntroductionRevision: 1.1, February 22, 2006Ken RobinsonSchool of Computer Science &amp; Engineering The University of New South Wales, Sydney AustraliaMarch 9, 2006c Ken Robinso
Virgin Islands - SENG - 130
SENG130 Assignment 2: Extended Web Server Due: Thurs., April 3rd IN CLASS.1. Write a non-persistant stateless web server in Java that will listen to a designated port according to the following specifications (note: this is a proper extension of you
Allan Hancock College - CS - 2111
System Modelling and DesignAn Introduction to ModellingRevision: 1.2, May 19, 2004Ken Robinson 1st March 2005c Ken Robinson 2005mailto:k.robinson@unsw.edu.auContents1 2 Prelude Modelling: Why? and What? 2.1 2.2 3 Why? . . . . . . . . . . .
Virgin Islands - SENG - 130
SENG130 Assignment 1: Simple Socket Echo Server Due: Thurs., February 28 IN CLASS.1. Write a persistent stateless server in Java that will listen to a designated port according to the following specifications (note: this is a proper extension of you
Allan Hancock College - CS - 2111
Outline Prelude Modelling: Why? and What? Software ModellingSystem Modelling and DesignAn Introduction to ModellingRevision: 1.2, May 19, 2004Ken RobinsonSchool of Computer Science &amp; Engineering The University of New South Wales, Sydney Austra
Allan Hancock College - CS - 2111
School of Computer Science &amp; Engineering - UNSWhttp:/www.cse.unsw.edu.au/An Introduction to the B Method An OverviewRevision: 1.2, March 5, 2003Introduction to BIn this course we will be introducing you to the formal method, whose full name is
Allan Hancock College - CS - 2111
School of Computer Science &amp; Engineering - UNSWhttp:/www.cse.unsw.edu.au/An Introduction to the B Method An OverviewRevision: 1.2, March 5, 2003c Ken Robinson mailto:k.robinson@unsw.edu.auIntroduction to BIn this course we will be introducin
Allan Hancock College - CS - 2111
School of Computer Science &amp; Engineering - UNSWhttp:/www.cse.unsw.edu.au/An Introduction to the B Method An OverviewRevision: 1.2, March 5, 2003c Ken Robinson mailto:k.robinson@unsw.edu.auIntroduction to BIn this course we will be introducin
Allan Hancock College - CS - 2111
School of Computer Science &amp; Engineering - UNSWhttp:/www.cse.unsw.edu.au/An Introduction to the B Method An OverviewRevised 5th March 2001Ken Robinsonmailto:k.robinson@unsw.edu.auk.robinson@unsw.edu.auAn Introduction to BIn this course we w
Allan Hancock College - CS - 2111
School of Computer Science &amp; Engineering UNSWhttp:/www.cse.unsw.edu.au/Objectives of this lectureThe two concepts ofpreconditionsandguardsare frequently confused, butin this lecture we will attempt to show that they are very dierent. I
Allan Hancock College - CS - 2111
School of Computer Science &amp; Engineering UNSWhttp:/www.cse.unsw.edu.au/An Introduction to the B Method Preconditions and GuardsRevised 27th March 2001Ken Robinsonmailto:k.robinson@unsw.edu.auk.robinson@unsw.edu.auObjectives of this lecture
Allan Hancock College - CS - 2111
System Modelling and DesignAn Introduction to the B Method Proof: Discharging Proof ObligationsRevision: 1.5, April 18, 2007Ken Robinson April 19, 2007c Ken Robinson 2005mailto:k.robinson@unsw.edu.auContents1 2 Objectives of this Lecture Pr
Allan Hancock College - CS - 2111
School of Computer Science &amp; Engineering UNSWhttp:/www.cse.unsw.edu.au/Objectives of this lectureTo understand the basic ideas of discharging proof obligations. To understand the use of inference rules, for forward or backward inference. To gain
Allan Hancock College - CS - 2111
Outline Objectives of this Lecture Prover Rules But the proof rules may be wrong!System Modelling and DesignAn Introduction to the B Method Proof: Discharging Proof ObligationsRevision: 1.5, April 18, 2007Ken RobinsonSchool of Computer Science
Allan Hancock College - CS - 2111
System Modelling and DesignRenement Towards ImplementationRevision: 1.2, October 20, 2006Ken Robinson May 10, 2007c Ken Robinson 2005mailto:k.robinson@unsw.edu.auPart IInformal notions of renementContentsI1Informal notions of renement
Allan Hancock College - CS - 2111
System Modelling and DesignRefinement Towards ImplementationRevision: 1.2, October 20, 2006Ken RobinsonSchool of Computer Science &amp; Engineering The University of New South Wales, Sydney AustraliaMay 10, 2007c Ken Robinson 2005mailto:k.robin
Allan Hancock College - CS - 2111
School of Computer Science &amp; Engineering UNSWhttp:/www.cse.unsw.edu.au/Modelling sequences using setsReminder:sets are an aggregate structure possessing neitherorderingnormulitplicity.Sets have onlymembership. orderingand multiplicit
Allan Hancock College - CS - 2111
School of Computer Science &amp; Engineering UNSWhttp:/www.cse.unsw.edu.au/Index Predicate Logic Set TheoryAn Introduction to the B Method Set TheoryRevision: 1.2, March 12, 2002 Relations Functions Sequences Substitutionsc Ken Robinson
Allan Hancock College - CS - 2111
School of Computer Science &amp; Engineering - UNSWhttp:/www.cse.unsw.edu.au/An Introduction to the B Method Set TheoryRevision: 1.2, March 12, 2002c Ken Robinsonmailto:k.robinson@unsw.edu.au1/104?iPIndex Predicate Logic Set Theory R
Allan Hancock College - CS - 2111
School of Computer Science &amp; Engineering - UNSWhttp:/www.cse.unsw.edu.au/An Introduction to the B Method Set TheoryRevision: 1.2, March 12, 2002c Ken Robinsonmailto:k.robinson@unsw.edu.auIndex Predicate Logic Set Theory Relations Functi
Washington - FE - 450
List of TablesTable 3.1 Table 3.2 Table 3.3 Table 4.1 Table 4.2 Table 6.1 Table 6.2 Table 6.3 Table 6.4 Table 6.5 Table 7.1 Table 7.2 Table 7.3 Table 7.4 Table 7.5 Table 7.6 Table 7.7 FVS growth outputs by ten year period. General pattern of silvicu
Allan Hancock College - CS - 2111
Specification Using BB Method Overview/1Specification Using BB Method Overview/2Specification Using BWhat do we mean by Formal Methods?B Method OverviewIn our use of the term Formal Methods we mean the application of mathematics (set the
Washington - FE - 450
UNIVERSITY OF WASHINGTONCollege of Forest Resources Seattle WA 98195List of Participants The following Senior Forest Engineering and Forest Management students participated in the 1997 Spring Field Studies program for the Toutle planning area and
Allan Hancock College - CS - 2111
Specification Using BA Simple Library/1Specification Using BA Simple LibraryKen RobinsonSchool of Computer Science and Engineering University of New South Wales Sydney Australia2000 Ken RobinsonSession One 2000B@UNSWSession 1 2000/
American - BUAD - 651
Revised Representative SQL statements for Employee DatabaseSELECT Employees.[Last Name], Employees.[First Name], Employees.[Hourly Rate] FROM Employees WHERE Employees.[Hourly Rate] &gt; 12; SELECT Employees.[Last Name], Employees.State FROM Employees
Allan Hancock College - CS - 2111
Specication Using BPreconditions and Guards/1Specication Using BPreconditions and GuardsKen RobinsonSchool of Computer Science and Engineering University of New South Wales Sydney Australia 2000 Ken RobinsonSession One 2000B@UNSWSessio
Allan Hancock College - CS - 2111
Specification Using BTraffic Lights/1Specification Using BTraffic Lights/2Specification Using BA simple 4-way intersectionTraffic LightsConsider traffic lights at the intersection of two roads, one running North-South and the other East
Allan Hancock College - CS - 2111
Specification Using BPreconditions and Guards Revisited/1Specification Using BPreconditions and Guards Revisited/2Specification Using BPreconditions and Guards Revisited/3Specification Using BPreconditions and Guards Revisited/4Specif
Allan Hancock College - CS - 2111
Specification Using BGeneralised Substitutions and Proof Obligations/1Specification Using BGeneralised Substitutions and Proof Obligations/2Specification Using BThe Simple SubstitutionThe simple substitution x := E changes the state by rep
Allan Hancock College - CS - 2111
Solutions to B Exercises 1 SetsThe following sets are used in the exercises: NAMES PHONE = {Jack , Jill };= {123, 456, 789}1. In this question you will be dealing with products, or sets of pairs. Instead of writing a pair as (a, b), which is pro
Allan Hancock College - CS - 2111
Solutions to B Exercises 2 Generalised Substitutions and Proof ObligationsGiven, the proof obligation for maintaining the machine invariant for the operation: result - Op(args) = PRE P THEN G END is I P [G] I where I is the state invariant. 1. The
Allan Hancock College - CS - 2111
Solutions to B Exercises 6 Refinement1. The general concept of refinement can be expressed using the second order predicate calculus. Let's use SA SC to mean SA is refined by SC . Then we can say SA SC P .([SA ](P ) [SC ](P )This is second orde
Allan Hancock College - CS - 2111
System Modelling and DesignStructuring Specications A Library Case StudyRevision: 1.2, April 25, 2007Ken Robinson May 2, 2007c Ken Robinson 2005mailto:k.robinson@unsw.edu.auContents1 2 3 Objectives of this lecture A Small library developmen
Allan Hancock College - CS - 2111
School of Computer Science &amp; Engineering UNSWhttp:/www.cse.unsw.edu.au/An Introduction to the B Method Structuring Specications: A Case StudyRevision: 1.5, June 30, 2003c Ken Robinson mailto:k.robinson@unsw.edu.auObjectives of this lectureT
Allan Hancock College - CS - 2111
Outline Objectives of this lecture A Small library development What is a book? User Services Book reservation Browsing Books in the Library Preparing for a Robust machine ISystem Modelling and DesignStructuring Specifications A Library Case Study
Allan Hancock College - CS - 2111
System Modelling and DesignGeneralised Substitutions and Proof ObligationssRevision: 1.1, November 16, 2005Ken Robinson March 8, 2006c Ken Robinson 2005mailto:k.robinson@unsw.edu.auContents1 Assigning Meanings to Programs 1.1 1.2 1.3 1.4 1.
Allan Hancock College - CS - 2111
School of Computer Science &amp; Engineering - UNSWhttp:/www.cse.unsw.edu.au/Objectives of this lectureTo introduce the idea of asubstitutions and in particular the Generalised Substitution Language (GSL), which is the basis of B. GSL.To show the