lean4-htt/tests/lean/as_pattern.lean
2017-11-27 12:43:15 +01:00

54 lines
1.2 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

namespace as_pattern
inductive foo
| a | b | c
inductive bar : foo → Type
| a : bar foo.a
| b : bar foo.b
def basic : list foo → list foo
| x@([_]) := x -- `@[` starts an attribute
| x@_ := x
#print prefix as_pattern.basic.equations
def nested : list foo → list foo
| (x@foo.b :: _) := [x]
| x := x
#print prefix as_pattern.nested.equations
def value : option → option
| (some x@2) := some x
| x := x
#print prefix as_pattern.value.equations
def weird_but_ok :
| x@y@z := x+y+z
#print prefix as_pattern.weird_but_ok.equations
def too_many :
| x@_ := x
| x@0 := x
| x@_ := x
| x := x
def too_many2 :
| x@x@0 := x
| x@x := x
def dependent : Π (f : foo), bar f → foo
| x@foo.a bar.a := x
| x@_ bar.b := x
#print prefix as_pattern.dependent.equations
section involved
universe variables u v
inductive imf {A : Type u} {B : Type v} (f : A → B) : B → Type (max 1 u v)
| mk : ∀ (a : A), imf (f a)
definition inv_1 {A : Type u} {B : Type v} (f : A → B) : ∀ (b : B), imf f b → A
| x@.(f w) y@(imf.mk z@.(f) w@a) := w
end involved
def unicode :
| n₁@_ := n₁
end as_pattern