1. RE: 'Unknown' and three-valued logic
- Posted by Patrick.Barnes at transgrid.com.au Nov 26, 2002
- 475 views
I can't see ANY need for knowing whether something is initialised. If you want, define a NULL value to put things to when you're finished with them, however if you try to reference an uninitialised value.. (and if your program initialises and uninitialises values arbitrarily, that's quite likely) ..then the user will end up with a lovely application crash. NULL can be anything that the data in question will never be. 0 and kludge values are popular, but those values might be valid data. You could declare everything as object, and for atoms have the null value {}, and for sequences the null value 0. If you REALLY need that functionality, I daresay it'd only be for one or two variables. In that case, you can have a separate boolean to be valid_var ie if valid_var and var = 15 then --if it is initialised and set to 15, valid_var = 0 --set to uninitialised. end if -----Original Message----- From: Derek Parnell [mailto:ddparnell at bigpond.com] Sent: Wednesday, 27 November 2002 10:19 To: EUforum Subject: Re: 'Unknown' and three-valued logic On Tue, 26 Nov 2002 23:55:24 +0100, Rom <kjehas at frisurf.no> wrote: [snip] > What I am trying to point out is that whole problem is created by missing > elements in all(?)current languages.....you cannot state: > > integer a, b > > -- program code > > if not assigned( a) then ..... > and you cannot state: > > unassign( a) I proposed the need for knowing whether or not a variable has been initialized to RDS a long time ago. Also I mentioned the usefulness of setting a variable back to its uninitialized state. RDS declined to incorporate these into the language. It is obvious that the Euphoria interpreter can ALREADY determine if a variable is initialized or not, however there is no programmer access to that information. > > If we accept the there is no hope that any language will accept nil as a > legal value (unless one developes a new one oneself) ...[snip] I have been using the language called Progress since 1985. It has always had the ability to detect and set a variable to the 'unknown' state. > (this is my final position is this discussion) Thank you. -- cheers, Derek Parnell *********************************************************************** authority states them to be the views of TransGrid. TransGrid uses virus scanning software but excludes any liability for viruses contained in any attachment. ***********************************************************************
2. RE: 'Unknown' and three-valued logic
- Posted by rforno at tutopia.com Nov 28, 2002
- 464 views
So, instead of saying FALSE, they say NIL. Conclusion: you wont get the benefit. ----- Original Message ----- From: Rom <kjehas at frisurf.no> Subject: Re: 'Unknown' and three-valued logic From: <dm31 at uow.edu.au> |Example case: |Simplified rules for unemployments benefits. How to program such rules? | |To qualify for unemployment benefits.... |1) you must be a national citizen |2) you must be unemployed |3) you must have earned more than $10000 previous year |4) all facts must be documented (if you haven't supplied sufficient domentation then employment office cannot make a positive decision) > All you get is check that the document has been submitted, if yes, > then proceed, if no, then send them a leeter asking for more. I don't > see anything hard in that. No 3-state needed... I think you have got > uninitialised vcars and logic mixed up to much... Sorry, wrong answer. Even if sufficient documentation is not submitted, they cannot say that you are not eligble for benefits. Rom The following program produces too many rejections, leading to a row of complains...... boolean N, U, I /* N = person is a national citizen U = person is unemployed I = income previous year was > 10000 */ // Facts N = True U = True I = False // meaning income was < 10000 or documentation was not submitted if N and U and I then printf( "Accept application") else printf( "Reject application") end if ==^^=============================================================== This email was sent to: rforno at tutopia.com
3. RE: 'Unknown' and three-valued logic
- Posted by rforno at tutopia.com Nov 28, 2002
- 448 views
Simple. If you are not a citizen OR you are not unemployed OR you have not earned more than $ 10000 previous year OR you don't have documentation proving all of these asserts, you wont receive the benefit. Alternative solution: If you are a citizen AND you are unemployed AND you have earned more than $ 10000 previous year AND you have documentation proving all this, you'll receive the benefit. If employment office cannot make a positive decision, it means you wont receive the benefit. No one can get money that wasn't released. And I think most Informatics courses students will easily solve this problem, without having to be very talented. Regards. ----- Original Message ----- From: Rom <kjehas at frisurf.no> To: EUforum <EUforum at topica.com> Sent: Tuesday, November 26, 2002 5:18 AM Subject: Re: 'Unknown' and three-valued logic From: "Juergen Luethje" <jluethje at gmx.de> > Rob kindly put my small Euphoria library containing logical, > relational, and arithmetic operations that can handle the value > 'unknown' at the 'Recent User Contributions' Page: > > http://www.rapideuphoria.com/unknown.zip > > Any comments are welcome. I posted the example below two weeks ago(?) here (what none except the most talented programmers can solve) as something that requires three-valued logic. Do you agree? (I already feel I was right i my assupmtion) Rom Example case: Simplified rules for unemployments benefits. How to program such rules? To qualify for unemployment benefits.... 1) you must be a national citizen 2) you must be unemployed 3) you must have earned more than $10000 previous year 4) all facts must be documented (if you haven't supplied sufficient domentation then employment office cannot make a positive decision) ==^^=============================================================== This email was sent to: rforno at tutopia.com
4. RE: 'Unknown' and three-valued logic
- Posted by rforno at tutopia.com Nov 29, 2002
- 445 views
It seems your idea of simplicity does not agree with mine. Regards. ----- Original Message ----- From: Rom <kjehas at frisurf.no> Subject: Re: 'Unknown' and three-valued logic From: <rforno at tutopia.com> > Simple. If you are not a citizen OR you are not unemployed OR you have not > earned more than $ 10000 previous year OR you don't have documentation > proving all of these asserts, you wont receive the benefit. > Alternative solution: > If you are a citizen AND you are unemployed AND you have earned more than $ > 10000 previous year AND you have documentation proving all this, you'll > receive the benefit. Of course you can try to analyze the rules in this way ... it requires some consentration. Check the simple Eupohia program below. If you come to the same result, you have found a solution (there are 27 combinations .... I prefer to let a program do the reasoning .. it can do it faultless on such a problem) > And I think most Informatics courses students will easily solve this > problem, without having to be very talented. They have been tested. Rom -- Simple Euphoria answer to the problem case putting NIL into a boolean variable global constant TRUE = 1, FALSE = -1, NIL = 0 global type eboolean( atom x) return (x = TRUE) or (x = FALSE) or (x = NIL) end type global function pAND( sequence a) eboolean res res = TRUE for i = 1 to length( a) do if a[ i] < res then res = a[ i] end if end for -- i.e min( a[ 1] ...a[ n]) -- truthtable here is 27 possibilities -- pOR will be max( a[ 1] ...a[ n]) return res end function -- N = you must be a national citizen -- U = you must be unemployed -- I = you must have earned more than $10000 previous year eboolean N, U, I, decision N = TRUE U = TRUE I = NIL -- documentation is missing decision = pAND( {N, U, I}) if decision = TRUE then puts( 1, "accept" ) elsif decision = FALSE then puts( 1, "reject" ) elsif decision = NIL then puts( 1, "ask for more documentation" ) end if object line line = gets( 0) ==^^=============================================================== This email was sent to: rforno at tutopia.com