test: contradiction

This commit is contained in:
Leonardo de Moura 2021-03-03 17:13:25 -08:00
parent 1d98edfeea
commit 1ecc50f809
3 changed files with 18 additions and 12 deletions

View file

@ -1,5 +1,3 @@
def f (x : Nat) : Nat :=
match x with
| 30 => 31
@ -39,14 +37,14 @@ by {
}
theorem ex7 (a : Bool) (p q : Prop) (h₁ : a = true → p) (h₂ : a = false → q) : p q :=
match h:a with
| true => Or.inl $ h₁ h
| false => Or.inr $ h₂ h
match h:a with
| true => Or.inl $ h₁ h
| false => Or.inr $ h₂ h
def head {α} (xs : List α) (h : xs = [] → False) : α :=
match he:xs with
| [] => False.elim $ h he
| x::_ => x
match he:xs with
| [] => by contradiction
| x::_ => x
variable {α : Type u} {p : α → Prop}

View file

@ -59,12 +59,12 @@ theorem ex3b (n : Nat) : Exists (fun m => n = m + m n = m + m + 1) := by
def ex4 {α} (xs : List α) (h : xs = [] → False) : α := by
cases he:xs with
| nil => apply False.elim; exact h he; done
| nil => contradiction
| cons x _ => exact x
def ex5 {α} (xs : List α) (h : xs = [] → False) : α := by
cases he:xs using List.casesOn with
| nil => apply False.elim; exact h he; done
| nil => contradiction
| cons x _ => exact x
theorem ex6 {α} (f : List α → Bool) (h₁ : {xs : List α} → f xs = true → xs = []) (xs : List α) (h₂ : xs ≠ []) : f xs = false :=
@ -82,9 +82,9 @@ theorem ex8 {α} (f : List α → Bool) (h₁ : {xs : List α} → f xs = true
| true => exact False.elim (h₂ (h₁ he))
| false => rfl
theorem ex9 {α} (xs : List α) (h : xs = [] → False) : Nonempty α := by
theorem ex9 (xs : List α) (h : xs = [] → False) : Nonempty α := by
cases xs using List.rec with
| nil => apply False.elim; apply h; rfl
| nil => contradiction
| cons x _ => apply Nonempty.intro; assumption
theorem modLt (x : Nat) {y : Nat} (h : y > 0) : x % y < y := by

View file

@ -39,3 +39,11 @@ theorem ex13 (h : id False) : α := by
theorem ex14 (h : 100000000 ≤ 20) : α := by
contradiction
theorem ex15 (x : α) (h : x = x → False) : α := by
contradiction
theorem ex16 (xs : List α) (h : xs = [] → False) : Nonempty α := by
cases xs using List.rec with
| nil => contradiction
| cons x _ => apply Nonempty.intro; assumption