高完整性系统工程(三): Logic Intro Formal Specification
目录
1. Propositions 命题
2.1 Propositional Connectives 命题连接词
2.2 Variables 变量
2.3 Sets
2.3.1 Set Operations
2.4 Predicates
2.5 Quantification 量化
2.6 Relations
2.6.1 What Is A Relation?
2.6.2 Relations as Sets
2.6.3 Binary Relations as Pictures
2.6.4 Relation Example
2.6.5 Functions
2.6.6 Total vs Partial Functions 全函数 VS 部分函数
2.6.7 Relation Operations
2.6.8 Relation Joins
3. TEMPORAL LOGIC 时序逻辑
3.1 Next State
3.1.1 Transitions and Traces
3.2 Temporal Operators 时间运算符
4. SPECIFICATIONS SAY “WHAT” DESIGNS SAY “HOW”
4.1 Specifying Software
4.2 Aside: Functions as Relations
4.3 Modelling Data Types
4.4 Sequences as Relations 作为关系的序列
4.5 Searching
4.6 Pre and Postconditions 前置条件和后置条件
4.7 Formal Model-Based Specs
4.8 Advantages
4.9 Effect on Cost
4.10 Disadvantages
4.11 Difficulty
5. SPECIFICATIONS IN ALLOY
5.1 Alloy
6. LASTPASS DEMO
6.1 Alloy Modelling Overview
1. Propositions 命题
定义:A statement that is either true or false

2.1 Propositional Connectives 命题连接词

2.2 Variables 变量
Variables allow propositions to talk about state

Variables talk about different parts of the state of the formal model. (not state of the system/program)
2.3 Sets
A collection of things


2.3.1 Set Operations





2.4 Predicates
Extend propositions with the ability to quantify the values of a variable that a proposition is true for
all: Proposition P(x) holds for all values of x
all x | P[x]
all city | Raining[city]
all city: AustralianCities | Raining[city]
some: Proposition P(x) holds for at least one value of x
some x | P[x]
some city | not Raining[city]
2.5 Quantification 量化
De Morgan’s Laws
all x | P[x] is equivalent to not some x | not P[x]
some x | P[x] is equivalent to not all x | not P[x]
Alloy Specific Quantifiers
one x | P[x] P(x) holds for exactly one value x
lone x | P[x] P(x) holds for at most one value x
none x | P[x] P(x) holds for no value x
2.6 Relations
A proposition that relates things together =, <, etc.
arity: the number of things the relation relates =, < etc. are all binary relations; relate two numbers 3 < 4, (5 - 1) = (3 + 1), etc.
A relation that relates three things together: IsSum(x,y,z) <=> z = x + y
Relations are just predicate
2.6.1 What Is A Relation?
How would you write down unambiguously what a relation means?
Simplest answer: just list all of the things it relates together.

Any relation is a simply a set of tuples.
2.6.2 Relations as Sets
Factor(x,y,z) — {(x,y,z) | x = y * z}
{(1,1,1), (2,1,2), (2,2,1), (3,1,3), (3,3,1),(4,4,1), (4,2,2),…}
Use Factor to define when a number is prime, i.e. define the predicate IsPrime[x] 使用Factor来定义一个数字何时是质数,即定义谓词IsPrime[x]。
all y,z | (x,y,z) in Factor implies y = 1 or z = 1
A relation with arity n (i.e. an n-ary relation) R, is a set of n-tuples of atoms. 一个有n个算数的关系(即n-ary关系)R,是一个由n个原子图元组成的集合。
A binary (2-ary) relation R(a,b) is a set of: pairs
A ternary (3-ary) relation R(a,b,c) is a set of: triples
A unary (1-ary) relation R(a) is a set of: atoms
Sets are relations, and relations are sets. 集合是关系,而关系是集合。
Sets are predicates, and predicates are sets. 集合是谓词,而谓词是集合。
Relations are predicates, and predicates are relations. 关系是谓词,而谓词是关系。
2.6.3 Binary Relations as Pictures

2.6.4 Relation Example
Imagine 2 sets of atoms:
Username = {n1, n2, …}
Password = {p1, p2, …}
Imagine an LDAP username/password database.
LDAPDB : Username -> Password
LDAPDB ⊆ 𝒫 (Username x Password)

2.6.5 Functions
For every username, there is only one password in LDAPDB
all u:Username, pw1:Password, pw2:Password | LDAPDB(u,pw1) and LDAPDB(u,pw2) implies pw1 = pw2

2.6.6 Total vs Partial Functions 全函数 VS 部分函数
LDAPDB : Username -> Password
Does every username in Username have a password?
A total function gives an answer for every (type-correct) argument
A partial function is one that is not total

2.6.7 Relation Operations



xQ




2.6.8 Relation Joins




3. TEMPORAL LOGIC 时序逻辑
3.1 Next State
if x is a variable, then x’ refers to x’s value in the next state 如果x是一个变量,那么x'指的是x在下一个状态中的值
To specify that x is incremented, we would write 要指定x被递增,我们可以写成
x’ = x + 1
Predicates that talk about x are also allowed to talk about x’s value in future states, e.g. x’, x’’ etc. and how it relates to x’s current value 谈论x的谓词也被允许谈论x在未来状态下的价值,例如x',x''等,以及它与x的当前价值的关系。
These predicates define state transitions 这些谓词定义了状态转换
3.1.1 Transitions and Traces

3.2 Temporal Operators 时间运算符
We can also write predicates that talk about future and even past states using temporal operators 我们还可以使用时间运算符编写谈论未来甚至是过去状态的谓词
always P

after P

eventually P

P; Q
equivalent to P and (after Q)
4. SPECIFICATIONS SAY “WHAT” DESIGNS SAY “HOW”
4.1 Specifying Software
Specify modules
Formally describe (an abstraction of) the module’s state 正式描述(抽象的)模块的状态
Formally describe the behaviour of the module’s operations (e.g. procedures, functions etc.). 正式描述模块的操作行为(如程序、函数等)
Behaviour specified in terms of state (transition) relations. 用状态(转换)关系来指定行为。
Trivial example: a counter
State: natural number n : ℕ
Operation: increment n’ = n+1
4.2 Aside: Functions as Relations

4.3 Modelling Data Types
Data types modelled as sets, relations, functions etc. 以集合、关系、函数等为模型的数据类型。

4.4 Sequences as Relations 作为关系的序列

4.5 Searching


4.6 Pre and Postconditions 前置条件和后置条件
Precondition: Specifies the assumptions made by a procedure/function 前提条件。指明一个程序/函数所做的假设
Postcondition: Specifies the behaviour, assuming that the precondition holds 后置条件。指定行为,假设前提条件成立
Precondition for binary search: list is sorted 二进制搜索的前提条件:列表被排序
sorted(list) <=> all i : ℤ | i < #list implies list[i] ≤ list[i+1]
4.7 Formal Model-Based Specs
Model the behaviour of each operation as a relation 将每个操作的行为建模为一种关系
The relation captures the relationship between the operation’s inputs and outputs 该关系捕捉到操作的输入和输出之间的关系
In general: relates the states before and after the operation 一般来说:将操作前后的状态联系起来
Says how they are allowed to differ (postcondition) under assumptions about the inputs (precondition) 说出了在关于输入(前提条件)的假设下允许它们有什么不同(后置条件)
Says what the operation does, not how it does it. 说的是操作做什么,而不是它如何做
4.8 Advantages
- Small
- Unambiguous
- Abstract from Implementation
- Machine-Checkable
- Forces thinking up-front
- Gets mistakes out of the way early (i.e. when they are cheaper to fix)
- 小型
- 毫不含糊
- 从实现中抽象出来
- 可由机器检查
- 迫使人们提前思考
- 尽早消除错误(即当它们的修复成本较低时)。
4.9 Effect on Cost


4.10 Disadvantages
- Requires specialised expertise 需要专门的专业知识
- Might lengthen time to implementation 可能会延长实施的时间
- Loads more effort early in the development process 在开发过程的早期要付出更多的努力
- Not necessarily well suited to projects with rapidly changing requirements. 不一定很适合于需求快速变化的项目
- (So it’s important to get your HAZOP etc. correct) (所以,正确地进行HAZOP等是很重要的)
4.11 Difficulty
All programmers know many formal languages 所有的程序员都知道许多形式语言
Specs are shorter and thus simpler to write than code 规范更短,因此比代码更容易编写
Specs say only what not how 规范只说什么,不说怎么做
Programs must say both 程序必须说明这两点
Ordinary programmers not trained to write and read formal specs 普通程序员没有受过编写和阅读正式规范的训练
5. SPECIFICATIONS IN ALLOY
5.1 Alloy

6. LASTPASS DEMO
6.1 Alloy Modelling Overview
signatures: declaring sets and relations 声明集合和关系
facts: axioms that hold over signatures and globally constrain the model to rule out nonsense 适用于签名的公理,并在全局上约束模型以排除无意义的东西
predicates: define relations between variables in a model, used to specify operations, state transitions 定义模型中变量之间的关系,用于指定操作和状态转换
functions: shorthand for expressions 表达式的简写
相关文章:
高完整性系统工程(三): Logic Intro Formal Specification
目录 1. Propositions 命题 2.1 Propositional Connectives 命题连接词 2.2 Variables 变量 2.3 Sets 2.3.1 Set Operations 2.4 Predicates 2.5 Quantification 量化 2.6 Relations 2.6.1 What Is A Relation? 2.6.2 Relations as Sets 2.6.3 Binary Relations as…...
【linux】多线程概念详述
文章目录一、线程基本概念1.1 进程地址空间与页表1.2 页表结构1.3 线程的理解1.3.1 如何描述线程1.4 再谈进程1.5 代码理解1.5.1 原生库提供线程pthread_create1.6 资源共享问题1.7 资源私有问题二、总结2.1 什么是线程2.2 并行与并发2.3 线程的优点2.4 线程的缺点2.5 线程异常…...
【Java】P8 面向对象(3)方法 基本知识
面向对象 方法方法方法的声明权限修饰符返回值类型方法名形参列表方法体简单案例方法 方法 是对类或对象行为特征的抽象,用来完成某个功能的操作。方法的目的 是为了实现代码复用,减少冗余,简化代码;方法不能独立存在,…...
js中null和undefined的区别
js中null和undefined的区别?这也是一个常见的js面试题 相同点 1,都是基本类型。 2,做判断值都是false。 !!null false // true !!undefined false // true不同点 1,诞生时间null在前,undefined在后。因为js作者Brendan-Eic…...
【Linux】linux中的c++怎么调试?gdb的介绍和使用。
背景1.1.前提知识程序的发布方式有两种,debug模式和release模式Linux gcc/g出来的二进制程序,默认是release模式 要使用gdb调试,必须在源代码生成二进制程序的时候, 加上 -g 选项windows上的调试方法有区别吗?1.调试思路是一样的2…...
提升Python代码性能的六个技巧
文章目录前言为什么要写本文?1、代码性能检测1.1、使用 timeit 库1.2、使用 memory_profiler 库1.3、使用 line_profiler 库2、使用内置函数和库3、使用内插字符串 f-string4、使用列表推导式5、使用 lru_cache 装饰器缓存数据6、针对循环结构的优化7、选择合适算法…...
VI的常用命令
VI的常用命令 文章目录VI的常用命令vi/vim是什么?VI普通模式命令VI编辑模式命令VI指令模式vi/vim是什么? VI是Unix操作系统和类Unix操作系统中最通用的文本编辑器 VIM编辑器是从VI发展出来的一个性能更强大的文本编辑器。可以主动的将字体颜色辨别语法…...
【数据结构】万字深入浅出讲解单链表(附原码 | 超详解)
🚀write in front🚀 📝个人主页:认真写博客的夏目浅石. 🎁欢迎各位→点赞👍 收藏⭐️ 留言📝 📣系列专栏:C语言实现数据结构 💬总结:希望你看完…...
无线WiFi安全渗透与攻防(五)之aircrack-ng破解WEP加密
系列文章 无线WiFi安全渗透与攻防(一)之无线安全环境搭建 无线WiFi安全渗透与攻防(二)之打造专属字典 无线WiFi安全渗透与攻防(三)之Windows扫描wifi和破解WiFi密码 无线WiFi安全渗透与攻防(四)之kismet的使用 aircrack-ng破解WEP加密 1.WEP介绍 其实我们平常在使用wifi的时…...
MySQL中事务的相关问题
事务 一、事务的概述: 1、事务处理(事务操作):保证所有事务都作为一个工作单元来执行,即使出现了故障,都不能改变这种执行方式。当在一个事务中执行多个操作时,要么所有的事务都被提交(commit…...
推荐算法再次踩坑记录
去年搞通了EasyRec这个玩意,没想到今年还要用推荐方面的东西,行吧,再来一次,再次踩坑试试。1、EasyRec训练测试数据下载:git clone后,进入EasyRec,然后执行:bash scripts/init.sh 将…...
STM32 (十五)MPU6050
简介前言一、MPU6050简介MPU6050是一款性价比很高的陀螺仪,可以读取X Y Z 三轴角度,X Y Z 三轴加速度,还有内置的温度传感器,在姿态解析方面应用非常广泛。下面是它在淘宝上的参数图产品尺寸产品参数产品原理图:二、硬…...
使用yarn,依赖报各种错误怎么办
使用 yarn^3.x 版本时,默认并不会安装包到 node_modules,因为 yarn3.x 是即插即用的,也就是说如果你下载过这个包,yarn只会生成一个 Png文件,然后将包的路径 link 到下载过的地方,这样可以省去很多时间。而…...
面试官:rem和vw有什么区别
"rem" 和 "vw"的区别 "rem" 和 "vw" 都是用于网页设计的CSS单位。 "rem" 是相对于根元素的字体大小来计算的单位,即相对于 "html" 标签的字体大小。例如,如果 "html" 标签的字…...
【GPT-4】GPT-4 相关内容总结
目录 编辑 官网介绍 GPT-4 内容提升总结 GPT-4 简短版总结 GPT-4 基础能力 GPT-4 图像处理 GPT-4 技术报告 训练过程 局限性 GPT-4 风险和应对措施 开源项目:OpenAI Evals 申请 GPT-4 API API的介绍以及获取 官网介绍 官网:GPT-4 API候…...
5.springcloud微服务架构搭建 之 《springboot集成Hystrix》
1.springcloud微服务架构搭建 之 《springboot自动装配Redis》 2.springcloud微服务架构搭建 之 《springboot集成nacos注册中心》 3.springcloud微服务架构搭建 之 《springboot自动装配ribbon》 4.springcloud微服务架构搭建 之 《springboot集成openFeign》 目录 1.项目…...
【工作中问题解决实践 七】SpringBoot集成Jackson进行对象序列化和反序列化
去年10月份以来由于公司和家里的事情太多,所以一直没有学习,最近缓过来了,学习的脚步不能停滞啊。回归正题,其实前年在学习springMvc的时候也学习过Jackson【Spring MVC学习笔记 五】SpringMVC框架整合Jackson工具,但是…...
香港服务器遭受DDoS攻击后如何恢复运行?
您是否发现流量异常上升?您的网站突然崩溃了吗?当您注意到这些迹象时,可能是在陷入了DDoS攻击的困境,因而,当开始考虑使用香港服务器时,也应该考虑香港服务器设备受DDoS攻击时,如何从中恢复。 在 DDoS 攻击香港…...
【Hive】配置
目录 Hive参数配置方式 参数的配置方式 1. 文件配置 2. 命令行参数配置 3. 参数声明配置 配置源数据库 配置元数据到MySQL 查看MySQL中的元数据 Hive服务部署 hiveserver2服务 介绍 部署 启动 远程连接 1. 使用命令行客户端beeline进行远程访问 metastore服务 …...
IP-GUARD如何强制管控电脑设置开机密码要符合密码复杂度?
如何强制管控电脑设置开机密码要符合密码复杂度? 7 可以在控制台-【策略】-【定制配置】,添加一条配置,开启系统密码复杂度检测。 类别:自定义 关键字:bp_password_complexity 内容:1 效果图:...
【大模型RAG】拍照搜题技术架构速览:三层管道、两级检索、兜底大模型
摘要 拍照搜题系统采用“三层管道(多模态 OCR → 语义检索 → 答案渲染)、两级检索(倒排 BM25 向量 HNSW)并以大语言模型兜底”的整体框架: 多模态 OCR 层 将题目图片经过超分、去噪、倾斜校正后,分别用…...
python执行测试用例,allure报乱码且未成功生成报告
allure执行测试用例时显示乱码:‘allure’ �����ڲ����ⲿ���Ҳ���ǿ�&am…...
python报错No module named ‘tensorflow.keras‘
是由于不同版本的tensorflow下的keras所在的路径不同,结合所安装的tensorflow的目录结构修改from语句即可。 原语句: from tensorflow.keras.layers import Conv1D, MaxPooling1D, LSTM, Dense 修改后: from tensorflow.python.keras.lay…...
LeetCode - 199. 二叉树的右视图
题目 199. 二叉树的右视图 - 力扣(LeetCode) 思路 右视图是指从树的右侧看,对于每一层,只能看到该层最右边的节点。实现思路是: 使用深度优先搜索(DFS)按照"根-右-左"的顺序遍历树记录每个节点的深度对于…...
springboot整合VUE之在线教育管理系统简介
可以学习到的技能 学会常用技术栈的使用 独立开发项目 学会前端的开发流程 学会后端的开发流程 学会数据库的设计 学会前后端接口调用方式 学会多模块之间的关联 学会数据的处理 适用人群 在校学生,小白用户,想学习知识的 有点基础,想要通过项…...
django blank 与 null的区别
1.blank blank控制表单验证时是否允许字段为空 2.null null控制数据库层面是否为空 但是,要注意以下几点: Django的表单验证与null无关:null参数控制的是数据库层面字段是否可以为NULL,而blank参数控制的是Django表单验证时字…...
Linux系统部署KES
1、安装准备 1.版本说明V008R006C009B0014 V008:是version产品的大版本。 R006:是release产品特性版本。 C009:是通用版 B0014:是build开发过程中的构建版本2.硬件要求 #安全版和企业版 内存:1GB 以上 硬盘…...
《信号与系统》第 6 章 信号与系统的时域和频域特性
目录 6.0 引言 6.1 傅里叶变换的模和相位表示 6.2 线性时不变系统频率响应的模和相位表示 6.2.1 线性与非线性相位 6.2.2 群时延 6.2.3 对数模和相位图 6.3 理想频率选择性滤波器的时域特性 6.4 非理想滤波器的时域和频域特性讨论 6.5 一阶与二阶连续时间系统 6.5.1 …...
DAY 45 超大力王爱学Python
来自超大力王的友情提示:在用tensordoard的时候一定一定要用绝对位置,例如:tensorboard --logdir"D:\代码\archive (1)\runs\cifar10_mlp_experiment_2" 不然读取不了数据 知识点回顾: tensorboard的发展历史和原理tens…...
【题解-洛谷】P10480 可达性统计
题目:P10480 可达性统计 题目描述 给定一张 N N N 个点 M M M 条边的有向无环图,分别统计从每个点出发能够到达的点的数量。 输入格式 第一行两个整数 N , M N,M N,M,接下来 M M M 行每行两个整数 x , y x,y x,y,表示从 …...
