Skip to content

Replace use of impossible idiom with proof by reflection#409

Merged
wenkokke merged 9 commits intodevfrom
proof-by-reflection
Jul 13, 2020
Merged

Replace use of impossible idiom with proof by reflection#409
wenkokke merged 9 commits intodevfrom
proof-by-reflection

Conversation

@wenkokke
Copy link
Copy Markdown
Collaborator

@wenkokke wenkokke commented Sep 18, 2019

The purpose of this WIP pull request is to slowly remove all usage of the impossible idiom by proof-by-reflection. A new development in Agda has made it possible to do this without using instance search.

  • define product and unit types as records in Connectives;
  • explain difference between data and records w.r.t. definitional equality in Connectives;
  • define True in Decidable;
  • add exercise for defining False in Decidable;
  • replace S constructor in Lambda with a version which checks the inequality implicitly;

Copy link
Copy Markdown
Member

@wadler wadler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!
I like the use of monus as an example.
"it is very painful to use" --> "it is painful to use"
"know the two numbers statically" --> "at the point minus is called"
"The trick is ..." Recall the definition of T (as a sentence, not code) and give a backwards reference to the place it is defined.
"For instance, _n≤m_254 : ⊥." --> "For instance, if we call 3 - 5 we get "
"We obtain ..." Same for toWitness. Possibly restructure, to do this for T and toWitness together.
"as long as we statically know the two numbers" --> "as long as we provide known numbers"
Explain how you can write x - y where x and y are known variables. I presume we can write something like
minus : (m n : ℕ) (n≤m : n ≤ m) → ℕ
minus m n n≤m = - m n {f n≤m}
for a suitable choice of f?
The exercise refers to True, but the text refers to T.

@wenkokke
Copy link
Copy Markdown
Collaborator Author

wenkokke commented Sep 20, 2019

Explain how you can write x - y where x and y are known variables. I presume we can write something like
minus : (m n : ℕ) (n≤m : n ≤ m) → ℕ
minus m n n≤m = - m n {f n≤m}
for a suitable choice of f?

This technique is really only useful when both arguments to _-_ are literals. I'd prefer not to pretend that it has any value if you have any evidence that n ≤ m for two variables n and m, as the whole point is the fact that Agda can compute the answer for you, which goes out the window if you have to provide explicit evidence.

Furthermore, _-_ is defined in terms of minus, so your code here ties a strange loop?

The exercise refers to True, but the text refers to T.

True is defined just before the exercise and is distinct from T.

@wenkokke wenkokke marked this pull request as ready for review July 2, 2020 11:54
@wenkokke
Copy link
Copy Markdown
Collaborator Author

wenkokke commented Jul 2, 2020

@wadler This is now done. Could you review the changes?

@wenkokke wenkokke changed the title [WIP] Replace use of impossible idiom with proof by reflection Replace use of impossible idiom with proof by reflection Jul 2, 2020
@wenkokke wenkokke merged commit 11d8dff into dev Jul 13, 2020
@wenkokke wenkokke deleted the proof-by-reflection branch October 1, 2020 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants