lean2/tests/lean/sec2.lean
Leonardo de Moura 4f2e0c6d7f refactor(frontends/lean): add 'attribute' command
The new command provides a uniform way to set declaration attributes.
It replaces the commands: class, instance, coercion, multiple_instances,
reducible, irreducible
2015-01-24 20:23:21 -08:00

24 lines
581 B
Text

structure A : Type := mk
structure B : Type := mk
constant f : A → B
constant g : B → B
constant a : A
namespace foo
attribute f [coercion]
print coercions
check g a
end foo
check g a -- Error
section boo
attribute f [coercion]
print coercions
check g a
end boo
-- The metaobjects defined in the section persist to the outer level.
-- This is not a bug. The idea is: we can use the scope to define
-- auxiliary variables that are then used to define classes/instances/etc.
-- That is, the whole point of the scope is to define these metaobjects.
check g a -- Ok