Why is this a proof by contradiction for this algorithm? Isn't this a direct proof instead?
$begingroup$
First Slide: Find Max(A)
- // INPUT: A[1..n] - an array of integers
- // OUTPUT: an element m of A such that m >= A[j], for all 1 <= j <= A.length
- max = A[j==1]
- for j = 2 to A.length
- if max < A[j]
- max = A[j]
- return max
Second Slide: Proof By Contradiction
Proof: Suppose the algorithm is incorrect. Then for some input A, either:
- max is not an element of A or
- A has an element A[j] such that max < A[j]
Max is initialized to and assigned to elements of A - so (1) is impossible.
After the j-th iteration of the for loop (lines 4 - 6), max >= A[j]. From lines 5,6 max only increases. Therefore upon termination, max >= A[j] which contradicts (2).
End Of Slides
This algorithm (first slide) finds the max element in the array. This is a proof by contradiction. Isn't this algorithm already proved when it gets to max >= A[j] in the last line of the second slide. Is which contradicts (2) even necessary? Because in the second slide you showed max is in the array, and then you met the condition of a maxium m: an element m of A such
that m >= A[j] for all 1 <= j <= A.length.
This seems to be two proofs in one. And since it seems to me that the direct proof happens first, then the proof by contradiction is redundant and therefore not necessary. Am i missing something here? Is this only a proof by contradiction? Or is it a direct proof instead?
The image below is just the slides 1 and 2 that I transcribed above. From York University.
algorithms correctness-proof check-my-answer
New contributor
$endgroup$
add a comment |
$begingroup$
First Slide: Find Max(A)
- // INPUT: A[1..n] - an array of integers
- // OUTPUT: an element m of A such that m >= A[j], for all 1 <= j <= A.length
- max = A[j==1]
- for j = 2 to A.length
- if max < A[j]
- max = A[j]
- return max
Second Slide: Proof By Contradiction
Proof: Suppose the algorithm is incorrect. Then for some input A, either:
- max is not an element of A or
- A has an element A[j] such that max < A[j]
Max is initialized to and assigned to elements of A - so (1) is impossible.
After the j-th iteration of the for loop (lines 4 - 6), max >= A[j]. From lines 5,6 max only increases. Therefore upon termination, max >= A[j] which contradicts (2).
End Of Slides
This algorithm (first slide) finds the max element in the array. This is a proof by contradiction. Isn't this algorithm already proved when it gets to max >= A[j] in the last line of the second slide. Is which contradicts (2) even necessary? Because in the second slide you showed max is in the array, and then you met the condition of a maxium m: an element m of A such
that m >= A[j] for all 1 <= j <= A.length.
This seems to be two proofs in one. And since it seems to me that the direct proof happens first, then the proof by contradiction is redundant and therefore not necessary. Am i missing something here? Is this only a proof by contradiction? Or is it a direct proof instead?
The image below is just the slides 1 and 2 that I transcribed above. From York University.
algorithms correctness-proof check-my-answer
New contributor
$endgroup$
3
$begingroup$
The proof assumes the opposite of what is to be proved then shows a contradiction. So it is a proof by contradiction. And so it is not a direct proof. It happens to prove that the algorithm is correct. "when it gets to max >= A[j]" it has gotten there by having assumed the opposite of what is to be proved; it has not proved "max >= A[j]" having assumed nothing. Indeed since it assumed something that happens to be false, anything can be derived thereafter before discharging that assumption.
$endgroup$
– philipxy
yesterday
1
$begingroup$
Don't use images as main content of your post. This makes your question impossible to search and inaccessible to the visually impaired; we don't like that. Please transcribe text and mathematics (note that you can use LaTeX) and don't forget to give proper attribution to your sources!
$endgroup$
– dkaeae
yesterday
add a comment |
$begingroup$
First Slide: Find Max(A)
- // INPUT: A[1..n] - an array of integers
- // OUTPUT: an element m of A such that m >= A[j], for all 1 <= j <= A.length
- max = A[j==1]
- for j = 2 to A.length
- if max < A[j]
- max = A[j]
- return max
Second Slide: Proof By Contradiction
Proof: Suppose the algorithm is incorrect. Then for some input A, either:
- max is not an element of A or
- A has an element A[j] such that max < A[j]
Max is initialized to and assigned to elements of A - so (1) is impossible.
After the j-th iteration of the for loop (lines 4 - 6), max >= A[j]. From lines 5,6 max only increases. Therefore upon termination, max >= A[j] which contradicts (2).
End Of Slides
This algorithm (first slide) finds the max element in the array. This is a proof by contradiction. Isn't this algorithm already proved when it gets to max >= A[j] in the last line of the second slide. Is which contradicts (2) even necessary? Because in the second slide you showed max is in the array, and then you met the condition of a maxium m: an element m of A such
that m >= A[j] for all 1 <= j <= A.length.
This seems to be two proofs in one. And since it seems to me that the direct proof happens first, then the proof by contradiction is redundant and therefore not necessary. Am i missing something here? Is this only a proof by contradiction? Or is it a direct proof instead?
The image below is just the slides 1 and 2 that I transcribed above. From York University.
algorithms correctness-proof check-my-answer
New contributor
$endgroup$
First Slide: Find Max(A)
- // INPUT: A[1..n] - an array of integers
- // OUTPUT: an element m of A such that m >= A[j], for all 1 <= j <= A.length
- max = A[j==1]
- for j = 2 to A.length
- if max < A[j]
- max = A[j]
- return max
Second Slide: Proof By Contradiction
Proof: Suppose the algorithm is incorrect. Then for some input A, either:
- max is not an element of A or
- A has an element A[j] such that max < A[j]
Max is initialized to and assigned to elements of A - so (1) is impossible.
After the j-th iteration of the for loop (lines 4 - 6), max >= A[j]. From lines 5,6 max only increases. Therefore upon termination, max >= A[j] which contradicts (2).
End Of Slides
This algorithm (first slide) finds the max element in the array. This is a proof by contradiction. Isn't this algorithm already proved when it gets to max >= A[j] in the last line of the second slide. Is which contradicts (2) even necessary? Because in the second slide you showed max is in the array, and then you met the condition of a maxium m: an element m of A such
that m >= A[j] for all 1 <= j <= A.length.
This seems to be two proofs in one. And since it seems to me that the direct proof happens first, then the proof by contradiction is redundant and therefore not necessary. Am i missing something here? Is this only a proof by contradiction? Or is it a direct proof instead?
The image below is just the slides 1 and 2 that I transcribed above. From York University.
algorithms correctness-proof check-my-answer
algorithms correctness-proof check-my-answer
New contributor
New contributor
edited 9 hours ago
user100752
New contributor
asked yesterday
user100752user100752
163
163
New contributor
New contributor
3
$begingroup$
The proof assumes the opposite of what is to be proved then shows a contradiction. So it is a proof by contradiction. And so it is not a direct proof. It happens to prove that the algorithm is correct. "when it gets to max >= A[j]" it has gotten there by having assumed the opposite of what is to be proved; it has not proved "max >= A[j]" having assumed nothing. Indeed since it assumed something that happens to be false, anything can be derived thereafter before discharging that assumption.
$endgroup$
– philipxy
yesterday
1
$begingroup$
Don't use images as main content of your post. This makes your question impossible to search and inaccessible to the visually impaired; we don't like that. Please transcribe text and mathematics (note that you can use LaTeX) and don't forget to give proper attribution to your sources!
$endgroup$
– dkaeae
yesterday
add a comment |
3
$begingroup$
The proof assumes the opposite of what is to be proved then shows a contradiction. So it is a proof by contradiction. And so it is not a direct proof. It happens to prove that the algorithm is correct. "when it gets to max >= A[j]" it has gotten there by having assumed the opposite of what is to be proved; it has not proved "max >= A[j]" having assumed nothing. Indeed since it assumed something that happens to be false, anything can be derived thereafter before discharging that assumption.
$endgroup$
– philipxy
yesterday
1
$begingroup$
Don't use images as main content of your post. This makes your question impossible to search and inaccessible to the visually impaired; we don't like that. Please transcribe text and mathematics (note that you can use LaTeX) and don't forget to give proper attribution to your sources!
$endgroup$
– dkaeae
yesterday
3
3
$begingroup$
The proof assumes the opposite of what is to be proved then shows a contradiction. So it is a proof by contradiction. And so it is not a direct proof. It happens to prove that the algorithm is correct. "when it gets to max >= A[j]" it has gotten there by having assumed the opposite of what is to be proved; it has not proved "max >= A[j]" having assumed nothing. Indeed since it assumed something that happens to be false, anything can be derived thereafter before discharging that assumption.
$endgroup$
– philipxy
yesterday
$begingroup$
The proof assumes the opposite of what is to be proved then shows a contradiction. So it is a proof by contradiction. And so it is not a direct proof. It happens to prove that the algorithm is correct. "when it gets to max >= A[j]" it has gotten there by having assumed the opposite of what is to be proved; it has not proved "max >= A[j]" having assumed nothing. Indeed since it assumed something that happens to be false, anything can be derived thereafter before discharging that assumption.
$endgroup$
– philipxy
yesterday
1
1
$begingroup$
Don't use images as main content of your post. This makes your question impossible to search and inaccessible to the visually impaired; we don't like that. Please transcribe text and mathematics (note that you can use LaTeX) and don't forget to give proper attribution to your sources!
$endgroup$
– dkaeae
yesterday
$begingroup$
Don't use images as main content of your post. This makes your question impossible to search and inaccessible to the visually impaired; we don't like that. Please transcribe text and mathematics (note that you can use LaTeX) and don't forget to give proper attribution to your sources!
$endgroup$
– dkaeae
yesterday
add a comment |
2 Answers
2
active
oldest
votes
$begingroup$
It's a proof by contradiction that could easily be rewritten as a direct proof.
To rephrase it as a direct proof, we divide it into two claims:
$max$ is an element of $A$.
$max geq A[j]$ for all $j$.
We can conclude that $max = max(A)$.
$endgroup$
add a comment |
$begingroup$
You seem to think the structure of the proof is:
- suppose the algorithm is incorrect;
- prove that the algorithm is, in fact, correct;
- this contradicts 1., so the algorithm is correct.
That's almost, but not quite true. Step 2 doesn't prove that the returned value $mathrm{max}$ is bigger than every element of the array, which is what would be required to prove that the algorithm is correct. It just proves that $mathrm{max}$ is bigger than the specific array value that was supposed to be a counterexample in step 1.
But, as Yuval has pointed out, the proof is much easier if you forget about contradiction completely and prove that $mathrm{max}$ is in the array (identical to the given proof) and then show that $mathrm{max}$ is at least as big as every array element (identical to the proof except "for all $j$" instead of just for one supposed counterexample.
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "419"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
user100752 is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcs.stackexchange.com%2fquestions%2f106019%2fwhy-is-this-a-proof-by-contradiction-for-this-algorithm-isnt-this-a-direct-pro%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
It's a proof by contradiction that could easily be rewritten as a direct proof.
To rephrase it as a direct proof, we divide it into two claims:
$max$ is an element of $A$.
$max geq A[j]$ for all $j$.
We can conclude that $max = max(A)$.
$endgroup$
add a comment |
$begingroup$
It's a proof by contradiction that could easily be rewritten as a direct proof.
To rephrase it as a direct proof, we divide it into two claims:
$max$ is an element of $A$.
$max geq A[j]$ for all $j$.
We can conclude that $max = max(A)$.
$endgroup$
add a comment |
$begingroup$
It's a proof by contradiction that could easily be rewritten as a direct proof.
To rephrase it as a direct proof, we divide it into two claims:
$max$ is an element of $A$.
$max geq A[j]$ for all $j$.
We can conclude that $max = max(A)$.
$endgroup$
It's a proof by contradiction that could easily be rewritten as a direct proof.
To rephrase it as a direct proof, we divide it into two claims:
$max$ is an element of $A$.
$max geq A[j]$ for all $j$.
We can conclude that $max = max(A)$.
answered yesterday
Yuval FilmusYuval Filmus
195k14184348
195k14184348
add a comment |
add a comment |
$begingroup$
You seem to think the structure of the proof is:
- suppose the algorithm is incorrect;
- prove that the algorithm is, in fact, correct;
- this contradicts 1., so the algorithm is correct.
That's almost, but not quite true. Step 2 doesn't prove that the returned value $mathrm{max}$ is bigger than every element of the array, which is what would be required to prove that the algorithm is correct. It just proves that $mathrm{max}$ is bigger than the specific array value that was supposed to be a counterexample in step 1.
But, as Yuval has pointed out, the proof is much easier if you forget about contradiction completely and prove that $mathrm{max}$ is in the array (identical to the given proof) and then show that $mathrm{max}$ is at least as big as every array element (identical to the proof except "for all $j$" instead of just for one supposed counterexample.
$endgroup$
add a comment |
$begingroup$
You seem to think the structure of the proof is:
- suppose the algorithm is incorrect;
- prove that the algorithm is, in fact, correct;
- this contradicts 1., so the algorithm is correct.
That's almost, but not quite true. Step 2 doesn't prove that the returned value $mathrm{max}$ is bigger than every element of the array, which is what would be required to prove that the algorithm is correct. It just proves that $mathrm{max}$ is bigger than the specific array value that was supposed to be a counterexample in step 1.
But, as Yuval has pointed out, the proof is much easier if you forget about contradiction completely and prove that $mathrm{max}$ is in the array (identical to the given proof) and then show that $mathrm{max}$ is at least as big as every array element (identical to the proof except "for all $j$" instead of just for one supposed counterexample.
$endgroup$
add a comment |
$begingroup$
You seem to think the structure of the proof is:
- suppose the algorithm is incorrect;
- prove that the algorithm is, in fact, correct;
- this contradicts 1., so the algorithm is correct.
That's almost, but not quite true. Step 2 doesn't prove that the returned value $mathrm{max}$ is bigger than every element of the array, which is what would be required to prove that the algorithm is correct. It just proves that $mathrm{max}$ is bigger than the specific array value that was supposed to be a counterexample in step 1.
But, as Yuval has pointed out, the proof is much easier if you forget about contradiction completely and prove that $mathrm{max}$ is in the array (identical to the given proof) and then show that $mathrm{max}$ is at least as big as every array element (identical to the proof except "for all $j$" instead of just for one supposed counterexample.
$endgroup$
You seem to think the structure of the proof is:
- suppose the algorithm is incorrect;
- prove that the algorithm is, in fact, correct;
- this contradicts 1., so the algorithm is correct.
That's almost, but not quite true. Step 2 doesn't prove that the returned value $mathrm{max}$ is bigger than every element of the array, which is what would be required to prove that the algorithm is correct. It just proves that $mathrm{max}$ is bigger than the specific array value that was supposed to be a counterexample in step 1.
But, as Yuval has pointed out, the proof is much easier if you forget about contradiction completely and prove that $mathrm{max}$ is in the array (identical to the given proof) and then show that $mathrm{max}$ is at least as big as every array element (identical to the proof except "for all $j$" instead of just for one supposed counterexample.
answered yesterday
David RicherbyDavid Richerby
69.1k15106195
69.1k15106195
add a comment |
add a comment |
user100752 is a new contributor. Be nice, and check out our Code of Conduct.
user100752 is a new contributor. Be nice, and check out our Code of Conduct.
user100752 is a new contributor. Be nice, and check out our Code of Conduct.
user100752 is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Computer Science Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcs.stackexchange.com%2fquestions%2f106019%2fwhy-is-this-a-proof-by-contradiction-for-this-algorithm-isnt-this-a-direct-pro%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
$begingroup$
The proof assumes the opposite of what is to be proved then shows a contradiction. So it is a proof by contradiction. And so it is not a direct proof. It happens to prove that the algorithm is correct. "when it gets to max >= A[j]" it has gotten there by having assumed the opposite of what is to be proved; it has not proved "max >= A[j]" having assumed nothing. Indeed since it assumed something that happens to be false, anything can be derived thereafter before discharging that assumption.
$endgroup$
– philipxy
yesterday
1
$begingroup$
Don't use images as main content of your post. This makes your question impossible to search and inaccessible to the visually impaired; we don't like that. Please transcribe text and mathematics (note that you can use LaTeX) and don't forget to give proper attribution to your sources!
$endgroup$
– dkaeae
yesterday