|
1 /** Isabelle System **/ |
|
2 |
|
3 val sys = new isabelle.IsabelleSystem |
|
4 |
|
5 |
|
6 /* Isabelle settings environment */ |
|
7 |
|
8 sys.getenv("ISABELLE_HOME") |
|
9 sys.getenv("ISABELLE_PATH") |
|
10 |
|
11 |
|
12 /* Isabelle tools */ |
|
13 |
|
14 sys.isabelle_tool() |
|
15 sys.isabelle_tool("doc") |
|
16 sys.isabelle_tool("doc", "system") |
|
17 |
|
18 |
|
19 sys.find_logics |
|
20 |
|
21 |
|
22 /* Isabelle symbols */ |
|
23 |
|
24 val symbols = sys.symbols |
|
25 val s1 = symbols.decode("""\<forall>x. x \<in> A --> x \<in> B""") |
|
26 val s2 = symbols.encode(s1) |
|
27 |
|
28 |
|
29 |
|
30 /** Isabelle Process **/ |
|
31 |
|
32 /* demo command loop */ |
|
33 |
|
34 val p = new isabelle.IsabelleProcess |
|
35 |
|
36 p.command("theory A imports Main begin") |
|
37 p.command(""" lemma "A --> A" """) |
|
38 p.command("..") |
|
39 p.command("end") |
|
40 |
|
41 p.close |
|
42 |
|
43 |
|
44 val p = new isabelle.IsabelleProcess |
|
45 |
|
46 p.ML("fun f 0 = 1 | f n = n * f (n - 1)") |
|
47 p.ML("f 1000") |
|
48 |
|
49 p.ML("OS.Process.sleep (Time.fromSeconds 10)"); |
|
50 p.interrupt |
|
51 |
|
52 |
|
53 /* receiving messages */ |
|
54 |
|
55 import isabelle._ |
|
56 import scala.actors._ |
|
57 |
|
58 def self_receiver(): EventBus[IsabelleProcess.Result] = { |
|
59 val self = Actor.self |
|
60 new EventBus[IsabelleProcess.Result] + (result => self ! result) |
|
61 } |
|
62 |
|
63 def receive(): Option[IsabelleProcess.Result] = { |
|
64 Actor.self.receiveWithin(100) { |
|
65 case TIMEOUT => None |
|
66 case result: IsabelleProcess.Result => Some(result) |
|
67 } |
|
68 } |
|
69 |
|
70 val p = new IsabelleProcess(new IsabelleSystem, self_receiver()) |
|
71 |
|
72 p.command("theory A imports Main begin") |
|
73 p.command(""" term "x + y" """) |
|
74 p.ML(""" tracing (Syntax.string_of_term @{context} @{term "x + y"}) """) |
|
75 |
|
76 |
|
77 |
|
78 /** basic document model **/ |
|
79 |
|
80 import isabelle._ |
|
81 |
|
82 val p = new IsabelleProcess with IsarDocument |
|
83 |
|
84 p.define_command("1", "theory A imports Main begin") |
|
85 p.define_command("2", "lemma \"A --> A\"") |
|
86 p.define_command("3", "..") |
|
87 p.define_command("4", "end") |
|
88 |
|
89 p.begin_document("doc1", "A.thy") |
|
90 p.edit_document("doc1", "doc2", |
|
91 List(("doc1", Some("1")), ("1", Some("2")), ("2", Some("3")), ("3", Some("4")))) |
|
92 |
|
93 p.edit_document("doc2", "doc3", List(("2", None))) |
|
94 p.edit_document("doc3", "doc4", List(("1", None))) |
|
95 p.edit_document("doc4", "doc5", List(("1", Some("2")), ("2", Some("3")))) |
|
96 |
|
97 p.end_document("doc5") |
|
98 |