{-# OPTIONS --cubical-compatible #-}
open import Padova2025.ProgrammingBasics.Naturals.Base
open import Padova2025.ProgrammingBasics.Naturals.Arithmetic
open import Padova2025.ProgrammingBasics.Lists
open import Padova2025.ProvingBasics.Negation
open import Padova2025.ProvingBasics.Equality.Base
open import Padova2025.ProvingBasics.Equality.General
open import Padova2025.ProvingBasics.Equality.NaturalNumbers
open import Padova2025.ProvingBasics.Connectives.Disjunction
open import Padova2025.ProvingBasics.Connectives.Existential
open import Padova2025.ProvingBasics.Connectives.Conjunction
open import Padova2025.ProvingBasics.Connectives.More
open import Padova2025.ProvingBasics.Termination.Ordering
open import Padova2025.Explorations.Pigeonhole
module Padova2025.Recreational.Choice.Boxes.Base (β : Set) (n : β) where
Intro
An evil monster prepares a secret room containing infinitely many opaque boxes. The boxes are numbered by the naturals and each box contains a real number of the monsterβs choosing.
One by one, the evil monster privately guides the members of a team
of n mathematicians into the room, with the other members
waiting outside. While in the room, each mathematician may open as many
boxes as they wish, even infinitely many, inspecting their contents.
They may base their decision as to which boxes to open on the contents
they have seen so far. The only requirement is that they keep one box of
their choosing untouched: The monster will ask them for a guess
regarding the contents of that box.
The mathematicians win as a team if and only if at most one of them guesses incorrectly. As usual, communication among the team is allowed only beforehand. Between successive visits to the room, the room is reset to its original state (so all the opened boxes are closed again).
Config : Set Config = β β β
Player : Set Player = Fin n
β : β β Set β _ = β₯
infixl 5 _β·_
_β·_ : {I : Set} β (β β Set) β (I β β) β (β β Set)
Opened β· xs = Ξ» x β Opened x β β[ i ] xs i β‘ x
For a predicate Opened : β β Set, the type
PlayerStrategy Opened is the type of all possible
strategies which are valid in the sense of not offering a guess for an
already opened box.
data PlayerStrategy (Opened : β β Set) : Setβ where
guess : (x : β) β Β¬ Opened x β β β PlayerStrategy Opened
peek : {I : Set} β (xs : I β β) β ((I β β) β PlayerStrategy (Opened β· xs)) β PlayerStrategy Opened
guessesCorrectly : {Opened : β β Set} β PlayerStrategy Opened β Config β Set
guessesCorrectly (guess x _ y) c = y β‘ c x
guessesCorrectly (peek xs k) c = guessesCorrectly (k (Ξ» i β c (xs i))) c
TeamStrategy : Setβ TeamStrategy = Player β PlayerStrategy β
isSuccessful : TeamStrategy β Set isSuccessful s = (c : Config) β (q q' : Player) β Β¬ guessesCorrectly (s q) c β Β¬ guessesCorrectly (s q') c β q β‘ q'
Lane arithmetic
pack : Player β β β β
pack p zero = toβ p
pack p (succ m) = n + pack p m
pack-β₯ : (p : Player) (m : β) β pack p (succ m) β₯ n
pack-β₯ p m = +-inflationaryβ n (pack p m)
pack-injective : {q q' : Player} {m m' : β} β pack q m β‘ pack q' m' β q β‘ q' Γ m β‘ m'
pack-injective {q} {q'} {zero} {zero} eq = toβ-injective eq , refl
pack-injective {q} {q'} {zero} {succ m'} eq = β₯-elim (<-irreflexive' (β€-trans (pack-β₯ q' m') (β‘ββ€ (sym eq))) (toβ-bounded q))
pack-injective {q} {q'} {succ m} {zero} eq = β₯-elim (<-irreflexive' (β€-trans (pack-β₯ q m) (β‘ββ€ eq)) (toβ-bounded q'))
pack-injective {q} {q'} {succ m} {succ m'} eq with pack-injective (+-cancelβ n _ _ eq)
... | qβ‘q' , mβ‘m' = qβ‘q' , cong succ mβ‘m'
insert : (j : β) β (Ξ£[ i β β ] i β’ j β β) β β β Config insert j c x i with eq? i j ... | left _ = x ... | right iβ’j = c (i , iβ’j)
insert-β* : (j : β) β (c : Config) β (x : β) β insert j (Ξ» (i , _) β c i) x β* c insert-β* j c x = j β· [] , go where go : (i : β) β insert j (Ξ» (i , _) β c i) x i β‘ c i β i β (j β· []) go i with eq? i j ... | left refl = right (here refl) ... | right _ = left refl
TODO cite GabayβOβConnor and Hardin & Taylor