lean2/tests/lean/univ_vars.lean
Leonardo de Moura ca632cca13 feat(frontends/lean): add 'universe variable' command
We can declare variables anywhere. So, we must also be able do declare
"universe" variables anywhere. Here is a minimal example that requires
this feature

```
-- We want A and B to be in the same universe
universe variable l
variable A : Type.{l}
variable B : Type.{l}
definition tst := A = B
```

The following doesn't work because A and B are in different universes
```
variable A : Type
variable B : Type
definition tst := A = B
```

The following works, but tst is not universe polymorphic, since l is
one *fixed* global universe
```
universe l
variable A : Type.{l}
variable B : Type.{l}
definition tst := A = B
```
2014-10-11 14:22:33 -07:00

28 lines
427 B
Text

import logic
set_option pp.universes true
universe u
variable A : Type.{u}
definition id1 (a : A) : A := a
check @id1
variable B : Type
definition id2 (a : B) : B := a
check @id2
universe variable k
variable C : Type.{k}
definition id3 (a : C) := a
check @id3
universe variables l m
variable A₁ : Type.{l}
variable A₂ : Type.{l}
definition foo (a₁ : A₁) (a₂ : A₂) := a₁ == a₂
check @foo
check Type.{m}