Zulip Chat Archive

Stream: Is there code for X?

Topic: DecidableRel on structures


Bhakti Shah (Jul 26 2023 at 17:37):

Is there something that says decLt a.f₀ b.f₀ ∧ decLt a.f₁ b.f₁ → decLt a b if a and b are structures with fields f₀ and f₁? (I'm also not sure if this is even true; but it seems true to me :D)

Eric Wieser (Jul 26 2023 at 17:46):

That doesn't typecheck, docs#DecidableRel takes just one argument

Bhakti Shah (Jul 26 2023 at 17:48):

oops I edited the question (also changed it to be a bit more specific)

Julian Berman (Jul 26 2023 at 17:54):

What's decLt? Can you include your imports?

Julian Berman (Jul 26 2023 at 17:54):

(And if it exists it probably will be with \to rather than \and, and maybe some exting)

Bhakti Shah (Jul 26 2023 at 17:59):

Don't have any imports. decLt as seen here, basically just a -> b -> Decidable (a < b) Here's an mwe of what i was trying to do:

abbrev ID := String

structure Name where
  id : ID
  path : List ID

deriving instance DecidableEq for Name

instance : LT Name where
  lt a b := (a.id < b.id)  (a.path < b.path)

instance Name.decLt (n m : Name) : Decidable (n < m)  := sorry

Eric Wieser (Jul 26 2023 at 18:06):

Note your edited version still doesn't typecheck (assuming it refers to String.decLt), as decLt is a proof not a proposition

Eric Wieser (Jul 26 2023 at 18:07):

Your new version is fine, but it doesn't resemble your question any more!

Eric Wieser (Jul 26 2023 at 18:08):

instance Name.decLt (n m : Name) : Decidable (n < m)  := by
  show Decidable (_  _)
  infer_instance

Eric Wieser (Jul 26 2023 at 18:08):

Or even use docs#instDecidableAnd directly:

instance Name.decLt (n m : Name) : Decidable (n < m) := instDecidableAnd

Bhakti Shah (Jul 26 2023 at 18:11):

oh that's amazing thank you! sorry about the original question i keep trying to generalize my question :')


Last updated: Dec 20 2023 at 11:08 UTC