test: split tactic tests
This commit is contained in:
parent
ad539a23e1
commit
22a80a9623
3 changed files with 38 additions and 23 deletions
|
|
@ -1,18 +1,30 @@
|
|||
|
||||
|
||||
def f : Bool → Bool → Nat
|
||||
| _, _ => 10
|
||||
| true, true => 0
|
||||
| _, _ => 3
|
||||
|
||||
example : f true true = 10 :=
|
||||
rfl
|
||||
example : f true true = 0 :=
|
||||
rfl
|
||||
|
||||
def g : Bool → Bool → Bool → Nat
|
||||
| true, _, true => 1
|
||||
| _, false, false => 2
|
||||
| _, _, _ => 3
|
||||
| true, _, true => 1
|
||||
| _, false, false => 2
|
||||
| a, _, b => f a b
|
||||
|
||||
theorem ex1 : g true true true = 1 := rfl
|
||||
theorem ex2 : g true false true = 1 := rfl
|
||||
theorem ex3 : g true false false = 2 := rfl
|
||||
theorem ex4 : g false false false = 2 := rfl
|
||||
theorem ex5 : g false true true = 3 := rfl
|
||||
|
||||
theorem f_eq (h : a = true → b = true → False) : f a b = 3 := by
|
||||
simp [f]
|
||||
split
|
||||
. contradiction
|
||||
. rfl
|
||||
|
||||
theorem ex6 : g x y z > 0 := by
|
||||
simp [g]
|
||||
split
|
||||
next => decide
|
||||
next => decide
|
||||
next a b c h₁ h₂ => simp [f_eq h₁]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
def f : Char → Nat
|
||||
| 'a' => 0
|
||||
| 'b' => 1
|
||||
|
|
@ -38,3 +36,10 @@ def r : String × String → Nat
|
|||
|
||||
theorem ex4 : (r ("hello", "world"), r ("world", "hello"), r ("a", "b")) = (0, 1, 2) :=
|
||||
rfl
|
||||
|
||||
example (a b : String) (h : a.length > 10) : r (a, b) = 2 := by
|
||||
simp [r]
|
||||
split
|
||||
next h => injection h with h; subst h; contradiction
|
||||
next h => injection h with h; subst h; contradiction
|
||||
next => decide
|
||||
|
|
|
|||
|
|
@ -1,25 +1,23 @@
|
|||
|
||||
|
||||
inductive Foo : Bool → Type
|
||||
| Z : Foo false
|
||||
| O : Foo false → Foo true
|
||||
| E : Foo true → Foo false
|
||||
inductive Foo : Bool → Type where
|
||||
| Z : Foo false
|
||||
| O : Foo false → Foo true
|
||||
| E : Foo true → Foo false
|
||||
|
||||
open Foo
|
||||
|
||||
def toNat : {b : Bool} → Foo b → Nat
|
||||
| _, Z => 0
|
||||
| _, O n => toNat n + 1
|
||||
| _, E n => toNat n + 1
|
||||
| _, Z => 0
|
||||
| _, O n => toNat n + 1
|
||||
| _, E n => toNat n + 1
|
||||
|
||||
example : toNat (E (O Z)) = 2 :=
|
||||
rfl
|
||||
rfl
|
||||
|
||||
example : toNat Z = 0 :=
|
||||
rfl
|
||||
rfl
|
||||
|
||||
example (a : Foo false) : toNat (O a) = toNat a + 1 :=
|
||||
rfl
|
||||
rfl
|
||||
|
||||
example (a : Foo true) : toNat (E a) = toNat a + 1 :=
|
||||
rfl
|
||||
rfl
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue