Post Reply 
Proof of X≤Y inverse to X˃Y
09-01-2018, 08:40 AM (This post was last modified: 09-01-2018 08:52 AM by Gamo.)
Post: #1
Proof of X≤Y inverse to X˃Y
HP-12C only got two conditional test of [X≤Y] and [X=0]

Recently I try to do the inverse of the [X≤Y] to [X˃Y]

To get [X˃Y] this must use [X≤Y] three times.

Here is the simple program to make this proof.

Case 1. [X≤Y] If true result show 101 If false result show 1
Case 2. [X˃Y] If true result show 101 If false result show 1

101 for True
1 for False

Procedure:
Y [ENTER] X [R/S] ---> Case 1
Y [ENTER] X [R/S] ---> Case 2

Example:
Y stack is 100 and X stack is 100

100 [ENTER] 100 [R/S] display 101 // [X≤Y] 100 ≤ 100 that is TRUE
100 [ENTER] 100 [R/S] display 1 // [X˃Y] 100 ˃ 100 that is FALSE

Y stack is 100 and X stack is 101

100 [ENTER] 101 [R/S] display 1 // [X≤Y] 101 ≤ 100 that is FALSE
100 [ENTER] 101 [R/S] display 101 //[X˃Y] 101 ˃ 100 that is TRUE


Program: Conditional Test comparison between [X≤Y] and [X˃Y]
Code:

01 X≤Y ?
02 GTO 05   // True
03  1    // False
04 GTO 08
05  1
06  0
07  1
08 R/S
09 X≤Y ?    // Line 9 to 11 test become X˃Y ?
10 X≤Y ?
11 X≤Y ?
12 GTO 17    // False
13  1    // True
14  0
15  1
16 GTO 00
17  1
18 GTO 00

This is just a curiosity. Is this really work as show in these example?

Gamo
Find all posts by this user
Quote this message in a reply
09-01-2018, 09:31 AM
Post: #2
RE: Proof of X≤Y inverse to X˃Y
(09-01-2018 08:40 AM)Gamo Wrote:  HP-12C only got two conditional test of [X≤Y] and [X=0]

Recently I try to do the inverse of the [X≤Y] to [X˃Y]

Gamo

I don't have a 12C, but can't you just programmatically do...

if X <= Y
GTO 10 ; X<=Y
else
GTO 20 ; X > Y

cheers

Tony
Find all posts by this user
Quote this message in a reply
09-01-2018, 10:10 AM
Post: #3
RE: Proof of X≤Y inverse to X˃Y
The OP seems to be under the impression that repeating a test instruction 3x equates to the inverse test. I've already debunked this on facebook but somehow the post seems to have disappeared!
Find all posts by this user
Quote this message in a reply
09-01-2018, 10:19 AM (This post was last modified: 09-01-2018 10:19 AM by pier4r.)
Post: #4
RE: Proof of X≤Y inverse to X˃Y
little request.
While facebook is great for immediate discussion (as other social networks), its ability to retrieve historical content converge to 0 quite fast (like after 2-3 days something was posted). And this is a community based on historical content. For posts that contain information or costed some effort, wouldn't be bad to share them also here.

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
09-01-2018, 12:27 PM
Post: #5
RE: Proof of X≤Y inverse to X˃Y
(09-01-2018 08:40 AM)Gamo Wrote:  This is just a curiosity. Is this really work as show in these example?

No. If you repeat a conditional three times, all you're accomplishing is to waste two lines. Consider: if the condition is true, by the do-if-true / skip-if-false rule, the second of the three conditionals will also be true, and the third, and finally the instruction after the third conditional is executed. If the condition is false, the second conditional is skipped, the third is executed, and since the condition is still false, the function after the third conditional is skipped.

I'm not even going to try to pick apart that "example," since it seems designed to confuse, and I have a headache. Smile
Visit this user's website Find all posts by this user
Quote this message in a reply
09-01-2018, 12:31 PM
Post: #6
RE: Proof of X≤Y inverse to X˃Y
(09-01-2018 10:19 AM)pier4r Wrote:  While facebook is great for immediate discussion (as other social networks), its ability to retrieve historical content converge to 0 quite fast (like after 2-3 days something was posted).

Especially when said historical content has been deleted rather than just aged away.
Find all posts by this user
Quote this message in a reply
09-01-2018, 12:57 PM (This post was last modified: 09-01-2018 01:13 PM by Gamo.)
Post: #7
RE: Proof of X≤Y inverse to X˃Y
To recap on this topic the main part of these two test difference is

1. X is less than or equal to Y
2. X is greater than Y

Example with equal integers on stacks X and Y will get result
with "less than or equal to" another is "greater than"

When stacks X and Y are both 100
[X≤Y] 100 ≤ 100 is True
[X˃Y] 100 ˃ 100 is False // This test will not use greater than or equal to

When doing the inverse logic in program next line will be False follow by True

01 Inverse Logic
02 False
03 True

I believe that it is sometime very handy to have this conditional test when needed.


Gamo
Find all posts by this user
Quote this message in a reply
09-01-2018, 02:04 PM
Post: #8
RE: Proof of X≤Y inverse to X˃Y
Gamo, why are lines 09-17 in this program?
Find all posts by this user
Quote this message in a reply
09-01-2018, 07:51 PM
Post: #9
RE: Proof of X≤Y inverse to X˃Y
(09-01-2018 08:40 AM)Gamo Wrote:  Recently I try to do the inverse of the [X≤Y] to [X˃Y]
To get [X˃Y] this must use [X≤Y] three times.

No, this can and will not work. Three times the same test does exactly the same as one single test.
So...

X≤Y?
X≤Y?
X≤Y?

...is the same as a single X≤Y? test. Just with two wasted program lines.
Do you want a proof?

(09-01-2018 12:57 PM)Gamo Wrote:  When doing the inverse logic in program next line will be False follow by True

01 Inverse Logic
02 False
03 True

To invert a test simply have it followed by another test that always is false.
Your third step ("True") does not change anything and can be removed.

Example: if you know that X definitely is not zero, the "always false" step can be "X=0?".
This way...

X≤Y?
X=0?

...becomes an "X>Y?" test.

BUT: On the 12C or other calculators with line addressing inverting a test can be done even easier: simply have the test followed by a GTO to the second next line.

Code:
21 ...
22 X≤Y?
23 GTO 25
24 ...     <= this line is executed if X>Y, else it is skipped
25 ...     program continues here

Of course you can also skip two or more lines.
Example: if X>Y store R1 into R2.

Code:
21 ...
22 X≤Y?
23 GTO 26
24 RCL 1   these two lines are only executed
25 STO 2   if X>Y, else they are skipped
26 ...     program continues here

Dieter
Find all posts by this user
Quote this message in a reply
09-01-2018, 08:27 PM
Post: #10
RE: Proof of X≤Y inverse to X˃Y
(09-01-2018 07:51 PM)Dieter Wrote:  BUT: On the 12C or other calculators with line addressing inverting a test can be done even easier: simply have the test followed by a GTO to the second next line.

Code:
21 ...
22 X≤Y?
23 GTO 25
24 ...     <= this line is executed if X>Y, else it is skipped
25 ...     program continues here

Dieter

Gene: And the beauty of this (IMO) is that on a line-addressing model with limited steps, it is VERY efficient. No step burned with a LBL.

Of course... that's only true until you have to modify the program and then it really hurts.

Or if you have a ton of memory! :-)
Find all posts by this user
Quote this message in a reply
09-02-2018, 01:29 AM
Post: #11
RE: Proof of X≤Y inverse to X˃Y
Dieter thank You

Your explanations is very clear and easy to understand.
My proof is usually not work as expected.

Thank You

Gamo
Find all posts by this user
Quote this message in a reply
09-02-2018, 01:52 PM
Post: #12
RE: Proof of X≤Y inverse to X˃Y
One more example for X>Y conditional test out of curiosity.

This program keep adding 1 and pause in X stack to compare with 10 in Y stack

Procedure: Clear Register REG

R/S --> 1, 2, 3,...,10 then stop at 11 because 11 > 10

Program:
Code:

01  1
02 STO+1
03 RCL 1
04 PSE
05  1
06  0
07 X<>Y
08 X≤Y ?    // Line 08 to 10 test become  X>Y
09 X≤Y ?
10 X≤Y ?
11 GTO 01    // (False) number still less than 10 then loop and add
12 RCL 1    // (Ture) Now number is larger than 10 and stop

Gamo
Find all posts by this user
Quote this message in a reply
09-02-2018, 02:01 PM
Post: #13
RE: Proof of X≤Y inverse to X˃Y
(09-02-2018 01:52 PM)Gamo Wrote:  
Code:

08 X≤Y ?    // Line 08 to 10 test become  X>Y
09 X≤Y ?
10 X≤Y ?
11 GTO 01    // (False) number still less than 10 then loop and add

No it doesn't.

Take a closer look at the order in which your numbers are in the stack.

When execution reaches line 08, you have 10 in the Y register and your count in the X register. Of course you're going to keep counting with an X<=Y? command, it's blinking obvious.

If line 08 to 10 equated to X>Y? then you wouldn't loop until your count exceeded 10.
Find all posts by this user
Quote this message in a reply
09-02-2018, 02:07 PM (This post was last modified: 09-02-2018 02:08 PM by Dieter.)
Post: #14
RE: Proof of X≤Y inverse to X˃Y
(09-02-2018 01:52 PM)Gamo Wrote:  
Code:
05  1
06  0
07 X<>Y
08 X≤Y ?    // Line 08 to 10 test become  X>Y
09 X≤Y ?
10 X≤Y ?
11 GTO 01    // (False) number still less than 10 then loop and add

Gamo, it has just been shown that three consecutive tests do NOT invert it. So line 08 to 10 do NOT become an X>Y? test. They are exactly the same as one single X≤Y? test:

Code:
05  1
06  0
07 X<>Y
08 X≤Y ?     // is the counter still ≤ 10 ?
09 GTO 01    // then do another loop

The program works just because here NOT an X>Y? is required, but the correct test is X≤Y?. And that's what the program does: Three times X≤Y? is the same as a single X≤Y? test! I thought this was clear from the previous posts where this has been proven.

Dieter
Find all posts by this user
Quote this message in a reply
09-02-2018, 02:40 PM (This post was last modified: 09-02-2018 03:07 PM by Gamo.)
Post: #15
RE: Proof of X≤Y inverse to X˃Y
Oops my bad now that even more clear that it is really not work.
I did try the single X≤Y and result is the same.

With X≤Y and X=0 together work on the same program that stop at 11.

Thanks to Dieter and grsbanks to make this clear up.

Thanks again

Gamo
Find all posts by this user
Quote this message in a reply
09-02-2018, 05:11 PM (This post was last modified: 09-02-2018 05:25 PM by Dieter.)
Post: #16
RE: Proof of X≤Y inverse to X˃Y
(09-02-2018 02:40 PM)Gamo Wrote:  I did try the single X≤Y and result is the same.

Yes.

More precisely:
If you repeat the same test n times, the result is
– the same as one single test if n is odd
– always true if n is even, i.e. nothing is tested at all.

(09-02-2018 02:40 PM)Gamo Wrote:  With X≤Y and X=0 together work on the same program that stop at 11.

No.
Try it and see what you get.

Code:
01 CLX
02 STO 1
03 1
04 STO+1
05 RCL 1
06 PSE
07  1
08  0
09 X<>Y
10 X≤Y?     ' since X is never zero
11 X=0?     ' line 10 + 11 are equivalent to "X>Y?"
12 GTO 03
13 GTO 00

Note: R1 is cleared on start, so no Clear REG is required.

What's the final number?

[  ]  1
[  ]  10
[  ]  11

Check the correct answer. :-)

Dieter
Find all posts by this user
Quote this message in a reply
09-02-2018, 05:43 PM
Post: #17
RE: Proof of X≤Y inverse to X˃Y
The previous posts have shown (and proven) that repeating the same test command multiple times makes no sense at all: If the number of repetitions is even the result is always "true", so nothing is tested at all; two consecutive X≤Y? test are the same as a NOP. If the number of repetitions is odd the result is the same as a single test. So three times X≤Y? is the same as one X≤Y?.

But there is one exception: there are test commands that alter the test condition. The most relevant example is the FS?C test (or F2? and F3? on the HP67/97 that do the same). Here testing a flag also clears that flag. This means that the next FS?C test always tests false, and the original test is inverted.
So...

FS?C 00
FS?C 00

...is the same as FC?C 00

And on the HP67/97...

F2?
F2?


...is the same as FC?C 2.

Otherwise repeating the same test does not make any sense at all. As explained above.

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)