Fundamentals of Programming Languages I Introduction and Logics

Size: px
Start display at page:

Download "Fundamentals of Programming Languages I Introduction and Logics"

Transcription

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

3 Instructor and Teaching Assistants Guoqiang LI Homepage: liguoqiang Course page: liguoqiang/teaching/prog17/index.htm Office: Rm. 1212, Building of Software Phone:

4 Instructor and Teaching Assistants Guoqiang LI Homepage: liguoqiang Course page: liguoqiang/teaching/prog17/index.htm Office: Rm. 1212, Building of Software Phone: TA: Yuwei WANG: wangyuwei95 (AT) qq (DOT) com

5 Instructor and Teaching Assistants Guoqiang LI Homepage: liguoqiang Course page: liguoqiang/teaching/prog17/index.htm Office: Rm. 1212, Building of Software Phone: TA: Yuwei WANG: wangyuwei95 (AT) qq (DOT) com Office hour: Tue. Software Building 3203

6 What does the lecture aim for?

7 Similar Lectures I Fundamentals of Programming Languages by University of Colorado Boulder bec/courses/csci5535-f13/

8 Similar Lectures I Fundamentals of Programming Languages by University of Colorado Boulder bec/courses/csci5535-f13/ 2010 Spring Programming semantics 2013 Fall Programming analysis and verification

9 Similar Lectures II Principles of Programming Languages by University of Oxford Foundations of Programming Languages by CMU rjsimmon/15312-s14/schedule.html Theory of Programming Languages by ECNU basics.sjtu.edu.cn/ yuxin/teaching/semantics/sem.html

10 Similar Lectures II Principles of Programming Languages by University of Oxford Foundations of Programming Languages by CMU rjsimmon/15312-s14/schedule.html Theory of Programming Languages by ECNU basics.sjtu.edu.cn/ yuxin/teaching/semantics/sem.html Programming Semantics

11 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 hwxi/academic/courses/cs520/fall15

12 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 hwxi/academic/courses/cs520/fall15 Programming Analysis and Verification

13 Similar Lectures IV Theory of Programming Languages by CMU aldrich/courses/15-819o-13sp Introduction to Programming Languages Theory by Standford Theory of Programming Languages by SJTU xiaojuan/tapl2016/index.html

14 Similar Lectures IV Theory of Programming Languages by CMU aldrich/courses/15-819o-13sp Introduction to Programming Languages Theory by Standford Theory of Programming Languages by SJTU xiaojuan/tapl2016/index.html Types and Functional Programming Languages

15 Fundamental Requirements Program Verification and Analysis

16 Fundamental Requirements Program Verification and Analysis Propositional logic, predicate logic etc. Automata theory, DFA, NFA, PDS, PN etc. Algorithm.

17 Fundamental Requirements Program Verification and Analysis Propositional logic, predicate logic etc. Automata theory, DFA, NFA, PDS, PN etc. Algorithm. Program Semantics

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

19 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

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

21 Fundamental of Fundamental Several theories in theoretical computer science are given, which is a minimal requirement and self-contained in this lecture.

22 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,

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

24 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,

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

26 Lecture Agenda Introduction and logic basics (1 lecture) Formal basics (3 lectures) Programming verification (2 or 3 lectures) Exercise I. (1 lecture) Programming semantics (2 lectures) Basic functional programming (3 lectures) Exercise II. (1 lecture) Conclusion and wrap up (1 lecture)

27 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) Exercise I. (1 lecture) Programming semantics (2 lectures) Basic functional programming (3 lectures) Exercise II. (1 lecture) Conclusion and wrap up (1 lecture)

28 Lecture Agenda Introduction and logic basics (1 lecture) Formal basics (3 lectures) 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) Basic functional programming (3 lectures) Exercise II. (1 lecture) Conclusion and wrap up (1 lecture)

29 Lecture Agenda Introduction and logic basics (1 lecture) Formal basics (3 lectures) Programming verification (2 or 3 lectures) Exercise I. (1 lecture) Programming semantics (2 lectures) Denotational semantics Operational semantics Axiomatic semantics Basic functional programming (3 lectures) Exercise II. (1 lecture) Conclusion and wrap up (1 lecture)

30 Lecture Agenda Introduction and logic basics (1 lecture) Formal basics (3 lectures) Programming verification (2 or 3 lectures) Exercise I. (1 lecture) Programming semantics (2 lectures) Basic functional programming (3 lectures) Lambda calculus Simple types Functional programming Exercise II. (1 lecture) Conclusion and wrap up (1 lecture)

31 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

32 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, Several famous papers + Lecture notes shared in the course webpage.

33 Scoring Policy 10% Attendance. 20% Homework. 70% Final exam.

34 Scoring Policy 10% Attendance. 20% Homework. Four assignments. 70% Final exam.

35 Scoring Policy 10% Attendance. 20% Homework. Four assignments. Each one is 5pts. 70% Final exam.

36 Scoring Policy 10% Attendance. 20% Homework. Four assignments. Each one is 5pts. Work out individually. 70% Final exam.

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

38 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!

39 Any Questions?

40 Logic Basics

41 Brief Historical Notes on Logic

42 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

43 Philosophical Logic

44 500 B.C - 19th Century Philosophical Logic

45 Philosophical Logic 500 B.C - 19th Century Logic dealt with arguments in the natural language used by humans.

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

47 Philosophical Logic

48 Philosophical Logic Natural languages are very ambiguous.

49 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

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

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

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

53 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 did not educate him well enough, and does not deserve the money.

54 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 did not educate him well enough, and does not 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.

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

56 Logic in Computer Science Propositional Logic First Order Logic Higher Order Logic Temporal Logic

57 Propositional Logic: Syntax

58 Propositional Logic

59 Propositional Logic A proposition: a sentence that can be either true or false.

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

61 Propositional Logic: Syntax

62 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: (, ).

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

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

65 Formulas Grammar of well-formed propositional formulas Formula := prop (Formula) (Formula Formula) where prop Prop and is one of the binary relations.

66 Formulas Examples of well-formed formulas: ( A) ( ( A)) (A (B C)) (A (B C)) Correct expressions of Propositional Logic are full of unnecessary parenthesis.

67 Formulas: Abbreviations We write A B C...

68 Formulas: Abbreviations We write in place of A B C... (A (B (C...)))

69 Formulas: Abbreviations We write in place of A B C... (A (B (C...))) Thus, we write A B C, A B C,...

70 Formulas: Abbreviations We write in place of A B C... (A (B (C...))) Thus, we write A B C, A B C,... in place of (A (B C)), (A (B C)),...

71 Formulas: Abbreviations We omit parenthesis whenever we may restore them through operator precedence:

72 Formulas: Abbreviations We omit parenthesis whenever we may restore them through operator precedence: binds more strictly than,, and, bind more strictly than,.

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

74 Propositional Logic: Semantics

75 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

76 Propositional Logic: Semantics Truth tables define the semantics (=meaning) of the operators Convention: 0 = false, 1 = true A B A A B A B

77 Back to Q1 Q1: How many binary operators can we define that have different semantic definition?

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

79 Satisfiability and Validity

80 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,...}

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

82 Let φ = (A (B C)) Example

83 Example Let φ = (A (B C)) Let α = {A 0, B 0, C 1}

84 Example Let φ = (A (B C)) Let α = {A 0, B 0, C 1} Q: Does α satisfy φ (α = φ?)

85 Example Let φ = (A (B C)) Let α = {A 0, B 0, C 1} Q: Does α satisfy φ (α = φ?) A: (0 (0 1)) = (0 1) = 1

86 Example Let φ = (A (B C)) Let α = {A 0, B 0, C 1} Q: Does α satisfy φ (α = φ?) A: (0 (0 1)) = (0 1) = 1 Hence, α = φ.

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

88 Satisfaction Relation ( =): Formalities = is a relation: = (2 Prop Formula)

89 Satisfaction Relation ( =): Formalities = is a relation: = (2 Prop Formula) Examples: ({A}, A B): the assignment α = {A} satisfies A B ({A, B}, A B)

90 Satisfaction Relation ( =): Formalities = is a relation: = (2 Prop Formula) Examples: ({A}, A B): the assignment α = {A} satisfies A B ({A, B}, A B) Alternatively: = ({0, 1} Prop Formula)

91 Satisfaction Relation ( =): Formalities = is a relation: = (2 Prop Formula) Examples: ({A}, A B): the assignment α = {A} satisfies A B ({A, B}, A B) Alternatively: = ({0, 1} Prop Formula) Examples: (01, A B): the assignment α = {A 0, B 1} satisfies A B (11, A B)

92 Satisfaction Relation ( =): Formalities = is defined recursively: α = A if α(a) = true α = ϕ if α = ϕ α = ϕ 1 ϕ 2 if α = ϕ 1 and α = ϕ 2 α = ϕ 1 ϕ 2 if α = ϕ 1 or α = ϕ 2 α = ϕ 1 ϕ 2 if α = ϕ 1 implies α = ϕ 2 α = ϕ 1 ϕ 2 if α = ϕ 1 iff α = ϕ 2

93 From Definition to an Evaluation Algorithm Truth Evaluation Problem: Given ϕ Formula and α 2 AP (ϕ), does α = ϕ?

94 From Definition to an Evaluation Algorithm Truth Evaluation Problem: Given ϕ Formula and α 2 AP (ϕ), does α = ϕ? Eval(ϕ, α) if ϕ A then return α(a); if ϕ φ then return Eval (φ, α); if ϕ ψ φ then return Eval (ψ, α) Eval (φ, α);

95 From Definition to an Evaluation Algorithm Truth Evaluation Problem: Given ϕ Formula and α 2 AP (ϕ), does α = ϕ? Eval(ϕ, α) if ϕ A then return α(a); if ϕ φ then return Eval (φ, α); if ϕ ψ φ then return Eval (ψ, α) Eval (φ, α); Eval uses polynomial time and space.

96 Nothing More Than What We Already Know Recall the Example: Let φ = (A (B C)) Let α = {A 0, B 0, C 1}

97 Nothing More Than What We Already Know Recall the Example: Let φ = (A (B C)) Let α = {A 0, B 0, C 1} Eval(φ, α) = Eval(A, α) Eval(B C, α) = 0 Eval(B, α) Eval(C, α) = 0 (0 1) = 0 1 = 1

98 Nothing More Than What We Already Know Recall the Example: Let φ = (A (B C)) Let α = {A 0, B 0, C 1} Eval(φ, α) = Eval(A, α) Eval(B C, α) = 0 Eval(B, α) Eval(C, α) = 0 (0 1) = 0 1 = 1 Hence, α = φ.

99 Extending Truth Table p q (p (q p)) (p p) (p q)

100 Extending Truth Table p q r (p (q r)

101 Extending Truth Table p q r (p (q r)

102 Set of Assignment Intuition: a formula specifies a set of truth assignments. Function models: models : Formula 2 2Prop (a formula set of satisfying assignments) Recursive definition: models(a) = {α α(a) = 1}, A Prop models( ϕ) = 2 Prop models(ϕ) models(ϕ 1 ϕ 2 ) = models(ϕ 1 ) models(ϕ 2 ) models(ϕ 1 ϕ 2 ) = models(ϕ 1 ) models(ϕ 2 ) models(ϕ 1 ϕ 2 ) = (2 Prop models(ϕ 1 ) models(ϕ 2 )

103 Example models(a B) = {{10}, {01}, {11}} This is compatible with the recursive definition: models(a B) = models(a) models(b) = {{10}, {11}} {{01}, {11}} = {{10}, {01}, {11}}

104 Theorem Let ϕ Formula and α 2 Prop, then the following statements are equivalent: α = ϕ α models(ϕ)

105 Projected Assignment AP(ϕ): the Atomic Propositions in ϕ. Clearly AP(ϕ) Prop. Let α 1, α 2 2 Prop, Formula. Lemma: if α 1 AP(ϕ) = α 2 AP(ϕ), then α 1 = ϕ iff α 2 = ϕ Corollary: α = ϕ iff α AP(ϕ) = ϕ We will assume, for simplicity, that Prop = AP(ϕ).

106 Extension of = to Assignment Sets Let ϕ Formula Let T be a set of assignments, i.e., T 2 2Prop Definition. T = ϕ if T models(ϕ) i.e., = 2 2Prop Formula

107 Extension of = to Formulas = 2 Formula 2 Formula Definition. Let Γ 1, Γ 2 be propositional formulas. Γ 1 = Γ 2 iff models(γ 1 ) models(γ 2 ) iff for all α 2 Prop if α = Γ 1 then α = Γ 2 Examples: x 1 x 2 = x 1 x 2 x 1 x 2 = x 2 x 3

108 Classification of Formulas A formula ϕ is called valid if models(ϕ) = 2 Prop. (also called a tautology). A formula ϕ is called satisfiable if models(ϕ). A formula ϕ is called unsatisfiable if models(ϕ) = (also called a contradiction).

109 Characteristics of Formulas A formula ϕ is valid iff ϕ is unsatisfiable. ϕ is satisfiable iff ϕ is not valid.

110 Characteristics of Formulas We can write = ϕ when ϕ is valid. = ϕ when ϕ is not valid. = ϕ when ϕ is satisfiable. = ϕ when ϕ is unsatisfiable

111 Examples (p q) (p q) is valid (p q) p is satisfiable (p q) p is unsatisfiable

112 Equivalences = A 1 A = A 0 0 = A A = A (B C) (A B) (A C) = (A B) ( A B) = (A B) ( A B)

113 Minimal Set of Binary Operators Recall the question: what is the minimal set of operators necessary? A: Through such equivalences all Boolean operators can be written with a single operator ( ). Indeed, typically industrial circuits only use one type of logical gate. We will see how two are enough: and Or: = (A B) ( A B) Implies: = (A B) ( A B) Equivalence: = (A B) (A B) (B A)

114 Decision Problem The decision problem: Given a propositional formula φ, is φ satisfiable? An algorithm that always terminates with a correct answer to this problem is called a decision procedure for propositional logic.

115 Normal Forms

116 Definitions A literal is either an atom or a negation of an atom. Let φ = (A B). Then: Atoms: AP(φ) = {A, B} Literals: lit(φ) = {A, B} Equivalent formulas can have different literals φ = (A B) = A B Now lit(φ) = { A, B}

117 Definitions A term is a conjunction of literals Example: (A B C) A clause is a disjunction of literals Example: (A B C)

118 Negation Normal Form (NNF) A formula is said to be in Negation Normal Form (NNF) if it only contains,, connectives and only atoms can be negated. Examples: (A B) is not in NNF A B is in NNF

119 Coverting to NNF Every formula can be converted to NNF in linear time: Eliminate all connectives other than,, Use De Morgan and double-negation rules to push negations to the right Example: (A B) Eliminate : ( A B) Push negation using De Morgan: ( A B) Use Double negation rule: (A B)

120 Disjunctive Normal Form (DNF) A formula is said to be in Disjunctive Normal Form (DNF) if it is a disjunction of terms. In other words, it is a formula of the form ( l i,j ) i j where l i,j is the j-th literal in the i-th term. Examples (A B C) ( A D) (B) is in DNF.

121 Disjunctive Normal Form (DNF) A formula is said to be in Disjunctive Normal Form (DNF) if it is a disjunction of terms. In other words, it is a formula of the form ( l i,j ) i j where l i,j is the j-th literal in the i-th term. Examples (A B C) ( A D) (B) is in DNF. DNF is a special case of NNF.

122 Coverting to DNF Every formula can be converted to DNF in exponential time and space: Convert to NNF Distribute disjunctions following the rule: = A (B C) ((A B) (A C)) Example: (A B) ( C D) ((A B) ( C)) ((A B) D) (A C) (B C) (A D) (B D)

123 Coverting to DNF Every formula can be converted to DNF in exponential time and space: Convert to NNF Distribute disjunctions following the rule: = A (B C) ((A B) (A C)) Example: (A B) ( C D) ((A B) ( C)) ((A B) D) (A C) (B C) (A D) (B D) Q:How many clauses would the DNF have had we started from a conjunction of n clauses?

124 Satisfiability of DNF Is the following DNF formula satisfiable? (x 1 x 2 x 1 ) (x 2 x 1 ) (x 2 x 3 x 3 )

125 Satisfiability of DNF Is the following DNF formula satisfiable? (x 1 x 2 x 1 ) (x 2 x 1 ) (x 2 x 3 x 3 ) What is the complexity of satisfiability of DNF formulas?

126 Conjunctive Normal Form (CNF) A formula is said to be in Conjunctive Normal Form (CNF) if it is a conjunction of clauses. In other words, it is a formula of the form ( l i,j ) i j where l i,j is the j-th literal in the i-th term. Examples (A B C) ( A D) (B) is in CNF

127 Conjunctive Normal Form (CNF) A formula is said to be in Conjunctive Normal Form (CNF) if it is a conjunction of clauses. In other words, it is a formula of the form ( l i,j ) i j where l i,j is the j-th literal in the i-th term. Examples (A B C) ( A D) (B) is in CNF CNF is a special case of NNF.

128 Coverting to CNF Every formula can be converted to CNF:

129 Coverting to CNF Every formula can be converted to CNF: in exponential time and space with the same set of atoms

130 Coverting to CNF Every formula can be converted to CNF: in exponential time and space with the same set of atoms in linear time and space if new variables are added.

131 Coverting to CNF Every formula can be converted to CNF: in exponential time and space with the same set of atoms in linear time and space if new variables are added. In this case the original and converted formulas are equi-satisfiable. This technique is called Tseitin s encoding.

132 Converting to CNF: the Exponential Way CNF(φ){ case } φ is a literal: return φ φ is ϕ 1 ϕ 2 : return CNF(ϕ 1 ) CNF(ϕ 2 ) φ is ϕ 1 ϕ 2 : return Dist(CNF(ϕ 1 ), CNF(ϕ 2 )) Dist(ϕ 1, ϕ 2 ){ case } ϕ 1 is ψ 11 ψ 12 : return Dist(ψ 11, ϕ 2 ) Dist(ψ 12, ϕ 2 ) ϕ 2 is ψ 21 ψ 22 : return Dist(ϕ 1, ψ 21 ) Dist(ϕ 1, ψ 22 )

133 Converting to CNF: the Exponential Way Consider the formula φ = (x 1 y 1 ) (x 2 y 2 )

134 Converting to CNF: the Exponential Way Consider the formula φ = (x 1 y 1 ) (x 2 y 2 ) CNF(φ) = (x 1 x 2 ) (x 1 y 2 ) (y 1 x 2 ) (y 1 y 2 )

135 Converting to CNF: the Exponential Way Consider the formula φ = (x 1 y 1 ) (x 2 y 2 ) CNF(φ) = (x 1 x 2 ) (x 1 y 2 ) (y 1 x 2 ) (y 1 y 2 ) Now consider: φ n = (x 1 y 1 ) (x 2 y 2 )... (x n y n )

136 Converting to CNF: the Exponential Way Consider the formula φ = (x 1 y 1 ) (x 2 y 2 ) CNF(φ) = (x 1 x 2 ) (x 1 y 2 ) (y 1 x 2 ) (y 1 y 2 ) Now consider: φ n = (x 1 y 1 ) (x 2 y 2 )... (x n y n ) Q: How many clauses CNF(φ n ) returns?

137 Converting to CNF: the Exponential Way Consider the formula φ = (x 1 y 1 ) (x 2 y 2 ) CNF(φ) = (x 1 x 2 ) (x 1 y 2 ) (y 1 x 2 ) (y 1 y 2 ) Now consider: φ n = (x 1 y 1 ) (x 2 y 2 )... (x n y n ) Q: How many clauses CNF(φ n ) returns? A: 2 n

138 Tseitin s Encoding Consider the formula (A (B C))

139 Tseitin s Encoding Consider the formula (A (B C)) The parse tree:

140 Tseitin s Encoding Consider the formula (A (B C)) The parse tree: Associate a new auxiliary variable with each gate. Add constraints that define these new variables. Finally, enforce the root node.

141 (a 1 (A a 2 )) (a 2 (B C)) (a 1 ) Tseitin s Encoding

142 Tseitin s Encoding (a 1 (A a 2 )) (a 2 (B C)) (a 1 ) Each such constraint has a CNF representation with 3 or 4 clauses.

143 Tseitin s Encoding (a 1 (A a 2 )) (a 2 (B C)) (a 1 ) Each such constraint has a CNF representation with 3 or 4 clauses. First: (a 1 A) (a 1 a 2 ) ( a 1 A a 2 ) Second: ( a 2 B) ( a 2 C) (a 2 B C)

144 Tseitin s Encoding φ n = (x 1 y 1 ) (x 2 y 2 )... (x n y n )

145 Tseitin s Encoding φ n = (x 1 y 1 ) (x 2 y 2 )... (x n y n ) With Tseitin s encoding we need: n auxiliary variables a 1,..., a n. Each adds 3 constraints. Top clause: (a 1... a n )

146 Tseitin s Encoding φ n = (x 1 y 1 ) (x 2 y 2 )... (x n y n ) With Tseitin s encoding we need: n auxiliary variables a 1,..., a n. Each adds 3 constraints. Top clause: (a 1... a n ) Hence, we have 3n + 1 clauses, instead of 2 n. 3n variables rather than 2n.

147 SAT Problem and SAT Solver SAT problem is: Given a Boolean formula in CNF, asking whether there exists an assignment to each variable so that the value of the formula is true.

148 SAT Problem and SAT Solver SAT problem is: Given a Boolean formula in CNF, asking whether there exists an assignment to each variable so that the value of the formula is true. It is a NPC problem, which means that there is only exponential algorithm so far. A SAT solver is a tool that solves the SAT problem.

149 SAT Problem and SAT Solver SAT problem is: Given a Boolean formula in CNF, asking whether there exists an assignment to each variable so that the value of the formula is true. It is a NPC problem, which means that there is only exponential algorithm so far. A SAT solver is a tool that solves the SAT problem. However, SAT solver is to be said as the most successful formal tools, which can handle 100,000 variables with millions of clauses in less than one sec.

A brief introduction to Logic. (slides from

A brief introduction to Logic. (slides from A brief introduction to Logic (slides from http://www.decision-procedures.org/) 1 A Brief Introduction to Logic - Outline Propositional Logic :Syntax Propositional Logic :Semantics Satisfiability and validity

More information

Comp487/587 - Boolean Formulas

Comp487/587 - Boolean Formulas Comp487/587 - Boolean Formulas 1 Logic and SAT 1.1 What is a Boolean Formula Logic is a way through which we can analyze and reason about simple or complicated events. In particular, we are interested

More information

Tecniche di Verifica. Introduction to Propositional Logic

Tecniche di Verifica. Introduction to Propositional Logic Tecniche di Verifica Introduction to Propositional Logic 1 Logic A formal logic is defined by its syntax and semantics. Syntax An alphabet is a set of symbols. A finite sequence of these symbols is called

More information

CS156: The Calculus of Computation Zohar Manna Autumn 2008

CS156: The Calculus of Computation Zohar Manna Autumn 2008 Page 3 of 52 Page 4 of 52 CS156: The Calculus of Computation Zohar Manna Autumn 2008 Lecturer: Zohar Manna (manna@cs.stanford.edu) Office Hours: MW 12:30-1:00 at Gates 481 TAs: Boyu Wang (wangboyu@stanford.edu)

More information

CS156: The Calculus of Computation

CS156: The Calculus of Computation CS156: The Calculus of Computation Zohar Manna Winter 2010 It is reasonable to hope that the relationship between computation and mathematical logic will be as fruitful in the next century as that between

More information

02 Propositional Logic

02 Propositional Logic SE 2F03 Fall 2005 02 Propositional Logic Instructor: W. M. Farmer Revised: 25 September 2005 1 What is Propositional Logic? Propositional logic is the study of the truth or falsehood of propositions or

More information

Logic: Propositional Logic (Part I)

Logic: Propositional Logic (Part I) Logic: Propositional Logic (Part I) Alessandro Artale Free University of Bozen-Bolzano Faculty of Computer Science http://www.inf.unibz.it/ artale Descrete Mathematics and Logic BSc course Thanks to Prof.

More information

The Calculus of Computation: Decision Procedures with Applications to Verification. Part I: FOUNDATIONS. by Aaron Bradley Zohar Manna

The Calculus of Computation: Decision Procedures with Applications to Verification. Part I: FOUNDATIONS. by Aaron Bradley Zohar Manna The Calculus of Computation: Decision Procedures with Applications to Verification Part I: FOUNDATIONS by Aaron Bradley Zohar Manna 1. Propositional Logic(PL) Springer 2007 1-1 1-2 Propositional Logic(PL)

More information

CS1021. Why logic? Logic about inference or argument. Start from assumptions or axioms. Make deductions according to rules of reasoning.

CS1021. Why logic? Logic about inference or argument. Start from assumptions or axioms. Make deductions according to rules of reasoning. 3: Logic Why logic? Logic about inference or argument Start from assumptions or axioms Make deductions according to rules of reasoning Logic 3-1 Why logic? (continued) If I don t buy a lottery ticket on

More information

Automated Program Verification and Testing 15414/15614 Fall 2016 Lecture 2: Propositional Logic

Automated Program Verification and Testing 15414/15614 Fall 2016 Lecture 2: Propositional Logic Automated Program Verification and Testing 15414/15614 Fall 2016 Lecture 2: Propositional Logic Matt Fredrikson mfredrik@cs.cmu.edu October 17, 2016 Matt Fredrikson Propositional Logic 1 / 33 Propositional

More information

Deductive Systems. Lecture - 3

Deductive Systems. Lecture - 3 Deductive Systems Lecture - 3 Axiomatic System Axiomatic System (AS) for PL AS is based on the set of only three axioms and one rule of deduction. It is minimal in structure but as powerful as the truth

More information

Knowledge base (KB) = set of sentences in a formal language Declarative approach to building an agent (or other system):

Knowledge base (KB) = set of sentences in a formal language Declarative approach to building an agent (or other system): Logic Knowledge-based agents Inference engine Knowledge base Domain-independent algorithms Domain-specific content Knowledge base (KB) = set of sentences in a formal language Declarative approach to building

More information

Advanced Topics in LP and FP

Advanced Topics in LP and FP Lecture 1: Prolog and Summary of this lecture 1 Introduction to Prolog 2 3 Truth value evaluation 4 Prolog Logic programming language Introduction to Prolog Introduced in the 1970s Program = collection

More information

Description Logics. Foundations of Propositional Logic. franconi. Enrico Franconi

Description Logics. Foundations of Propositional Logic.   franconi. Enrico Franconi (1/27) Description Logics Foundations of Propositional Logic Enrico Franconi franconi@cs.man.ac.uk http://www.cs.man.ac.uk/ franconi Department of Computer Science, University of Manchester (2/27) Knowledge

More information

CSE507. Introduction. Computer-Aided Reasoning for Software. Emina Torlak courses.cs.washington.edu/courses/cse507/17wi/

CSE507. Introduction. Computer-Aided Reasoning for Software. Emina Torlak courses.cs.washington.edu/courses/cse507/17wi/ Computer-Aided Reasoning for Software CSE507 courses.cs.washington.edu/courses/cse507/17wi/ Introduction Emina Torlak emina@cs.washington.edu Today What is this course about? Course logistics Review of

More information

Part 1: Propositional Logic

Part 1: Propositional Logic Part 1: Propositional Logic Literature (also for first-order logic) Schöning: Logik für Informatiker, Spektrum Fitting: First-Order Logic and Automated Theorem Proving, Springer 1 Last time 1.1 Syntax

More information

PROPOSITIONAL LOGIC. VL Logik: WS 2018/19

PROPOSITIONAL LOGIC. VL Logik: WS 2018/19 PROPOSITIONAL LOGIC VL Logik: WS 2018/19 (Version 2018.2) Martina Seidl (martina.seidl@jku.at), Armin Biere (biere@jku.at) Institut für Formale Modelle und Verifikation BOX Game: Rules 1. The game board

More information

Propositional Logic: Models and Proofs

Propositional Logic: Models and Proofs Propositional Logic: Models and Proofs C. R. Ramakrishnan CSE 505 1 Syntax 2 Model Theory 3 Proof Theory and Resolution Compiled at 11:51 on 2016/11/02 Computing with Logic Propositional Logic CSE 505

More information

Lecture 2. Logic Compound Statements Conditional Statements Valid & Invalid Arguments Digital Logic Circuits. Reading (Epp s textbook)

Lecture 2. Logic Compound Statements Conditional Statements Valid & Invalid Arguments Digital Logic Circuits. Reading (Epp s textbook) Lecture 2 Logic Compound Statements Conditional Statements Valid & Invalid Arguments Digital Logic Circuits Reading (Epp s textbook) 2.1-2.4 1 Logic Logic is a system based on statements. A statement (or

More information

Propositional Logic Basics Propositional Equivalences Normal forms Boolean functions and digital circuits. Propositional Logic.

Propositional Logic Basics Propositional Equivalences Normal forms Boolean functions and digital circuits. Propositional Logic. Propositional Logic Winter 2012 Propositional Logic: Section 1.1 Proposition A proposition is a declarative sentence that is either true or false. Which ones of the following sentences are propositions?

More information

Propositional Logic. Methods & Tools for Software Engineering (MTSE) Fall Prof. Arie Gurfinkel

Propositional Logic. Methods & Tools for Software Engineering (MTSE) Fall Prof. Arie Gurfinkel Propositional Logic Methods & Tools for Software Engineering (MTSE) Fall 2017 Prof. Arie Gurfinkel References Chpater 1 of Logic for Computer Scientists http://www.springerlink.com/content/978-0-8176-4762-9/

More information

Propositional logic (revision) & semantic entailment. p. 1/34

Propositional logic (revision) & semantic entailment. p. 1/34 Propositional logic (revision) & semantic entailment p. 1/34 Reading The background reading for propositional logic is Chapter 1 of Huth/Ryan. (This will cover approximately the first three lectures.)

More information

COMP9414: Artificial Intelligence Propositional Logic: Automated Reasoning

COMP9414: Artificial Intelligence Propositional Logic: Automated Reasoning COMP9414, Monday 26 March, 2012 Propositional Logic 2 COMP9414: Artificial Intelligence Propositional Logic: Automated Reasoning Overview Proof systems (including soundness and completeness) Normal Forms

More information

LOGIC PROPOSITIONAL REASONING

LOGIC PROPOSITIONAL REASONING LOGIC PROPOSITIONAL REASONING WS 2017/2018 (342.208) Armin Biere Martina Seidl biere@jku.at martina.seidl@jku.at Institute for Formal Models and Verification Johannes Kepler Universität Linz Version 2018.1

More information

Propositional Logic: Methods of Proof (Part II)

Propositional Logic: Methods of Proof (Part II) Propositional Logic: Methods of Proof (Part II) You will be expected to know Basic definitions Inference, derive, sound, complete Conjunctive Normal Form (CNF) Convert a Boolean formula to CNF Do a short

More information

Part I: Propositional Calculus

Part I: Propositional Calculus Logic Part I: Propositional Calculus Statements Undefined Terms True, T, #t, 1 False, F, #f, 0 Statement, Proposition Statement/Proposition -- Informal Definition Statement = anything that can meaningfully

More information

Propositional Calculus: Formula Simplification, Essential Laws, Normal Forms

Propositional Calculus: Formula Simplification, Essential Laws, Normal Forms P Formula Simplification, Essential Laws, Normal Forms Lila Kari University of Waterloo P Formula Simplification, Essential Laws, Normal CS245, Forms Logic and Computation 1 / 26 Propositional calculus

More information

Propositional Logic: Methods of Proof (Part II)

Propositional Logic: Methods of Proof (Part II) Propositional Logic: Methods of Proof (Part II) This lecture topic: Propositional Logic (two lectures) Chapter 7.1-7.4 (previous lecture, Part I) Chapter 7.5 (this lecture, Part II) (optional: 7.6-7.8)

More information

Introduction to Artificial Intelligence Propositional Logic & SAT Solving. UIUC CS 440 / ECE 448 Professor: Eyal Amir Spring Semester 2010

Introduction to Artificial Intelligence Propositional Logic & SAT Solving. UIUC CS 440 / ECE 448 Professor: Eyal Amir Spring Semester 2010 Introduction to Artificial Intelligence Propositional Logic & SAT Solving UIUC CS 440 / ECE 448 Professor: Eyal Amir Spring Semester 2010 Today Representation in Propositional Logic Semantics & Deduction

More information

Propositional Reasoning

Propositional Reasoning Propositional Reasoning CS 440 / ECE 448 Introduction to Artificial Intelligence Instructor: Eyal Amir Grad TAs: Wen Pu, Yonatan Bisk Undergrad TAs: Sam Johnson, Nikhil Johri Spring 2010 Intro to AI (CS

More information

cis32-ai lecture # 18 mon-3-apr-2006

cis32-ai lecture # 18 mon-3-apr-2006 cis32-ai lecture # 18 mon-3-apr-2006 today s topics: propositional logic cis32-spring2006-sklar-lec18 1 Introduction Weak (search-based) problem-solving does not scale to real problems. To succeed, problem

More information

Propositional and Predicate Logic - V

Propositional and Predicate Logic - V Propositional and Predicate Logic - V Petr Gregor KTIML MFF UK WS 2016/2017 Petr Gregor (KTIML MFF UK) Propositional and Predicate Logic - V WS 2016/2017 1 / 21 Formal proof systems Hilbert s calculus

More information

Lecture 3: Semantics of Propositional Logic

Lecture 3: Semantics of Propositional Logic Lecture 3: Semantics of Propositional Logic 1 Semantics of Propositional Logic Every language has two aspects: syntax and semantics. While syntax deals with the form or structure of the language, it is

More information

Normal Forms of Propositional Logic

Normal Forms of Propositional Logic Normal Forms of Propositional Logic Bow-Yaw Wang Institute of Information Science Academia Sinica, Taiwan September 12, 2017 Bow-Yaw Wang (Academia Sinica) Normal Forms of Propositional Logic September

More information

Announcements. CS243: Discrete Structures. Propositional Logic II. Review. Operator Precedence. Operator Precedence, cont. Operator Precedence Example

Announcements. CS243: Discrete Structures. Propositional Logic II. Review. Operator Precedence. Operator Precedence, cont. Operator Precedence Example Announcements CS243: Discrete Structures Propositional Logic II Işıl Dillig First homework assignment out today! Due in one week, i.e., before lecture next Tuesday 09/11 Weilin s Tuesday office hours are

More information

CS 375/CS M75 Logic for Computer Science

CS 375/CS M75 Logic for Computer Science CS 375/CS M75 Logic for Computer Science Ulrich Berger Department of Computer Science Swansea University Fall 2013 u.berger@swan.ac.uk http://www.cs.swan.ac.uk/ csulrich/ tel 513380, fax 295708, room 306,

More information

Lecture #14: NP-Completeness (Chapter 34 Old Edition Chapter 36) Discussion here is from the old edition.

Lecture #14: NP-Completeness (Chapter 34 Old Edition Chapter 36) Discussion here is from the old edition. Lecture #14: 0.0.1 NP-Completeness (Chapter 34 Old Edition Chapter 36) Discussion here is from the old edition. 0.0.2 Preliminaries: Definition 1 n abstract problem Q is a binary relations on a set I of

More information

ECE473 Lecture 15: Propositional Logic

ECE473 Lecture 15: Propositional Logic ECE473 Lecture 15: Propositional Logic Jeffrey Mark Siskind School of Electrical and Computer Engineering Spring 2018 Siskind (Purdue ECE) ECE473 Lecture 15: Propositional Logic Spring 2018 1 / 23 What

More information

Language of Propositional Logic

Language of Propositional Logic Logic A logic has: 1. An alphabet that contains all the symbols of the language of the logic. 2. A syntax giving the rules that define the well formed expressions of the language of the logic (often called

More information

Knowledge representation DATA INFORMATION KNOWLEDGE WISDOM. Figure Relation ship between data, information knowledge and wisdom.

Knowledge representation DATA INFORMATION KNOWLEDGE WISDOM. Figure Relation ship between data, information knowledge and wisdom. Knowledge representation Introduction Knowledge is the progression that starts with data which s limited utility. Data when processed become information, information when interpreted or evaluated becomes

More information

Decision Procedures for Satisfiability and Validity in Propositional Logic

Decision Procedures for Satisfiability and Validity in Propositional Logic Decision Procedures for Satisfiability and Validity in Propositional Logic Meghdad Ghari Institute for Research in Fundamental Sciences (IPM) School of Mathematics-Isfahan Branch Logic Group http://math.ipm.ac.ir/isfahan/logic-group.htm

More information

Agenda. Artificial Intelligence. Reasoning in the Wumpus World. The Wumpus World

Agenda. Artificial Intelligence. Reasoning in the Wumpus World. The Wumpus World Agenda Artificial Intelligence 10. Propositional Reasoning, Part I: Principles How to Think About What is True or False 1 Introduction Álvaro Torralba Wolfgang Wahlster 2 Propositional Logic 3 Resolution

More information

Truth-Functional Logic

Truth-Functional Logic Truth-Functional Logic Syntax Every atomic sentence (A, B, C, ) is a sentence and are sentences With ϕ a sentence, the negation ϕ is a sentence With ϕ and ψ sentences, the conjunction ϕ ψ is a sentence

More information

Lecture 4: Proposition, Connectives and Truth Tables

Lecture 4: Proposition, Connectives and Truth Tables Discrete Mathematics (II) Spring 2017 Lecture 4: Proposition, Connectives and Truth Tables Lecturer: Yi Li 1 Overview In last lecture, we give a brief introduction to mathematical logic and then redefine

More information

Propositional logic. Programming and Modal Logic

Propositional logic. Programming and Modal Logic Propositional logic Programming and Modal Logic 2006-2007 4 Contents Syntax of propositional logic Semantics of propositional logic Semantic entailment Natural deduction proof system Soundness and completeness

More information

Announcements. CS311H: Discrete Mathematics. Propositional Logic II. Inverse of an Implication. Converse of a Implication

Announcements. CS311H: Discrete Mathematics. Propositional Logic II. Inverse of an Implication. Converse of a Implication Announcements CS311H: Discrete Mathematics Propositional Logic II Instructor: Işıl Dillig First homework assignment out today! Due in one week, i.e., before lecture next Wed 09/13 Remember: Due before

More information

Lecture 2 Propositional Logic & SAT

Lecture 2 Propositional Logic & SAT CS 5110/6110 Rigorous System Design Spring 2017 Jan-17 Lecture 2 Propositional Logic & SAT Zvonimir Rakamarić University of Utah Announcements Homework 1 will be posted soon Propositional logic: Chapter

More information

COMP219: Artificial Intelligence. Lecture 20: Propositional Reasoning

COMP219: Artificial Intelligence. Lecture 20: Propositional Reasoning COMP219: Artificial Intelligence Lecture 20: Propositional Reasoning 1 Overview Last time Logic for KR in general; Propositional Logic; Natural Deduction Today Entailment, satisfiability and validity Normal

More information

Propositional Logic. Testing, Quality Assurance, and Maintenance Winter Prof. Arie Gurfinkel

Propositional Logic. Testing, Quality Assurance, and Maintenance Winter Prof. Arie Gurfinkel Propositional Logic Testing, Quality Assurance, and Maintenance Winter 2018 Prof. Arie Gurfinkel References Chpater 1 of Logic for Computer Scientists http://www.springerlink.com/content/978-0-8176-4762-9/

More information

Solvers for the Problem of Boolean Satisfiability (SAT) Will Klieber Aug 31, 2011

Solvers for the Problem of Boolean Satisfiability (SAT) Will Klieber Aug 31, 2011 Solvers for the Problem of Boolean Satisfiability (SAT) Will Klieber 15-414 Aug 31, 2011 Why study SAT solvers? Many problems reduce to SAT. Formal verification CAD, VLSI Optimization AI, planning, automated

More information

Propositional and Predicate Logic - II

Propositional and Predicate Logic - II Propositional and Predicate Logic - II Petr Gregor KTIML MFF UK WS 2016/2017 Petr Gregor (KTIML MFF UK) Propositional and Predicate Logic - II WS 2016/2017 1 / 16 Basic syntax Language Propositional logic

More information

Propositional Logic: Methods of Proof. Chapter 7, Part II

Propositional Logic: Methods of Proof. Chapter 7, Part II Propositional Logic: Methods of Proof Chapter 7, Part II Inference in Formal Symbol Systems: Ontology, Representation, ti Inference Formal Symbol Systems Symbols correspond to things/ideas in the world

More information

Chapter 4: Computation tree logic

Chapter 4: Computation tree logic INFOF412 Formal verification of computer systems Chapter 4: Computation tree logic Mickael Randour Formal Methods and Verification group Computer Science Department, ULB March 2017 1 CTL: a specification

More information

Propositional Logic: Evaluating the Formulas

Propositional Logic: Evaluating the Formulas Institute for Formal Models and Verification Johannes Kepler University Linz VL Logik (LVA-Nr. 342208) Winter Semester 2015/2016 Propositional Logic: Evaluating the Formulas Version 2015.2 Armin Biere

More information

Propositional Logic Language

Propositional Logic Language Propositional Logic Language A logic consists of: an alphabet A, a language L, i.e., a set of formulas, and a binary relation = between a set of formulas and a formula. An alphabet A consists of a finite

More information

1 Propositional Logic

1 Propositional Logic CS 2800, Logic and Computation Propositional Logic Lectures Pete Manolios Version: 384 Spring 2011 1 Propositional Logic The study of logic was initiated by the ancient Greeks, who were concerned with

More information

Propositional Logic. Yimei Xiang 11 February format strictly follow the laws and never skip any step.

Propositional Logic. Yimei Xiang 11 February format strictly follow the laws and never skip any step. Propositional Logic Yimei Xiang yxiang@fas.harvard.edu 11 February 2014 1 Review Recursive definition Set up the basis Generate new members with rules Exclude the rest Subsets vs. proper subsets Sets of

More information

CS 512, Spring 2017, Handout 10 Propositional Logic: Conjunctive Normal Forms, Disjunctive Normal Forms, Horn Formulas, and other special forms

CS 512, Spring 2017, Handout 10 Propositional Logic: Conjunctive Normal Forms, Disjunctive Normal Forms, Horn Formulas, and other special forms CS 512, Spring 2017, Handout 10 Propositional Logic: Conjunctive Normal Forms, Disjunctive Normal Forms, Horn Formulas, and other special forms Assaf Kfoury 5 February 2017 Assaf Kfoury, CS 512, Spring

More information

Notes. Corneliu Popeea. May 3, 2013

Notes. Corneliu Popeea. May 3, 2013 Notes Corneliu Popeea May 3, 2013 1 Propositional logic Syntax We rely on a set of atomic propositions, AP, containing atoms like p, q. A propositional logic formula φ Formula is then defined by the following

More information

Course Staff. Textbook

Course Staff. Textbook Course Staff CS311H: Discrete Mathematics Intro and Propositional Logic Instructor: Işıl Dillig Instructor: Prof. Işıl Dillig TAs: Jacob Van Geffen, Varun Adiga, Akshay Gupta Class meets every Monday,

More information

CHAPTER 2 INTRODUCTION TO CLASSICAL PROPOSITIONAL LOGIC

CHAPTER 2 INTRODUCTION TO CLASSICAL PROPOSITIONAL LOGIC CHAPTER 2 INTRODUCTION TO CLASSICAL PROPOSITIONAL LOGIC 1 Motivation and History The origins of the classical propositional logic, classical propositional calculus, as it was, and still often is called,

More information

Propositional Logic and Semantics

Propositional Logic and Semantics Propositional Logic and Semantics English is naturally ambiguous. For example, consider the following employee (non)recommendations and their ambiguity in the English language: I can assure you that no

More information

Propositional Logic: Methods of Proof (Part II)

Propositional Logic: Methods of Proof (Part II) Propositional Logic: Methods of Proof (Part II) You will be expected to know Basic definitions Inference, derive, sound, complete Conjunctive Normal Form (CNF) Convert a Boolean formula to CNF Do a short

More information

Introduction to Solving Combinatorial Problems with SAT

Introduction to Solving Combinatorial Problems with SAT Introduction to Solving Combinatorial Problems with SAT Javier Larrosa December 19, 2014 Overview of the session Review of Propositional Logic The Conjunctive Normal Form (CNF) Modeling and solving combinatorial

More information

COMP 2600: Formal Methods for Software Engineeing

COMP 2600: Formal Methods for Software Engineeing COMP 2600: Formal Methods for Software Engineeing Dirk Pattinson Semester 2, 2013 What do we mean by FORMAL? Oxford Dictionary in accordance with convention or etiquette or denoting a style of writing

More information

EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS Lecture 10, 5/9/2005 University of Washington, Department of Electrical Engineering Spring 2005 Instructor: Professor Jeff A. Bilmes Logical Agents Chapter 7

More information

Artificial Intelligence Chapter 7: Logical Agents

Artificial Intelligence Chapter 7: Logical Agents Artificial Intelligence Chapter 7: Logical Agents Michael Scherger Department of Computer Science Kent State University February 20, 2006 AI: Chapter 7: Logical Agents 1 Contents Knowledge Based Agents

More information

cse541 LOGIC FOR COMPUTER SCIENCE

cse541 LOGIC FOR COMPUTER SCIENCE cse541 LOGIC FOR COMPUTER SCIENCE Professor Anita Wasilewska Spring 2015 LECTURE 2 Chapter 2 Introduction to Classical Propositional Logic PART 1: Classical Propositional Model Assumptions PART 2: Syntax

More information

A New 3-CNF Transformation by Parallel-Serial Graphs 1

A New 3-CNF Transformation by Parallel-Serial Graphs 1 A New 3-CNF Transformation by Parallel-Serial Graphs 1 Uwe Bubeck, Hans Kleine Büning University of Paderborn, Computer Science Institute, 33098 Paderborn, Germany Abstract For propositional formulas we

More information

Introduction to Metalogic

Introduction to Metalogic Introduction to Metalogic Hans Halvorson September 21, 2016 Logical grammar Definition. A propositional signature Σ is a collection of items, which we call propositional constants. Sometimes these propositional

More information

Chapter 4: Classical Propositional Semantics

Chapter 4: Classical Propositional Semantics Chapter 4: Classical Propositional Semantics Language : L {,,, }. Classical Semantics assumptions: TWO VALUES: there are only two logical values: truth (T) and false (F), and EXTENSIONALITY: the logical

More information

Outline. Logical Agents. Logical Reasoning. Knowledge Representation. Logical reasoning Propositional Logic Wumpus World Inference

Outline. Logical Agents. Logical Reasoning. Knowledge Representation. Logical reasoning Propositional Logic Wumpus World Inference Outline Logical Agents ECE57 Applied Artificial Intelligence Spring 007 Lecture #6 Logical reasoning Propositional Logic Wumpus World Inference Russell & Norvig, chapter 7 ECE57 Applied Artificial Intelligence

More information

Introduction to Sets and Logic (MATH 1190)

Introduction to Sets and Logic (MATH 1190) Introduction to Sets Logic () Instructor: Email: shenlili@yorku.ca Department of Mathematics Statistics York University Sept 18, 2014 Outline 1 2 Tautologies Definition A tautology is a compound proposition

More information

SAT Solvers: Theory and Practice

SAT Solvers: Theory and Practice Summer School on Verification Technology, Systems & Applications, September 17, 2008 p. 1/98 SAT Solvers: Theory and Practice Clark Barrett barrett@cs.nyu.edu New York University Summer School on Verification

More information

First-order resolution for CTL

First-order resolution for CTL First-order resolution for Lan Zhang, Ullrich Hustadt and Clare Dixon Department of Computer Science, University of Liverpool Liverpool, L69 3BX, UK {Lan.Zhang, U.Hustadt, CLDixon}@liverpool.ac.uk Abstract

More information

What is logic, the topic of this course? There are at least two answers to that question.

What is logic, the topic of this course? There are at least two answers to that question. Applied Logic Lecture 1 CS 486 Spring 2005 Tuesday, January 25, 2005 What is Logic? What is logic, the topic of this course? There are at least two answers to that question. General logic: critical examination

More information

Logical Inference. Artificial Intelligence. Topic 12. Reading: Russell and Norvig, Chapter 7, Section 5

Logical Inference. Artificial Intelligence. Topic 12. Reading: Russell and Norvig, Chapter 7, Section 5 rtificial Intelligence Topic 12 Logical Inference Reading: Russell and Norvig, Chapter 7, Section 5 c Cara MacNish. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Logical

More information

1 Classical Propositional Logic [20 points]

1 Classical Propositional Logic [20 points] Homework 1 Solutions 15-414/614 : Bug Catching, Spring 2014 1 Classical Propositional Logic [20 points] Let x, y and z be three propositions. (a) (8 points) Show that the two propositional formulas, (x

More information

Quantified Boolean Formulas: Complexity and Expressiveness

Quantified Boolean Formulas: Complexity and Expressiveness Dagstuhl SAT Interactions 2012 Quantified Boolean Formulas: Complexity and Expressiveness Uwe Bubeck University of Paderborn 20.11.2012 Outline Introduction Free Variables and Equivalence Complexity Expressiveness

More information

Classes of Boolean Functions

Classes of Boolean Functions Classes of Boolean Functions Nader H. Bshouty Eyal Kushilevitz Abstract Here we give classes of Boolean functions that considered in COLT. Classes of Functions Here we introduce the basic classes of functions

More information

Conjunctive Normal Form and SAT

Conjunctive Normal Form and SAT Notes on Satisfiability-Based Problem Solving Conjunctive Normal Form and SAT David Mitchell mitchell@cs.sfu.ca October 4, 2015 These notes are a preliminary draft. Please use freely, but do not re-distribute

More information

Model Checking: An Introduction

Model Checking: An Introduction Model Checking: An Introduction Meeting 3, CSCI 5535, Spring 2013 Announcements Homework 0 ( Preliminaries ) out, due Friday Saturday This Week Dive into research motivating CSCI 5535 Next Week Begin foundations

More information

Logic and Inferences

Logic and Inferences Artificial Intelligence Logic and Inferences Readings: Chapter 7 of Russell & Norvig. Artificial Intelligence p.1/34 Components of Propositional Logic Logic constants: True (1), and False (0) Propositional

More information

Propositional and Predicate Logic. jean/gbooks/logic.html

Propositional and Predicate Logic.   jean/gbooks/logic.html CMSC 630 February 10, 2009 1 Propositional and Predicate Logic Sources J. Gallier. Logic for Computer Science, John Wiley and Sons, Hoboken NJ, 1986. 2003 revised edition available on line at http://www.cis.upenn.edu/

More information

Outline. Logical Agents. Logical Reasoning. Knowledge Representation. Logical reasoning Propositional Logic Wumpus World Inference

Outline. Logical Agents. Logical Reasoning. Knowledge Representation. Logical reasoning Propositional Logic Wumpus World Inference Outline Logical Agents ECE57 Applied Artificial Intelligence Spring 008 Lecture #6 Logical reasoning Propositional Logic Wumpus World Inference Russell & Norvig, chapter 7 ECE57 Applied Artificial Intelligence

More information

Propositional Logic: Part II - Syntax & Proofs 0-0

Propositional Logic: Part II - Syntax & Proofs 0-0 Propositional Logic: Part II - Syntax & Proofs 0-0 Outline Syntax of Propositional Formulas Motivating Proofs Syntactic Entailment and Proofs Proof Rules for Natural Deduction Axioms, theories and theorems

More information

SAT, NP, NP-Completeness

SAT, NP, NP-Completeness CS 473: Algorithms, Spring 2018 SAT, NP, NP-Completeness Lecture 22 April 13, 2018 Most slides are courtesy Prof. Chekuri Ruta (UIUC) CS473 1 Spring 2018 1 / 57 Part I Reductions Continued Ruta (UIUC)

More information

Propositional logic. First order logic. Alexander Clark. Autumn 2014

Propositional logic. First order logic. Alexander Clark. Autumn 2014 Propositional logic First order logic Alexander Clark Autumn 2014 Formal Logic Logical arguments are valid because of their form. Formal languages are devised to express exactly that relevant form and

More information

Inference Methods In Propositional Logic

Inference Methods In Propositional Logic Lecture Notes, Artificial Intelligence ((ENCS434)) University of Birzeit 1 st Semester, 2011 Artificial Intelligence (ENCS434) Inference Methods In Propositional Logic Dr. Mustafa Jarrar University of

More information

EECS 1028 M: Discrete Mathematics for Engineers

EECS 1028 M: Discrete Mathematics for Engineers EECS 1028 M: Discrete Mathematics for Engineers Suprakash Datta Office: LAS 3043 Course page: http://www.eecs.yorku.ca/course/1028 Also on Moodle S. Datta (York Univ.) EECS 1028 W 18 1 / 12 Using the laws

More information

CSE507. Course Introduction. Computer-Aided Reasoning for Software. Emina Torlak

CSE507. Course Introduction. Computer-Aided Reasoning for Software. Emina Torlak Computer-Aided Reasoning for Software CSE507 courses.cs.washington.edu/courses/cse507/14au/ Course Introduction Emina Torlak emina@cs.washington.edu Today What is this course about? Course logistics Review

More information

CSE 555 HW 5 SAMPLE SOLUTION. Question 1.

CSE 555 HW 5 SAMPLE SOLUTION. Question 1. CSE 555 HW 5 SAMPLE SOLUTION Question 1. Show that if L is PSPACE-complete, then L is NP-hard. Show that the converse is not true. If L is PSPACE-complete, then for all A PSPACE, A P L. We know SAT PSPACE

More information

Formal Verification Methods 1: Propositional Logic

Formal Verification Methods 1: Propositional Logic Formal Verification Methods 1: Propositional Logic John Harrison Intel Corporation Course overview Propositional logic A resurgence of interest Logic and circuits Normal forms The Davis-Putnam procedure

More information

Warm-Up Problem. Is the following true or false? 1/35

Warm-Up Problem. Is the following true or false? 1/35 Warm-Up Problem Is the following true or false? 1/35 Propositional Logic: Resolution Carmen Bruni Lecture 6 Based on work by J Buss, A Gao, L Kari, A Lubiw, B Bonakdarpour, D Maftuleac, C Roberts, R Trefler,

More information

LING 106. Knowledge of Meaning Lecture 3-1 Yimei Xiang Feb 6, Propositional logic

LING 106. Knowledge of Meaning Lecture 3-1 Yimei Xiang Feb 6, Propositional logic LING 106. Knowledge of Meaning Lecture 3-1 Yimei Xiang Feb 6, 2016 Propositional logic 1 Vocabulary of propositional logic Vocabulary (1) a. Propositional letters: p, q, r, s, t, p 1, q 1,..., p 2, q 2,...

More information

CS:4420 Artificial Intelligence

CS:4420 Artificial Intelligence CS:4420 Artificial Intelligence Spring 2018 Propositional Logic Cesare Tinelli The University of Iowa Copyright 2004 18, Cesare Tinelli and Stuart Russell a a These notes were originally developed by Stuart

More information

CSE 20 DISCRETE MATH WINTER

CSE 20 DISCRETE MATH WINTER CSE 20 DISCRETE MATH WINTER 2016 http://cseweb.ucsd.edu/classes/wi16/cse20-ab/ Reminders Exam 1 in one week One note sheet ok Review sessions Saturday / Sunday Assigned seats: seat map on Piazza shortly

More information

CS 730/730W/830: Intro AI

CS 730/730W/830: Intro AI CS 730/730W/830: Intro AI 1 handout: slides 730W journal entries were due Wheeler Ruml (UNH) Lecture 9, CS 730 1 / 16 Logic First-Order Logic The Joy of Power Wheeler Ruml (UNH) Lecture 9, CS 730 2 / 16

More information

Propositional Logic Part 1

Propositional Logic Part 1 Propositional Logic Part 1 Yingyu Liang yliang@cs.wisc.edu Computer Sciences Department University of Wisconsin, Madison [Based on slides from Louis Oliphant, Andrew Moore, Jerry Zhu] slide 1 5 is even

More information

The Importance of Being Formal. Martin Henz. February 5, Propositional Logic

The Importance of Being Formal. Martin Henz. February 5, Propositional Logic The Importance of Being Formal Martin Henz February 5, 2014 Propositional Logic 1 Motivation In traditional logic, terms represent sets, and therefore, propositions are limited to stating facts on sets

More information