On Wed, Nov 08, 2023 at 11:51:12AM +1100, Hill Strong wrote:
> In terms of defining any kind of variable, the language and its associated
> semantics should have a [bottom] value. Interestingly, FriCAS does have
> such a value defined. However, what is not clear is whether this [bottom]
> can serve for all domains.
> 
> There are a couple of alternatives here. One is that every domain has its
> own [bottom] value seperate from all other domains. Another is that all
> domains inherit the same [bottom] value.
> 
> I am in the process of looking at the FriCAS language to see where the
> semantic definition is either problematic or not defined. There appears to
> be quite a number of such things to fix. Reading the various threads shows
> that some serious language definitions are required.

Well, 'bottom' may be used in _description_ of semantics of a language.
There are many approches to describing semantics.  One approach that
I like and I think fits well to FriCAS is axiomatic approach.
In this approach we have logical formulas associated with states
and each piece of code have two related formulas: precondition
and postcondition with meaning that if precondition is satisfied
then code will execite succesfuly and finish satisfying postcondition.
Theoretically, only precondition is neccesay, as one can replace
postcondition by appropriate code.  Also, theory is nicer when
using infinitary logic, but practical approach uses clasical
(finite) logic.

Fundamental part of this apprach is that when precondition is not
satisfied, then there is no warranty, anything can happen: program
may crash, computer may explode or something else bad may happen.
Some people are unhappy about consequences of failed precondition
and invent formalizms where everthing is "defined", such formalizms
miss important property is real world languages and are not
appropriate to describe FriCAS.

Concerning uninitialized variables: it is convenient to use
special "bad" values (say 'bottom') to "mark" uninitialized
variables.  That way statement 'a is initialized' can be
written as 'a \ne bottom'.  But note that such 'bottom' by
neccessity is _not_ a valid value of variable: initialized
variable can not have 'bottom' as its value.  So here
'bottom' is purely virtual: does not exist in reality and
can not be value of any type.

Some people want to eliminate uninitialized variables by
providing default initialization, say to 0 or to 'botton'.
However, this replaces problem of uninitialized variables
by problems of wrongly uninitialized variables.  Wrong
initialization is at least as bad as lack in initialization,
so in practice this in not very useful.  If variables are
initialized to 'bottom' and attempts to use 'bottom'
in computations are detected, then this may help in
finding uses of uninitialized variables.  However, such
approach is costly at runtime, so not appropriate for
high perfomance software.

-- 
                              Waldek Hebisch

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/ZUsAUrV8%2BSI51M3K%40fricas.org.

Reply via email to