plfa.github.io icon indicating copy to clipboard operation
plfa.github.io copied to clipboard

Possible wrong hint in part1.Relations exercise Bin-predicates

Open gdahia opened this issue 6 years ago • 4 comments

First of all, thanks for writing and making the book available. I am learning Agda from it, and I think it's great.

I believe there is a mistake in the hint for the exercise Bin-predicates in part1.Relations. It says

you may need to prove that 1 is less or equal to the result of from b

but 1 is greater than from (⟨⟩ O) which satisfies from (⟨⟩ O) ≡ 0. Is there something I am not seeing here? Thanks again.

gdahia avatar Mar 25 '20 00:03 gdahia

Thank you for the kind words, and for bringing up the issue. According to my records, Jeremy Siek added that phrase. I've written to him to ask why. I agree, it looks wrong to me; inequality is irrelevant to that exercise.

wadler avatar Mar 25 '20 11:03 wadler

Since my point was not the irrelevance of inequality to that exercise -- my proof used the fact that binary strings which start with a one are greater than zero

zero-<-from-one : ∀ (bin : Bin)
  → One bin
     -------------
  → 0 < (from bin)

and that binary strings obtained from adding these numbers two times is equivalent to adding an O to the end of their binary strings

to-suc-n-2-O : ∀ (n : ℕ)
  → 0 < n
     ---------------------
  → to (n + n) ≡ (to n) O

-- I am now curious about how to prove the exercise without inequality; maybe it was the hint's suggestion that led me to that path. I don't know whether this is the appropriate place to ask, nor if it is too much to ask, but could you illustrate how to do it without inequality?

gdahia avatar Mar 25 '20 12:03 gdahia

I think this was fixed in 8ef93f790bdc17c487972b0054e0369d55861a6f:

Also, you may need to prove that if One b then 1 is less or equal to the result of from b.

Your theorem is responsive to the hint, it seems to me. For what it's worth, I also used similar inequality theorems.

dsheets avatar May 11 '20 19:05 dsheets

I think this was fixed in 8ef93f7

I agree, and I am closing the issue because of that. Thanks for the update.

gdahia avatar May 12 '20 02:05 gdahia