Zulip Chat Archive

Stream: general

Topic: Invalid type ascription??


Neil Strickland (Feb 05 2019 at 14:55):

I am mystified by this:

def foo (a : ) : fin a.succ := begin
 let z : fin a.succ := 0,
 let q :   (fin a.succ) := λ b, z,
 exact z
end

After the definition of q, I get

invalid type ascription, term has type
    fin (nat.succ a)
but is expected to have type
  Π (a : ), fin (nat.succ a)
state:
a : ,
z : fin (nat.succ a) := 0
 fin (nat.succ a)

So q has the type that I said it should have, but for some reason Lean expects it to have a different type?

Reid Barton (Feb 05 2019 at 14:57):

You have stumbled across a highly dubious Lean feature.

Reid Barton (Feb 05 2019 at 14:58):

In tactic mode (only), q : ℕ → (fin a.succ) means q : Π (a : ℕ), (fin a.succ).

Reid Barton (Feb 05 2019 at 14:59):

In other words is expanded to a Pi type using the fixed variable name a.

Mario Carneiro (Feb 05 2019 at 15:02):

'''''''''''feature'''''''''''

Neil Strickland (Feb 05 2019 at 15:05):

Thanks. So I see that this works instead:

def foo (a : ) : fin a.succ := begin
 let z : fin a.succ := 0,
 let q :  b : , (fin a.succ) := λ b, z,
 exact z
end

Kevin Buzzard (Feb 05 2019 at 17:32):

What did I tell you about making definitions using tactic mode Neil??

Kevin Buzzard (Feb 05 2019 at 17:32):

[PS I was doing this myself earlier today :-)]


Last updated: Dec 20 2023 at 11:08 UTC