{-# OPTIONS --cubical-compatible #-}
open import Padova2025.ProgrammingBasics.Naturals.Base
open import Padova2025.ProvingBasics.Negation
open import Padova2025.ProvingBasics.Equality.Base
open import Padova2025.ProvingBasics.Equality.General
open import Padova2025.ProvingBasics.Connectives.Disjunction
open import Padova2025.ProvingBasics.Connectives.Conjunction
open import Padova2025.ProvingBasics.Connectives.More
open import Padova2025.ProvingBasics.Termination.Ordering
open import Padova2025.Explorations.Pigeonhole
import Padova2025.Recreational.Choice.Boxes.Base as Base
module Padova2025.Recreational.Choice.Boxes.Correctness
(β : Set) (n : β) (R : Normalizer β β)
(open Base β n)
(c : Config)
where
Correctness
import Padova2025.Recreational.Choice.Boxes.Stage1 β n as Stage1 import Padova2025.Recreational.Choice.Boxes.Stage2 β n as Stage2 import Padova2025.Recreational.Choice.Boxes.Stage3 β n as Stage3 open import Padova2025.Recreational.Choice.Boxes.Combined β n
infixr 9 _β_
_β_ : {X Y Z : Set} β (Y β Z) β (X β Y) β (X β Z)
g β f = Ξ» x β g (f x)
open Normalizer R
module PlayerView (p : Player) where open Stage1 p public their-box-contents : I β β their-box-contents = c β their-box-indices open Stage2 R p their-box-contents public our-box-contents : J β β our-box-contents = c β our-box-indices open Stage3 R p their-box-contents our-box-contents public lane : Player β Config lane p = c β pack p rep-is-truthful : Player β Set rep-is-truthful p = rep (lane p) (succ M) β‘ (lane p) (succ M) where open PlayerView p truthful-causes-win : (p : Player) β rep-is-truthful p β guessesCorrectly (assemble R p) c truthful-causes-win p eq = trans (respects (insert-β* (succ M) (lane p) dummy) (succ M)) eq where open PlayerView p in-bad-list : (p p' : Player) β p β’ p' β (x : β) β rep (lane p) x β’ lane p x β x β PlayerView.known-bad-lane-indices p' p in-bad-list p p' pβ’p' x neq with p β‘? p' ... | yes pβ‘p' = β₯-elim (pβ’p' pβ‘p') ... | no _ = β¨-notβ (β¨-comm (snd (repβ* (lane p)) x)) neq bound : (p p' : Player) β p β’ p' β Β¬ rep-is-truthful p β succ (PlayerView.M p) β€ PlayerView.M p' bound p p' pβ’p' p-l = maximum-β₯ _ _ (β-concat (in-bad-list p p' pβ’p' (succ (PlayerView.M p)) p-l) (β-tabulate-Fin _ p)) one-loser : (p p' : Player) β Β¬ rep-is-truthful p β Β¬ rep-is-truthful p' β p β‘ p' one-loser p p' p-l p'-l with p β‘? p' ... | yes pβ‘p' = pβ‘p' ... | no pβ’p' = β₯-elim (<-irreflexive'' (bound p p' pβ’p' p-l) (bound p' p (pβ’p' β sym) p'-l)) correct : (p p' : Player) β Β¬ guessesCorrectly (assemble R p) c β Β¬ guessesCorrectly (assemble R p') c β p β‘ p' correct p p' Β¬gc-p Β¬gc-p' = one-loser p p' (contraposition (truthful-causes-win p) Β¬gc-p) (contraposition (truthful-causes-win p') Β¬gc-p')
theorem : (R : Normalizer β β) β isSuccessful (assemble R) theorem R c = Correctness.correct R c