Skip to content

Coq: MiniCandid#147

Merged
nomeata merged 27 commits into
masterfrom
joachim/coq-candid
Jan 19, 2021
Merged

Coq: MiniCandid#147
nomeata merged 27 commits into
masterfrom
joachim/coq-candid

Conversation

@nomeata
Copy link
Copy Markdown
Contributor

@nomeata nomeata commented Dec 3, 2020

This contains an initial formalization of Candid in Coq. It covers these types:
nat, int, null, opt t, empty, reserved

It considers two different formalisms:

  • NoOpportunisticDecoding
    This is without t <: opt t', but with t <: opt t.
    Things go through, although the opt t <: opt t' rule has to be tweaked to keep subtyping transitive (see Subtyping: Transitivity of opt-to-constituent rule #146).

  • OpportunisticDecoding
    This is with t <: opt t'.
    Because of the negative hypotheses in the coercion relation, this can’t be defined as a simple inductive relation (which is a seroius smell!).
    So instead I define it as a function (which is mostly straight forward), and prove the properties there.
    We could take this as indication that maybe our spec should also just define it via equations. We don’t gain anything from the relational presentation, I think, and implementors all anyways implement functions.
    Nevertheless, I did prove that the relation defined by admits the intro and induction rules that would come out of the inductive relation (ignoring the negative hypotheses). This revealed some issues with the way the rules are presented, will create a PR for that soon.

In both cases, I prove

  • Correctness of decoding
  • Roundtripping
  • Uniqueness of decoding
  • Soundness of subtyping
  • Transitivity of subtyping

I do not prove Higher-order soundness, because we know it does not hold (see #141).

This also uses some proof-of-concept “named Coq cases“ feature, see https://www.joachim-breitner.de/blog/777-Named_goals_in_Coq.

using the shiny new support in dune to build Coq projects:
https://dune.readthedocs.io/en/stable/dune-files.html#coq-theory
without the proof for canonical subtyping yet.
starting a bit on a Candid formalization, focusing on the
Opt-to-constituent rule.

Stuck at #146,
and worked around by adding restrictions to the compositional rule for
opt.
@nomeata nomeata changed the base branch from master to joachim/coq December 3, 2020 17:31
Comment thread coq/MiniCandid.v

Theorem subtyping_trans: transitive _ Subtype.
Proof.
cofix Hyp.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just to show off: This is a proof by coinduction.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bravo!

Base automatically changed from joachim/coq to master December 4, 2020 09:19
nomeata added a commit that referenced this pull request Dec 4, 2020
based on our experience, we really can really use some formal treatment of our
Candid work.

This branch contains some initial work. Part of this commit:

 * A simple Coq setup (using the more modern dune-based setup)
 * A nix-setup to build this
 * Simple CI integration
 * A Coq-ification of the definitions in IDL-Soundness.md
 * Mechanizing the “canonical subtyping is sound” proof in that document

More work is pending on #141, with ongoing experiments in #147.
nomeata added a commit that referenced this pull request Dec 11, 2020
the coq formalization in #147 shows that the old rule didn’t quite work
(it was confused about `5 ~> ? : opt null` I believe), but this variant
does. I think all implemnetations do the right thing anways (so maybe
rewriting this as a partial coercion _function_ would be helpful)
@nomeata
Copy link
Copy Markdown
Contributor Author

nomeata commented Dec 11, 2020

This is ready for master; I updated the PR summary with a overview of what we are doing.

@nomeata nomeata marked this pull request as ready for review December 11, 2020 17:02
@nomeata
Copy link
Copy Markdown
Contributor Author

nomeata commented Jan 19, 2021

I woudn’t mind parking this in master.

@nomeata nomeata merged commit 315cb99 into master Jan 19, 2021
@nomeata nomeata deleted the joachim/coq-candid branch January 19, 2021 17:21
ninegua pushed a commit to ninegua/candid that referenced this pull request Apr 22, 2022
* test: mitmproxy for certificate

* fix

* fix

* fix

* fix

* fix

* fix

* Try mitmproxy 4

* Try mitmproxy 4 with python 3.6

* Try latest version

* Try --setheaders

* CLI flag changed

* dumm di dumm

* add mitm test

* bump icref

* fix

* fix

* fix

* fix

* fix

* fix

Co-authored-by: Joachim Breitner <mail@joachim-breitner.de>
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.

3 participants