lean4-htt/tests/lean/run/matchtac.lean
2020-08-28 09:18:22 -07:00

42 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.

new_frontend
theorem tst1 {α : Type} {p : Prop} (xs : List α) (h₁ : (a : α) → (as : List α) → xs = a :: as → p) (h₂ : xs = [] → p) : p :=
begin
match h:xs with
| [] => exact h₂ h
| z::zs => { apply h₁ z zs; assumption }
end
theorem tst2 {α : Type} {p : Prop} (xs : List α) (h₁ : (a : α) → (as : List α) → xs = a :: as → p) (h₂ : xs = [] → p) : p :=
begin
match h:xs with
| [] => ?nilCase
| z::zs => ?consCase;
case consCase exact h₁ z zs h;
case nilCase exact h₂ h;
end
def tst3 {α β γ : Type} (h : α × β × γ) : β × α × γ :=
begin
match h with
| (a, b, c) => exact (b, a, c)
end
theorem tst4 {α : Type} {p : Prop} (xs : List α) (h₁ : (a : α) → (as : List α) → xs = a :: as → p) (h₂ : xs = [] → p) : p :=
begin
match h:xs with
| [] => _
| z::zs => _;
case match_2 exact h₁ z zs h;
exact h₂ h
end
theorem tst5 {p q r} (h : p q r) : r q p:=
begin
match h with
| Or.inl h => exact Or.inr (Or.inr h)
| Or.inr (Or.inl h) => ?c1
| Or.inr (Or.inr h) => ?c2;
case c2 { apply Or.inl; assumption };
{ apply Or.inr; apply Or.inl; assumption }
end