人工智能数学验证工具LEAN4【入门介绍2】加法世界-数学归纳法,证明自然数是加法交换幺半群

本文介绍了使用LEAN4这款人工智能数学验证工具,通过实例演示了如何通过数学归纳法证明自然数集合中加法的结合律(add_assoc)。学习者通过练习证明自然数是加法交换幺半群,为后续的数学探索打下基础。
摘要由CSDN通过智能技术生成

视频链接,创作不易记得投币哦:人工智能数学验证工具LEAN4【入门介绍2】加法世界-数学归纳法,自然数是加法交换幺半群_哔哩哔哩_bilibili

import Game.Levels.Addition.L03add_comm


World "Addition"
Level 4
Title "add_assoc (associativity of addition)"

namespace MyNat

Introduction
"
  We've been adding up two numbers; in this level we will add up three.

  What does $x+y+z$ *mean*? It could either mean $(x+y)+z$, or it
  could mean $x+(y+z)$. In Lean, $x+y+z$ means $(x+y)+z$.

  But why do we care which one it means; $(x+y)+z$ and $x+(y+z)$ are *equal*!

  That's true, but we didn't prove it yet. Let's prove it now by induction.
"

LemmaDoc MyNat.add_assoc as "add_assoc" in "+" "`add_assoc a b c` is a proof
that `(a + b) + c = a + (b + c)`. Note that in Lean `(a + b) + c` prints
as `a + b + c`, because the notation for addition is defined to be left
associative. "

/-- On the set of natural numbers, addition is associative.
In other words, if $a, b$ and $c$ are arbitrary natural numbers, we have
$ (a + b) + c = a + (b + c). $ -/
Statement add_assoc (a b c : ℕ) : a + b + c = a + (b + c) := by
  Hint "Remember that when Lean writes `a + b + c`, it means `(a + b) + c`.
  If you are not sure where the brackets are in an expression, just hover
  your cursor over it and look at what gets highlighted. For example,
  hover over both `+` symbols on the left hand side of the goal and
  you'll see where the invisible brackets are."
  induction c with d hd
  · rw [add_zero, add_zero]
    rfl
  · rw [add_succ, add_succ, hd, add_succ]
    rfl

-- Adding this instance to make `ac_rfl` work.
instance : Lean.IsAssociative (α := ℕ) (· + ·) := 〈add_assoc〉

LemmaTab "+"

Conclusion
"
A passing mathematician congratulates you on proving that naturals
are an additive commutative monoid.

Let's practice using `add_assoc` and `add_comm` in one more level,
before we leave addition world.
"

  • 5
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值