TLA + "Specifying Systems" draft translation --Section 6.2 Silly Expressions (stupid expression)

Most modern programming languages ​​will introduce some form of type checking to prevent you write stupid expression, for example, 3 / " a b c " 3/"abc" . TLA + is not based on the type of formal language mathematicians introduced in untyped language, the correct syntax for each expression has its own meaning, even as 3 / " a b c " 3/"abc" stupid such expression. Mathematically, the expression 3 / " a b c " 3/"abc" than the expression 3 / 0 3/0 more stupid, and mathematicians have been implicitly write those stupid expression. For example, consider the formula x R e a l : ( x 0 ) ( x 3 / x ) = 3 ) \forall x \in Real:(x\neq0) \Rightarrow(x*3/x)=3) , where R e a l Real is the set of real numbers, the equation statement ( x 0 ) ( x 3 / x ) = 3 ) (x\neq0) \Rightarrow(x*3/x)=3) arbitrary real number of x x are established. will x = 0 x=0 into the formula, the resulting ( 0 0 ) ( 0 3 / 0 ) = 3 ) (0\neq0) \Rightarrow(0*3/0)=3) , included here stupid expression 3 / 0 3/0 . This expression is true, because 0 0 0 \ neq 0 is false, F A L S E P FALSE \Rightarrow P for any expression P P are established (The operator contains \Rightarrow definition).

A correct formula can contain stupid expression, for example, 3 / 0 = 3 / 0 3/0=3/0 is a correct formula, since all values are equal to itself. However, a correct formula depends on the meaning of true value can not be stupid expression. If an expression is stupid, then its value may not be clear. Standard module R e a l Real / * and the definition does not include 0 ( 3 / 0 ) 0*(3/0) , so that it could not tell whether the value is equal to 3.

You can write 3 / 0 3/0 , you can write perfectly reasonable expression, without any proper grammar rules to stop you. In general mathematics, there is no written rule like programming language like that, there are limitations complicated. In a well-designed programming language, type checking costs and benefits balance will consider: the introduction of the type that allows the compiler to generate more efficient code, but you can catch the error type checking. For the programming language, earnings seem to outweigh the costs. When writing TLA + specification, I found the costs outweigh the benefits.

If you are accustomed to the shackles of the programming language, so it may take a while to start enjoying the freedom given to mathematics. First of all, you do not think of as in Section 5.2 on page 50, defined operator R is defined as anything that is defined way, in a type of programming language does not appear.

发布了4 篇原创文章 · 获赞 1 · 访问量 5529

Guess you like

Origin blog.csdn.net/robinhzp/article/details/103541566