Stream: Beginner Questions

Topic: Failed to refined pending goal when implementing class


view this post on Zulip David Wang (Apr 30 2024 at 13:12):

I am trying to derive an instance of proper_interval for a custom variable type. However, Isabelle fails to refined a pending goal in the instance proof:

type_synonym name = string
datatype variable = varname: Var name

instantiation variable::ord begin
  fun less_eq_variable::"variable ⇒ variable ⇒ bool" where
    "less_eq_variable (variable.Var x) (variable.Var y) = (String.implode x ≤ String.implode y)"

  fun less_variable::"variable ⇒ variable ⇒ bool" where
    "less_variable (variable.Var x) (variable.Var y) = (String.implode x < String.implode y)"
instance proof
qed
end

instantiation variable::proper_interval begin
  fun not_adj::"variable ⇒ variable ⇒ bool" where
    "not_adj (variable.Var x) (variable.Var y) = (y ≠ (x @ [CHR 0x00]))"

  fun proper_interval_variable::"variable proper_interval" where
    "proper_interval_variable None None = True"
  | "proper_interval_variable None (Some (variable.Var x)) = (x ≠ [])"
  | "proper_interval_variable (Some x) None = True"
  | "proper_interval_variable (Some x) (Some y) = (less x y ∧ not_adj x y)"
instance proof
  show "proper_interval None None = True"
qed
end

Another attempt:

instantiation variable::proper_interval begin
  fun proper_interval_variable::"variable proper_interval" where
    "proper_interval_variable None None = True"
  | "proper_interval_variable None (Some (variable.Var x)) = (x ≠ [])"
  | "proper_interval_variable (Some x) None = True"
  | "proper_interval_variable (Some (variable.Var x)) (Some (variable.Var y)) =
    (less (variable.Var x) (variable.Var y) ∧ y ≠ (x @ [CHR 0x00]))"
instance proof
  show "proper_interval None None = True"
qed
end

Does anyone know what I am doing wrong?

view this post on Zulip Mathias Fleury (Apr 30 2024 at 13:14):

  show "proper_interval (None::variable option) None = True"
    sorry

view this post on Zulip Mathias Fleury (Apr 30 2024 at 13:15):

very typical issue to forget type annotations in the instantiation…

view this post on Zulip David Wang (Apr 30 2024 at 13:15):

Thank you.

view this post on Zulip Kevin Kappelmann (Apr 30 2024 at 13:20):

Mathias Fleury said:

very typical issue to forget type annotations in the instantiation…

Is this something you could summarise in a few words so that we can add it here? :)
https://github.com/isabelle-prover/cookbook/blob/master/_data/common_errors.yml

It will then be displayed here:
https://isabelle.systems/cookbook/src/common_errors/

view this post on Zulip Kevin Kappelmann (May 02 2024 at 08:15):

Merged. Now online here:
https://isabelle.systems/cookbook/src/common_errors/

Thanks @David Wang :)


Last updated: Dec 21 2024 at 16:20 UTC