I'm trying to come up with a syntax and semantics for a simple c-like program in coq. This is for a uni course I'm taking on the principles of programming languages.
I have checked the site for similar questions and only found two threads that got close to what I needed, but they were not really on par with what I am required to do.
Long story short, I currently have this definition for a class:
Inductive Object :=
| object : string -> list_variable -> Function -> Object.
Where list_variable is declared as:
Inductive list_variable : Type :=
| null
| cons (s : string) (l : list_variable).
and Function is declared as:
Inductive Function :=
| function : string -> list_variable -> Function.
All of this should be included in the following statement, which is what I need to use to build some test programs that should run without error:
Inductive Stmt :=
| var_declare : string -> Stmt
| object_declare : Object -> string -> Stmt
| function_declare : function -> Stmt -> Stmt
| assignment : string -> Exp -> Stmt
| sequence : Stmt -> Stmt -> Stmt
| ifthenelse : Exp -> Stmt -> Stmt -> Stmt
| ifthen : Exp -> Stmt -> Stmt
| while : Exp -> Stmt -> Stmt.
Exp is simply an inductive type that has variables, numbers, arithmetic and boolean expressions.
My question is, how can I simulate a memory-like environment where I can define an object, create an instance for said object and be able to access at the very least the member variables for a specific instance?
I got some hints which resume to using two maps, one from variables (or objects) to memory addresses and the other one from memory addresses to values. So, it should be something of the form:
Definition Address := Object -> ObjAddress.
Definition ObjValues := Address -> Value (nat, bool or string)
In the end, I would like to have something among the lines of:
class example {member variables and methods};
example e1;
e1.variable=1.
Do you have any ideas as to how this could be coded into coq?