Rep Invariant and Abstraction Function

* According to the Reading 13 of MIT 6.005 course

In order to finish Lab 2, in which the ps 2 gives instructions about rep invariant and abstract function, I read the reading material released by MIT 6.005.

1. Some Terminology

The space of representation value: actual implementation

The space of abstract value: values that the type is designed to support, mainly about imagination stuffs

 

2. Example

 

As the figure given above, the map between R and A maps the elements in R to A

Apparently, we can easily find out that:

1). Every abstract value is mapped by some rep value

2). Some abstract value are mapped to by more than one rep value

3). Not all rep values are mapped

So it is a surjection but maybe not an injection

 

Rep Invariant: maps the rep values to booleans

RI: R->boolean

 

Abstraction Function: maps rep values to the abstract values they represent

AF:R->A

 

3. Explanation

1). The abstraction function and the rep invariants are not determined by the choice of rep and abstract value spaces

2). The abstract value space alone doesn't determine AF/RI

     For the same abstract type, there can be several representations

3). The choice of both spaces doesn't determine AF and RI

     Same rep space but different rep invariant. We can set different rules to restrict the values of the rep space such as no duplication and nondecreasing.

 

转载于:https://www.cnblogs.com/SebastianLiu/p/10583479.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值