lean4-htt/tests/lean/run/eq9.lean
Leonardo de Moura 1e6b3614ab feat(frontends/lean): new pattern matching validation
@Kha, we now support variable/constant shadowing in patterns.
A constant may occur in a pattern if it is a constructor or tagged with
the new [pattern] attribute. In the standard library, I have tagged
'add', 'zero', 'one', 'bit0', 'bit1' and 'rfl' with this new attribute.
BTW, arbitrary constants and variables may occur nested in type ascriptions and
inaccessible terms.

Here is an example:

     meta_definition tactic_result_to_string {A : Type} : tactic_result A → string
     | (success a s)   := to_string a
     | (exception ⌞A⌟ e s) := "Exception: " ++ to_string (e ())

I had to use the inaccessible ⌞A⌟ in the example above, otherwise, we would be shadowing the parameter
{A : Type}, and we would get a type error.

The new validation is performed at to_pattern_fn (parser.cpp).
2016-08-07 11:31:11 -07:00

11 lines
386 B
Text

open nat
attribute [pattern] lt.base
attribute [pattern] lt.step
theorem lt_trans : ∀ {a b c : nat}, a < b → b < c → a < c
| lt_trans h (lt.base _) := lt.step h
| lt_trans h₁ (lt.step h₂) := lt.step (lt_trans h₁ h₂)
theorem lt_succ : ∀ {a b : nat}, a < b → succ a < succ b
| lt_succ (lt.base a) := lt.base (succ a)
| lt_succ (lt.step h) := lt.step (lt_succ h)