-
Notifications
You must be signed in to change notification settings - Fork 85
/
helloErrProgScript.sml
57 lines (47 loc) · 1.71 KB
/
helloErrProgScript.sml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
(*
Hello World on standard error.
*)
open preamble basis
val _ = new_theory "helloErrProg"
val _ = translation_extends"basisProg";
val helloErr = process_topdecs
`fun helloErr u =
(TextIO.output TextIO.stdErr "Well oH lord!\n";
Runtime.abort())`
val () = append_prog helloErr;
val st = get_ml_prog_state ()
Theorem helloErr_spec:
app (p:'ffi ffi_proj) ^(fetch_v "helloErr" st)
[Conv NONE []]
(RUNTIME * STDIO fs)
(POSTf n. λ c b. RUNTIME * &(n = "exit" /\ c = [] /\ b = [1w]) *
STDIO (add_stderr fs (strlit "Well oH lord!\n")))
Proof
xcf "helloErr" st
\\ xlet `(POSTv uv. &(UNIT_TYPE () uv) * RUNTIME *
STDIO (add_stderr fs (strlit "Well oH lord!\n")))`
>- (xapp_spec output_stderr_spec
\\ xsimpl \\ MAP_EVERY qexists_tac [`RUNTIME`,`fs`] \\ xsimpl)
\\ xlet_auto
>- (xcon \\ xsimpl)
\\ xapp \\ xsimpl
QED
Theorem helloErr_whole_prog_spec:
whole_prog_ffidiv_spec ^(fetch_v "helloErr" st) cl fs
(λn c b fs'. n = "exit" /\ c = [] /\ b = [1w] /\ add_stderr fs (strlit "Well oH lord!\n") = fs')
Proof
rw[basis_ffiTheory.whole_prog_ffidiv_spec_def]
\\ qmatch_goalsub_abbrev_tac`fs1 = _ with numchars := _`
\\ qexists_tac `fs1`
\\ simp[Abbr`fs1`,GSYM add_stdo_with_numchars,with_same_numchars]
\\ match_mp_tac (MP_CANON (MATCH_MP app_wgframe helloErr_spec))
\\ xsimpl
QED
val (helloErr_sem_thm, helloErr_prog_tm) = whole_prog_thm st "helloErr" helloErr_whole_prog_spec;
Definition helloErr_prog_def:
helloErr_prog = ^helloErr_prog_tm
End
Theorem helloErr_semantics =
helloErr_sem_thm |> ONCE_REWRITE_RULE[GSYM helloErr_prog_def]
|> DISCH_ALL |> SIMP_RULE std_ss [AND_IMP_INTRO,GSYM CONJ_ASSOC]
val _ = export_theory ()