Replies: 1 comment
-
これで通るようです.Leanは,パターンマッチでそれまでのケースに当てはまらないという仮定を追加してくれないのでしょうか…? import Mathlib.Tactic
def gcd : (a : Nat) → (b : Nat) → Nat
| a, 0 => a
| a, k + 1 =>
let b := k + 1
have : a % b < b := by
refine Nat.mod_lt a ?_
linarith
gcd b (a % b)
termination_by _ a b => b
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
gcd 関数が停止することの証明がわからないのですが,以下の sorry を埋めるにはどうしたらいいでしょうか?
(lean4 web で再現してください)
調べると,Mechanics of Proof では gcd 関数が停止することの証明にいくつか補題を用意していますが,そこまで準備しなくても示せるはずでは?と思っています
https://hrmacbeth.github.io/math2001/06_Induction.html?highlight=gcd#the-euclidean-algorithm
Beta Was this translation helpful? Give feedback.
All reactions