Philip Wadler
2018-05-15 22:27:37 UTC
Dear Agda mailing list,
I am defining substitution on possibly open terms, and therefore need a way
to generate fresh variable names. The operation
fresh x xs
returns a name that is similar to x but does not appear in the list xs,
where similar means that it may have extra primes at the end. For example,
fresh "x" [ "x" , "xâ²" , "xâ²â²" , "y" ] â¡ "xâ²â²â²"
To define `fresh`, I start by defining operations on identifiers and
corresponding lemmas including the following:
make : Prefix â â â Id
prefix : Id â Prefix
suffix : Id â â
prefix-lemma : â {p n} â prefix (make p n) â¡ p
suffix-lemma : â {p n} â suffix (make p n) â¡ n
make-lemma : â {x} â make (prefix x) (suffix x) â¡ x
Prefix is defined to be a String that does not end in a prime.
The definitions of make, prefix, and suffix are quite involved, so in order
to prevent them expanding to unreadable length in proofs I have made them
and the corresponding lemmas abstract. Doing so, the proof was fairly easy
to complete. However, because the definitions are abstract, Agda cannot
actually compute fresh variables as in the example above.
That's ok. Having completed the proofs with readable terms, I should be
able to now remove the abstract declaration. Since everything typechecked
before, revealing the definition bodies should preserve types. But in fact,
Agda now complains about one of the key proofs!
Is there any way to *both* be able to compute fresh names *and* retain my
related proofs, in particular, the proof that `fresh x xs` generates a name
not in `xs`?
The relevant files are attached, or can be found at
https://github.com/wenkokke/sf
Thank you for your help! Cheers, -- P
. \ Philip Wadler, Professor of Theoretical Computer Science,
. /\ School of Informatics, University of Edinburgh
. / \ and Senior Research Fellow, IOHK
. http://homepages.inf.ed.ac.uk/wadler/
I am defining substitution on possibly open terms, and therefore need a way
to generate fresh variable names. The operation
fresh x xs
returns a name that is similar to x but does not appear in the list xs,
where similar means that it may have extra primes at the end. For example,
fresh "x" [ "x" , "xâ²" , "xâ²â²" , "y" ] â¡ "xâ²â²â²"
To define `fresh`, I start by defining operations on identifiers and
corresponding lemmas including the following:
make : Prefix â â â Id
prefix : Id â Prefix
suffix : Id â â
prefix-lemma : â {p n} â prefix (make p n) â¡ p
suffix-lemma : â {p n} â suffix (make p n) â¡ n
make-lemma : â {x} â make (prefix x) (suffix x) â¡ x
Prefix is defined to be a String that does not end in a prime.
The definitions of make, prefix, and suffix are quite involved, so in order
to prevent them expanding to unreadable length in proofs I have made them
and the corresponding lemmas abstract. Doing so, the proof was fairly easy
to complete. However, because the definitions are abstract, Agda cannot
actually compute fresh variables as in the example above.
That's ok. Having completed the proofs with readable terms, I should be
able to now remove the abstract declaration. Since everything typechecked
before, revealing the definition bodies should preserve types. But in fact,
Agda now complains about one of the key proofs!
Is there any way to *both* be able to compute fresh names *and* retain my
related proofs, in particular, the proof that `fresh x xs` generates a name
not in `xs`?
The relevant files are attached, or can be found at
https://github.com/wenkokke/sf
Thank you for your help! Cheers, -- P
. \ Philip Wadler, Professor of Theoretical Computer Science,
. /\ School of Informatics, University of Edinburgh
. / \ and Senior Research Fellow, IOHK
. http://homepages.inf.ed.ac.uk/wadler/