semantics dr liam o connor
play

Semantics Dr. Liam OConnor University of Edinburgh LFCS UNSW, Term - PowerPoint PPT Presentation

Overview Operational Semantics Equivalence Proof Semantics Dr. Liam OConnor University of Edinburgh LFCS UNSW, Term 3 2020 1 Overview Operational Semantics Equivalence Proof Semantics Semantics Scopes Scopes 2


  1. Overview Operational Semantics Equivalence Proof Semantics Dr. Liam O’Connor University of Edinburgh LFCS UNSW, Term 3 2020 1

  2. Overview Operational Semantics Equivalence Proof Semantics σηµαντιχως Semantics Scopes Scopes 2

  3. Overview Operational Semantics Equivalence Proof Semantics σηµαντιχως Dynamic Static Scopes Scopes 3

  4. Overview Operational Semantics Equivalence Proof Semantics σηµαντιχως Dynamic Static Types Scopes Scopes Scopes 4

  5. Overview Operational Semantics Equivalence Proof Semantics σηµαντιχως Dynamic Static Types Behaviour Scopes Scopes Scopes Cost 5

  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? 6

  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). 7

  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.

  9. 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. 9

  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. 10

  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. 11

  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. 12

  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. 13

  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" )))) 14

  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" )))) 15

  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" )))) 16

  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" )))) 17

  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" )))) 18

  19. Overview Operational Semantics Equivalence Proof Dynamic Semantics Dynamic Semantics can be specified in many ways: Denotational Semantics is the compositional construction of a mathematical 1 object for each form of syntax . COMP6752 (briefly) 19

  20. Overview Operational Semantics Equivalence Proof Dynamic Semantics Dynamic Semantics can be specified in many ways: Denotational Semantics is the compositional construction of a mathematical 1 object for each form of syntax . COMP6752 (briefly) Axiomatic Semantics is the construction of a proof calculus to allow correctness of 2 a program to be verified. COMP2111, COMP6721 20

  21. Overview Operational Semantics Equivalence Proof Dynamic Semantics Dynamic Semantics can be specified in many ways: Denotational Semantics is the compositional construction of a mathematical 1 object for each form of syntax . COMP6752 (briefly) Axiomatic Semantics is the construction of a proof calculus to allow correctness of 2 a program to be verified. COMP2111, COMP6721 Operational Semantics is the construction of a program-evaluating state machine 3 or transition system . 21

  22. Overview Operational Semantics Equivalence Proof Dynamic Semantics Dynamic Semantics can be specified in many ways: Denotational Semantics is the compositional construction of a mathematical 1 object for each form of syntax . COMP6752 (briefly) Axiomatic Semantics is the construction of a proof calculus to allow correctness of 2 a program to be verified. COMP2111, COMP6721 Operational Semantics is the construction of a program-evaluating state machine 3 or transition system . In this course We focus mostly on operational semantics. We will use axiomatic semantics (Hoare Logic) on Thursday in the imperative programming topic. Denotational semantics are mostly an extension topic, except for the very next slide. 22

  23. Overview Operational Semantics Equivalence Proof Denotational Semantics � · � : AST → � Num n � = � Var x � = � Plus e 1 e 2 � = � Times e 1 e 2 � = � Let x e 1 e 2 � = 23

Recommend


More recommend