# Syntax of The Formal Specification Language Z

## MATHS

This document is prepared using the MATHS notation [ math.syntax.html ] and a goal for Dr. Botting's MATHS project is to get the power of Z without the baggage of TeX. This notation is used in this document and is called MATHS.

When used for syntax it close enough to EBNF to be called XBNF. The following special forms are used in syntax

1. L(X,Y)::=X #(Y X), list of X's separated by Ys.
2. List(X)::=X #("," X), list of X's separated by Ys.
3. #X::=any number of X including none.
4. O(X)::= (|X), optional X.
5. definer::= ":" ":" "=", two colons and an equalsign.
6. EOLN::=end of line.

## Lexicon

Z depends on the being able to express mathematical style formulae. As a result it is either hand written or prepared using TeX and/or a special font. The special fonts for MS Windows and Macintoshes and the TeX style. [ comp.text.TeX.html ] [ comp.text.ASCII.html ]

*New* Proposed standard lexemes for ASCII/EMail: [ z.lexis.html ]

There is a computerized code developed at York University England and tools that translate that into TeX.

## Grammar

The following is based on [Spivey89]
7. Specification::= L(Paragraph, EOLN).
8. Paragraph::= Declare_generic_sets| Box | Schema_Name O( Gen_Formals) Define_symbol Schema_exp | Def_Lhs "==" Expression | Ident definer L(Branch, "|") | Predicate.
9. Declare_generic_sets::= "[" List(Ident) "]" .
10. Box::= Axiomatic_Box | Schema_Box | Generic_Box.
11. Define_symbol::=equals sign with circumflex accent.

12. Axiomatic_box::= start_axiom Decl_part Possible_Axioms end_axiom.
13. Possible_Axioms::=O( EOLN such_that EOLN Axiom_part).

Email Form

  	+..
  	  Decls
  	|--
  	  Axioms
  	-..
It looks like this:
 	| Decls
 	|-------
 	| Axioms

14. Schema_Box::= start_schema Schema_Name O(Gen_Formals) dash EOLN Decl_Part Possible_Axioms end. Email Form
  	+-- Name ---
  	  Decls
  	---
 giving
 	 -------Name----------
 	| Decls
 	 --------------
or
  	+-- Name ---
  	  Decls
  	|--
  	  Axioms
  	---
giving this kind of thing:
 	 -------Name----------
 	| Decls
 	|--------------
 	| Axioms
 	 ----------------------

15. Generic_Box::= start_generic O(Gen_Formals) double_dash EOLN vertical_bar Decl_Part Possible_Axioms.

Email:

  	+== [Para] ===
  	  Decls
  	|--
  	  Axioms
  	-==

giving this kind of thing:

 	 ======[Para]======
 	| Decls
 	|------------
 	| Axioms
 	 ------------

16. Decl_Part::= L(Basic_Decl, Sep).
17. Axiom_Part::=L(Predicate, Sep).
18. Sep::= ";" | EOLN.

19. Def_Lhs::= Var_name O(Gen_Formals) | Pre_Gen Ident | Ident In_Gen Ident.

20. Branch::= Ident | Var_Name French_open_quotes Expression French_close_quotes.

21. Schema_Exp::= (for_all | for_some | for_one ) Schema_text big_dot Schema_Exp | Schema_Exp_1.
22. Schema_Exp_1::= "[" Schema_Text "]" | Schema_Ref | IBM_not Schema_Exp_1 | Schema_Exp_1 infix_operator Schema_Exp_1 | Schema_Exp_1 "\" "(" List(Decl_Name) ")" | "(" Schema_Exp ")"
23. infix_operator::= and| or| implies| iff| hide| rename| schema_compose.
Name EMailTeXMATHS
and /\\landand
or \/\loror
implies==>\implies
iff <=>\iffiff
hide |\vbar
rename \?
compose%%;bbfont semicolon

I've chosen to model infix operators as a map that associates the syntax with its priority and associativity:

24. infix_properties::=following
Net
1. binding_power::Nat.
2. associativity::{left,right}.

(End of Net)
25. Infix::infix_operator->infix_properties. Infix= and+>(7, left) | or+>(6, left) | implies+>(5, right) | iff+>(4, left) | hide+>(3, left) | rename+>(2, left) | schema_compose+>(1, left).

26. Schema_Text::= Declaration O(bar Predicate).

27. Schema_ref::= Schema_Name Decoration O(Gen_Actuals).

28. Declaration::= L(Basic_Decl, ";").
29. Basic_Decl::= List(Decl_name)":" Expression | Schema_ref.

30. Predicate::= (for_all | for_some | for_one ) Schema_text big_dot Predicate | Predicate_1.

31. Predicate_1::=L(Expression Rel) |Prefix_Rel Expression | Schema_Ref | "pre" Schema_ref | "true" | "false" IBM_not Predicate_1 | Predicate_1 infix_operator Predicate_1 | "(" Predicate ")".

32. Rel::= "=" | \in | Infix_Rel.

33. Expression_0::= \lambda Schema_Text big_dot Expression | \mu Schema_Text O(big_dot Expression) | Expression.

34. Expression::= Expression Infix_Gen Expression | L(Expression_1, cross) | Expression_1.

35. Expression_1::= Expresssion Infix_Fun Expression | \powset Expression_3 | Prefix_Gen Expression_3 | minus Expression_3 | Expression_3 Postfix_Fun | Expression_3 superscript(Expression) | expression_3 left_barred_paren Expression_0 right_barred_paren | Expression_2.

36. Expression2::= Expression_2 Expression_3 | Expression_3.

37. Expression_3::= Var_Name O(Gen_Actuals) | Number | Schema_Ref | Set_Expresssion | left_diamond_bracket O(List(Expression)) right_diamond_bracket | left_double_bracket L(Expression) right_double_bracket | \theta Schema_Name Decoration | Expression_3 "." Var_Name | left_paren Expression_0 right_paren.

38. Set_Exp::= left_brace L(Expression) right_brace | left_brace Schem_Text O(big_dot Expression) right_brace.

39. Ident::= Word Decoration.

40. Decl_Name::= Ident | Op_name.
41. Var_Name::= Ident | left_paren Op_Name right_paren.

42. Op_name::= "_" Infix_Sym "_" | Prefix_Sym "_" | "_" Post_Sym | "_" left_barred_paren "_" right_barred_paren | "_".

43. Infix_Sym::= Infix_Fun | Infix_Gen | Infix_Rel.
44. Prefix_Sym::= Prefix_Gen | Prefix_Rel.

45. Gen_Formals::= "[" List(Ident) "]".
46. Gen_Actuals::= "[" List(Expression) "]".

47. Word::@lexeme=undecorated name of special symbol.
48. Stroke::@lexeme= "'" | "?" | "!" | subscript_digit.
49. Decoration::@lexemes=It may be the same as a Stroke?, [click here if you can fill this hole]

50. Infix_Fun::@lexeme=Infix function symbol.
51. Infix_Rel::@lexeme=Infix relation symbol.
52. Infix_Gen::@lexeme=Infix generic symbol.
53. Prefix_Gen::@lexeme=prefix generic symbol.
54. Prefix_Rel::@lexeme=prefix relation symbol.
55. Postfix_Fun::@lexeme=postfix function symbol.
56. Number::=unsigned decimal integer.

. . . . . . . . . ( end of section Syntax of The Formal Specification Language Z) <<Contents | Index>>