lean4-htt/tests/lean/as_pattern.lean
2017-11-17 16:35:21 -08:00

49 lines
1 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.

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 basic.equations
def nested : list foo → list foo
| (x@foo.b :: _) := [x]
| x := x
#print prefix nested.equations
def value : option → option
| (some x@2) := some x
| x := x
#print prefix value.equations
def weird_but_ok :
| x@y@z := x+y+z
#print prefix 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 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