diff options
| author | Jakob L. Kreuze | 2024-07-13 18:04:05 -0400 |
|---|---|---|
| committer | Jakob L. Kreuze | 2024-07-13 18:11:42 -0400 |
| commit | 81c4d517735983a5afd6e9dc800257c761598527 (patch) | |
| tree | 6b924707914d385126e6d330d2c628fd26f23a27 /org/What I've Learned About Formal Methods In Half a Year | |
| parent | 7f37518e4792f040a753a5d8d68d51e76cc0b2be (diff) | |
The `org' directory is no longer necessary
Diffstat (limited to 'org/What I've Learned About Formal Methods In Half a Year')
| -rw-r--r-- | org/What I've Learned About Formal Methods In Half a Year/1670-problem.frg | 227 | ||||
| -rw-r--r-- | org/What I've Learned About Formal Methods In Half a Year/forge-1-1.png | bin | 76319 -> 0 bytes | |||
| -rw-r--r-- | org/What I've Learned About Formal Methods In Half a Year/forge-1-2.png | bin | 76837 -> 0 bytes | |||
| -rw-r--r-- | org/What I've Learned About Formal Methods In Half a Year/forge-1-3.png | bin | 52219 -> 0 bytes | |||
| -rw-r--r-- | org/What I've Learned About Formal Methods In Half a Year/forge-1-4.png | bin | 53208 -> 0 bytes | |||
| -rw-r--r-- | org/What I've Learned About Formal Methods In Half a Year/outline.org | 82 |
6 files changed, 0 insertions, 309 deletions
diff --git a/org/What I've Learned About Formal Methods In Half a Year/1670-problem.frg b/org/What I've Learned About Formal Methods In Half a Year/1670-problem.frg deleted file mode 100644 index d82d709..0000000 --- a/org/What I've Learned About Formal Methods In Half a Year/1670-problem.frg +++ /dev/null @@ -1,227 +0,0 @@ -#lang forge - -option solver "/tmp/sat1/solver.py" - -option problem_type temporal -option min_tracelength 2 -option max_tracelength 10 - -sig File { - ctime: one Int, - var free: one Int -} - -sig Snapshot extends File { - children: set File, - retired_list: set File -} - -one sig CurrentRoot { - var live_children: set File, - var live_retired_list: set File -} - -pred referenced_by_snapshot[f: File] { - some s: Snapshot { - s.free = 0 - f in s.children - } -} - -pred valid_state { - all f: File { - -- No referenced file should be free. - (f in CurrentRoot.live_children or (some s: Snapshot | f in s.children and s.free = 0)) => f.free = 0 - - -- No file in a retired list should referenced - f in CurrentRoot.live_retired_list => f not in CurrentRoot.live_children - all s: Snapshot { - f in s.retired_list and s.free = 0 => f not in s.children - } - - -- Treat `free` as a boolean. - f.free = 0 or f.free = 1 - } - - -- Snapshots must be roots. - all s1 : Snapshot { - s1 not in CurrentRoot.live_children - s1 not in CurrentRoot.live_retired_list - all s2: Snapshot { - s1 not in s2.children - s1 not in s2.retired_list - } - } - - -- Added this! - all f: File | (all s1: Snapshot | f in s1.retired_list => { - f not in CurrentRoot.live_children - all s2: Snapshot { - s2.ctime > s1.ctime => f not in s2.children - } - }) - - -- This was also necessary -- clock is monotone. - all disj f1, f2: File | f1.ctime != f2.ctime -} - --- - --- We start with an empty filesystem, where everything is free. -pred init { - no CurrentRoot.live_children - no CurrentRoot.live_retired_list - all f: File { - f.free = 1 iff f != CurrentRoot - } -} - -pred make_snapshot { - one s: Snapshot { - -- The snapshot captures the state of the filesystem at this point in time. - s.children = CurrentRoot.live_children - s.retired_list = CurrentRoot.live_retired_list - - -- The snapshot is now marked as allocated. - s.free = 1 - s.free' = 0 - - all f: File { - f != s => { - -- The free flag is unchanged for every other file. - f.free' = f.free - - -- All other creations happened in the past, relative to this one. - f.free = 0 => s.ctime > f.ctime - } - } - } - - -- The retired list is emptied for the current filesystem. - no live_retired_list' - - -- Nothing else changes. - live_children' = live_children -} - -pred referenced_by_no_other_snapshot[f: File] { - all s: Snapshot { - s.free = 0 => f not in s.children - } -} - -pred delete_snapshot { - one s: Snapshot { - -- The snapshot is now marked as free - s.free = 0 - s.free' = 1 - - all f: File { - (f in s.retired_list and referenced_by_no_other_snapshot[f]) => { - f.free' = 1 - } else { - -- The free flag is unchanged for every other file. - f != s => f.free' = f.free - } - } - } - - -- Nothing else changes. - live_retired_list' = live_retired_list - live_children' = live_children -} - -pred make_file { - one f: File { - -- `f` is added to the set of live children. - CurrentRoot.live_children' = CurrentRoot.live_children + f - -- `f` is marked as allocated. - f.free' = 0 - - -- n.b. it could already be allocated, if a previous snapshot refers to it. - - all f2: File { - f2 != f => { - -- Free flag for other files remains unchanged. - f2.free' = f2.free - - -- All other creations happened in the past, relative to this one. - f2.free = 0 => f.ctime > f2.ctime - } - } - } - - -- Nothing else changes. - live_retired_list' = live_retired_list - live_children' = live_children -} - -pred delete_file { - one f: File { - -- It only makes sense to delete a file if it's in the filesystem - f in CurrentRoot.live_children - - -- Remove it from the filesystem, and reclaim it if applicable. - -- Otherwise, put it in the retired list. - CurrentRoot.live_children' = CurrentRoot.live_children - f - - referenced_by_snapshot[f] => { - -- If another snapshot refers to this one, we don't free it - -- but add it to the retired list. - f.free' = 0 - CurrentRoot.live_retired_list' = CurrentRoot.live_retired_list + f - } else { - -- Otherwise we can free it and the retired list is unchanged. - f.free' = 1 - live_retired_list' = live_retired_list - } - - all f2: File { - -- Free flag for other files remains unchanged. - f2 != f => f2.free' = f2.free - } - } -} - -pred traces { - init - always (make_snapshot or delete_snapshot or make_file or delete_file) -} - - -test expect { - valid_state_vacuity1: { valid_state } for 5 File is sat - valid_state_vacuity2: { valid_state } for exactly 5 File is sat - - init_vacuity1: { init } for 5 File is sat - init_vacuity2: { init } for exactly 5 File is sat - - make_snapshot_vacuity1: { valid_state and make_snapshot } for 5 File is sat - make_snapshot_vacuity2: { valid_state and make_snapshot } for exactly 5 File is sat - make_snapshot_good: { - (valid_state and make_snapshot) => next_state valid_state - } for 5 File is theorem - - delete_snapshot_vacuity1: { valid_state and delete_snapshot } for 5 File is sat - delete_snapshot_vacuity2: { valid_state and delete_snapshot } for exactly 5 File is sat - delete_snapshot_good: { - (valid_state and delete_snapshot) => next_state valid_state - } for 5 File is theorem - - make_file_vacuity1: { valid_state and make_file } for 5 File is sat - make_file_vacuity2: { valid_state and make_file } for exactly 5 File is sat - make_file_good: { - (valid_state and make_file) => next_state valid_state - } for 5 File is theorem - - delete_file_vacuity1: { valid_state and delete_file } for 5 File is sat - delete_file_vacuity2: { valid_state and delete_file } for exactly 5 File is sat - delete_file_good: { - (valid_state and delete_file) => next_state valid_state - } for 5 File is theorem - - traces_vacuity: { traces } for 5 File is sat - traces_vacuity: { traces } for exactly 5 File is sat - - problem_2b: { traces => always { all f: File | referenced_by_snapshot[f] => (some s: Snapshot | s.free = 0 and s.ctime > f.ctime) } } for exactly 5 File is theorem -} diff --git a/org/What I've Learned About Formal Methods In Half a Year/forge-1-1.png b/org/What I've Learned About Formal Methods In Half a Year/forge-1-1.png Binary files differdeleted file mode 100644 index 0fbe29e..0000000 --- a/org/What I've Learned About Formal Methods In Half a Year/forge-1-1.png +++ /dev/null diff --git a/org/What I've Learned About Formal Methods In Half a Year/forge-1-2.png b/org/What I've Learned About Formal Methods In Half a Year/forge-1-2.png Binary files differdeleted file mode 100644 index 9196000..0000000 --- a/org/What I've Learned About Formal Methods In Half a Year/forge-1-2.png +++ /dev/null diff --git a/org/What I've Learned About Formal Methods In Half a Year/forge-1-3.png b/org/What I've Learned About Formal Methods In Half a Year/forge-1-3.png Binary files differdeleted file mode 100644 index 634939c..0000000 --- a/org/What I've Learned About Formal Methods In Half a Year/forge-1-3.png +++ /dev/null diff --git a/org/What I've Learned About Formal Methods In Half a Year/forge-1-4.png b/org/What I've Learned About Formal Methods In Half a Year/forge-1-4.png Binary files differdeleted file mode 100644 index da6832e..0000000 --- a/org/What I've Learned About Formal Methods In Half a Year/forge-1-4.png +++ /dev/null diff --git a/org/What I've Learned About Formal Methods In Half a Year/outline.org b/org/What I've Learned About Formal Methods In Half a Year/outline.org deleted file mode 100644 index 255ad05..0000000 --- a/org/What I've Learned About Formal Methods In Half a Year/outline.org +++ /dev/null @@ -1,82 +0,0 @@ -* Outline -** Introduction -- Where are you in school right now? - - CSCI 1951X last semester - - CSCI 1710 now - - Doing research on formal methods with Shriram Krishnamurti, Rob Lewis, and Nikos Vasilakis -- What are formal methods and why are the classes you took considered "formal methods classes". -** Preliminaries -*** What are specifications? -** Lightweight formal methods: SAT/SMT solvers like Alloy -https://people.csail.mit.edu/dnj/publications/alloy-journal.pdf -*** What makes these methods "lightweight"? -*** What are they, in principle? -*** Forge versus Alloy -*** How do they work? -*** Application: Memory Management -*** Margrave -http://www.margrave-tool.org/ -** Heavyweight formal methods: specification and theorem proving -*** Specification -*** Programming Language Semantics -**** Big-Step -**** Small-Step -**** Denotational -*** Theorem Proving -**** Lean -**** Coq -*** Refinement -*** Application: Proving the Correctness of a Scheme Program -"what I did for the final project was somewhat natural, so we'll dive into that and then explain how it's similar to refinement" -**** Parsing Lisp -**** Modeling Scheme -**** A Type-Theoretic Representation for Programs -**** A Type-Theoretic Representation for Programs -**** A (Sketch of a) Realized Interpreter -**** A Proof of Correctness for Factorial -** What I hope to learn, eventually -While I feel I'm leaving with a good understanding of the underlying concepts.. - -Ultimately, I'd like to bring what I learn back to work. There's a big push for [[https://inl.gov/digital-engineering/][digital engineering]] where I sit. - -And I think there are a few specific tools that would be especially useful in my line of work. -*** TLA+ -*** EasyCrypt -*** VerifPal -Christine described it as the "one with an anime mascot" once. -** Conclusion -** Appendix: Tooling on Gentoo -*** Forge - -I didn't bother packaging it. I just use =raco= to update. - -I use =alloy-mode=, which is pretty broken, but sufficient for my needs. - -#+BEGIN_SRC elisp -(use-package alloy-mode - :straight (alloy-mode :type git :host github :repo "torus/alloy-mode" - :fork (:host github :repo "dwwmmn/alloy-mode")) - ;; For some reason, `alloy-mode' indents with tabs of width 3. Let's change - ;; that to something more sensical. - :init - (setq alloy-basic-offset 4) - :hook - (alloy-mode-hook . (lambda () (setq indent-tabs-mode nil))) - ;; Use alloy-mode for Forge files as well. - :config - (add-to-list 'auto-mode-alist '("\\.frg\\'" . alloy-mode))) -#+END_SRC - -*** Lean - -Lean 3 is packaged in Gentoo and =lean-mode= works out of the box, but my experience has been that Lean 4 is way better. - -**** =lean4-mode= - -This probably also works out of the box but I hate =lsp-mode=, so I hacked together some code to get a functional goal buffer. - -# TODO - -I hear that [[https://proofgeneral.github.io/][Proof General]] might be getting Lean support soon, and I'm 50/50 on whether or not I'd switch. It's a very nice interface to Coq, but I think my fingers might get an extra year or two of life if I don't have to =C-c C-.= every time I want to update the goal buffer - -**** ebuild |