-
Notifications
You must be signed in to change notification settings - Fork 210
Open
Labels
Description
- Modeling towers as Naturals in Hanoi.tla is rather low-level/close to an implementation. A high-level spec is likely simpler to grasp if it models towers as sequences...
- Current Hanoi.tla refinement for high-level spec?!
Add comments to Bits And operator and explain what it is doingMoved to CommunityModules](https://github.com/tlaplus/CommunityModules/blob/master/modules/Bitwise.tla)- Existing comments limited to TLC module overwrite
- State Hanoi problem at the beginning of Hanoi.tla in case the file is passed around without README.md
- TypeOK not a type invariant because it omits that tower is a function
- Comment states that a tower is a number in 1..2^D, while the formula says it's a number in 0..(2^D-1)
(see personal email "RE: Github examples" dated 07/17/19 from LL)
And more explicit variant of how to specify logical and. It is broken when Len(by) # Len(bx)
LOCAL INSTANCE Sequences
LOCAL Max(n, m) == IF n < m THEN m ELSE n
RECURSIVE ToBase2(_, _)
ToBase2(d, b) == IF d > 0
THEN ToBase2(d \div 2, b) \o <<d % 2>>
ELSE b
ToBase10(b) == LET d[i \in DOMAIN b] == IF i = 1
THEN b[Len(b) + 1 - i] * (2^(i-1))
ELSE b[Len(b) + 1 - i] * (2^(i-1)) + d[i - 1]
IN d[Len(b)]
LOCAL And2(x,y) == LET bx == ToBase2(x, <<>>)
by == ToBase2(y, <<>>)
and == [ i \in DOMAIN bx \cup DOMAIN by |->
IF bx[i] = 1 /\ by[i] = 1 THEN 1 ELSE 0 ]
IN ToBase10(and)