<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="http://nt-appn.comp.nus.edu.sg/fm/zml/objectzed.xsl"?>
<!DOCTYPE unicode SYSTEM "http://nt-appn.comp.nus.edu.sg/fm/zml/unicode.dtd">
<objectZnotation xmlns="x-schema:objectZschema.xml" xmlns:HTML="http://www.w3.org/Profiles/XHTML-transitional">
	<description align="center">This is a BirthdayBook specification example.</description>
	<description align="left">{Some remarks about the display:  Use
IE5 for browsing, it supports XSL; For the display of mathematical
symbols, please install Unicode font (<link name="Arial Unicode MS" href="http://www.hclrss.demon.co.uk/unicode/fonts.html#arialunicodems"/>, also
provided in the Office 2000), after the installation make sure to set the
Unicode font as your Web page font; If the page could not be displayed
properly (for some IE5, we encountered the same problem before), please
update your IE5 to the new <link name="IE5.5" href="http://www.microsoft.com/windows/ie/download/ie55sp1.htm"/> 
version. If you have any problem or suggestion about the 
demo, please feel free to write to <link name="us" href="mailto:dongjs@comp.nus.edu.sg"/>. Thank you.}
	</description>
	<tydef align="left">
		[<name>DATE</name>,<name>NAME</name>]
	</tydef>
	<!--<description align="left">The BirthdayBook schema defines the state space of the birthday book system.</description>-->
	<tydef align="left">
		<name>REPORT</name> == 
	ok &bbar; already_known &bbar; not_known
	</tydef>
	<!--<description align="left">First we define auxiliary schemas that capture various success and error cases.</description>
-->
	<schemadef layout="simpl" align="left">
		<name>BirthdayBook</name>
		<decl>
			<name>known</name>
			<dtype>&pset; <type>NAME</type>
			</dtype>
		</decl>
		<decl>
			<name>birthday</name>
			<dtype>
				<type>NAME</type> &tfun; <type>DATE</type>
			</dtype>
		</decl>
		<st/>
		<predicate>known = &dom; birthday</predicate>
	</schemadef>
	<!--<description align="left">This InitBirthdayBook specifies the initial state of the birthday book system.  It does not say explicitly that birthday is empty, but that is implicit, because its domain is empty.</description>-->
	<schemadef layout="simpl" align="left">
		<name>InitBirthdayBook</name>
		<incl>
			<type>BirthdayBook</type>
		</incl>
		<st/>
		<predicate>known = &emptyset;</predicate>
	</schemadef>
	<!--<description align="left">Next we have several operation schemas to define the normal (non-error) behaviour of the system.</description>-->
	<schemadef layout="simpl" align="left">
		<name>AddBirthday</name>
		<del>
			<type>BirthdayBook</type>
		</del>
		<decl>
			<name>name?</name>
			<dtype>
				<type>NAME</type>
			</dtype>
		</decl>
		<decl>
			<name>date?</name>
			<dtype>
				<type>DATE</type>
			</dtype>
		</decl>
		<st/>
		<predicate>name? &nem; known</predicate>
		<predicate>birthday' = birthday &uni; {(name?, date?)}</predicate>
	</schemadef>
	<schemadef layout="simpl" align="left">
		<name>RemoveBirthday</name>
		<del>
			<type>BirthdayBook</type>
		</del>
		<decl>
			<name>name?</name>
			<dtype>
				<type>NAME</type>
			</dtype>
		</decl>
		<st/>
		<predicate>name? &mem; known</predicate>
		<predicate>birthday' = {name?} &dsub; birthday</predicate>
	</schemadef>
	<schemadef layout="calc" align="left">
		<name>ModifyBirthday</name>
		<predcalc op="com">
			<type>RemoveBirthday</type>
			<type>AddBirthday</type>
		</predcalc>
	</schemadef>
	<!--<description align="left">Note that the ModifyBirthday operation is a compostion of the RemoveBirthday and AddBirthday operations.</description>-->
	<schemadef layout="simpl" align="left">
		<name>FindBirthday</name>
		<xi>
			<type>BirthdayBook</type>
		</xi>
		<decl>
			<name>name?</name>
			<dtype>
				<type>NAME</type>
			</dtype>
		</decl>
		<decl>
			<name>date!</name>
			<dtype>
				<type>DATE</type>
			</dtype>
		</decl>
		<st/>
		<predicate>name? &mem; known</predicate>
		<predicate>date! = birthday(name?)</predicate>
	</schemadef>
	<schemadef layout="simpl" align="left">
		<name>Remind</name>
		<xi>
			<type>BirthdayBook</type>
		</xi>
		<decl>
			<name>today?</name>
			<dtype>
				<type>DATE</type>
			</dtype>
		</decl>
		<decl>
			<name>cards!</name>
			<dtype>&pset;<type>NAME</type>
			</dtype>
		</decl>
		<st/>
		<predicate>cards! = {n : known | birthday(n) = today?}</predicate>
	</schemadef>
	<!--<description align="left">Now we strengthen the specification by adding error handling.</description>-->
	<schemadef layout="simpl" align="left">
		<name>Success</name>
		<decl>
			<name>result!</name>
			<dtype>
				<type>REPORT</type>
			</dtype>
		</decl>
		<st/>
		<predicate>result! = 'ok'</predicate>
	</schemadef>
	<schemadef layout="simpl" align="left">
		<name>AlreadyKnown</name>
		<xi>
			<type>BirthdayBook</type>
		</xi>
		<decl>
			<name>name?</name>
			<dtype>
				<type>NAME</type>
			</dtype>
		</decl>
		<decl>
			<name>result!</name>
			<dtype>
				<type>REPORT</type>
			</dtype>
		</decl>
		<st/>
		<predicate>name? &mem; known</predicate>
		<predicate>result! = 'already_known'</predicate>
	</schemadef>
	<schemadef layout="simpl" align="left">
		<name>NotKnown</name>
		<xi>
			<type>BirthdayBook</type>
		</xi>
		<decl>
			<name>name?</name>
			<dtype>
				<type>NAME</type>
			</dtype>
		</decl>
		<decl>
			<name>result!</name>
			<dtype>
				<type>REPORT</type>
			</dtype>
		</decl>
		<st/>
		<predicate>name? &nem; known</predicate>
		<predicate>result! = 'not_known'</predicate>
	</schemadef>
	<!--<description align="left">Finally, we define robust versions of all the operations by specifying how errors are handled.</description>-->
	<schemadef layout="calc" align="left">
		<name>RAddBirthday</name>
		<predcalc op="or">
			<predcalc op="and">
				<type>AddBirthday</type>
				<type>Success</type>
			</predcalc>
			<type>AlreadyKnown</type>
		</predcalc>
	</schemadef>
	<schemadef layout="calc" align="left">
		<name>RFindBirthday</name>
		<predcalc op="or">
			<predcalc op="and">
				<type>FindBirthday</type>
				<type>Success</type>
			</predcalc>
			<type>NotKnown</type>
		</predcalc>
	</schemadef>
	<schemadef layout="calc" align="left">
		<name>RRemind</name>
		<predcalc op="and">
			<type>Remind</type>
			<type>Success</type>
		</predcalc>
	</schemadef>
	<schemadef layout="calc" align="left">
		<name>RModifyBirthday</name>
		<predcalc op="and">
			<type>ModifyBirthday 
</type>
			<type>Success</type>
		</predcalc>
	</schemadef>
</objectZnotation>
