-
Notifications
You must be signed in to change notification settings - Fork 1
/
RunSimulation.agda
36 lines (29 loc) · 1.17 KB
/
RunSimulation.agda
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
{-# OPTIONS --guardedness #-}
open import Data.Unit
open import Data.List
open import Data.Bool renaming (Bool to 𝔹)
open import Data.Product using (_×_; ∃-syntax; proj₁; proj₂) renaming (_,_ to ⟨_,_⟩)
open import Relation.Binary.PropositionalEquality using (_≡_; refl)
open import Agda.Builtin.String
open import Text.Printf
open import IO
open import Common.Utils
open import Common.Types
open import Common.BlameLabels
open import Surface.SurfaceLang
open import ExamplePrograms.Simulation.Examples
open import Simulator.Simulator
open import PrettyPrinter.GraphViz.Simulation
dir = "plot/"
main = run {Agda.Primitive.lzero} (foldr run-cfg (return tt) cfgs)
where
run-cfg : Cfg → IO ⊤ → IO ⊤
run-cfg ⟨ name , M , M′ , _ , _ , ⊢M , ⊢M′ ⟩ rest =
do
(putStrLn (primStringAppend "Running example: " name))
(let ⟨ ⟨ n , _ , _ , _ , N₁↠N₂ ⟩ ,
⟨ m , _ , _ , _ , N₁′↠N₂′ ⟩ ,
edges ⟩ = simulator M M′ ⊢M ⊢M′ in
let output-file = primStringAppend dir (primStringAppend name ".dot") in
writeFile output-file (print-sim-diagram N₁↠N₂ N₁′↠N₂′ edges))
rest