人工智能数学验证工具LEAN4【入门介绍6】算法世界-机器人的思维跳步,如何自定义高级证明策略,还有逆否命题的使用

视频点赞过10会继续出下一期哦:人工智能数学验证工具LEAN4【入门介绍6】算法世界-机器人的思维跳步,如何自定义高级证明策略,还有逆否命题的使用_哔哩哔哩_bilibili

import Game.Levels.Algorithm.L07succ_ne_succ

import Game.MyNat.DecidableEq

World "Algorithm"

Level 8

Title "decide"

TheoremTab "Peano"

namespace MyNat

/--

Summary

`decide` will attempt to solve a goal if it can find an algorithm which it

can run to solve it.

Example

A term of type `DecidableEq ℕ` is an algorithm to decide whether two naturals

are equal or different. Hence, once this term is made and made into an `instance`,

the `decide` tactic can use it to solve goals of the form `a = b` or `a ≠ b`.

-/

TacticDoc decide

NewTactic decide

Introduction

"

Implementing the algorithm for equality of naturals, and the proof that it is correct,

looks like this:

```

instance instDecidableEq : DecidableEq ℕ

| 0, 0 => isTrue <| by

show 0 = 0

rfl

| succ m, 0 => isFalse <| by

show succ m ≠ 0

exact succ_ne_zero m

| 0, succ n => isFalse <| by

show 0 ≠ succ n

exact zero_ne_succ n

| succ m, succ n =>

match instDecidableEq m n with

| isTrue (h : m = n) => isTrue <| by

show succ m = succ n

rw h

rfl

| isFalse (h : m ≠ n) => isFalse <| by

show succ m ≠ succ n

exact succ_ne_succ m n h

```

This Lean code is a formally verified algorithm for deciding equality

between two naturals. I've typed it in already, behind the scenes.

Because the algorithm is formally verified to be correct, we can

use it in Lean proofs. You can run the algorithm with the `decide` tactic.

"

/-- 20+20=40. -/

Statement : (20 : ℕ) + 20 = 40 := by

decide

Conclusion "You can read more about the `decide` tactic by clicking

on it in the top right."

相关推荐
航飞光电市场经理11 分钟前
人员定位系统“全栈自研”技术解析:从射频前端到定位引擎的架构拆解
前端·架构
Apifox14 分钟前
Apifox 9 月更新|CLI 能力升级、GitLab 私有化部署接入与产品体验优化
前端·后端·测试
deli00715 分钟前
随机乱跳为什么能画出完美三角形:混沌游戏分形实验室
前端
小小龙学IT18 分钟前
Go 泛型(Generics)深度解析:从类型参数到生产实践
开发语言·数据库·golang
Gizzap_Tech22 分钟前
国内官网增加英文版:URL、语言切换与 hreflang 怎么配置?
前端
hold?fish:palm26 分钟前
45 二叉树的右视图
开发语言·c++·算法
MI_farmer29 分钟前
Anaconda 安装在 D 盘但虚拟环境跑到 C 盘,以及 Conda PermissionError: WinError 5 的解决方法
c语言·开发语言·conda
剪刀石头布啊30 分钟前
泛洪DFS、BFS
前端
qetfw30 分钟前
Windows Server AD CS:根 CA、Web 证书模板与域内自动注册
前端·windows·windows-server
剪刀石头布啊30 分钟前
为什么React组件很少前缀,而vue的不少组件都有前缀
前端