Ok. Imperative programming would need more stringent requirements in order to conform to to the question’s assumptions. [to be evaluated as a function where each variable affects the others].
When you first asked the question, this is how my imperative programming mindset read it: (pseudocode)
Values [P,Q,R,I] can only evaluate to TRUE or FALSE.
P is type BOOLEAN
Q is type BOOLEAN
R is type BOOLEAN
I is type BOOLEAN
INPUT P
IF P = TRUE THEN
Q= TRUE;
IF Q=TRUE THEN
R=TRUE;
IF R=TRUE THEN
I=TRUE;
I=FALSE
PRINT P:
“TRUE”
PRINT Q”
“TRUE”
PRINT R
“TRUE’
PRINT I
“FALSE”
END
======
he fewer assumptions the better. I neglected the part in the pseudocode where the user asserts P=TRUE.
====
[that was a mistake on my part]
====
Yes because you have them dependent upon each other. In imperative programming [or algorithms], variables are not required to be dependent upon each other.
But I can rewrite a situation where they are dependent upon each other.
====
“If p, then q. If q, then r. If r, then i. Not i….therefore…?”
x=1
SUB JLS
If P(x)=TRUE THEN Q(x)=TRUE;
if Q(x)=TRUE THEN R(x)=TRUE;
if R(x)=TRUE THEN I(x)=TRUE;
RETURN;
x=2
LET I(x) = FALSE
For x=1 to 2
PRINT “Run #” & x & “: I = ” & I(x);
next x;
——-
Run #1: I=TRUE
Run #2: I=FALSE
====
I forgot to set P(1) = true again lol]
==============
[ok, I didn’t have the heart to write a contradiction in code. I just displayed the results of two different I’s (“possible worlds” in philosophy I think?) for the user to decide.
I can’t write TRUE=FALSE but I can assign variables with those results.
====
In programming (algorithms), you *can’t* write illogical code. If it’s illogical it won’t run, it won’t compile. It’ll just spit out an ERROR and you have to redo your code.
=====
Now you CAN write *wrong* code. If it’s wrong, it’s internally logically consistent. [it has to be for it to run or compile].
But you can end up with unexpected results if your coding is wrong.
You can make algorithms / code do whatever you want them to do. They’ll be automatically logically consistent [otherwise you never leave the editor].
But you won’t get the results you want.
This is why it’s important to carefully analyze beyond logical consistency: Logical consistency is usually pretty easy to achieve but if you give crappy information for the variables, you can give misleading results.
=====
It’s possible to mislead with algorithms – just as many documentaries do with “The REAL TRUTH ABOUT [x]” – because everything is logically consistent, so long as you set a few “IF”s to TRUE.
Everything follows along nicely and logically mined people are misled because they didn’t fully analyze the first few “IF” in the presentation.
====
[responsivevoice_button voice="US English Male"]