目录
2.1 Propositional Connectives 命题连接词
2.6.3 Binary Relations as Pictures
2.6.6 Total vs Partial Functions 全函数 VS 部分函数
4. SPECIFICATIONS SAY “WHAT” DESIGNS SAY “HOW”
4.2 Aside: Functions as Relations
4.4 Sequences as Relations 作为关系的序列
4.6 Pre and Postconditions 前置条件和后置条件
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.