{-# OPTIONS --cubical --no-import-sorts -WnoUnsupportedIndexedMatch --allow-unsolved-metas #-}
module AFF2024.Basics where

open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Powerset
open import Cubical.HITs.PropositionalTruncation
open import Cubical.HITs.PropositionalTruncation.Monad
open import Cubical.Data.Empty
open import Cubical.Data.Sigma
open import Cubical.Data.Sum
open import Cubical.Data.Nat
open import Cubical.Relation.Nullary.Base
open import Data.List
open import Data.List.Relation.Unary.All
open import Data.List.Relation.Unary.AllPairs

module _ { ℓ' : Level} (X : Type ) (R : X  X  Type ℓ') where
  Infinite : Type (ℓ-max  ℓ')
  Infinite = (xs : List X)  ∃[ y  X ] All (R y) xs

module _ { ℓ' : Level} {X : Type } {R : X  X  Type ℓ'} where
  module _ (inf : Infinite X R) where
    takeFrom∞ : (n : )  ∃[ xs  List X ] ((length xs  n) × AllPairs R xs)
    takeFrom∞ zero    =  [] , refl , [] ∣₁
    takeFrom∞ (suc n) = do
      (xs , len , p)  takeFrom∞ n
      (y , q)         inf xs
      return (y  xs , cong suc len , q  p)

allP : { ℓ' : Level} {X : Type } {P : X  Type ℓ'}  ((x : X)  P x)  (xs : List X)  All P xs
allP f []       = []
allP f (x  xs) = f x  allP f xs

 : { : Level} {X : Type }   X
 x = ⊥* , isProp⊥*

_∪_ : { : Level} {X : Type }   X   X   X
A  B = λ x   fst (A x)  fst (B x) ∥₁ , isPropPropTrunc

module _ { : Level} {X : Type } where
  _≢_ : X  X  Type 
  a  b = ¬ (a  b)

module _ { : Level} {X : Type } where
  IsExploding : (A :  X)  Type 
  IsExploding A = ∃[ n   ] ((xs : List X)  length xs  n  All (_∈ A) xs  AllPairs _≢_ xs  (x : X)  x  A)

  ∅-isExploding : IsExploding 
  ∅-isExploding =  suc zero ,  { [] eq p q  Cubical.Data.Empty.rec (znots eq) ; (x  xs) eq (px  p) q  Cubical.Data.Empty.rec* px }) ∣₁

  ∪-isExploding : {A B :  X}  IsExploding A  IsExploding B  IsExploding (A  B)
  ∪-isExploding f g = do
    (n , p)  f
    (m , q)  g
    {!!}