Whiley / RFCs

Request for Comment (RFC) proposals for substantial changes to the Whiley language.
3 stars 2 forks source link

Unknown Values #78

Open DavePearce opened 4 years ago

DavePearce commented 4 years ago

(see also #35)

Sometimes it is helpful to be able to say: this function produces a result, without specifying what that result is. For example, in a recent type systems proof I've been working on, we have:

function typing(Environment R, Term t) -> Type:
    ...

function reduce(Store S1, Environment R, Term t1) -> (Store S2, Term t2)
requires typing(R,t1) == ??

Here, I don't care what the type produced is, only that one can be produced. (Technically, we also need termination but that is an orthogonal issue). To resolve this, I made a wierd hack:

function typing(Environment R, Term t) -> null|Type:
    ...

function reduce(Store S1, Environment R, Term t1) -> (Store S2, Term t2)
requires typing(R,t1) != null

Of course, typing can never return null (and this could be stated in the precondition). Eitherway, it does the trick! Therefore, we want a syntax like this:


function reduce(Store S1, Environment R, Term t1) -> (Store S2, Term t2)
requires typing(R,t1) == _

Here, _ is a don't care value.