{-

  This file contains:

  - Definition of Actions
  - Definition of GSets and the GSet Structure

-}

{-# OPTIONS --cubical #-}

open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Structure
open import Cubical.Algebra.Group
open import Cubical.Reflection.RecordEquiv

private
  variable
     : Level

-- An action of a group on a set
record Action (G : Group ) (X : Type ) : Type  where
  constructor
    action
  field
    _*_ :  G   X  X
    is-set : isSet X
    ·Unit : (x : X)  (str G).GroupStr.1g * x  x
    ·Composition : (g1 g2 :  G ) (x : X)  g1 * (g2 * x)  ((str G).GroupStr._·_ g1 g2) * x

unquoteDecl ActionIsoΣ = declareRecordIsoΣ ActionIsoΣ (quote Action)

record GSetStr (G : Group ) (X : Type ) : Type  where
  constructor gsetstr
  field
    ϕ : Action {} G X

  open Action ϕ public

unquoteDecl GSetStrIsoΣ = declareRecordIsoΣ GSetStrIsoΣ (quote GSetStr)

-- Useful lemma to show the action of inverses
act-inv : {G : Group } {X : Type } (F : Action G X) {a :  G } {x y : X}  x  F .Action._*_ a y  F .Action._*_ (str G .GroupStr.inv a) x  y
act-inv {G = G} F {a} {x} {y} p =
  inv a * x       ≡⟨ cong  x  inv a * x) p 
  inv a * (a * y) ≡⟨ ·Composition (inv a) a y 
  (inv a · a) * y ≡⟨ cong  x  x * y) (·InvL a) 
  1g * y          ≡⟨ ·Unit y 
  y               
  where
  open GroupStr (str G)
  open Action F

-- The type of G-sets
GSet : { : Level}  Group   Type (ℓ-suc )
GSet {} G = TypeWithStr  (GSetStr G)