theory a3 imports Main begin -- ----------------------------------------------------- section "Balanced Parentheses" datatype letter = L | R type_synonym lang = "letter list set" -- "a) define grammar for S inductively" -- "b) prove examples" -- "c) define is_bal" -- "d) show correctness of is_bal" -- ----------------------------------------------------- section "Expressions" datatype expr = Const nat | Var string | Plus expr expr type_synonym state = "string \ nat" -- "a) change to a function definition:" consts aval :: "expr \ state \ nat" -- "b)" type_synonym vars = "string \ nat option" -- "change to a function definition:" consts asimp :: "expr \ vars \ expr" -- "c) formulate and prove correctness lemma" -- ----------------------------------------------------- section "File System Paths" datatype seg = Root | Parent | Seg string type_synonym path = "seg list" fun str_of where "str_of Root = ''//''" | "str_of Parent = ''..''" | "str_of (Seg s) = s" -- "a)" -- "implement sep and str:" consts sep :: "'a \ 'a list \ 'a list" consts str :: "path \ string" -- "b) implement chdir" consts chdir :: "seg \ path \ path" -- "c) implement norm" consts norm :: "path \ path" -- "d) formulate and prove correctness of norm" -- "e) prove that norm is the identity on normal paths" end