------------------------------------------------------------------------
-- Assumptions used to state some theorems in
-- Graded.Erasure.LogicalRelation.Fundamental elsewhere for consequences
-- of the fundamental lemma.
------------------------------------------------------------------------

open import Graded.Modality
open import Graded.Usage.Restrictions
open import Definition.Typed.Restrictions

module Graded.Erasure.LogicalRelation.Fundamental.Assumptions
  {a} {M : Set a}
  {š•„ : Modality M}
  (TR : Type-restrictions š•„)
  (UR : Usage-restrictions š•„)
  where

open Modality š•„
open Usage-restrictions UR

open import Definition.Untyped M
open import Definition.Typed TR
open import Definition.Typed.Consequences.Consistency TR

open import Graded.Mode š•„
open import Graded.Restrictions š•„

open import Tools.Nat
open import Tools.PropositionalEquality
open import Tools.Sum

private variable
  k : Nat

-- A cut-down variant of Fundamental-assumptions (which is defined
-- below).

record Fundamental-assumptionsā» (Ī” : Con Term k) : Set a where
  no-eta-equality
  field
    -- If erased matches are allowed for emptyrec when the mode isĀ šŸ™įµ,
    -- then the context is consistent.
    consistent : Emptyrec-allowed šŸ™įµ šŸ˜ ā†’ Consistent Ī”
    -- Erased matches are not allowed unless the context is empty.
    closed-or-no-erased-matches : No-erased-matches TR UR āŠŽ k ā‰” 0

-- The fundamental lemma is proved under the assumption that a given
-- context Ī” satisfies the following assumptions.

record Fundamental-assumptions (Ī” : Con Term k) : Set a where
  no-eta-equality
  field
    -- The context is well-formed.
    well-formed : āŠ¢ Ī”
    -- Other assumptions.
    other-assumptions : Fundamental-assumptionsā» Ī”

  open Fundamental-assumptionsā» other-assumptions public

-- Fundamental-assumptionsā» holds unconditionally for empty contexts.

fundamental-assumptionsā»ā‚€ : Fundamental-assumptionsā» Īµ
fundamental-assumptionsā»ā‚€ = record
  { consistent                  = Ī» _ ā†’
                                    inhabited-consistent
                                      (_āŠ¢Ė¢_āˆ·_.id {Ļƒ = idSubst})
  ; closed-or-no-erased-matches = injā‚‚ refl
  }

-- Fundamental-assumptions holds unconditionally for empty contexts.

fundamental-assumptionsā‚€ : Fundamental-assumptions Īµ
fundamental-assumptionsā‚€ = record
  { well-formed       = Īµ
  ; other-assumptions = fundamental-assumptionsā»ā‚€
  }