0

how can i specify a mathematical expression using Z notation ? I think free types is appropriate for this situation because expressions has a recursive nature. please consider that we can have parenthesis and variables in our expression. and only ( + , - , / , * ) is allowed. for example : A + 2 * ( 3 - B ) / 4

please help me ...

Armin Balalaie
  • 591
  • 1
  • 5
  • 17

1 Answers1

0

You need to use the axiomatic definition: the definition of an object is constrained by conditions.

There is a schema specified in zet for this. Which is

| Declaration
------------------------------
| Predicate
|
|

A recursive example given:

[USERNAME] - An already defined type.

Given a username and a sequence of usernames(N1 --> USERNAME) return the number that the given username appears into the sequence.

|-occurs- USERNAME X seq USERNAME → N //here you define the input and what is returned.
---------------------------------------
|∀ u: USERNAME, s: seq USERNAME then
|s = < > => occurs(u,s) = 0
|s ≠ < > and head(s) = u => occurs(u,s) = 1+occurs(u,tail(s))
|s ≠ < > and head(s) ≠ u => occurs(u,s) = occurs(u,tail(s))
nmargaritis
  • 859
  • 7
  • 21