(* Open Source License *)
(* Copyright (c) 2020 Nomadic Labs. <contact@nomadic-labs.com> *)
(* Permission is hereby granted, free of charge, to any person obtaining a *)
(* copy of this software and associated documentation files (the "Software"), *)
(* to deal in the Software without restriction, including without limitation *)
(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)
(* and/or sell copies of the Software, and to permit persons to whom the *)
(* Software is furnished to do so, subject to the following conditions: *)
(* The above copyright notice and this permission notice shall be included *)
(* in all copies or substantial portions of the Software. *)
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *)
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *)
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)
(* DEALINGS IN THE SOFTWARE. *)
(* Coq *)
Require Import Coq.micromega.Lia.
(* Mi-Cho-Coq *)
Require Import Michocoq.macros.
Import syntax.
Import comparable.
Require Import util.
Import error.
(* Contracts Coq *)
Require Import contract_semantics.
(* Dexter *)
Require dexter_definition.
Require dexter_spec.
Require Import dexter_verification_ep_xtzToToken.
Require Import dexter_verification_ep_addLiquidity.
Require Import dexter_verification_ep_removeLiquidity.
Require Import dexter_verification_ep_xtzToToken.
Require Import dexter_verification_ep_tokenToXtz.
Require Import dexter_verification_ep_tokenToToken.
Require Import dexter_verification_ep_updateTokenPool.
Require Import dexter_verification_ep_updateTokenPoolInternal.
Require Import dexter_verification_ep_setBaker.
Require Import dexter_verification_ep_setManager.
Require Import dexter_verification_ep_setLqtAddress.
Require Import dexter_verification_ep_default.
Lemma main_correct
(env : @proto_env (Some (dexter_definition.parameter_ty, None)))
(p : data dexter_definition.parameter_ty)
(sto : data dexter_definition.storage_ty)
(ret_ops : Datatypes.list (data operation))
(ret_sto : data dexter_definition.storage_ty)
(fuel : Datatypes.nat) :
(* TODO: fuel may have to be adapted to suit the entrypoint *)
500 <= fuel ->
eval env dexter_definition.main2 fuel ((p, sto), tt) = Return ((ret_ops, ret_sto), tt) <->
dexter_spec.main env p sto ret_ops ret_sto.
Proof.
(* Case distinction on parameter p, and then apply lemmas from
section entrypoints. *)
unfold ">=".
intros Hfuel.
rewrite return_precond.
rewrite eval_precond_correct.
destruct p as
[ [ p | p ]
| [ p | p_xtzToToken ]
];
do 3 (more_fuel; simpl).
- destruct p as [ [ p_addLiquidity | p_default ] | [p_removeLiquidity | p_setBaker] ];
do 2 (more_fuel; simpl).
+ apply ep_addLiquidity_correct; lia.
+ apply ep_default_correct; lia.
+ apply ep_removeLiquidity_correct; lia.
+ apply ep_setBaker_correct; lia.
- destruct p as [ [ p_setLqtAddress | p_setManager ] | [p_tokenToToken | p_tokenToXtz] ];
do 2 (more_fuel; simpl).
+ apply ep_setLqtAddress_correct; lia.
+ apply ep_setManager_correct; lia.
+ apply ep_tokenToToken_correct; lia.
+ apply ep_tokenToXtz_correct; lia.
- destruct p as [ p_updateTokenPool | p_updateTokenPoolInternal ];
do 1 (more_fuel; simpl).
+ apply ep_updateTokenPool_correct; lia.
+ apply ep_updateTokenPoolInternal_correct; lia.
- apply ep_xtzToToken_correct; lia.
Qed.