The Flippin' Magician's 7-card Grand Finale

This question is a followup to this question by @ais523, which itself was a followup to this question by @Wen1now.

After touring the globe to accolades when performing his 10-card trick and 8-card trick, the magician noticed that the public's interest had waned, as had his own. Needing something to reinvigorate his act, he returned to an idea he pigeonholed long ago: the 7-card trick. Identifying four face-down cards from a group of seven would be something never before seen.

He took the 0 card from his 8-card deck and tossed it aside. With the cards numbered 1 to 7, he shuffled a while, flipped a bit, and after some time exclaimed "Eureka!" Hurriedly, he grabbed a note card and scribbled down the instructions for his assistant. Then he grabbed another and wrote instructions for himself.

The trick works in the following way:

• The implements are cards numbered from 1 to 7 and a layout with seven spots where cards are placed.
• At the beginning of the trick the magician leaves and is unable to communicate with anyone.
• A volunteer is selected and places one card, face up, on each layout spot in any desired arrangement.
• The assistant then points to four of the cards that the volunteer flips over in-place on the layout.
• The magician returns from isolation and is able to identify the number on each of the four face-down cards.

This a mathematical trick with no communication or collusion of any kind. The volunteer could place the cards randomly and the trick would still work. If the rest of humankind died while the magician was in isolation, he could still return and identify the values of the face-down cards (to somewhat muted applause).

This succinct description is blatantly stolen from @ais523's question and adapted for this one:

(Here's an equivalent formulation for the mathematicians and computer scientists out there: write a function whose input is a permutation of the list [1, 2, 3, 4, 5, 6, 7], and whose output is equal to the input except that four of the elements are replaced with "?", such that different inputs map to different outputs.)

There's one other restriction that the magician and assistant were working under: they wouldn't be able to take pages of notes with them when performing the trick, so whatever their strategies were, they would have to be simple enough to memorise; listing a separate strategy for each of the 5040 possible inputs isn't a reasonable answer here.

What are the instructions for the assistant and for the magician to perform this trick?

• Since it seemed to be implied by the context, I edited the question so that the randomiser places the cards face up. My apologies if I was mistaken.
– Bass
Oct 6, 2019 at 7:03
• @Bass Thanks. That's exactly right. Oct 6, 2019 at 14:46
• Is it possible to determine which card is "first"/leftmost? Oct 23, 2019 at 1:23
• @Skylar There aren't any restrictions on the geometry of layout spots, so feel free to use any arrangement you like. Oct 23, 2019 at 2:00

Here is a full implementation based on cycle structure.

A full explanation would be tedious. Instead here is a list of examples covering every single cycle structure. If you need more detail.please comment.

card arrangements can be grouped in terms of their cycle representation The $$7!=5040$$ arrangements can then be broken down as (cycle lengths, total count) (7): 720 --- (6): 840 --- (5): 504 --- (5,2): 504 --- (4): 210 --- (4,3): 420 --- (4,2): 630 --- (3): 70 --- (3,3): 280 --- (3,2): 420 --- (3,2,2): 210 --- (2): 21 --- (2,2): 105 --- (2,2,2): 105 --- (): 1
Similarly, codons can be broken down into open groups like (2,4),(4,3) and closed groups like (1,1). Then the $$\begin{pmatrix}7\\3\end{pmatrix}\times 7\times 6\times 5=7350$$ codons can be grouped into (ox: open group of size x, cx: closed group of size x) (o3,o2): 2520 --- (o2,o2,c1): 1260 --- (o4): 840 --- (o2,o2,o2): 840 --- (o3,c1): 840 --- (o2,c1,c1): 420 --- (o2,c2): 420 --- (c2,c1): 105 --- (c3): 70 --- (c1,c1,c1): 35