Overview Operational Semantics Equivalence Proof Semantics Liam O’Connor CSE, UNSW (and data61) Term3 2019 1
Overview Operational Semantics Equivalence Proof Misc The midsession exam is on at 11am, Fri 11th of October, 2019 . It should last for 50 minutes. You must be seated in your assigned location by 11:05am . The exam will start right at that time. You may bring one , single-sided a4 sheet of paper with hand-written notes. A sample midsession paper has been provided. There are two venues for the exam. You will be assigned a venue automatically, and can check which venue you have been assigned to on the course website. The venues are OMB 149 (normal lecture theatre), and CLB 2 . Don’t be late! Figure out where your venue is ahead of time! Marks will be returned to you before the census date. 2
Overview Operational Semantics Equivalence Proof Semantics σηµαντιχως Semantics Scopes 3
Overview Operational Semantics Equivalence Proof Semantics σηµαντιχως Dynamic Static Scopes 4
Overview Operational Semantics Equivalence Proof Semantics σηµαντιχως Dynamic Static Types Scopes Scopes 5
Overview Operational Semantics Equivalence Proof Semantics σηµαντιχως Dynamic Static Types Behaviour Scopes Scopes Cost 6
Overview Operational Semantics Equivalence Proof Static Semantics Definition The static semantics of a program is those significant aspects of the meaning of P that can be determined by the compiler (or an external lint tool) without running the program. Recall our arithmetic expression language. What properties might we derive statically about those terms? 7
Overview Operational Semantics Equivalence Proof Static Semantics Definition The static semantics of a program is those significant aspects of the meaning of P that can be determined by the compiler (or an external lint tool) without running the program. Recall our arithmetic expression language. What properties might we derive statically about those terms? The only thing we can check is that the program is well-scoped (assuming FOAS). 8
Overview Operational Semantics Equivalence Proof Scope-Checking e 1 ok e 2 ok e 1 ok e 2 ok ( Num n ) ok ( Times e 1 e 2 ) ok ( Plus e 1 e 2 ) ok Γ ⊢ ( Var x ) ok Key Idea We keep a context Γ, a set of assumptions, on the left hand of our judgement e ok , indicating what is required in order for e to be well-scoped . This could be read as hypothetical derivations for the judgement e ok or as a binary judgement Γ ⊢ e ok ; whichever you prefer.
Overview Operational Semantics Equivalence Proof Scope-Checking Γ ⊢ e 1 ok Γ ⊢ e 2 ok Γ ⊢ e 1 ok Γ ⊢ e 2 ok Γ ⊢ ( Num n ) ok Γ ⊢ ( Times e 1 e 2 ) ok Γ ⊢ ( Plus e 1 e 2 ) ok Γ ⊢ ( Var x ) ok Key Idea We keep a context Γ, a set of assumptions, on the left hand of our judgement e ok , indicating what is required in order for e to be well-scoped . This could be read as hypothetical derivations for the judgement e ok or as a binary judgement Γ ⊢ e ok ; whichever you prefer. 10
Overview Operational Semantics Equivalence Proof Scope-Checking Γ ⊢ e 1 ok Γ ⊢ e 2 ok Γ ⊢ e 1 ok Γ ⊢ e 2 ok Γ ⊢ ( Num n ) ok Γ ⊢ ( Times e 1 e 2 ) ok Γ ⊢ ( Plus e 1 e 2 ) ok ( x bound ) ∈ Γ Γ ⊢ ( Var x ) ok Key Idea We keep a context Γ, a set of assumptions, on the left hand of our judgement e ok , indicating what is required in order for e to be well-scoped . This could be read as hypothetical derivations for the judgement e ok or as a binary judgement Γ ⊢ e ok ; whichever you prefer. 11
Overview Operational Semantics Equivalence Proof Scope-Checking Γ ⊢ e 1 ok Γ ⊢ e 2 ok Γ ⊢ e 1 ok Γ ⊢ e 2 ok Γ ⊢ ( Num n ) ok Γ ⊢ ( Times e 1 e 2 ) ok Γ ⊢ ( Plus e 1 e 2 ) ok ( x bound ) ∈ Γ Γ ⊢ ( Var x ) ok Γ ⊢ ( Let x e 1 e 2 ) ok Key Idea We keep a context Γ, a set of assumptions, on the left hand of our judgement e ok , indicating what is required in order for e to be well-scoped . This could be read as hypothetical derivations for the judgement e ok or as a binary judgement Γ ⊢ e ok ; whichever you prefer. 12
Overview Operational Semantics Equivalence Proof Scope-Checking Γ ⊢ e 1 ok Γ ⊢ e 2 ok Γ ⊢ e 1 ok Γ ⊢ e 2 ok Γ ⊢ ( Num n ) ok Γ ⊢ ( Times e 1 e 2 ) ok Γ ⊢ ( Plus e 1 e 2 ) ok ( x bound ) ∈ Γ Γ ⊢ e 1 ok Γ ⊢ ( Var x ) ok Γ ⊢ ( Let x e 1 e 2 ) ok Key Idea We keep a context Γ, a set of assumptions, on the left hand of our judgement e ok , indicating what is required in order for e to be well-scoped . This could be read as hypothetical derivations for the judgement e ok or as a binary judgement Γ ⊢ e ok ; whichever you prefer. 13
Overview Operational Semantics Equivalence Proof Scope-Checking Γ ⊢ e 1 ok Γ ⊢ e 2 ok Γ ⊢ e 1 ok Γ ⊢ e 2 ok Γ ⊢ ( Num n ) ok Γ ⊢ ( Times e 1 e 2 ) ok Γ ⊢ ( Plus e 1 e 2 ) ok ( x bound ) ∈ Γ Γ ⊢ e 1 ok x bound , Γ ⊢ e 2 ok Γ ⊢ ( Var x ) ok Γ ⊢ ( Let x e 1 e 2 ) ok Key Idea We keep a context Γ, a set of assumptions, on the left hand of our judgement e ok , indicating what is required in order for e to be well-scoped . This could be read as hypothetical derivations for the judgement e ok or as a binary judgement Γ ⊢ e ok ; whichever you prefer. 14
Overview Operational Semantics Equivalence Proof Scope-Checking Example Γ ⊢ e 1 ok Γ ⊢ e 2 ok Γ ⊢ e 1 ok Γ ⊢ e 2 ok Γ ⊢ ( Num n ) ok Γ ⊢ ( Times e 1 e 2 ) ok Γ ⊢ ( Plus e 1 e 2 ) ok ( x bound ) ∈ Γ Γ ⊢ e 1 ok x bound , Γ ⊢ e 2 ok Γ ⊢ ( Var x ) ok Γ ⊢ ( Let x e 1 e 2 ) ok ⊢ ( Let "x" ( N 3) ( Let "y" ( N 4) ( Plus ( V "x" ) ( V "y" )))) 15
Overview Operational Semantics Equivalence Proof Scope-Checking Example Γ ⊢ e 1 ok Γ ⊢ e 2 ok Γ ⊢ e 1 ok Γ ⊢ e 2 ok Γ ⊢ ( Num n ) ok Γ ⊢ ( Times e 1 e 2 ) ok Γ ⊢ ( Plus e 1 e 2 ) ok ( x bound ) ∈ Γ Γ ⊢ e 1 ok x bound , Γ ⊢ e 2 ok Γ ⊢ ( Var x ) ok Γ ⊢ ( Let x e 1 e 2 ) ok ⊢ ( N 3) ⊢ ( Let "x" ( N 3) ( Let "y" ( N 4) ( Plus ( V "x" ) ( V "y" )))) 16
Overview Operational Semantics Equivalence Proof Scope-Checking Example Γ ⊢ e 1 ok Γ ⊢ e 2 ok Γ ⊢ e 1 ok Γ ⊢ e 2 ok Γ ⊢ ( Num n ) ok Γ ⊢ ( Times e 1 e 2 ) ok Γ ⊢ ( Plus e 1 e 2 ) ok ( x bound ) ∈ Γ Γ ⊢ e 1 ok x bound , Γ ⊢ e 2 ok Γ ⊢ ( Var x ) ok Γ ⊢ ( Let x e 1 e 2 ) ok ⊢ ( N 3) "x" ⊢ ( Let "y" ( N 4) ( Plus ( V "x" ) ( V "y" ))) ⊢ ( Let "x" ( N 3) ( Let "y" ( N 4) ( Plus ( V "x" ) ( V "y" )))) 17
Overview Operational Semantics Equivalence Proof Scope-Checking Example Γ ⊢ e 1 ok Γ ⊢ e 2 ok Γ ⊢ e 1 ok Γ ⊢ e 2 ok Γ ⊢ ( Num n ) ok Γ ⊢ ( Times e 1 e 2 ) ok Γ ⊢ ( Plus e 1 e 2 ) ok ( x bound ) ∈ Γ Γ ⊢ e 1 ok x bound , Γ ⊢ e 2 ok Γ ⊢ ( Var x ) ok Γ ⊢ ( Let x e 1 e 2 ) ok "x" ⊢ ( N 4) "y" , "x" ⊢ ( Plus ( V "x" ) ( V "y" )) ⊢ ( N 3) "x" ⊢ ( Let "y" ( N 4) ( Plus ( V "x" ) ( V "y" ))) ⊢ ( Let "x" ( N 3) ( Let "y" ( N 4) ( Plus ( V "x" ) ( V "y" )))) 18
Overview Operational Semantics Equivalence Proof Scope-Checking Example Γ ⊢ e 1 ok Γ ⊢ e 2 ok Γ ⊢ e 1 ok Γ ⊢ e 2 ok Γ ⊢ ( Num n ) ok Γ ⊢ ( Times e 1 e 2 ) ok Γ ⊢ ( Plus e 1 e 2 ) ok ( x bound ) ∈ Γ Γ ⊢ e 1 ok x bound , Γ ⊢ e 2 ok Γ ⊢ ( Var x ) ok Γ ⊢ ( Let x e 1 e 2 ) ok "y" , "x" ⊢ ( V "x" ) "y" , "x" ⊢ ( V "y" ) "x" ⊢ ( N 4) "y" , "x" ⊢ ( Plus ( V "x" ) ( V "y" )) ⊢ ( N 3) "x" ⊢ ( Let "y" ( N 4) ( Plus ( V "x" ) ( V "y" ))) ⊢ ( Let "x" ( N 3) ( Let "y" ( N 4) ( Plus ( V "x" ) ( V "y" )))) 19
Overview Operational Semantics Equivalence Proof Dynamic Semantics Dynamic Semantics can be speciified in many ways: Denotational Semantics is the compositional construction of a 1 mathematical object for each form of syntax . COMP6752 20
Overview Operational Semantics Equivalence Proof Dynamic Semantics Dynamic Semantics can be speciified in many ways: Denotational Semantics is the compositional construction of a 1 mathematical object for each form of syntax . COMP6752 Axiomatic Semantics is the construction of a proof calculus to 2 allow correctness of a program to be verified. COMP2111 21
Overview Operational Semantics Equivalence Proof Dynamic Semantics Dynamic Semantics can be speciified in many ways: Denotational Semantics is the compositional construction of a 1 mathematical object for each form of syntax . COMP6752 Axiomatic Semantics is the construction of a proof calculus to 2 allow correctness of a program to be verified. COMP2111 Operational Semantics is the construction of a 3 program-evaluating state machine or transition system . 22
Recommend
More recommend