Skip to content

Finite equality for empty domains breaks subject reduction #6016

Open

Description

@plt-amy

At the same time as I was pondering #6015, I remembered this little gem from @pigworker's note "Grins from my Ripley Cupboard":

{-# OPTIONS --cubical --safe --two-level #-}
module ripley where
open import Agda.Primitive.Cubical
open import Agda.Primitive

record Liftₛ (A : Set) : SSet where
  constructor lift
  field
    lower : A

data Bool : Set where
  tt ff : Bool

data Idₛ {ℓ} (A : SSet ℓ) (a : A) : A → SSet ℓ where
  reflₛ : Idₛ A a a

module _ (p : IsOne i0) where
  module _ (theₛ : ∀ {ℓ} {A : Set ℓ} → Partial i0 A → A) where
    f : Partial i0 Bool
    f = λ _ → tt

    g : Partial i0 Bool
    g = λ _ → ff

    h : Idₛ (Liftₛ Bool) (lift (theₛ f)) (lift (theₛ g))
    h = reflₛ

  i : Idₛ (Liftₛ Bool) (lift tt) (lift ff)
  i = h λ f → f p

  k : Idₛ (Liftₛ Bool) (lift tt) (lift ff)
  k = {! i   !}

Try asking for the normal form of i in the right-hand-side of k, and you'll see that Agda says it's reflₛ. To clarify: I'm not pointing out that assuming IsOne i0 (which is empty) lets you prove true ≡ false. I'm pointing out that I've managed to convince Agda that true and false are definitionally equal.

Activity

  1. jonsterling commented on Aug 10, 2022

    @jonsterling
  2. plt-amy commented on Aug 10, 2022

    @plt-amy
    ContributorAuthor

    Oh, of course!

    [edit: updated the issue post instead]

  3. plt-amy commented on Aug 10, 2022

    @plt-amy
    ContributorAuthor

    SSet/--two-level is a red herring; Here's one that uses just paths.

    {-# OPTIONS --cubical --safe #-}
    module ripley where
    open import Agda.Builtin.Cubical.Path
    open import Agda.Primitive.Cubical
    open import Agda.Primitive
    
    data Bool : Set where
      tt ff : Bool
    
    module _ (p : IsOne i0) where
      module _ (theₛ : ∀ {ℓ} {A : Set ℓ} → Partial i0 A → A) where
        f : Partial i0 Bool
        f = λ _ → tt
    
        g : Partial i0 Bool
        g = λ _ → ff
    
        h : (theₛ f) ≡ (theₛ g)
        h = λ i → theₛ f
    
      i : tt ≡ ff
      i = h λ f → f p
    
      k : tt ≡ ff
      k = {! i   !}

    Asking for the normal form of i gets me λ i₁ → tt.

  4. jonsterling commented on Aug 11, 2022

    @jonsterling
    Contributor

    Very nicely done @plt-amy! For the benefit of the Agda devs, let me comment a bit on how cooltt/redtt were carefully designed to avoid failures of subject reduction like this. I hadn't predicted this issue in particular, but there were other similar problems that I predicted and was careful to avoid in my design of cooltt and redtt.

    In our tools, we have a syntactic phase distinction between cubical things (dimensions, cofibrations, proofs of cofibrations) and non-cubical things. In particular, this means that you cannot ever write something like nat -> I or Path A a b -> IsOne i0. This obviously has some downsides for expressivity, but it has one upside that has always been non-negotiable to me --- and which the evidence presented by this ticket suggests should also be non-negotiable to any implementer of cubical type theory. This upside is that you can always decide whether the current context is "judgmentally inconsistent"; it is then trivial to avoid the failure of subject reduction exhibited here, since k = refl would actually be well-typed in any context in which there can be derived some p : IsOne i0. (In such a context, all judgments hold.)

    This particular benefit is a special case of the way that this phase distinction allows us to have a generalization of 'equality reflection' for the cofibration logic, which I suppose might be referred to as 'truth reflection', without disrupting either decidability of critical global properties of the algorithmic typing rules such as subject reduction or transitivity of definitional equality.

  5. added
    type: bug
    cubical
    subject reduction
    on Aug 14, 2022
  6. added this to the 2.6.3 milestone on Aug 23, 2022
  7. modified the milestones: 2.6.3, 2.6.4 on Aug 28, 2022
  8. modified the milestones: 2.6.4, 2.6.5 on May 29, 2023
  9. modified the milestones: 2.7.0, icebox on Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    cubicalsubject reductiontype: bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions