Answers.Body: <p>I agree that the number is very low. Namely 0.</p>
  
  <p>A legal position is defined as a position reachable by regular moves.
  Your diagrams do not show legal positions.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-27T20:27:09.140Z
Answers.Text: OP has already clarified what they mean by 'legal' in a comment on the question.
Answers.UserDisplayName: konsolas
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-27T20:21:03.033Z
Answers.LastActivityDate: 2019-12-27T20:21:03.033Z
Answers.UserDisplayName: Adam P.
Answers.Body: <p>As others have said, the number of those unreachable positions is rather small. There are other important things to consider, though: it seems rather difficult to determine which positions are unreachable and which are not for all but the trivial cases. And then, even if you know which positions are unreachable, that information can hardly be used to minimise the database size, as you cannot just remove some "random" positions. The positions are not stored as such, but just the values. Hence, you would need to construct an indexing function that skips just those positions, which seems impossible. (If not removed, it might bring tiny tiny gains during compression if you treat those positions as "don't cares", but this is probably negligible, and dangerous when looking at the position and not knowing it's unreachable).</p>
  
  <p>As a side note, the Nalimov databases don't include illegal positions with unblockable checks, i.e. wKe1 bQe2 BTM, but they do include illegal positions with the slider away more than one square. These positions take up a significant part of the database, but it's rather difficult to exclude them in the indexing.</p>
  
  <p>As far as "legal but unreachable" goes, keep in mind that even if unreachable, the position might become legal in a real game (after a non-disputed illegal move).</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-27T17:14:23.060Z
Answers.LastActivityDate: 2016-09-27T17:14:23.060Z
Answers.UserDisplayName: Eiko
Answers.Body: <p>also consider the number of pawns stacked in a file vs the number of captured enemy pieces. For example, if two pawns are on the c-file, one enemy piece must have been captured; and if 6 pawns are on the a- or h-file, 15 enemy pieces (i.e. all but the king) must have been captured: the nearest knight's pawn must have made one capture, the bishop's pawn must have made two captures and so on.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-20T11:39:08.527Z
Answers.Text: But there are positions with for example white pawns on h3,h2,g2. Those are illegal as well.
Answers.UserDisplayName: BlindKungFuMaster
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-13T14:42:51.477Z
Answers.Text: @RosieF I think it's George Jelliss - wonderful guy - hope to meet him one day
Answers.UserDisplayName: Laska
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-13T16:58:58.587Z
Answers.Text: @Laska I stand corrected. I beg his pardon. The following corrects and replaces an old comment which I've now deleted: George Peter Jelliss.lists many examples in Chessics 19, p32-3 and Chessics 29, p.159. Some more examples: double check by two units neither of which can discover from the other, where no ep capture can discover both; wBa1 bKb2; wRa1 bKb1 anything a2; wNa1 bKb3 anything c2; check by unmoved pawn.
Answers.UserDisplayName: Rosie F
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-02-27T01:46:45.773Z
Answers.Text: This won't end up disallowing any positions, since any position in an endgame tablebase will have so few pieces on the board (especially if there are many pawns) that this constraint will certainly be satisfied.
Answers.UserDisplayName: dfan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-02-27T01:27:57.127Z
Answers.LastActivityDate: 2015-08-20T10:39:27.627Z
Answers.LastEditDate: 2015-08-20T10:39:27.627Z
Answers.UserDisplayName: Mc Kevin
Answers.Body: <p>The question remains a bit vague, but the suggestion in a couple of answers was that the most arrangements of pieces would be "reachable" (by which they mean in FIDE laws terms "legal" i.e. that can be arrived at by a sequence of legal moves). The supporting argument was the behaviour with 6 pieces. There just isn't much opportunity for illegality with 6 pieces, but the number of arrangements increases exponentially as the number of pieces on the board increases, so the 6-piece behaviour is not statistically relevant. </p>
  
  <p>More importantly, 6-piece behaviour is also highly untypical. <a href="https://mathoverflow.net/questions/138133/what-proportion-of-chess-positions-that-one-can-set-up-on-the-board-using-a-leg">The mathoverflow.net version of the question</a>, which @GloriaVictis sensibly pointed us to in a comment, has a much more rigorous question and answers, and shows by detailed analysis that almost all arrangements of chess pieces are illegal. </p>
  
  <p>What they do seem to miss even in mathoverflow is that the notion of position includes who has the move and also castling and en passant capability, and that increases both the number of positions and the proportion which are illegal.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-27T16:23:08.073Z
Answers.LastActivityDate: 2019-12-27T16:23:08.073Z
Answers.UserDisplayName: Laska
Answers.Body: <p>The fraction of all six-man positions that are unreachable from the starting position is very, very small. Removing them would have a tiny effect on the size of a six-man database.</p>
  
  <p>Here is an example of how rare these positions are. First of all, we can't get into one of these unreachable positions without a bishop and a pawn, so we already have a small subset of the number of total six-man positions. But okay, say that one side is lucky enough to have one pawn, one bishop, and a king. The bishop will have to be in one of its own corners (not the far corners!) and the pawn will have to be diagonally adjacent to it. So only 2 out of the 64 bishop positions could lead to a trapped bishop, and out of those, the pawn has to be in the one spot of its possible 48 positions that would trap the bishop. So <em>even if you have one pawn and one bishop</em>, which is pretty unlikely, the chances of randomly getting an unreachable position are only (2/64) * (1/48) = 1 in 1536.</p>
  
  <p>Let's do one bishop, two pawns, and a king just for fun. If the bishop is in its own corner (2/64 chance), the chance of getting one of the two pawns in the diagonally adjacent square is 2/48 (2 of the 48 squares in ranks 2 through 7 have pawns in them). If the bishop is one of the other spots on the first rank (4/64 chance - c1 and f1 are definitely OK!), both pawns have to be in exactly the right spot (1/48 * 1/47) chance. When I do the math I get a chance of around 1.33% for getting an unreachable position even if you start with this very unlikely great combination of material for generating unreachable positions.</p>
  
  <p>My conclusion, as first predicted in my comment above and now backed up by some math, is that these unreachable positions are an extremely small subset of the set of all six-man positions.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-02-26T22:49:03.257Z
Answers.Text: How about opposite corners with opposite side's pawns? For e.g. Black bishop on h1, white pawn on g2.
Answers.UserDisplayName: NM Wesley Falcao
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-02-26T22:53:09.313Z
Answers.Text: Good point! I expect that would double the number. (It will still be really really small in comparison to the entire set.)
Answers.UserDisplayName: dfan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-02-26T22:57:50.917Z
Answers.Text: I'm thinking if there are other possible unreachable positions. Maybe some positions are unreachable because the king cannot get there successfully without being under check.
Answers.UserDisplayName: NM Wesley Falcao
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-02-26T23:12:50.833Z
Answers.Text: It is totally possible that there are a few other cases, but the overwhelming majority are going to come from bishops being trapped behind pawns.
Answers.UserDisplayName: dfan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-02-26T23:18:55.253Z
Answers.Text: By the way, I take back my agreement about a Black bishop on h1 and a White pawn on g2 being an unreachable position. You'd have to put a White pawn on h2 as well for it to be unreachable.
Answers.UserDisplayName: dfan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-02-26T23:39:14.453Z
Answers.Text: good point there!
Answers.UserDisplayName: NM Wesley Falcao
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-02-27T12:42:53.093Z
Answers.Text: Indeed! We got too excited about the trapped-bishop case. Another example: 4/64 * 3/63 + 24/64 * 5/63 + 36/64 * 8/63 = 10.42% of all positions will have adjacent kings.
Answers.UserDisplayName: dfan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-02-26T22:08:46.340Z
Answers.LastActivityDate: 2014-02-26T23:17:29.373Z
Answers.LastEditDate: 2014-02-26T23:17:29.373Z
Answers.UserDisplayName: dfan
Body: <p>Consider this legal chess position which can never be reached from the normal starting position. </p>
  
  <pre><code>    [FEN "6kb/6p1/6K1/8/8/8/8/8 w - - 0 1"]
  </code></pre>
  
  <p>The Black bishop is placed on h8, but with the Black pawn on g7, there is no way the bishop could have actually reached h8. How many such positions exist in chess which are legal but unreachable? Is there any research on reachable/non-reachable positions? </p>
  
  <p>I found that endgame tablebases don't necessarily take this into consideration, but if the number of non-reachable positions is significantly large, it might possibly help minimize the size of endgame tablebases. </p>
  
  <p>Here's a screenshot from the online <a href="http://www.k4it.de/index.php?lang=en&amp;topic=egtb" rel="noreferrer">Nalimov</a> tablebases. </p>
  
  <p><img src="https://i.sstatic.net/muGNs.jpg" alt="enter image description here"></p>
  
  <p>Now, in this unreachable position, I can add another piece like a knight on almost every square. </p>
  
  <p><img src="https://i.sstatic.net/tjjEj.jpg" alt="enter image description here"></p>
  
  <p>I can add an additional piece, like a rook. </p>
  
  <p><img src="https://i.sstatic.net/BT736.jpg" alt="enter image description here"></p>
  
  <p>This can go on and on and I can keep adding more pieces, but all those positions would be unreachable. We thus end up storing unnecessary positions in the tablebase and increasing its size. </p>
  
  <p>Of course, it's a good thing for tablebases to have these positions if we want to use them for chess variants like Chess960, but they are not necessary for the standard version of chess. It would be quite interesting to know how many such unreachable positions exist. </p>
  
  <p>(Addition of more relevant tags suggested)</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-01-23T09:44:22.043Z
Comments.Text: Actually "legal" is a fixed expression meaning "reachable". It is commonly used to describe studies and other compositions. No big deal of course, you made it clear enough ...
Comments.UserDisplayName: BlindKungFuMaster
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-08-20T13:18:54.140Z
Comments.Text: Related, may be of interest: http://mathoverflow.net/questions/138133/what-proportion-of-chess-positions-that-one-can-set-up-on-the-board-using-a-leg
Comments.UserDisplayName: GloriaVictis
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-09-28T00:36:32.383Z
Comments.Text: You ask an interesting question. I wonder: what if there exist positions *whose reachability is unknown?* That is, suppose that I set up a specific position as you have done; but, looking at my position, you are unable to tell me whether the position is reachable. What then?
Comments.UserDisplayName: thb
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-09-30T09:42:26.717Z
Comments.Text: @dfan 1% of the 7-man tablebases is 1.4 terabytes
Comments.UserDisplayName: M.M
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-02-26T15:16:12.590Z
Comments.Text: By "legal" I mean a position where the side to move doesn't have the opponent's king already in check.
Comments.UserDisplayName: NM Wesley Falcao
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-02-26T19:05:27.287Z
Comments.Text: I am sure that the fraction of positions in a tablebase that are unreachable is a tiny, tiny fraction of the total number of positions. Just from general combinatorial principles, I would imagine that is far less than a thousandth of all tablebase positions. Omitting these positions is going to have basically no effect on the size of your tablebase.
Comments.UserDisplayName: dfan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-02-26T20:19:08.483Z
Comments.Text: I didn't want to make it an answer unless I actually provided a mathematical demonstration or something rather than just saying "I'm sure this is true". Nevertheless, I am sure it is true :)
Comments.UserDisplayName: dfan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-02-26T21:47:45.100Z
Comments.Text: @dfan I'm sure many people aren't sure about how sure your statement is. :)
Comments.UserDisplayName: NM Wesley Falcao
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-02-26T22:08:59.483Z
Comments.Text: OK, I did some math and put it in an answer.
Comments.UserDisplayName: dfan
Tags: <rules><tablebases>
Title: How many legal but unreachable positions exist?
ThreadText: # How many legal but unreachable positions exist?
  
  (Asked by: username_0 on 2014-02-26)
  
  Consider this legal chess position which can never be reached from the normal starting position. 
      [FEN "6kb/6p1/6K1/8/8/8/8/8 w - - 0 1"]
  
  The Black bishop is placed on h8, but with the Black pawn on g7, there is no way the bishop could have actually reached h8. How many such positions exist in chess which are legal but unreachable? Is there any research on reachable/non-reachable positions? 
  I found that endgame tablebases don't necessarily take this into consideration, but if the number of non-reachable positions is significantly large, it might possibly help minimize the size of endgame tablebases. 
  Here's a screenshot from the online Nalimov tablebases. 
  
  Now, in this unreachable position, I can add another piece like a knight on almost every square. 
  
  I can add an additional piece, like a rook. 
  
  This can go on and on and I can keep adding more pieces, but all those positions would be unreachable. We thus end up storing unnecessary positions in the tablebase and increasing its size. 
  Of course, it's a good thing for tablebases to have these positions if we want to use them for chess variants like Chess960, but they are not necessary for the standard version of chess. It would be quite interesting to know how many such unreachable positions exist. 
  (Addition of more relevant tags suggested)
  
  **Tags:** rules, tablebases
  
  > **Comments:**
  > **username_0**: By "legal" I mean a position where the side to move doesn't have the opponent's king already in check.  
  > **username_5**: I am sure that the fraction of positions in a tablebase that are unreachable is a tiny, tiny fraction of the total number of positions. Just from general combinatorial principles, I would imagine that is far less than a thousandth of all tablebase positions. Omitting these positions is going to have basically no effect on the size of your tablebase.  
  > **username_5**: I didn't want to make it an answer unless I actually provided a mathematical demonstration or something rather than just saying "I'm sure this is true". Nevertheless, I am sure it is true :)  
  > **username_0**: @username_5 I'm sure many people aren't sure about how sure your statement is. :)  
  > **username_5**: OK, I did some math and put it in an answer.  
  > **username_1**: Actually "legal" is a fixed expression meaning "reachable". It is commonly used to describe studies and other compositions. No big deal of course, you made it clear enough ...  
  > **username_2**: Related, may be of interest: http://mathoverflow.net/questions/138133/what-proportion-of-chess-positions-that-one-can-set-up-on-the-board-using-a-leg  
  > **username_3**: You ask an interesting question. I wonder: what if there exist positions *whose reachability is unknown?* That is, suppose that I set up a specific position as you have done; but, looking at my position, you are unable to tell me whether the position is reachable. What then?  
  > **username_4**: @username_5 1% of the 7-man tablebases is 1.4 terabytes  
  
  ---
  
  ## 5 answers
  
  ### Answer by username_5 on 2014-02-26. Score: 7 | Accepted answer
  
  The fraction of all six-man positions that are unreachable from the starting position is very, very small. Removing them would have a tiny effect on the size of a six-man database.
  
  Here is an example of how rare these positions are. First of all, we can't get into one of these unreachable positions without a bishop and a pawn, so we already have a small subset of the number of total six-man positions. But okay, say that one side is lucky enough to have one pawn, one bishop, and a king. The bishop will have to be in one of its own corners (not the far corners!) and the pawn will have to be diagonally adjacent to it. So only 2 out of the 64 bishop positions could lead to a trapped bishop, and out of those, the pawn has to be in the one spot of its possible 48 positions that would trap the bishop. So *even if you have one pawn and one bishop*, which is pretty unlikely, the chances of randomly getting an unreachable position are only (2/64) \* (1/48) = 1 in 1536.
  
  Let's do one bishop, two pawns, and a king just for fun. If the bishop is in its own corner (2/64 chance), the chance of getting one of the two pawns in the diagonally adjacent square is 2/48 (2 of the 48 squares in ranks 2 through 7 have pawns in them). If the bishop is one of the other spots on the first rank (4/64 chance - c1 and f1 are definitely OK!), both pawns have to be in exactly the right spot (1/48 \* 1/47) chance. When I do the math I get a chance of around 1.33% for getting an unreachable position even if you start with this very unlikely great combination of material for generating unreachable positions.
  
  My conclusion, as first predicted in my comment above and now backed up by some math, is that these unreachable positions are an extremely small subset of the set of all six-man positions.
  
  > **Comments:**
  > **username_0**: How about opposite corners with opposite side's pawns? For e.g. Black bishop on h1, white pawn on g2.  
  > **username_5**: Good point! I expect that would double the number. (It will still be really really small in comparison to the entire set.)  
  > **username_0**: I'm thinking if there are other possible unreachable positions. Maybe some positions are unreachable because the king cannot get there successfully without being under check.  
  > **username_5**: It is totally possible that there are a few other cases, but the overwhelming majority are going to come from bishops being trapped behind pawns.  
  > **username_5**: By the way, I take back my agreement about a Black bishop on h1 and a White pawn on g2 being an unreachable position. You'd have to put a White pawn on h2 as well for it to be unreachable.  
  > **username_0**: good point there!  
  > **username_5**: Indeed! We got too excited about the trapped-bishop case. Another example: 4/64 * 3/63 + 24/64 * 5/63 + 36/64 * 8/63 = 10.42% of all positions will have adjacent kings.  
  
  ---
  
  ### Answer by username_6 on 2019-12-27. Score: 4
  
  I agree that the number is very low. Namely 0.
  
  A legal position is defined as a position reachable by regular moves.
  Your diagrams do not show legal positions.
  
  > **Comments:**
  > **username_7**: OP has already clarified what they mean by 'legal' in a comment on the question.  
  
  ---
  
  ### Answer by username_8 on 2016-09-27. Score: 3
  
  As others have said, the number of those unreachable positions is rather small. There are other important things to consider, though: it seems rather difficult to determine which positions are unreachable and which are not for all but the trivial cases. And then, even if you know which positions are unreachable, that information can hardly be used to minimise the database size, as you cannot just remove some "random" positions. The positions are not stored as such, but just the values. Hence, you would need to construct an indexing function that skips just those positions, which seems impossible. (If not removed, it might bring tiny tiny gains during compression if you treat those positions as "don't cares", but this is probably negligible, and dangerous when looking at the position and not knowing it's unreachable).
  
  As a side note, the Nalimov databases don't include illegal positions with unblockable checks, i.e. wKe1 bQe2 BTM, but they do include illegal positions with the slider away more than one square. These positions take up a significant part of the database, but it's rather difficult to exclude them in the indexing.
  
  As far as "legal but unreachable" goes, keep in mind that even if unreachable, the position might become legal in a real game (after a non-disputed illegal move).
  
  
  ---
  
  ### Answer by username_9 on 2014-02-27. Score: 3
  
  also consider the number of pawns stacked in a file vs the number of captured enemy pieces. For example, if two pawns are on the c-file, one enemy piece must have been captured; and if 6 pawns are on the a- or h-file, 15 enemy pieces (i.e. all but the king) must have been captured: the nearest knight's pawn must have made one capture, the bishop's pawn must have made two captures and so on.
  
  > **Comments:**
  > **username_5**: This won't end up disallowing any positions, since any position in an endgame tablebase will have so few pieces on the board (especially if there are many pawns) that this constraint will certainly be satisfied.  
  > **username_1**: But there are positions with for example white pawns on h3,h2,g2. Those are illegal as well.  
  > **username_10**: @RosieF I think it's George Jelliss - wonderful guy - hope to meet him one day  
  > **username_11**: @username_10 I stand corrected. I beg his pardon. The following corrects and replaces an old comment which I've now deleted: George Peter Jelliss.lists many examples in Chessics 19, p32-3 and Chessics 29, p.159. Some more examples: double check by two units neither of which can discover from the other, where no ep capture can discover both; wBa1 bKb2; wRa1 bKb1 anything a2; wNa1 bKb3 anything c2; check by unmoved pawn.  
  
  ---
  
  ### Answer by username_10 on 2019-12-27. Score: 2
  
  The question remains a bit vague, but the suggestion in a couple of answers was that the most arrangements of pieces would be "reachable" (by which they mean in FIDE laws terms "legal" i.e. that can be arrived at by a sequence of legal moves). The supporting argument was the behaviour with 6 pieces. There just isn't much opportunity for illegality with 6 pieces, but the number of arrangements increases exponentially as the number of pieces on the board increases, so the 6-piece behaviour is not statistically relevant.
  
  More importantly, 6-piece behaviour is also highly untypical. [The mathoverflow.net version of the question](https://mathoverflow.net/questions/138133/what-proportion-of-chess-positions-that-one-can-set-up-on-the-board-using-a-leg), which @username_2 sensibly pointed us to in a comment, has a much more rigorous question and answers, and shows by detailed analysis that almost all arrangements of chess pieces are illegal.
  
  What they do seem to miss even in mathoverflow is that the notion of position includes who has the move and also castling and en passant capability, and that increases both the number of positions and the proportion which are illegal.
  
  
  ---
  
  