fix(tests/lean): fix tests
This commit is contained in:
parent
9f2980a524
commit
bae50f8ce6
6 changed files with 20 additions and 23 deletions
|
|
@ -1,5 +1,4 @@
|
|||
--
|
||||
constant nat.gcd : nat → nat → nat
|
||||
namespace foo
|
||||
constant f : nat → nat
|
||||
constant g : nat → nat
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
rquote.lean:14:7: error: invalid resolved quoted symbol, it is ambiguous, possible interpretations: boo.f foo.f (solution: use fully qualified names)
|
||||
rquote.lean:13:7: error: invalid resolved quoted symbol, it is ambiguous, possible interpretations: boo.f foo.f (solution: use fully qualified names)
|
||||
name.mk_string "g" (name.mk_string "foo" name.anonymous) : name
|
||||
name.mk_string "add" (name.mk_string "has_add" name.anonymous) : name
|
||||
name.mk_string "gcd" (name.mk_string "nat" name.anonymous) : name
|
||||
name.mk_string "f" name.anonymous : name
|
||||
name.mk_string "f" (name.mk_string "foo" name.anonymous) : name
|
||||
rquote.lean:32:9: error: invalid quoted symbol, failed to resolve it (solution: use `<identifier> to bypass name resolution)
|
||||
rquote.lean:31:9: error: invalid quoted symbol, failed to resolve it (solution: use `<identifier> to bypass name resolution)
|
||||
|
|
|
|||
|
|
@ -1,17 +1,15 @@
|
|||
open nat prod
|
||||
open decidable
|
||||
|
||||
constant modulo1 (x : ℕ) (y : ℕ) : ℕ
|
||||
infixl `mod`:70 := modulo1
|
||||
constant modulo' (x : ℕ) (y : ℕ) : ℕ
|
||||
infixl `mod`:70 := modulo'
|
||||
|
||||
constant gcd_aux : ℕ × ℕ → ℕ
|
||||
|
||||
noncomputable definition gcd (x y : ℕ) : ℕ := gcd_aux (x, y)
|
||||
noncomputable definition gcd' (x y : ℕ) : ℕ := gcd_aux (x, y)
|
||||
|
||||
theorem gcd_def (x y : ℕ) : gcd x y = @ite (y = 0) (nat.decidable_eq (snd (x, y)) 0) nat x (gcd y (x mod y)) :=
|
||||
theorem gcd_def (x y : ℕ) : gcd' x y = @ite (y = 0) (nat.decidable_eq (snd (x, y)) 0) nat x (gcd' y (x mod y)) :=
|
||||
sorry
|
||||
|
||||
constant succ_ne_zero (a : nat) : succ a ≠ 0
|
||||
|
||||
theorem gcd_succ (m n : ℕ) : gcd m (succ n) = gcd (succ n) (m mod succ n) :=
|
||||
theorem gcd_succ (m n : ℕ) : gcd' m (succ n) = gcd' (succ n) (m mod succ n) :=
|
||||
eq.trans (gcd_def _ _) (if_neg (nat.succ_ne_zero _))
|
||||
|
|
|
|||
|
|
@ -1,21 +1,21 @@
|
|||
open nat well_founded
|
||||
|
||||
def gcd : ℕ → ℕ → ℕ | y := λ x,
|
||||
def gcd' : ℕ → ℕ → ℕ | y := λ x,
|
||||
if h : y = 0 then
|
||||
x
|
||||
else
|
||||
have x % y < y, by { apply mod_lt, cases y, contradiction, apply succ_pos },
|
||||
gcd (x % y) y
|
||||
gcd' (x % y) y
|
||||
|
||||
lemma gcd_zero_right (x : nat) : gcd 0 x = x :=
|
||||
lemma gcd_zero_right (x : nat) : gcd' 0 x = x :=
|
||||
begin
|
||||
rw [gcd],
|
||||
rw [gcd'],
|
||||
simp
|
||||
end
|
||||
|
||||
lemma ex (x : nat) (h : gcd 0 x = 0) : x + x = 0 :=
|
||||
lemma ex (x : nat) (h : gcd' 0 x = 0) : x + x = 0 :=
|
||||
begin
|
||||
rw [gcd] at h,
|
||||
rw [gcd'] at h,
|
||||
simp at h,
|
||||
simp [h]
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
open nat well_founded
|
||||
|
||||
def gcd : ℕ → ℕ → ℕ | y := λ x,
|
||||
def gcd' : ℕ → ℕ → ℕ | y := λ x,
|
||||
if h : y = 0 then
|
||||
x
|
||||
else
|
||||
have x % y < y, by { apply mod_lt, cases y, contradiction, apply succ_pos },
|
||||
gcd (x % y) y
|
||||
gcd' (x % y) y
|
||||
|
||||
lemma gcd_zero_right (x : nat) : gcd 0 x = x :=
|
||||
lemma gcd'_zero_right (x : nat) : gcd' 0 x = x :=
|
||||
begin
|
||||
simp [gcd] {single_pass := tt},
|
||||
simp [gcd'] {single_pass := tt},
|
||||
simp
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
open nat well_founded
|
||||
|
||||
def gcd : ℕ → ℕ → ℕ | y := λ x,
|
||||
def gcd' : ℕ → ℕ → ℕ | y := λ x,
|
||||
if h : y = 0 then
|
||||
x
|
||||
else
|
||||
have x % y < y, by { apply mod_lt, cases y, contradiction, apply succ_pos },
|
||||
gcd (x % y) y
|
||||
gcd' (x % y) y
|
||||
|
||||
@[simp] lemma gcd_zero_right (x : nat) : gcd 0 x = x := rfl
|
||||
@[simp] lemma gcd_zero_right (x : nat) : gcd' 0 x = x := rfl
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue