1. Example where Euphoria defaults on a boolean expression

You get a phone call from your boss where you are ordered to search for =
information about dyslexia .. immediately! You go to the PC and start =
websearching. In the phone conversation you were told which words to =
search for...... it was "dyslexia"(A) and "adult"(B) and something =
else(C) which you don't remember. What to do when you don't know the =
third search criterium?

In this situation you will probably dismiss C from the rule and state:

 if A and B then match.....

Is this a valid transformation of boolean logic ... when one variable is =
unknown? What this rule returns is not the same as what your boss asked =
you to do.

Any variable may be nil (=3Duninstanciated). That has a lot of =
implications.

 if A and B and C then match....

When A=3DTrue, B=3DTrue and C=3Dnil then this rule CANNOT be solved as =
True or False  (i.e result is nil). That is consistent with boolean =
logic (and any other logic too)=20

Logically you could deduct that the paper you return is:

 not (what he asked for)  and
 not (not (what he asked for))

If E =3D what he asked for then
 not E and not( not E)   =3D>   not E and E  =3D> E and not E

The paper you returned to your boss was what he asked for and was not he =
asked for ( =3D "maybe" what he asked for)

So how do Euphoria handle this?

      atom e,=20

      e =3D 2  -- what he asked for
      f =3D 3 -- what you gave him
      if (f =3D e) and not ( f !=3D e) then print( 1, 1)
      else print ( 1, 0)
      end if

      object line
      line =3D gets( 0)


The Euphoria program returns "0" ...... which is wrong!

"not E and E" is unsolvable, neither true nor false.=20
Euphoria cannot handle this (like C and Pascal).

Rom

new topic     » topic index » view message » categorize

2. Re: Example where Euphoria defaults on a boolean expression

Rom wrote:

<snip>

> "not E and E" is unsolvable, neither true nor false.

No. "not E and E" is always false, of course.

> Euphoria cannot handle this (like C and Pascal).

No, please try:

integer E
E = 0
? not E and E
E = not E
? not E and E


Regards,
   Juergen

new topic     » goto parent     » topic index » view message » categorize

3. Re: Example where Euphoria defaults on a boolean expression

From: "Juergen Luethje" <jluethje at gmx.de>

> No, please try:
>=20
> integer E
> E =3D 0
> ? not E and E
> E =3D not E
> ? not E and E


There was a bug in my example:

    atom e, f

    e =3D 3 -- does not matter what value you state here
    f =3D 3 --  does not matter what value you state here

--  (I wrote  wrongly "if (f =3D e) and not ( f !=3D e) then ..." )

    if (f =3D e) and ( f !=3D e) then print( 1, 1)
    else print ( 1, 0)
    end if

    object line
    line =3D gets( 0)


f =3D e and f !=3D e cannot be resolved.  The evaluation should return =
nil.

Euphoria will alway return False here. Euphoria will never return =
possible true.=20
Then we are a long way into philosophy.

I tried to exemplify that with the examle. If we have rule (A and B and =
C), and we don't know C, then we cannot know if (A and B and C) is true. =
We cannot conclude from the (A and B) about (A and B and C). That is =
what a program has to be evaluated if we don't know C. That is an =
unresolvable boolean problem (but we all know that if (A and B) is true =
then (A and B and C) may be true. What is unresolvable (=3Dnil) here is =
nothing more mysterious than maybe.=20

But C/Delphi/Euphoria never return unresolvable as a possible result for =
ANY logical expression (implying that all logic statements can be =
solved) . That does not mean that every logical expression can be =
solved,  just that these languages cannot return unresolvable as a =
possible result.

Of course an evaluation of an uninstanciated boolean var is =
unresolvable. If a program output True or False here that output is =
rubbish.=20

It is so easy to implement a nil flag (=3D uninstanciated var) to deal =
with uninstanciated vars.

 A =3D nil                            if A -> nil
 A =3D True, B =3D nil          if A and B -> nil
 A =3D False, B =3D nil          if A and B -> False
 A =3D True, B =3D nil          if A or B -> True
 A =3D False, B =3D nil          if A or B -> nil
 3 * nil -> nil
 3 / 0 -> nil

Rom

new topic     » goto parent     » topic index » view message » categorize

4. Re: Example where Euphoria defaults on a boolean expression

|    atom e, f
|
|    e = 3 -- does not matter what value you state here
|    f = 3 --  does not matter what value you state here
|
|--  (I wrote  wrongly "if (f = e) and not ( f != e) then ..." )
|
|    if (f = e) and ( f != e) then print( 1, 1)
|    else print ( 1, 0)
|    end if
|
|    object line
|    line = gets( 0)
|
|
|f = e and f != e cannot be resolved.  The evaluation should return
nil.

Why can they not be resolved?? Both e and f are true values (!= 0),
and (f = e) is true and (f != e) is not true. true and not true =
true.

This is the simplest example they give in first year logic course at
uni's of a contridiction. ie, when false is always the result. It does
not matter what numbers e & f are, true or false. This should always,
and does always return false.

|Euphoria will alway return False here. Euphoria will never return
possible true. 

That is correct. What was the problem??

new topic     » goto parent     » topic index » view message » categorize

5. Re: Example where Euphoria defaults on a boolean expression

(myself)
>>|f =3D e and f !=3D e cannot be resolved.  The evaluation should =
return nil.

From: <dm31 at uow.edu.au>
> Why can they not be resolved?? Both e and f are true values (!=3D 0),
> and (f =3D e) is true and (f !=3D e) is not true. true and not true =
=3Dtrue.


>>Euphoria will alway return False here. Euphoria will never return=20
>>possible true.=20

From: <dm31 at uow.edu.au>
>That is correct. What was the problem??


I also also feel bad about  how I formulated the example.

I withdraw the whole example "if (f =3D e) and (f !=3D e) then ....." =
.... You are right. Big blunder sad(

The problem I tried to exemplify about (f =3D e) and (f !=3D e) cannot =
be translated into an if statement. I cannot state that both (f =3D e) =
is true and (f !=3D e) is true the way I tried to in the example.

To state (f =3De) is true and (f !=3D e) is true cannot be done i =
Euphoria. Euphoria does not support that kind of logic statements. I =
don't have that option with a procedural language.=20

How to evaluate (A and B and C) (...the kind of logical statements =
Euphora supports) when we don't know C is however unresolvable (we can =
neither conclude True nor False, which will leave us with an unresolved =
result). Euphoria forces us to state some value for anything, so you may =
say that C cannot be unknown. That we don't know the value of a var is =
something any program used for programming logic must deal with. I feel =
dealing with that is the first step in any AI-project.

Regards
Rom

new topic     » goto parent     » topic index » view message » categorize

6. Re: Example where Euphoria defaults on a boolean expression

On 23 Nov 2002, at 17:31, Rom wrote:

<snip>

> How to evaluate (A and B and C) (...the kind of logical statements Euphora
> supports) when we don't know C is however unresolvable (we can neither
> conclude
> True nor False, which will leave us with an unresolved result). Euphoria
> forces
> us to state some value for anything, so you may say that C cannot be unknown.
> That we don't know the value of a var is something any program used for
> programming logic must deal with. I feel dealing with that is the first step
> in
> any AI-project.

Correct. The first step is to know if you do not know something. This means 
knowing if equal(table,"red"), which is bad is table was undefined. Also in Eu, 
you can't import a new OOP-ish object of table during runtime. You can add 
it to an associated array, but you can't add the methods of how to deal with 
tables.

Kat

new topic     » goto parent     » topic index » view message » categorize

7. Re: Example where Euphoria defaults on a boolean expression

Rom wrote:

> From: "Juergen Luethje" <jluethje at gmx.de>
>
>> No, please try:
>>
>> integer E
>> E = 0
>> ? not E and E
>> E = not E
>> ? not E and E
>
>
> There was a bug in my example:
>
>     atom e, f
>
>     e = 3 -- does not matter what value you state here
>     f = 3 --  does not matter what value you state here
>
> --  (I wrote  wrongly "if (f = e) and not ( f != e) then ..." )
>
>     if (f = e) and ( f != e) then print( 1, 1)
>     else print ( 1, 0)
>     end if
>
>     object line
>     line = gets( 0)
>
>
> f = e and f != e cannot be resolved.  The evaluation should return nil.
>
> Euphoria will alway return False here. Euphoria will never return
> possible true. Then we are a long way into philosophy.
>
> I tried to exemplify that with the examle. If we have rule (A and B
> and C), and we don't know C, then we cannot know if (A and B and C) is
> true. We cannot conclude from the (A and B) about (A and B and C). That
> is what a program has to be evaluated if we don't know C. That is an
> unresolvable boolean problem (but we all know that if (A and B) is true
> then (A and B and C) may be true. What is unresolvable (=nil) here is
> nothing more mysterious than maybe.

Yes, I understand. But "maybe E" is not logically equivalent to
"not E and E". (Well, you talked about that with dm31 at uow.edu.au in the
meantime.)


> But C/Delphi/Euphoria never return unresolvable as a possible result
> for ANY logical expression (implying that all logic statements can be
> solved) . That does not mean that every logical expression can be
> solved, just that these languages cannot return unresolvable as a
> possible result.
>
> Of course an evaluation of an uninstanciated boolean var is
> unresolvable. If a program output True or False here that output is
> rubbish.
>
> It is so easy to implement a nil flag (= uninstanciated var) to deal
> with uninstanciated vars.
>
>  A = nil                    if A -> nil
>  A = True, B = nil          if A and B -> nil
>  A = False, B = nil         if A and B -> False
>  A = True, B = nil          if A or B -> True
>  A = False, B = nil         if A or B -> nil
>  3 * nil -> nil
>  3 / 0 -> nil

If "nil" means "unknown", then "not nil" means "known" -- but known to
be true, or known to be false? Is there a solution to this logical
pitfall? I would appreciate it very much, if there were a "3-value-logic"
(false/unknown/true) in Euphoria.

For instance I also would prefer
   open(<non existing file>, "r")  ->  nil
to
   open(<non existing file>, "r")  ->  -1


The above mentioned use of "nil" is primarily independent of the problem
of uninstanciated variables, and those things shouldn't be mixed up, I
think. Using nil for such variables looks easy indeed, but I think it's
also easy to genarate a runtime error (as Euphoria currently does), to
deal with them. The question is to me, what brings more benefit?

>From my personal experience (being not an IT professional) it looks to
me, that generating runtime errors for uninstanciated variables is
better for the sake of safety.

Regards,
   Juergen
-- 
Q: How many Microsoft engineers does Bill need to change a light bulb?
A: None. He just declares darkness to be an industry standard.

new topic     » goto parent     » topic index » view message » categorize

8. Re: Example where Euphoria defaults on a boolean expression

I use a programming language called 'Progress'. It has an explicit 'unknown'
value that you can assign to any variable. It has been a very useful device.
The symbol for it in the language is '?'.

So ...
   if theDate = ? then
    theDate = today - 1.

reads...
   if the date is not known, set it to yesterday's date.



----------------
cheers,
Derek Parnell
----- Original Message -----
From: "Juergen Luethje" <jluethje at gmx.de>
To: "EUforum" <EUforum at topica.com>
Sent: Sunday, November 24, 2002 5:32 AM
Subject: Re: Example where Euphoria defaults on a boolean expression



Rom wrote:

> From: "Juergen Luethje" <jluethje at gmx.de>
>
>> No, please try:
>>
>> integer E
>> E = 0
>> ? not E and E
>> E = not E
>> ? not E and E
>
>
> There was a bug in my example:
>
>     atom e, f
>
>     e = 3 -- does not matter what value you state here
>     f = 3 --  does not matter what value you state here
>
> --  (I wrote  wrongly "if (f = e) and not ( f != e) then ..." )
>
>     if (f = e) and ( f != e) then print( 1, 1)
>     else print ( 1, 0)
>     end if
>
>     object line
>     line = gets( 0)
>
>
> f = e and f != e cannot be resolved.  The evaluation should return nil.
>
> Euphoria will alway return False here. Euphoria will never return
> possible true. Then we are a long way into philosophy.
>
> I tried to exemplify that with the examle. If we have rule (A and B
> and C), and we don't know C, then we cannot know if (A and B and C) is
> true. We cannot conclude from the (A and B) about (A and B and C). That
> is what a program has to be evaluated if we don't know C. That is an
> unresolvable boolean problem (but we all know that if (A and B) is true
> then (A and B and C) may be true. What is unresolvable (=nil) here is
> nothing more mysterious than maybe.

Yes, I understand. But "maybe E" is not logically equivalent to
"not E and E". (Well, you talked about that with dm31 at uow.edu.au in the
meantime.)


> But C/Delphi/Euphoria never return unresolvable as a possible result
> for ANY logical expression (implying that all logic statements can be
> solved) . That does not mean that every logical expression can be
> solved, just that these languages cannot return unresolvable as a
> possible result.
>
> Of course an evaluation of an uninstanciated boolean var is
> unresolvable. If a program output True or False here that output is
> rubbish.
>
> It is so easy to implement a nil flag (= uninstanciated var) to deal
> with uninstanciated vars.
>
>  A = nil                    if A -> nil
>  A = True, B = nil          if A and B -> nil
>  A = False, B = nil         if A and B -> False
>  A = True, B = nil          if A or B -> True
>  A = False, B = nil         if A or B -> nil
>  3 * nil -> nil
>  3 / 0 -> nil

If "nil" means "unknown", then "not nil" means "known" -- but known to
be true, or known to be false? Is there a solution to this logical
pitfall? I would appreciate it very much, if there were a "3-value-logic"
(false/unknown/true) in Euphoria.

For instance I also would prefer
   open(<non existing file>, "r")  ->  nil
to
   open(<non existing file>, "r")  ->  -1


The above mentioned use of "nil" is primarily independent of the problem
of uninstanciated variables, and those things shouldn't be mixed up, I
think. Using nil for such variables looks easy indeed, but I think it's
also easy to genarate a runtime error (as Euphoria currently does), to
deal with them. The question is to me, what brings more benefit?

>From my personal experience (being not an IT professional) it looks to
me, that generating runtime errors for uninstanciated variables is
better for the sake of safety.

Regards,
   Juergen
--
Q: How many Microsoft engineers does Bill need to change a light bulb?
A: None. He just declares darkness to be an industry standard.

==^^===============================================================
This email was sent to: ddparnell at bigpond.com

new topic     » goto parent     » topic index » view message » categorize

9. Re: Example where Euphoria defaults on a boolean expression

Rom wrote:

>
>      atom e, 
>
>      e = 2  -- what he asked for
>      f = 3 -- what you gave him
>      if (f = e) and not ( f != e) then print( 1, 1)
>      else print ( 1, 0)
>      end if
>
>      object line
>      line = gets( 0)
>
>
>The Euphoria program returns "0" ...... which is wrong!
>
>"not E and E" is unsolvable, neither true nor false. 
>Euphoria cannot handle this (like C and Pascal).
>
>Rom
>
In boolean logic, there are two possible states: True and False, 1 and 0.
If E = 1(True) then not E = 0(False)
0 and X (either 1 or 0) is always 0(False)
not E and E = 0
0 and 1 = 0

If E = 0(False) then not E = 1(True)
not E and E = 0
1 and 0 = 0

(3 = 2) is 0(False)  
not (3 != 2)  is 0(False)   -- (3 != 2) is 1(True),  not(1) is False(0)
(3 = 2) and not(3 != 2) is 0(False)  -- 0 and 0 is 0(False)

new topic     » goto parent     » topic index » view message » categorize

10. Re: Example where Euphoria defaults on a boolean expression

Rom wrote:

>    if (f = e) and ( f != e) then print( 1, 1)
>    else print ( 1, 0)
>    end if
>
>
>f = e and f != e cannot be resolved.  The evaluation should return nil.
>
>  
( f = e ) and ( f != e) evaluates to 0 also.
( 3 = 2) and (3 != 2) => 0
0 and 1 => 0

new topic     » goto parent     » topic index » view message » categorize

11. Re: Example where Euphoria defaults on a boolean expression

Rom wrote:

>How to evaluate (A and B and C) (...the kind of logical statements Euphora
>supports) when we don't know C is however unresolvable (we can neither conclude
>True nor False, which will leave us with an unresolved result).
>Regards
>Rom
>

We can conclude False if either A = 0 or B = 0.  However, if A = 1 and B 
= 1 then we can not resolve the statement as True or False without 
knowing the value of C.

new topic     » goto parent     » topic index » view message » categorize

12. Re: Example where Euphoria defaults on a boolean expression

From: <1evan at sbcglobal.net>

> Rom wrote:
>=20
> >    if (f =3D e) and ( f !=3D e) then print( 1, 1)
> >    else print ( 1, 0)
> >    end if
> >
> >
> >f =3D e and f !=3D e cannot be resolved.  The evaluation should =
return nil.
> >
> > =20
> ( f =3D e ) and ( f !=3D e) evaluates to 0 also.
> ( 3 =3D 2) and (3 !=3D 2) =3D> 0
> 0 and 1 =3D> 0

The example I formulated was a logical miss from my side. I have =
admitted that. What you are saying is true. Also that (False and True =
and nil) -> False, of course.

Rom

new topic     » goto parent     » topic index » view message » categorize

13. Re: Example where Euphoria defaults on a boolean expression

Yes, sorry.  I read your follow-up post after I sent mine.

Rom wrote:

>
>From: <1evan at sbcglobal.net>
>
>  
>>Rom wrote:
>>
>>    
>>>   if (f = e) and ( f != e) then print( 1, 1)
>>>   else print ( 1, 0)
>>>   end if
>>>
>>>
>>>f = e and f != e cannot be resolved.  The evaluation should return nil.
>>>
>>> 
>>( f = e ) and ( f != e) evaluates to 0 also.
>>( 3 = 2) and (3 != 2) => 0
>>0 and 1 => 0
>>    
>>
>The example I formulated was a logical miss from my side. I have admitted that.
>What you are saying is true. Also that (False and True and nil) -> False, of
>course.
>
>Rom
>
>==^^===============================================================
>This email was sent to: 1evan at sbcglobal.net
>
>
>

new topic     » goto parent     » topic index » view message » categorize

14. Re: Example where Euphoria defaults on a boolean expression

From: "Bernie Ryan" <xotron at bluefrognet.net>

> Rom:=20
>   If you are dissatisfied with the way Euphoria handles
>   true and false then why don't you write a library/include
>   file to place on the contribution page that performs the
>   way that you think is correct. This would benefit the other
>   users like yourself that need that capability.

I haven't planned that in near future. But I will by a month or two =
finish a small scripting interpreter where nil will be a possible state =
for vars and if ... then ... constructs. Everyone can do a bit toying =
with that when program is finished.=20

Also, defining a new boolean type (with empty/nil as a possible state) =
and defining implications of that type when implemented upon operators =
like > and < and control structures like if ... then  ... should be easy =
to post.

Rom

new topic     » goto parent     » topic index » view message » categorize

15. Re: Example where Euphoria defaults on a boolean expression

On Saturday 23 November 2002 05:40 pm, you wrote:
>
>
> From: "Bernie Ryan" <xotron at bluefrognet.net>
>
> > Rom:
> >   If you are dissatisfied with the way Euphoria handles
> >   true and false then why don't you write a library/include
> >   file to place on the contribution page that performs the
> >   way that you think is correct. This would benefit the other
> >   users like yourself that need that capability.
>
> I haven't planned that in near future. But I will by a month or two finish
> a small scripting interpreter where nil will be a possible state for vars
> and if ... then ... constructs. Everyone can do a bit toying with that when
> program is finished.
>
> Also, defining a new boolean type (with empty/nil as a possible state) and
> defining implications of that type when implemented upon operators like >
> and < and control structures like if ... then  ... should be easy to post.

Or, you could download Lua, which can assign nil as a value for a variable.

Irv

new topic     » goto parent     » topic index » view message » categorize

16. Re: Example where Euphoria defaults on a boolean expression

--- Rom <kjehas at frisurf.no> wrote:

> Of course an evaluation of an uninstanciated boolean var is unresolvable. If
> a program output True or False here that output is rubbish. 

I completely disagree.  More below...
 
> It is so easy to implement a nil flag (= uninstanciated var) to deal with
> uninstanciated vars.

I can see value in this, but not in regards to your 'unresolvable' boolean
statements.
 
>  A = nil                            if A -> nil
>  A = True, B = nil          if A and B -> nil
>  A = False, B = nil          if A and B -> False
>  A = True, B = nil          if A or B -> True
>  A = False, B = nil          if A or B -> nil
>  3 * nil -> nil
>  3 / 0 -> nil

If something is not true, then it's false.  If you really want to implement
this 3-value logic business, then fine, but that's not the world we live in. 
Suppose you have no brothers.  Please evaluate this statement:

"Your brother is named Joe."

You're telling me this is unresolvable, because 'brother' is uninstanciated. 
But the test here is, do you have a brother named Joe?  The answer is no,
except the reason is that you don't have a brother, rather than that his name
is Bob.

Please explain more on why this shouldn't work.  You've given us plenty of
examples of how your idea would work, but I haven't seen anything to justify
it.

Matt Lewis



__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus – Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu