Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in a recursive definition, the recursive call must specify the arguments before the colon #52

Open
semorrison opened this issue Nov 23, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@semorrison
Copy link
Contributor

In Lean 3, when making a recursive definition using the equation compiler, you had to leave out arguments that came before the colon when making a recursive call. In Lean 4, these arguments are required.

e.g. we used to write (from Lean 3 core)

instance decidable_mem [decidable_eq α] (a : α) : ∀ (l : list α), decidable (a ∈ l)
| []     := is_false not_false
| (b::l) :=
  if h₁ : a = b then is_true (or.inl h₁)
  else match decidable_mem l with
  | is_true  h₂ := is_true (or.inr h₂)
  | is_false h₂ := is_false (not_or h₁ h₂)
  end

but now write (from mathlib4):

instance decidableMem [DecidableEq α] (a : α) : ∀ (l : List α), Decidable (a ∈ l)
  | []     => isFalse not_false
  | b :: l =>
    if h₁ : a = b then isTrue (Or.inl h₁)
    else match decidableMem a l with
      | isTrue h₂  => isTrue (Or.inr h₂)
      | isFalse h₂ => isFalse (not_or_intro h₁ h₂)

mathport will need to insert these additional arguments while translating.

See e.g. https://github.com/leanprover-community/mathlib3port/blob/d82ba1c/Mathbin/Data/List/Defs.lean#L39.

@semorrison semorrison added the bug Something isn't working label Nov 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant