• Welcome to the new Internet Infidels Discussion Board, formerly Talk Freethought.

An Exercise In Logic

steve_bank

Diabetic retinopathy and poor eyesight. Typos ...
Joined
Nov 9, 2017
Messages
13,786
Location
seattle
Basic Beliefs
secular-skeptic
An Exercise In Logic. As a general overview you can look at as synthesizing a set of premises to support a conclusion. We start at the conclusion, the operation of an elevator, then work backwards to synthesize formal logic underneath the conclusion.

Consider an elevator. While the control system would be coded in a language like C, the decision making is done using a from of formal-symbolic logic. All computer lanmguages have some implementation of formal logic.

The task is to develop an algorithm using formal logic to determine the sequence of floor stops depending on the external call buttons and the buttons inside the elevator.

At any time an up or down button or the button fpr floors 1,2,3,4 can be pressed in the elevator.

There are logical hazards If the elevator is goind up headed towards the firs4 th floor and someone gets on at the third flor and presses 1, the elevator must go to 4 first. Another example, as people get on and off the elevator pessing the 2 anf 3 floor buttons the elevator can not get stuck going back and fothrt between the two floors.

Given are logical-Boolean variables.

Elevator call variables u. True if pressed false otherwise. When someone presses the button calling for an elevator the variable goes true. When the door opens at the floor the variable is returned to false.
F1_ Up
F2_Up
F2_Down
F3_Up
F3_Down
F4_Down

Floor indicators, tells you when a floor has been reacjed.
F1
F2
F3
F4

Up Down status.

Elevevator_Up
Elevator_Down


Elevator car buttons. Normally false, made true when pressed, and made false wham the floor is reached.

The algorithm must make the variables false when an operation is completed.

The algorithm will entail and ifnite loop.

START

…algorithm

Got TO START

When the algorithm starts it logically evaluates the buttons and determines the floor to go to. Paradoxes ot logical traps as outlined above are to be avoided. We all are familiar with elevators so the sequencing requirements should be obvious.

If the elevator is going up the Up vatribale is true. Down the Down variable is true.

Make use of logical contracts like if then else and while.

while(logical function){ logical stae,emts } executes the logical segments in the braces while the logical function is true.
If(logical function) { } same as above and so on.


If(logical function) { } else { }

Logical function is a variable or logical statement that evaluates to true or false. A logica; function could be if(F1_Up & F2_Up) ( …} If the function is true than excite the expressions in the braces. If false ignore.

It is a simplified version of a complete system. Simply properly sequence the elevator based on floor call buttons and elevator car buttons.

Something a little different than the usual syllogism. Applied logic.

https://en.wikipedia.org/wiki/Symbolic_language_(programming)

Some coding examples
https://en.wikipedia.org/wiki/List_of_logic_symbols
https://fresh2refresh.com/c-programming/c-operators-expressions/c-logical-operators/
https://www.tutorialspoint.com/cprogramming/c_logical_operators
 
Last edited:
How will we judge whether our solutions are correct?

Because they work? You know, like to walk into the lift and hope for the best? I did something like that, being in the lift, myself.

Still, I think Steve isn't really talking about logic.

Rather, he seems to be talking about producing an algorithm, a model of the lift going up and down. Funny, I want to do that, but it's not logic.

Still, if this is really a thread about the logic of the lift, I want first a common lexis of the terms and symbols allowed, like, for example, ¬, ∧, ∨, ⊻, →, ⇔, ≡, ⊢ etc., complete with a short definition of each symbol.

And then, why not, an algorithm implementing the logic. Really implementing the logic.

But again, I want the language first, and preferably, something in widespread use, things like do while/loop, for i = 1 to 10/next i, etc.

Second, Steve will have to show his own solution.

OK, it's a start. What do you think?

Steve?
EB
 
Because they work? You know, like to walk into the lift and hope for the best? I did something like that, being in the lift, myself.

Still, I think Steve isn't really talking about logic.

Rather, he seems to be talking about producing an algorithm, a model of the lift going up and down.
I say we're talking logic when we ask "how do we judge that the algorithm works independent of walking in and hoping for the best?"
 
Still, if this is really a thread about the logic of the lift, I want first a common lexis of the terms and symbols allowed, like, for example, ¬, ∧, ∨, ⊻, →, ⇔, ≡, ⊢ etc., complete with a short definition of each symbol.

Ooh, can we have that anyway?
 
The judge will be your self. You can test the algorithm with a truth table, one common way.

Computer languages implement versions of formal logic with varying symbols. Pick you symbols and define them. You can invent your own if you like. If you work the problem work out symbols among you. Just like a real working group....

To actually work out the code would take me a full time 4 or 5 days and a few days for testing.

It is not a simple problem and it has a few pitfalls. First think of how an elevator works, develop a mental picture.

It is an exercise in imagination, reason, and logic combined. There may be no obvious solution at the start, how do you get to a starting point? Aristotelian logic is used, but there are no deterministic rules on how to apply it, that is what reason9ing is about.

Trial and error is part of it.

It is an exercise to gain understanding. Even if you get nowhere the effort can improve your logic and reasoning. Try an approach that fails. Evaluate and try again.

That is engineering and scince. And that is The Scientific Method'.
 
Last edited:
Still, if this is really a thread about the logic of the lift, I want first a common lexis of the terms and symbols allowed, like, for example, ¬, ∧, ∨, ⊻, →, ⇔, ≡, ⊢ etc., complete with a short definition of each symbol.

Ooh, can we have that anyway?

I guess we'll have to wait and see whether Steve can step up to the plate.
EB
 
OK, I guess we won't get Steve to step up. All talk, no action. Get a lift, man. Or call for help, there's a button.

Me, it definitely got me thinking. So, I'll do it, just because it's a good exercise and there are a few things to clarify.

Clearly, the way Steve presented the problem, he is confusing algorithms with logic. Typical of your average software practitioner. Some computer scientists even believe computers are logic itself. Whoa, some serious dogma there. Still, I don't think there's any difficulty in formalising the logic of lifts. I could even do a more general class of problems with lifts as a particular case. Ultimately, lifts are a restriction of reality as a whole. But, sure, we can simplify and limit ourselves to a small set of premises because life is short. The lift will go up and down. It will stop at a floor if requested by the occupant of the lift but only if there is no fire going on at the floor. There will be a call-for-help button. And a button to play muzak. For stopping the doors closing or for asking immediate closing. What else?

And only logic and nothing else.
EB
 
An Exercise In Logic. As a general overview you can look at as synthesizing a set of premises to support a conclusion. We start at the conclusion, the operation of an elevator, then work backwards to synthesize formal logic underneath the conclusion.

Consider an elevator. While the control system would be coded in a language like C, the decision making is done using a from of formal-symbolic logic. All computer lanmguages have some implementation of formal logic.

The task is to develop an algorithm using formal logic to determine the sequence of floor stops depending on the external call buttons and the buttons inside the elevator.

At any time an up or down button or the button fpr floors 1,2,3,4 can be pressed in the elevator.

There are logical hazards If the elevator is goind up headed towards the firs4 th floor and someone gets on at the third flor and presses 1, the elevator must go to 4 first. Another example, as people get on and off the elevator pessing the 2 anf 3 floor buttons the elevator can not get stuck going back and fothrt between the two floors.

Given are logical-Boolean variables.

Elevator call variables u. True if pressed false otherwise. When someone presses the button calling for an elevator the variable goes true. When the door opens at the floor the variable is returned to false.
F1_ Up
F2_Up
F2_Down
F3_Up
F3_Down
F4_Down

Floor indicators, tells you when a floor has been reacjed.
F1
F2
F3
F4

Up Down status.

Elevevator_Up
Elevator_Down


Elevator car buttons. Normally false, made true when pressed, and made false wham the floor is reached.

The algorithm must make the variables false when an operation is completed.

The algorithm will entail and ifnite loop.

START

…algorithm

Got TO START

When the algorithm starts it logically evaluates the buttons and determines the floor to go to. Paradoxes ot logical traps as outlined above are to be avoided. We all are familiar with elevators so the sequencing requirements should be obvious.

If the elevator is going up the Up vatribale is true. Down the Down variable is true.

Make use of logical contracts like if then else and while.

while(logical function){ logical stae,emts } executes the logical segments in the braces while the logical function is true.
If(logical function) { } same as above and so on.


If(logical function) { } else { }

Logical function is a variable or logical statement that evaluates to true or false. A logica; function could be if(F1_Up & F2_Up) ( …} If the function is true than excite the expressions in the braces. If false ignore.

It is a simplified version of a complete system. Simply properly sequence the elevator based on floor call buttons and elevator car buttons.

Something a little different than the usual syllogism. Applied logic.

https://en.wikipedia.org/wiki/Symbolic_language_(programming)

Some coding examples
https://en.wikipedia.org/wiki/List_of_logic_symbols
https://fresh2refresh.com/c-programming/c-operators-expressions/c-logical-operators/
https://www.tutorialspoint.com/cprogramming/c_logical_operators

You're barely started, and already you have introduced a pointless inefficiency - there's no need for separate elevator_up and elevator_down variables; at all times elevator_up must be equal to NOT elevator_down, so you can dispense with one of these. Indeed, you must do so, because if both were to end up set to 'TRUE' it would be disastrous.

Unless you're building includes an elevator that can move in two directions at once?
 
Max = 6 ' floors
el_floor = 1
Start loop
If el_floor = max or el_floor = 1, then,
if el_floor = max, then skip = -1, else skip = 1 end if
end if
el_floor = el_floor + skip
goto el_floor
loop

It is terribly inefficient to run an elevator this way, but the code is pretty tight.
 
Still, if this is really a thread about the logic of the lift, I want first a common lexis of the terms and symbols allowed, like, for example, ¬, ∧, ∨, ⊻, →, ⇔, ≡, ⊢ etc., complete with a short definition of each symbol.

Ooh, can we have that anyway?



I guess we'll have to wait and see whether Steve can step up to the plate.
EB

You are equivocating and debating instead of doing.

Hmmm..you said 'my logic sucks' and 'I don't know shit about logic'.

For me this would have been a routine task. Computer languages are essentially symbolic logic. The problem can be simplified. Given a set of buttons that have been pushed and the elevator is at a floor, determine the next floor sequence. No looping.

Map logicaly push buttons to a a next floor.

This is logic. If,and, or, not, and so on. Nothing you do not know. if( logical state of buttons & current floor & current direction) then go to floor n.

I picked the problem because it is common, straightforward, and the solution can not be looked up.

If I did post a solution you would act like you knew it already and criticize.

It can be done in Boolean Algebra which I used regularly or formal logic symology. I would do it piece wise. Break it down into sections and then connect the sections. A logical system.

It could be brute forced by simply working out all the possible combinations of switched and floor stops, but that is not very elegant.

I did this stuff for 30 years. Steve's the name and logic is my game. As I try to communicate to you classic logic and syllogisms are only a small part of logic as a category.
 
OK, I guess we won't get Steve to step up. All talk, no action. Get a lift, man. Or call for help, there's a button.

Me, it definitely got me thinking. So, I'll do it, just because it's a good exercise and there are a few things to clarify.

Clearly, the way Steve presented the problem, he is confusing algorithms with logic. Typical of your average software practitioner. Some computer scientists even believe computers are logic itself. Whoa, some serious dogma there. Still, I don't think there's any difficulty in formalising the logic of lifts. I could even do a more general class of problems with lifts as a particular case. Ultimately, lifts are a restriction of reality as a whole. But, sure, we can simplify and limit ourselves to a small set of premises because life is short. The lift will go up and down. It will stop at a floor if requested by the occupant of the lift but only if there is no fire going on at the floor. There will be a call-for-help button. And a button to play muzak. For stopping the doors closing or for asking immediate closing. What else?

And only logic and nothing else.
EB

Computer code and algorithms are logic, an evolutionary strep past what you call Aristotelian Logic. AL has the well known shortcomings. It is not just software. Boolean Algebra is commonly used to describe logical conditions for both electronics' and mechanical systems. You argument that algorithms and code are not logic is ignorance. Bolean Algebra is mathematical logic. It is axiomatic and avoids the falsities' and conundrums of the syllogism.

The C Language implements part of symbolic logic. What is left out can be constructed from logic primitives. Programming is logic and reasoning.

You are stuck in the 19th century.
 
algorithms are logic.
No.
Algorithms are called "algorithms", logic is called "logic".
Look up a dictionary.
Even one on a computer will do.
EB

The OP is for you. I go by experience and common usage among peers. Logic refers in general to logical analysis using logic...how's that?

Logic is far more than syllogisms with premises and and a conclusion. Grow or stagnate in the pre 20th century thinking.
 
To actually work out the code would take me a full time 4 or 5 days and a few days for testing.
???

This "exercise" would take a software developer with a 30 year career 4 or 5 days full-time, without testing?

Got paid by the hour, eh?

I was a jack of all trades master o none. I did most everything. I was not a dedicated SW engineer. But logic is logic mechanical, electronic, or otherwise. Hence the OP problem. AND OR Aristotelian or Boolean logic can and has been implemented in mechanical systems.

Logic is not EBs abstractions, it exists in language we all use and in formal systems applied to real world situations.


When I was up to speed and could code in C without thinking about it this would take me 1 - 2 weeks including developing a simulation. Note I said code.

To develop the logic alone a day or two. It may seem trivial until you actually try to develop the logic in writing and think it all through.I did a lot of work in embedded systems with complex logic. Boolean logic and formal logic as implemented in languages.

These days you can develop a truth table and software will extract the Boolean expressions. Programmable logic devices like FPGAs can have thousands of logical terms. Systems beyond human capacity to develop by hand.

As a contractor in my last year about 7 years ago I made around $160k 'by the hour'.
 
The OP is for you. I go by experience and common usage among peers. Logic refers in general to logical analysis using logic...how's that?

Logic is far more than syllogisms with premises and and a conclusion. Grow or stagnate in the pre 20th century thinking.

Logic is what it is and you have no idea what it is.
EB
 
An Exercise In Logic. (...)
The task is to develop an algorithm using formal logic to determine the sequence of floor stops depending on the external call buttons and the buttons inside the elevator.
(...)
Something a little different than the usual syllogism. Applied logic.

If you understood logic at all you'd know that you don't need any algorithm to do the logic of a lift.

So if this is really an exercise in logic, your own post is a derail.
EB
 
Back
Top Bottom