fundamentals of programming languages i
play

Fundamentals of Programming Languages I Introduction and Logics - PowerPoint PPT Presentation

Fundamentals of Programming Languages I Introduction and Logics Guoqiang Li School of Software, Shanghai Jiao Tong University Instructor and Teaching Assistants Guoqiang LI Homepage: http://basics.sjtu.edu.cn/liguoqiang Course


  1. Fundamentals of Programming Languages I Introduction and Logics Guoqiang Li School of Software, Shanghai Jiao Tong University

  2. Instructor and Teaching Assistants • Guoqiang LI • Homepage: http://basics.sjtu.edu.cn/˜liguoqiang • Course page: http://basics.sjtu.edu.cn/˜liguoqiang/teaching/Prog17/index.htm • Email: li.g@outlook.com • Office: Rm. 1212, Building of Software • Phone: 3420-4167 • TA: • Yuwei WANG: wangyuwei95 (AT) qq (DOT) com • Office hour: Tue. 14:00-17:00 @ Software Building 3203

  3. What does the lecture aim for?

  4. Similar Lectures I Fundamentals of Programming Languages by University of Colorado Boulder http://www.cs.colorado.edu/˜bec/courses/csci5535-f13/ • 2010 Spring Programming semantics • 2013 Fall Programming analysis and verification

  5. Similar Lectures II Principles of Programming Languages by University of Oxford http://www.cs.ox.ac.uk/teaching/courses/2017-2018/principles/ Foundations of Programming Languages by CMU www.cs.cmu.edu/˜rjsimmon/15312-s14/schedule.html Theory of Programming Languages by ECNU basics.sjtu.edu.cn/˜yuxin/teaching/Semantics/sem.html Programming Semantics

  6. Similar Lectures III Fundamentals of Programming Analysis by MIT ocw.mit.edu/courses/electrical-engineering-and-computer-science/6- 820-fundamentals-of-program-analysis-fall-2015/lecture-notes/ Principles of Programming Languages by Boston University http://www.cs.bu.edu/˜hwxi/academic/courses/CS520/Fall15 Programming Analysis and Verification

  7. Similar Lectures IV Theory of Programming Languages by CMU www.cs.cmu.edu/ aldrich/courses/15-819O-13sp Introduction to Programming Languages Theory by Standford https://courseware.stanford.edu/pg/courses/lectures/261141 Theory of Programming Languages by SJTU http://basics.sjtu.edu.cn/˜xiaojuan/tapl2016/index.html Types and Functional Programming Languages

  8. Fundamental Requirements • Program Verification and Analysis • Propositional logic, predicate logic etc. • Automata theory, DFA, NFA, PDS, PN etc. • Algorithm. • Program Semantics • Set theory. • Algebra theory, group, ring, domain etc. • category theory, maybe... • Types and Programming Languages • Logic • Computability theory • Lambda calculus theory...

  9. Fundamental of Fundamental Several theories in theoretical computer science are given, which is a minimal requirement and self-contained in this lecture. All of three directions are taught, which only include very fundamental part, if time permitted. As simple as possible, although it is very theoretical.

  10. Lecture Agenda • Introduction and logic basics (1 lecture) • Formal basics (3 lectures) • Model checking • Finite and Büchi automata • LTL model checking • Programming verification (2 or 3 lectures) • Abstract interpretation • Pushdown automata and interprocedural programs • Petri Net and concurrent programs • Exercise I. (1 lecture) • Programming semantics (2 lectures) • Denotational semantics • Operational semantics • Axiomatic semantics • Basic functional programming (3 lectures) • Lambda calculus • Simple types • Functional programming • Exercise II. (1 lecture)

  11. References No particular textbook that can cover all the parts. Here are three Reference books: Edmund M. Clarke Jr., Orna Grumberg, Doron A. Peled. Model Checking. MIT Press, 1999 Glynn Winskel. Formal Semantics of Programming Languages: An Introduction. MIT Press, 1993 Benjamin C. Pierce. Types and Programming Languages. MIT Press, 2002 + Several famous papers + Lecture notes shared in the course webpage.

  12. Scoring Policy • 10% Attendance. • 20% Homework. • Four assignments. • Each one is 5pts. • Work out individually. • Each assignment will be evaluated by A , B , C , D , F (Excellent(5), Good(5), Fair(4), Delay(3), Fail(0)) • 70% Final exam. • Maybe replaced by report, if the condition is satisfied!

  13. Any Questions?

  14. Logic Basics

  15. Brief Historical Notes on Logic

  16. Historical View • Philosophical Logic • 500 BC to 19th Century • Symbolic Logic • Mid to late 19th Century • Mathematical Logic • Late 19th to mid 20th Century • Logic in Computer Science

  17. Philosophical Logic 500 B.C - 19th Century Logic dealt with arguments in the natural language used by humans. Example: • All men are mortal. • Socrates is a man. • Therefore, Socrates is mortal.

  18. Philosophical Logic Natural languages are very ambiguous. • Eric does not believe that Mary can pass any test. • does not believe that she can pass some test, or • does not believe that she can pass all tests • I only borrowed your car. • And not ‘borrowed and used’, or • And not ‘car and coat’ • Tom hates Jim and he likes Mary. • Tom likes Mary, or • Jim likes Mary It led to many paradoxes. • “This sentence is a lie.”(The Liar’s Paradox)

  19. Sophism …Sophism generally refers to a particularly confusing, illogical and/or insincere argument used by someone to make a point, or, perhaps, not to make a point. Sophistry refers to […] rhetoric that is designed to appeal to the listener on grounds other than the strict logical cogency of the statements being made.

  20. The Sophist’s Paradox A Sophist is sued for his tuition by the school that educated him. He argues that he must win, since, if he loses, the school didn’t educate him well enough, and doesn’t deserve the money. The school argues that he must lose, since, if he wins, he was educated well enough, and therefore should pay for it.

  21. Logic in Computer Science Logic has a profound impact on computer science. Some examples: • Propositional logic - the foundation of computers and circuitry • Databases - query languages • Programming languages (e.g. prolog) • Design Validation and verification • AI (e.g. inference systems) • …

  22. Logic in Computer Science Propositional Logic First Order Logic Higher Order Logic Temporal Logic …

  23. Propositional Logic: Syntax

  24. Propositional Logic A proposition: a sentence that can be either true or false. Propositions: • x is greater than y • Noam wrote this letter

  25. Propositional Logic: Syntax The symbols of the language: • Propositional symbols ( Prop ): A , B , C , . . . • Connectives: • ∧ and • ∨ or • ¬ not • → implies • ↔ equivalent to • ⊕ xor (different than) • ⊥ , ⊤ False, True • Parenthesis: ( , ) . Q1: How many different binary symbols can we define? Q2: What is the minimal number of such symbols?

  26. Formulas Grammar of well-formed propositional formulas Formula := prop | ¬ ( Formula ) | ( Formula ◦ Formula ) where prop ∈ Prop and ◦ is one of the binary relations.

  27. Formulas Examples of well-formed formulas: • ( ¬ A ) • ( ¬ ( ¬ A )) • ( A ∧ ( B ∧ C )) • ( A → ( B → C )) Correct expressions of Propositional Logic are full of unnecessary parenthesis.

  28. Formulas: Abbreviations We write A ◦ B ◦ C ◦ . . . in place of ( A ◦ ( B ◦ ( C ◦ . . . ))) Thus, we write A ∧ B ∧ C , A → B → C , . . . in place of ( A ∧ ( B ∧ C )) , ( A → ( B → C )) , . . .

  29. Formulas: Abbreviations We omit parenthesis whenever we may restore them through operator precedence: ¬ binds more strictly than ∧ , ∨ , and ∧ , ∨ bind more strictly than → , ↔ . Thus, we write: • ¬¬ A for ( ¬ ( ¬ A )) , • ¬ A ∧ B for (( ¬ A ) ∧ B ) • A ∧ B → C for (( A ∧ B ) → C ) • …

  30. Propositional Logic: Semantics

  31. Propositional Logic: Semantics Truth tables define the semantics (=meaning) of the operators Convention: 0 = false , 1 = true A ∧ B A ∨ B A → B A B 0 0 0 0 1 0 1 0 1 1 1 0 0 1 0 1 1 1 1 1

  32. Propositional Logic: Semantics Truth tables define the semantics (=meaning) of the operators Convention: 0 = false , 1 = true ¬ A A ↔ B A ⊕ B A B 0 0 1 1 0 0 1 1 0 1 1 0 0 0 1 1 1 0 1 0

  33. Back to Q1 Q1: How many binary operators can we define that have different semantic definition? A: 16

  34. Satisfiability and Validity

  35. Assignments Definition: A truth-values assignment, α , is an element of 2 Prop (i.e., α ∈ 2 Prop ). In other words, α is a subset of the variables that are assigned true. Equivalently, we can see α as a mapping from variables to truth values: α : Prop �→ { 0 , 1 } Example: α = { A �→ 0 , B �→ 1 , . . . }

  36. Satisfaction Relation ( | = ): Intuition An assignment can either satisfy or not satisfy a given formula. α | = φ means • α satisfies φ or • φ holds at α or • α is a model of φ We will first see an example. Then we will define these notions formally.

  37. Example Let φ = ( A ∨ ( B → C )) Let α = { A �→ 0 , B �→ 0 , C �→ 1 } Q: Does α satisfy φ ( α | = φ ?) A: ( 0 ∨ ( 0 → 1 )) = ( 0 ∨ 1 ) = 1 Hence, α | = φ . Let us now formalize an evaluation process.

  38. Satisfaction Relation ( | = ): Formalities = ⊆ ( 2 Prop × Formula ) | = is a relation: | Examples: • ( { A } , A ∨ B ) : the assignment α = { A } satisfies A ∨ B • ( { A , B } , A ∧ B ) = ⊆ ( { 0 , 1 } Prop × Formula ) Alternatively: | Examples: • ( 01 , A ∨ B ) : the assignment α = { A �→ 0 , B �→ 1 } satisfies A ∨ B • ( 11 , A ∧ B )

Recommend


More recommend