Skip to content

Commit 0a90457

Browse files
authored
Merge pull request #768 from formal-land/guillaume-claret@add-link-simulate-example
Add links and simulate example
2 parents 3e36769 + 3a9b939 commit 0a90457

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Require Import CoqOfRust.CoqOfRust.
2+
Require Import CoqOfRust.links.M.
3+
Require Import examples.default.examples.custom.loops_free.
4+
5+
(* pub fn max2(a: u32, b: u32) -> u32 *)
6+
Instance run_max2 (a b : U32.t) : Run.Trait max2 [] [] [φ a; φ b] U32.t.
7+
Proof.
8+
constructor.
9+
run_symbolic.
10+
Defined.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Require Import CoqOfRust.CoqOfRust.
2+
Require Import CoqOfRust.links.M.
3+
Require Import CoqOfRust.simulate.M.
4+
Require Import examples.default.examples.custom.links.loops_free.
5+
6+
Definition max2 (a b : U32.t) : U32.t :=
7+
if a.(Integer.value) <? b.(Integer.value) then
8+
b
9+
else
10+
a.
11+
12+
Lemma max2_eq (a b : U32.t) :
13+
{{
14+
SimulateM.eval_f (Stack := []) (run_max2 a b) tt 🌲
15+
(Output.Success (max2 a b), tt)
16+
}}.
17+
Proof.
18+
unfold max2.
19+
repeat (
20+
cbn ||
21+
get_can_access ||
22+
eapply Run.Call ||
23+
apply Run.Pure ||
24+
destruct (_ <? _)
25+
).
26+
Qed.

0 commit comments

Comments
 (0)