In this example, we have a map that has 3 entries:

KeyValue
nameJohn
cityNew York
countryUSA

And we want to update the key "city" with a new value "Denver"

The map is then updated to:
KeyValue
nameJohn
cityDenver
countryUSA

Step 1 sets "processed" to an empty map and "key found" to false.

Step 2 looks at the first "remaining" entry. Since the first key "name" does not match the key "city," we can just move "name": "John" to the "processed" map.

Step 3 again looks at the first "remaining" entry, which is now "city." This matches the key we are trying to update, so the value "New York" is replaced withe new value "Denver" and prepended to the "processed" map. Also, "key found" is now set to true.

In step 4, since we found the key, we just move "country":"USA" to the "processed" map.

In step 5, "remaining" is now empty. Thus the "processed" map now has all up-to-date entries, and we just need to reverse the entries.

Steps 6 - 9 performs the reverse operation, and from there, we use the Transitive Property of Equality a few times to arrive at the our claim.

Quiz (1 point)

Prove that:
result of storing "Denver" at key: "city" in map: [ entry "name": "John", [ entry "city": "New York", [ entry "country": "USA", [ ] ] ] ] = [ entry "name": "John", [ entry "city": "Denver", [ entry "country": "USA", [ ] ] ] ]

The following properties may be helpful:

Please write your proof in the table below. Each row should contain one claim. The last claim is the statement that you are trying to prove.

Step Claim Reason (optional) Error Message (if any)
1
2
3
4
5
6
7
8
9
10

Become a subscriber to save your progress, see the correct answer, and more!