Logic for Cs Notes

download Logic for Cs Notes

of 61

Transcript of Logic for Cs Notes

  • 8/12/2019 Logic for Cs Notes

    1/61

    Logic For Computer Science

    Adrian Cr aciun

    December 12, 2007

    1

  • 8/12/2019 Logic for Cs Notes

    2/61

    Contents

    I Motivation 4

    1 Mathematics, Reasoning, Logic 41.1 What is Mathematics? . . . . . . . . . . . . . . . . . . . . . . . . 41.2 Reasoning, Fundamental Properties of Reasoning . . . . . . . . . 51.3 What is (Mathematical) Logic? . . . . . . . . . . . . . . . . . . . 81.4 Language and Logic . . . . . . . . . . . . . . . . . . . . . . . . . 91.5 Languages: Distinctions . . . . . . . . . . . . . . . . . . . . . . . 101.6 The Notion of a Model in Logic . . . . . . . . . . . . . . . . . . . 11

    2 Logic Motivated by Mathematics 112.1 The Renement of Mathematical Reasoning . . . . . . . . . . . . 11

    2.2 The Solution to Foundational Problems . . . . . . . . . . . . . . 12

    3 Logic Motivated by Computer Science 13

    II Predicate Logic as a Working Language 15

    4 The Importance of Predicate Logic 15

    5 Informal Syntax and Semantics of First Order Predicate Logic 165.1 The Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165.2 Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165.3 Formulae . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

    6 Basic Proof Techniques 186.1 Proof Situations . . . . . . . . . . . . . . . . . . . . . . . . . . . 186.2 Basic Approaches to Proving . . . . . . . . . . . . . . . . . . . . 196.3 Denitions in Predicate Logic . . . . . . . . . . . . . . . . . . . . 236.4 Theories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

    7 Induction 25

    III Propositional Logic 26

    8 Informal Description 26

    9 Syntax of Propositional Logic 27

    10 Semantics of Propositional Logic 2910.1 Truth Valuations, Interpretation . . . . . . . . . . . . . . . . . . 2910.2 Validity, Satisability, Inconsistency . . . . . . . . . . . . . . . . 31

    2

  • 8/12/2019 Logic for Cs Notes

    3/61

    11 Propositional Equivalence, Normal Forms, Logical Consequence 3211.1 Logical Equivalence . . . . . . . . . . . . . . . . . . . . . . . . . . 3211.2 A Catalog of Equivalent Formulae . . . . . . . . . . . . . . . . . 3411.3 Normal Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3611.4 Logical Consequence . . . . . . . . . . . . . . . . . . . . . . . . . 42

    12 The Resolution Method in Propositional Logic 4412.1 Clause Form of Propositional Formulae . . . . . . . . . . . . . . 4412.2 Propositional Resolution . . . . . . . . . . . . . . . . . . . . . . . 4512.3 Improvements of Propositional Resolution . . . . . . . . . . . . . 48

    13 Applications of Propositional Logic: Digital Circuit Design 5213.1 Propositional Logic and Boolean Functions . . . . . . . . . . . . 5213.2 Complete Set of Boolean Operators . . . . . . . . . . . . . . . . . 5313.3 Digital Circuit Design . . . . . . . . . . . . . . . . . . . . . . . . 53

    14 Propositional Logic: Deduction in Natural Style 5614.1 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

    3

  • 8/12/2019 Logic for Cs Notes

    4/61

    Part I

    MotivationWhy study logic?Remark. This introductory section follows closely the rst chapter of [Buchberger, 1991],which is available at the website dedicated to this lecture.

    Essentially, logic is the science of reasoning .

    Mathematics: Reasoning is helpful , and even essential when doing mathemat-ics (foundational problems).

    Computer Science: The observation is that the automation of problem solv-ing is the automation of reasoning .

    1 Mathematics, Reasoning, Logic

    1.1 What is Mathematics?What is Mathematics?

    the dynamic picture: mathematics is the technique of problem solving inmodels ;

    the static picture: mathematics is the technique of obtaining informationin models .

    Remarks:

    working in models ;

    in fact, these are two faces of the same coin ( problem solving depends onobtaining information and obtaining information must be directed towardsgoals);

    the static aspect emphasized by pure mathematics (Bourbakism) nocomputers :( ;

    the dynamic aspect both ancient and modern:

    historically, rst math ideas arose from practical problem solving ; computers led to a renaissance of the problem solving aspect.

    4

  • 8/12/2019 Logic for Cs Notes

    5/61

    1.2 Reasoning, Fundamental Properties of Reasoning

    Reasoning

    Human intellect (mind) + pen and paper + computers form the sandtable on which models can be built and explored;

    Exploring intellectual models = reasoning (deduction, inference);

    Reasoning is at the heart of technical (intellectual) problem solving ;

    Problem solving :

    a problem is a situation in which a desired object is not immediatelyavailable;

    a solution to a problem is an action that produces the desired object.

    Technical Problem SolvingProblem solving based on mathematics (i.e. reasoning in intellectual models)

    has 3 steps:

    Figure 1: Mathematical Problem Solving.

    1. Observation and Model Construction

    the senses (rened with instruments - microscope, etc.) are brought incontact with the objects;

    a model (abstract picture of the universe of interest) is constructed; this is the realm of natural sciences ;

    2. Reasoning in the model

    new features can be constructed (without involving the senses);

    5

  • 8/12/2019 Logic for Cs Notes

    6/61

    the instrument for reasoning in models is the mind, often rened with otherinstruments (pen and paper, computers);

    this is the realm of mathematics ;

    3. Action

    interaction with the outside world in order to establish a solution to theoriginal problem;

    the instrument for transmitting the solution is the hand (rened by ma-chines);

    this is the realm of technical sciences .

    Progress through reasoningReasoning allows progress, evolution:

    from trial and error based problem solving - expensive, exhausting - nomodel;

    to human / computer reasoning in extremely complicated models.

    Fundamental Properties of ReasoningReasoning is

    I. abstract;

    II. veriable;

    III. correct;

    IV. general.

    I. Reasoning is abstract

    reasoning proceeds within intellectual models;

    no contact/interaction with the outside world is taking place duringreasoning;

    lat. abstrahere - pulling away (from the world);

    abstractness is the source of reasonings:

    practical usefulness

    there is nothing more practical than a good theory; advantage over trial and error (which is slow, potentially irre-versible);

    reasoning is fast, reversible; weakness

    6

  • 8/12/2019 Logic for Cs Notes

    7/61

    one may lose touch with reality; one can concentrate on some features, ignoring others (with effectin the real world);

    this has lead to the technological crisis the mankind faces today.

    II. Reasoning must be veriable

    reasoning proceeds in steps;

    each step should be controllable, i.e.

    so simple that anyone could repeat it, starting from the same initial situation, they would arrive at the same

    result;

    controllable patterns for steps of intellectual reasoning are called inferencerules;

    over the centuries of intellectual development several such rules have emerged;

    the creative part of reasoning is nding the right combination of suchinference rules.

    III. Reasoning must be correct

    whenever a statement B is inferred from statement A by the applicationof an inference rule, if A is true in the universe of discourse, then so mustbe B, i.e.

    truth must be transportedfrom its initial statement to the statementsbeing inferred.

    how to establish the correctness of inference rules?

    the evolutionary approach explains the correctness of (our usual setof) inference rules, for example predicate logic, as an accumulationof experience;

    mathematics as a metalanguage for the study of reasoning, give a mathematical denition of what the universe of dis-course is and of what validity (truth) of a statement is inthis universe, then show in the frame of that metalanguage that

    the inference rule is correct.Example: an inference rule from predicate logic .

    If xA is true then also x (A) is true.

    7

  • 8/12/2019 Logic for Cs Notes

    8/61

    the evolutionary approach : the correctness is observed by all individualsin various universes; Remark. In this view, reasoning and mathematics inparticular can be viewed as accumulated and condensed experience of mankindin observing (nite) universes.

    mathematics as a metalanguage : prove that in any universe in which

    xA is valid, x ( A) is valid.

    Remark. The second approach is an example of using a crude tool for rening(a copy of) itself.

    Remark. Using mathematics as a metalanguage amounts to bringing together nitelymany observations on the metalevel, so that a rule that governs innitely many in-stances on the object level can be established.

    To show that statement B follows from A, one would have to check in potentiallyinnitely many instances in the respective universe of discourse. Correct inferencerules spare us this effort.

    IV. Reasoning must be general

    reasoning should be general, i.e. applicable in whole classes of situations(in whole universes) independently.

    Reasoning vs. being

    reasoning should be understood as a tool (which can be put aside);

    being means more than that (other tools: meditation, eastern thinking),etc.

    1.3 What is (Mathematical) Logic?The Science of Reasoning

    Logic is the science of reasoning;

    mathematical logic uses the method of mathematics to study mathemati-cal reasoning,

    i.e. mathematical logic is reasoning about reasoning;

    terms used (interchangeably):

    mathematical logic, formal logic, symbolic logic, metamathematics .

    8

  • 8/12/2019 Logic for Cs Notes

    9/61

    Is Reasoning About Reasoning Possible?

    can a tool work on itself? Example 1. (Ancient) Using a stone to shape another one (sharper),

    leads to more advanced tools, ...

    Example 2. (Modern) Compiler P 1 takes a program P 2 and transformsit into another program P 2 , which can take data...

    the transition of an object from the stage where it is processed to thestage where it is itself processing (i.e. it is itself a tool) is at the core of technological evolution.

    1.4 Language and Logic

    Paraphrasing Models and Reasoning in Terms of Language

    language (written and spoken words and thoughts) is the traditional car-rier of intellectual models, i.e. the material from which intellectual modelsare constructed.

    hence reasoning is operating on linguistic objects.

    with the advent of computers, our perception of language must be dras-tically broadened: in fact, any collection of building blocks from whichmodels can be formed should be conceived as language.

    Languages

    a language consists of individual expressions (sentences, terms, state-ments);

    the expressions are models (pictures) of entities (situations, processes) inthe domains (structures, realities, universe of discourse) one is interestedin;

    the entities described by the expressions of a language form the meaningof a language;

    the syntax of a language: the structure (external form) of the expressions;

    the semantics of a language: the meaning of expressions;

    the expressions of a language are formed from elementary expressions byrules (syntactic rules) , which, in some way, reect (in often abstract ways)the way objects in the domains are formed from simpler objects.

    the elementary objects (expressions), the construction rules and hence,compound expressions of a language should be nitary ( manageable, al-gorithmic, simple) - this corresponds to the general objective of models:

    9

  • 8/12/2019 Logic for Cs Notes

    10/61

    models should be manageable pictures of the modelled world .

    reasoning, then, is operating on the expressions of a language with thegoal at arriving at new expressions with interesting meaning (expres-sions that describe the solution to the problem in the respective interestdomain).

    1.5 Languages: DistinctionsDescriptive vs. Algorithmic Languages

    descriptive languages describe objects, situations, relations between ob- jects;Example. In the context of traditional mathematics,predicate logic;

    algorithmic (imperative) languages describe processes, activities, func-tions;Example. In the context of computer science, the theory of formal languageshas long time been restricted to the syntax of programming languages;

    Attention! computational logic:

    logic of syntax and semantics of algorithmic languages; logic of automated reasoning;

    Attention! In fact, the treatment of (descriptive and imperative) lan-guages and reasoning (computing) is an integrated body of knowledge thatcannot be separated in independent parts without losing its power.

    Universal and Special Languages

    rst order predicate logic can be shown to be universal in the practical sense that all mathematics can be described in it, and in the theoreticalsense, in that it is so powerful that anything that is true in a semanticalsense can be derived using reasoning rules;

    special languages :

    CSG(constructive solid geometry); language of switching circuits; propositional logic ;

    10

  • 8/12/2019 Logic for Cs Notes

    11/61

    Natural Languages vs. Formal Languages

    natural languages are trained in context;

    formal languages : are dened in a metalanguage - a language that de-scribes the syntactical objects (expressions) of the languages, the objectsthat are described by the expressions of the language, the relation betweenthe syntactical objects and the objects described, the rules of reasoning;

    Attention! The property of being formal has nothing to do with thesyntax.

    Metalanguage vs. Object Language

    object language - the language being dened;

    metalanguage - the language being used to dene;

    Attention! These are not absolute terms.Example :

    set theory is the metalanguage for dening formally rst order pred-icate logic;

    set theory can then be a special theory in the language of rst orderlogic.

    1.6 The Notion of a Model in LogicModels in Mathematics and Logic

    mathematics is operating in (linguistic) models of real (or abstract) do-mains;

    in the technical terminology of mathematical logic, a model is a domainabout all of a set of statements are true.

    Math: some set of statements is a model of the real world;

    Logic: some domain is a model of a set of statements.

    2 Logic Motivated by Mathematics

    2.1 The Renement of Mathematical ReasoningLogic: Useful and Even Essential for Mathematics

    using logic improves the life of mathematicians of all sorts (e.g. studentsin CS);

    11

  • 8/12/2019 Logic for Cs Notes

    12/61

    logic proved essential in solving the proof crisis that became apparentat the end of XIX Century;Example (Russel) - an axiom for sets.

    intuition:

    For all properties E , there exist the set of all objects x thatpossess the property E .

    more exactly, for every property E :

    there exists the set M such that for all x (x M iff E ),

    where M is a variable.

    Example: Russels paradox

    Now, consider the property x x :

    there exists the set M such that for all x (x M iff x x )

    We take an M (since it exists):

    for all x (x M iff x x )

    Since the statement holds for all x , it holds also for x := M :

    (M M iff M M ),

    which is a contradiction.

    In fact the axiom can be patched to avoid the paradox: For every prop-erty E with free variable x and every variable B not occurring free inE :

    for all B there exists M such that for all x (x M iff (x B and E )).

    ... but does the restricted form introduce anymore contradictions?

    2.2 The Solution to Foundational ProblemsBasic Problems in the Foundations of Mathematics

    The Problem of Freedom from Contradiction (Consistency). Given anaxiom system for an area of mathematics, can reasoning ever deduce acontradiction from them?

    Mechanizability of Reasoning. Can reasoning be carried out by machines?

    12

  • 8/12/2019 Logic for Cs Notes

    13/61

    Completeness of Reasoning (of a Proof System). Given a set of inferencerules, can we add new inference rules and thereby extend the set of deriv-able sentences, or is the system complete?YES - Godels completeness theorem for rst order logic, 1930.

    Completeness of Axiom Systems. Given an axiom system, is it powerfulenough (complete) for establishing all true sentences in a domain?Canwe construct simple complete axiom systems?Godel 1931: NO simple axiom system for natural numbers (Incomplete-ness Theorems).

    Decidability of Truth. Can the decision be automatically made (by an algo-rithm) whether a sentence follows from given axioms?

    Church and Turing 1936,undecidability theorem: NO in rst orderlogic;

    YESin special domains: Euclidean geometry, real closed elds (Collins1973);

    Categoricity of Axiom Systems. Is the domain completely characterizedby the axiom system? Can one nd completely different (nonisomorphic)models for some axiom system?

    3 Logic Motivated by Computer ScienceWhy Should a Computer Scientist Know Logic?

    the traditional scope of CS was the automation of operation in numericalmodels;

    but, in fact, reasoning can be seen as a kind of computation, thus inprinciple it can be automated;

    Logic plays a fundamental role in computer science, similar to that playedby calculus in physics and traditional engineering. A knowledge of logic isbecoming a practical necessity for the computer professional. (Mannaand Waldinger 1985)

    Problem Solving in Computer ScienceFigure 2 illustrates the typical steps for (algorithmic) problem solving in

    computer science.

    13

  • 8/12/2019 Logic for Cs Notes

    14/61

    Figure 2: Problem Solving in Computer Science

    Logic-Based Techniques in Computer Science

    For Raising the Level of the Abstract Machine: boolean operations (log-ical gates), symbolic addresses (assembler), recursion (stacks), dynamicdata structures (garbage collection), functional programming (programsas data), abstract data programming, OO, relational databases, expertsystems, logic programming, CLP;

    For Bridging the Gap Between Problem and Program: program synthe-sis, program transformation, program verication.

    14

  • 8/12/2019 Logic for Cs Notes

    15/61

    Part II

    Predicate Logic as a WorkingLanguageOutline

    Before a formal presentation of (various languages of) logic:

    Importance of predicate logic (summary),

    introduce predicate logic (syntax and semantics) informally,

    introduce basic proof techniques for predicate logic, and

    introduce induction as a proof technique in various domains.

    4 The Importance of Predicate Logic1. General enough to be a formal frame for all of mathematics.

    2. It can serve as a formal frame for computer science.

    3. it is where most of the foundational research effort was concentrated inthe past decades.

    A Frame for Doing Mathematics

    By no means trivial;

    Took thousands of years to achieve these results;1879 Frege - rst complete syntactical presentation,1930 Godel - completeness of rst order predicate logic,1936 Church, Turing - undecidability;

    In fact, even a restricted form, rst order predicate logic (together withset theory), is sufficient for this.

    A Frame for Algorithmic Problem Solving

    Predicate logic si a general frame for proving mathematical concepts andfacts, therefore it can also be used as a universal frame for specifyingproblems;

    Proving is computing (Robinson 1965 - resolution);

    Logic programming (Prolog);

    Unifying potential and practical power in data design and analysis (ab-stract data types, relational databases).

    15

  • 8/12/2019 Logic for Cs Notes

    16/61

    5 Informal Syntax and Semantics of First Order

    Predicate Logic5.1 The LanguageThe Language

    variables (individual variables, object variables): x ,y,z , that rangeover arbitrary elements in a universe of discourse;

    function symbols (function names, function constants): representoperations, processes in the universe of discourse,

    + , , functions have arities (number of arguments),

    some functions are 0-ary, i.e. they have no arguments - they arecalled constants (individual constants),

    the 0-ary functions are in 1-to-1 correspondence with the elements of the universe of discourse, and are often identied with them.

    predicate symbols (relation symbols) denote attribute of / relationsbetween objects in the universe of discourse,

    2 n is an atomic formula,

    16

  • 8/12/2019 Logic for Cs Notes

    17/61

    an atomic formula asserts that the relation holds for the terms,

    such an assertion can be true or false (depending on assignments of values to variables). different notations are used:

    inx: m < n , prex: GCD (m, n ), postx: n!.

    given the formulae A, B , use propositional connectives to form compoundformulae:

    AA BA BA BA B

    given a variable x and a formula A , one can form the formulae:

    for all x A (alternative notation: xA ) - universal formula ,there exists x such that A (alternative notation: xA ) -existentialformula ,

    for all ( ) is called the universal quantier;

    exists ( ) is called the existential quantier;

    the variable x becomes bound by the quantiers.

    Example 2. In the formula:

    y(| y x |< ) | f y f x |< ,

    variables x and f are free, the others are bound.Remark. Using the term (rst order) predicate language:

    the language of (rst order) predicate logic = the language built fromvariables and arbitrary (all conceivable) functions and predicate symbols,

    a (rst order) predicate logic language = a language characterized by afew function and predicate symbols,i.e. a language of (rst order) predicate logic is characterized by its func-

    tion and predicate symbols (non-logical symbols).The meaning of expressions in predicate logic is computed according to

    the interpretations (i.e. assigned meanings) of its subexpressions.

    the meaning of terms f [t1 , . . . , t n ] is given by the interpretation of f ap-plied to the interpretations of t 1 , . . . , t n ,

    17

  • 8/12/2019 Logic for Cs Notes

    18/61

    the meaning of formulae with no free variables is either true of false,

    the meaning of A, A B, A B, A B , A B is given by rst inter-preting A, B , then computing the meaning of the formulae according tothe rules for , , , , ,

    A is true if A is false, A B is true if at least one of A, B is true,A B is true if both A, B are true, A B is false only when Ais true and B is false, A B is true when A, B have the samemeaning.

    the meaning of xA is true, if A is true for all possible value assign-ments of x , and false otherwise,

    the meaning of xA is true if A is true for some value assignment of x , and false otherwise.

    6 Basic Proof Techniques

    6.1 Proof Situations proving is stepwise arrangement of proof situations ,

    a proof situation is characterized by the current knowledge base (i.e. sen-tences known to be true, which can be used), and the current goal (i.e.sentence which should be proved),

    a proof situation is trivial if the goal occurs in the knowledge base,

    proof steps (proof techniques, proof rules, inference rules) describe how a

    proof situation is transformed in (one or more) simpler proof situations, new proof situations are simpler in the sense that either the goal has a

    simpler structure, or more sentences are added to the knowledge base (i.e.we know more),

    a proof describes the necessary inference steps that transform the initialproof situation into (one or more) trivial proof situations; (AND-OR) treesare suitable to represent proofs.

    only a few proof situations are possible,

    each determined by the structure of its sentences,

    and proof steps can be chosen according to the outermost construct in

    the sencence considered, below are described such typical situatons and the proof steps that can be

    applied,

    as a guideline for human proving (but note that this can be formalized tonatural deduction, and even automated theorem proving),

    18

  • 8/12/2019 Logic for Cs Notes

    19/61

    6.2 Basic Approaches to Proving

    For proving the sentence A (when not knowing whether A is true): Try to prove A . If successful, :) (be happy). Otherwise:

    Assume A and try to derive a contradiction. If successful, :) (be happy,A is proved). Otherwise:

    Try to prove A. If successful, :) (be happy). Otherwise:

    Assume A and try to derive a contradiction. If successful, :) (be happy,A is proved). Otherwise:

    Start again with the attempt to prove A. (By this time you have muchmore insight).

    Notation: In the following, A,B, C are formulae, s, t are terms, P is a predicate,f is a function constant, x is a variable. A[x ] is a formula where x is free, A [C ]is a formula where C is a subformula.

    xA [x ]

    Prove xA [x ]:

    For proving xA [x ], show A [x0], where x 0 is a new constant (which did not occur so far). Announcement in proofs:

    Let x 0 be arbitrary but xed. We show A [x0].

    Use xA [x ]:

    If xA [x ] is known, then one may conclude A [t] where t is an arbitrary term. Announcement in proofs: Since we know that xA [x ], we know that,

    in particular, A [t]. Note that the choice of t is probably going to be suggested by the

    goal statement.

    xA [x ]

    Prove xA [x ]: For proving xA [x ], try to nd a term t for which A [t ] can be shown, Finding such a term t is many times nontrivial step, which needs

    creativity.

    19

  • 8/12/2019 Logic for Cs Notes

    20/61

    Use xA [x ]:

    If xA [x ] is known, and B has to be proved, one may assume A[x0] where x 0 is a new constant, and try to prove

    B . Announcement in proofs: Since we know that xA [x ], let x0 be such

    that, A [x0]. We have to prove B .

    A B

    Prove A B :

    For proving A B

    prove A and

    prove B .

    Use A B :

    If A B is known, then A is known and B is known.

    A B

    Prove A B :

    For proving A B

    assume A and prove B

    (or assume B and prove A ).

    Use A B :

    If A B is known, and C has to be proved then assume A and prove C and assume B and prove C . Announcement in proofs: We prove by cases: Case A : We prove C .

    Case B : We prove C .

    20

  • 8/12/2019 Logic for Cs Notes

    21/61

    A B

    Prove A B : For proving A B assume A and prove B .

    Use A B :

    If B has to be proved then look for A B (or something that matches it) and prove A . Announcement in proofs: To prove B , since we know A B , it

    suffices to prove A .

    A B

    Prove A B :

    To prove A B , assume A and prove B , then assume B and prove A .

    Use A B : If C [A] has to be proved, and A B is known, then try to prove C [B ].

    A

    Prove A:

    To prove A, assume A ,

    and derive a contradiction , i.e. prove C , where C is in the knowledge base.

    21

  • 8/12/2019 Logic for Cs Notes

    22/61

    P (t 1 , . . . , t n )

    Prove P (t1 , . . . , t n ): To prove P (t 1 , . . . , t n ) look for an explicit denition

    x 1 ,...,x nP (x1 , . . . , x n ) A [x1 , . . . , x n ]

    and prove A [t1 , . . . , t n ].

    Use P (t1 , . . . , t n ):

    If P (t1 , . . . , t n ) is known and the denition:

    x 1 ,...,x nP (x1 , . . . , x n ) A [x1 , . . . , x n ] is in the knowledge base,

    then A [t 1 , . . . , t n ] can be added to the knowledge base.

    A[f (t 1 , . . . , t n )]

    Prove A [f (t1 , . . . , t n )]:

    To prove A [f (t 1 , . . . , t n )](a) explicit denition case:

    where the explicit denition of f :

    x 1 ,...,x nf (x1 , . . . , x n ) = s[x1 , . . . , x n ] is in the knowledge base,

    prove A [s [t1 , . . . , t n ]].(b) implicit denition case:

    where the implicit denition of f :

    x 1 ,...,x nf (x1 , . . . , x n ) = such a y that B [x1 , . . . , x n , y ]

    is in the knowledge base, prove

    yB [t 1 , . . . , t n , y ] A [y].

    Use A [f (t1 , . . . , t n )]:

    If A [f (t1 , . . . , t n )] is known:(a) explicit denition case:

    and the explicit denition of f :

    x 1 ,...,x nf (x1 , . . . , x n ) = s[x1 , . . . , x n ] is in the knowledge base,

    then A [s [t 1 , . . . , t n ]] can be added to the knowledge base.(b) implicit denition case:

    and the implicit denition of f :

    x 1 ,...,x nf (x1 , . . . , x n ) = such a y that B [x1 , . . . , x n , y ]

    is in the knowledge base, then

    yB [t 1 , . . . , t n , y ] A[y] can be added to the knowledge base.

    22

  • 8/12/2019 Logic for Cs Notes

    23/61

    6.3 Denitions in Predicate Logic

    denitions allow the introduction of new concepts in terms of existingones,

    it provides a facility for concise formalization of mathematics, but theyare not essential, i.e. they can be eliminated .

    however, they allow formulae to be shorter,

    and help structuring the knowledge.

    Practical mathematics would hardly be conceivable without this facility.

    Example 3 (Irreducible natural numbers) .

    is-nat ( i )( is-irreducible (i)

    deniendum(lat. to be dened)

    is-nat (n )(i |n (n = 1 n = i))

    deniens(lat. the dening))

    Four basic types of denitions:

    (explicit) denitions of predicate symbols, explicit denitions of function sybols, implicit nonunique denitions of function symbols, implicit unique denitions of function symbols.

    Properties of denitions:

    they are axioms, can always be eliminated, do not bring anything new to the power of the theory (conservative

    extensions), do not introduce contradictions.

    Correct denitions (watchlist):

    no extra variables in the deniens, denitions of terms, uniqueness, pairing functions,

    6.4 TheoriesStructure of a Theory

    a (mathematical) theory T is described by its:

    language (symbols) : LT = F T , P T , F T , i.e. its function, predicateand constant symbols respectively. Note that, for any theory, id, =(the identity function and the equality) can always be included inthe language;

    23

  • 8/12/2019 Logic for Cs Notes

    24/61

    knowledge base KB T , which contains facts (formulae over the lan-guage), i.e. axioms and propositions (theorems, lemmata, corollaries,etc.).

    inference rules , IR T . The rules for predicate logic, as well as rulesfor equality proving (rewriting) may be included in any theory. Ad-ditional rules may be included (depending of the nature of objects inthe theory), which make the theory more powerful , in the sense thatmore facts may be proved using these additional rules. These cannotbe applied outside of the theory.

    Example 4 (The theory of Strict partial orderings F PO ). the symbols in the language :

    function symbols, F PO = {} (no function symbols), predicate symbols, P PO = { p}, where p is a binary symbol, constants, C PO = {} (no constants either).

    the knowledge base KB P O :

    axioms describing strict partial orderings:

    x,y,z( p(x, y ) p(y, z ) p(x, z )) , (transitivity )

    x p(x, x ). (irreflexivity )

    the inference mechanism I R P O consists of the inference rules of predicatelogic.

    Development of a Theory theories are not static, but are developed:

    from initial descriptions (such as in the previous example), where theknowledge base contains axioms ,

    by adding new components:

    new formulae to the knowledge base, i.e. consequences of the existingformulae, proved using the mechanisms available,

    new symbols with their corresponding denitions (dening axioms,which are added to the knowledge base),

    new inference rules , a very subtle point - lifting knowledge to thelevel of inference, as these have to be proved correct

    questions that arise in the development of theories include:

    how much of the theory is relevant? (not always all knowledge isneeded, or even useful)

    ...

    24

  • 8/12/2019 Logic for Cs Notes

    25/61

  • 8/12/2019 Logic for Cs Notes

    26/61

  • 8/12/2019 Logic for Cs Notes

    27/61

    Propositional Logic: Synopsis

    dene the syntax of propositional logic;

    dene the semantics of propositional logic, and connected concepts likesatisability, logical consequence, etc.;

    show how to determine the truth value of arbitrary propositions for allpossible interpretations (this is possible in propositional logic, but expen-sive);

    show various methods to do reasoning in propositional logic (includingresolution and natural deduction);

    then show that the reasoning is correct and complete in propositional logic;

    and also present some applications for propositional logic (including digitalcircuit design).

    9 Syntax of Propositional LogicThe Symbols of Propositional Logic

    Denition 5 (Set of propositional variables) . V is a set of propositional vari-ables iff V is a denumerable innite set of words consisting of English letters(uppercase) possibly followed by numerical indices.

    Example 6. A, B , P 1 , Q 5 are examples of propositional variables.

    Denition 7 (Special symbols of propositional logic) . The special symbols of propositional logic are:

    1. variables from the set of propositional variables;

    2. symbols denoting the logical connectives (logical operators): , , , ,;

    3. parentheses: (, ).

    Well-formed FormulaeRemark . Propositional variables stand for atoms , i.e. simple propositions, notinvolving propositional connectives.

    Denition 8 (Well-formed formulae of propositional logic) . The well-formedformulae (formulae, WFFS) of propositional logic are dened recursively asfollows:

    1. An atom is a formula;

    2. If G is a formula, then ( G ) is a formula;

    27

  • 8/12/2019 Logic for Cs Notes

    28/61

    3. If G and H are formulae, then ( G H ), (G H ), (G H ) and ( G H )are formulae;

    4. All formulae are generated following the above rules.

    Example 9.

    1. A is a formula;

    2. B ) is not a formula;

    3. A B

    is not a formula, according to the denition, but why not allow it (for practical reasons)?

    Example 10 (Why use parentheses?) .

    P Q R is ambiguous:

    ((P Q ) R ), (P (Q R ))

    Relaxing the Syntax

    in practice, we allow a relaxed syntax, in that some of the parentheses aredropped;

    however, formulae should be nonambiguous, even in this relaxed syntax;

    the way to avoid ambiguity is to dene priorities (precedence) for propo-sitional connectives :

    Example 11 (Priorities for propositional connectives (decreasing)) .

    , , , , .

    Remark. The above is just an example of precedence. Different authors mayuse different precedences. When using a relaxed syntax, always specify theprecedence. When in doubt, use parentheses!!!Example 12 (Precedences revisited) . Using the precedence above,

    P Q R

    is, in fact(P (Q R )).

    Remark. From now on, if not otherwise specied, we allow the use of therelaxed syntax for propositional logic, with the precedence given above.

    28

  • 8/12/2019 Logic for Cs Notes

    29/61

    Notation for Propositional ConnectivesVarious notations are used in literature:

    , , , , ;

    if f , if...then... , or , and , not ;

    , , , , .

    10 Semantics of Propositional Logic

    10.1 Truth Valuations, InterpretationTruth Values, Truth Functions

    Denition 13 (Domain of truth values) . We choose 2 distinct values T , F . The set of truth values is the set {T , F }. The set of truth values is (totally) ordered,F < T .

    Denition 14 (Truth functions) . The following functions are called truth func-tions :

    B : {T , F } {T , F },B , B , B , B : {T , F } { T , F } {T , F } ,

    v w B (v) B (v, w ) B (v, w ) B (v, w ) B (v, w )T T F T T T T

    T F F T F F

    F T T F T T F

    F F F F T T

    Remark. The truth functions reect the intuitive meaning of the propositionalconnectives.

    Truth Valuation

    Denition 15 (Truth valuation/Interpretation) . T is a truth valuation (inter-pretation) iff T is a mapping from V to the set {T , F } of truth values.

    Example 16 (Truth valuation) . Let G .= ( P Q ) (R (S )).A truth valuation (interpretation) for the formula G isT (P ) = T , T (Q ) = F , T (R ) = T , T (S ) = T .

    Remark. The truth valuation assigns to each propositional variable that occursin the formula either one of the values T , F .

    29

  • 8/12/2019 Logic for Cs Notes

    30/61

    Interpretations of Propositional Formulae

    Denition 17 (Truth values under truth valuations/interpretations of proposi-tional formulae) . For all propositional formulae B , we denote B T - the truth value of B under the truth valuation/ interpretation T . It is dened inductivelyas follows:

    if V is a propositional variable, V T = T (V );

    if B is a formula B T = B ( B T );

    if B 1 , B 2 are formulae,

    (B 1 B 2) T = B ( B 1 T , B 2 T ), (B 1 B 2) T = B ( B 1 T , B 2 T ), (B 1 B 2) T = B ( B 1 T , B 2 T ),

    (B 1 B 2) T = B ( B 1 T , B 2 T ).Example 18 (Interpretation revisited) . Now lets compute the truth value of G.= (( P Q ) (R (S ))), from the example above, under the interpretationT ( T (P ) = T , T (Q ) = F , T (R ) = T , T (S ) = T ):

    G T

    = ((P Q ) (R (S ))) T

    = B ( (P Q ) T , (R (S )) T )

    = B (B ( P T , Q T ), B ( R T , (S ) T ))

    = B (B (T , F ), B (T , B ( S T )))

    = B (F

    , B (T

    ,F

    ))= B (F , F )

    = T .

    Denition 19 (True proposition) . A propositional formula B is said to be true under an interpretation if it is evaluated to T in the interpretation. OtherwiseB is said to be false .

    Remark. (Number of possible interpretations) If there are n distinct atoms ina formula, then there will be 2 n distinct interpretations for the formula.

    Representation of InterpretationsNotation. (Representation of interpretation) For a given formula, assume {A1 , . . . , A n }is the set of propositional variables. Then a particular interpretation can be rep-resented as the set {m 1 , . . . , m n } where m i is either Ai or A i , according towhether T (A i ) = T or T (A i ) = F , respectively.Example 20. Consider (( P Q ) R ).

    {P, Q, R } stands for T (P ) = T , T (Q ) = F , T (R ) = T .

    30

  • 8/12/2019 Logic for Cs Notes

    31/61

    10.2 Validity, Satisability, Inconsistency

    Tautologies, SatisabilityDenition 21 (Propositional Tautologies) . The formula B is valid in propo-sitional logic (or B is a propositional tautology) iff, for all truth valuations T ,B T = T (i.e. the proposition is true under all possible interpretations). The

    formula is invalid iff it is not valid.

    Denition 22 (Satisability) . A propositional formula B is said to be satis-able in propositional logic iff for some truth valuation T , B T = T (i.e. thereexists some interpretation for which the formula is evaluated to true).

    A propositional formula B is said to be inconsistent (unsatisable) iff it isfalse under all truth valuations (all interpretations).

    ExercisesUsing the denitions, show that:

    1. A formula is a tautology (valid) iff its negation is inconsistent.

    2. A formula is inconsistent iff its negation is valid.

    3. A formula is invalid iff there is at least one interpretation under which theformula is false.

    4. A formula is consistent iff there is at least one interpretation under whichthe formula is true.

    5. If a formula is valid, then it is consistent, but not vice-versa.

    6. If a formula is inconsistent, then it is invalid, but not vice-versa.

    Denition 23. If a formula B is true (evaluated to T ) under some truth valu-ation (interpretation) T , we say that T satises B (B is satised by T ).

    On the other hand, if a formula B is false (evaluated to F ) under T , we saythat T falsies B (B is falsied by T ).

    When an interpretation (truth valuation) T satises a formula B , T is calleda model of B .

    Truth Tables

    Denition 24 (Truth table (informal)) . A truth table corresponding to a propo-sitional formula is the table constructed in the following manner:

    on the rst row, list all propositional variables occurring in the formula,then ....

    ... list all subformulae of the formula tree, in a bottom-up manner, thelast one being the formula itself;

    31

  • 8/12/2019 Logic for Cs Notes

    32/61

    the columns under the propositional variables contain the truth valuesunder all possible truth valuations,

    the columns under each subformula contain on each position the valueunder the truth valuation taken from the corresponding row,

    note that using the bottom-up approach each computation amounts toone application of a truth function.

    Truth Tables: Example

    Example 25 (Truth table) . Consider the propositional formula ( P Q ) R .

    P Q R P Q (P Q ) RT T T T T

    F T T T T

    T F T F TF F T T T

    T T F T T

    F T F T T

    T F F F F

    F F F T T

    11 Propositional Equivalence, Normal Forms, Log-ical Consequence

    11.1 Logical Equivalence

    Logical EquivalenceDenition 26 (Equivalence of Propositional Formulae) . Two propositional for-mulae F and G are (propositionally) equivalent (and we write F G ) iff for alltruth valuations (interpretations) T , F T = G T .

    Example 27. Consider the formulae ( P Q ) and ( P Q ).

    P Q (P Q ) P (P Q )T T T F T

    T F F F F

    F T T T T

    F F T T T

    From the truth table we see that the two formulae are equivalent.(Propositional) formulae can have very different structure, but the same

    values under the same interpretations, for all possible interpretations.The question is how to detect the that two formulae are equivalent?

    truth tables work, but are very expensive ;

    32

  • 8/12/2019 Logic for Cs Notes

    33/61

    can we do better? try (something like) simplication.

    Exercise: How much time does a truth table take?

    How bad is expensive?Consider the following table, taken from [Kleinberg, Tardos 2006]:

    n nlog 2 n n2 n 3 1 . 5 n 2 n n !

    n = 10 < 1 sec < 1 sec < 1 sec < 1 sec < 1 sec < 1 sec 4 secn = 30 < 1 sec < 1 sec < 1 sec < 1 sec < 1 sec 18 min 10 25 yrsn = 50 < 1 sec < 1 sec < 1 sec < 1 sec 11 min 36 yrs very long

    n = 100 < 1 sec < 1 sec < 1 sec 1 sec 12892 yrs 10 17 y rs ve ry l ongn = 1000 < 1 sec < 1 sec 1 sec 18 min very long very long very long

    n = 10000 < 1 sec < 1 sec 2 min 12 days very long very long very longn = 100000 < 1 sec 2 sec 3 hours 32 yrs very long very long very long

    n = 1000000 1 sec 20 sec 12 days 31710 yrs very long very long very long

    running times are estimated for a processor capable of performing 1 million highlevel instructions per second (MIPS),

    very long is considered to be running time that exceeds 10 25 years, for comparison, currently (2007) available processors are capable of 10.000 -

    60.000 MIPS(see, for example, estimates at http://en.wikipedia.org/wiki/Million instructions per second ).

    expensive is still very very bad .

    Simplication

    The Idea of Simplication

    To decide if 2 expressions are equivalent (in some sense), reduce (sim-plify) each of them to their (unique) normal form , by applying nitely manyequivalence preserving steps. If these normal forms are (basically) the same,then the initial expressions are equivalent. Even if the normal form is notunique, it can still be useful, in that it contains information which could leadto the solving of the problem.

    Extending the Language of Propositional LogicWe extend the language with two symbols, , :

    denote formulae that are always false (inconsistent), i.e. for all truthvaluations T , T = F ;

    33

  • 8/12/2019 Logic for Cs Notes

    34/61

    denote formulae that are always true (valid), i.e. for all truth valuationsT , T = T ;

    Remark.

    F iff F is inconsistent;

    F iff F is valid.

    11.2 A Catalog of Equivalent FormulaeIn the following, F , G , H are propositional formulae.

    Reduction Laws:

    (a) ( F G ) (F G ) (G F ),(b) ( F G ) (F G ).

    Commutative Laws:

    (a) F G G F ,(b) F G G F ,

    (c) F G G F .

    Associative Laws:(a) ( F G ) H F (G H ),(b) ( F G ) H F (G H ),(c) (F G) H F (G H ).

    Distributive Laws:(a) F (G H ) (F G ) (F H ),(b) F (G H ) (F G ) (F H ),

    (c) (F G ) H (F H ) (G H ),(d) (F G ) H (F H ) (G H ),(e) F (G H ) (F G ) (F H ),(f ) F (G H ) (F G ) (F H ),(g) (F G ) H F (G H ).

    Laws of True and False:(a ) ,(b) ,

    (c) F F ,(d) F F ,(e) F ,(f ) F ,(g) F ,(h ) F .

    34

  • 8/12/2019 Logic for Cs Notes

    35/61

    Idempocy rules:

    (a ) F F F ,(b) F F F .

    Absorbtion Laws:(a ) F (F G ) F ,(b) F (F G ) F .

    Annihilation Laws:

    (a ) F F , (tertium non datur)(b) F F ,

    (c) F F .

    Negation Laws:

    (a ) (F ) F , (double negation)(b) (F G ) F G , (De Morgan)(c) (F G ) F G , (De Morgan)

    (d) (F G ) F (G),(e) (F G ) F (G ).

    Other Laws:(a ) F G F (F G ),(b) F G G (F G ).

    Conjunctions and Disjunctions of FormulaeRemark. Because of the associative laws, parantheses can be dropped, e.g. in(F G ) H or in F (G H ).

    Denition 28 (Conjunction of formulae) . Let F 1 , F 2 , . . . , F n be formulae. Theformula F 1 . . . F n , n 1, is called the conjunction of F 1 , . . . , F n , and itsvalue under a truth valuation T is:

    B ( F 1 T , . . . , F n T ) = T , if F 1 T = . . . = F n T = TF , otherwise .

    Denition 29 (Disjunction of formulae) . Let F 1 , F 2 , . . . , F n be formulae. Theformula F 1 . . . F n , n 1, is called the disjunction of F 1 , . . . , F n , and itsvalue under a truth valuation T is:

    B ( F 1 T , . . . , F n T ) = F , if F 1 T = . . . = F n T = FT , otherwise .

    35

  • 8/12/2019 Logic for Cs Notes

    36/61

    Principle of DualityDe Morgans laws ensure us of the following fact:

    starting from a tautology involving only , , , , ,

    the principle of duality states that one can swap the s and s, swapthe s and the s, and then negate the result,

    and get another tautology.

    Example 30. Start with F F , swap, obtaining F F , and then negate,obtaining (F F ) (the principle of noncontradiction).

    11.3 Normal FormsNegation Normal Form

    Literals, Negation Normal Form

    Denition 31 (Literal) . A literal is an atom or the negation of an atom. Atomsare called positive literals, negations of atoms are called negative literals.

    Denition 32 (Negation Normal Form) . A formula F is said in negation normal form (NNF) , iff:

    F is or F is ;

    F is constructed from literals, using only the binary connectives and .

    Example 33. Let P, Q, R, S be atoms. The following are in NNF:

    ,

    P ,

    P (Q (R S )),

    however,(P ),

    (P Q ) R ,

    are not.

    Transformation to NNF

    Remark. Any propositional logic formula can be transformed into an equivalentformula in NNF.

    Transformation to NNF

    1. use the reduction laws (given in the catalog of equivalent formulae) toeliminate , ;

    36

  • 8/12/2019 Logic for Cs Notes

    37/61

    2. repeatedly use the double negation and De Morgans laws to eliminate s and (. . . )s.

    3. at each of the steps above, it is useful to perform simplications of and (using the laws of true and false, annihilation, idempocy).

    Disjunctive Normal Form, Conjunctive Normal Form

    Disjunctive Normal Form

    Denition 34 (Disjunctive Normal Form) . A formula F is said to be in dis- junctive normal form (DNF) iff F has the form F .= F 1 . . . F n , n 1 , andeach of F 1 , . . . , F n is a conjunction of literals.

    Example 35 (Formulae in DNF) . Let P,Q, R be atoms,

    (P Q ) (P Q R )

    P ,

    P Q ,

    P Q R ,

    are in DNF.Remark. Any formula which is in DNF is also in NNF.

    Conjunctive Normal Form

    Denition 36 (Conjunctive Normal Form) . A formula F

    is said to be in con- junctive normal form (CNF) iff F has the form F .= F 1 . . . F n , n 1 , andeach of F 1 , . . . , F n is a disjunction of literals.

    Example 37 (Formulae in CNF) . Let P,Q, R be atoms,

    (P Q ) (P Q R )

    P ,

    P Q ,

    P Q R ,

    are in CNF.

    Remark. Any formula which is in CNF is also in NNF.

    37

  • 8/12/2019 Logic for Cs Notes

    38/61

    Normal Form Transformations

    Summary: Normal FormsNormal Form Transformations

    So far, we have seen thatany formula can be transformed into its NNF equivalent...

    ... and we dened DNF, CNF,

    the question now is how to transform the formula from NNF into DNF(or CNF),

    and if we can do that, what does that tell us?

    for once, if two formulae have the same normal form, they are equivalent,

    ... but, does it help in detecting tautologies, satisable formulae, unsatis-able formulae?

    and is it better than truth tables?

    DNF TransformationsDNF Transformation via Truth Tables

    Given a formula, one method to obtain a DNF equivalent formula is throughtruth tables, by:

    selecting all the rows that evaluate to T ,

    for each such row, constuct a conjunct of literals in the following way:positive literals for corresponding T values for the propositional variable,and negative literals otherwise.

    the DNF is the disjunctions of all these conjunctions.

    Example 38. DNF from truth tables

    P Q P QT T T

    T F F

    F T T

    F F T

    The corresponding equivalent DNF formula:(P Q ) (P Q ) (P Q ).

    Remark. in the above example, the DNF equivalent form is quite different from the

    well-known equivalent ( P Q ),

    in general, getting the DNF from the truth table is expensive: one has toconstruct the truth tables.

    38

  • 8/12/2019 Logic for Cs Notes

    39/61

    DNF Transformation

    Transformation to DNFAn arbitrary propositional formula can be transformed in an equivalent DNFby carrying out the following steps:

    bring the formula into NNF;

    repeatedly apply the tautologies:

    F (G H ) (F G) (F H ),

    (F G) H (F H ) (G H ),

    starting with the outermost , until the normal form is reached.

    Example 39 (DNF transformation) . Transform the following formula into itsDNF:

    (F (G H )) (F G).

    The formula is already in NNF.

    (F (G H )) distr

    (F G ) ((( F (G H ))

    distrF ) ((F (G H ))

    distrG ))

    ((( F G ) (F H )) distr

    F ) ((F G ) (F H )) distr

    G )) ((( F G F )

    ann(F H F ))

    ann((F G G )

    ann(F H G )))

    ( (F H G)) (F H G).

    Remark. In the above, distr , ann indicate the place where the distributive law(of over ) and the annihilation law (for ) were applied, respectively, ateach step.

    When transforming a formula into its DNF equivalent, it is a good idea toperform, after each transformation, checks for:

    contradictions within conjunctions:

    if both a subformula and its negation show up in the same conjunc-tion, then the conjunction is a contradiction (i.e. equivalent to ),

    since P P , contradictions can be discarded;

    subsumption :

    since (F G ) F (F F ) (G F ) F (G F ), we see that if F is true then the initial formula is true, and if F is false then the initialformula is false (read evaluated to false under some interpretation),i.e. the truth value of G plays no part in the result of the evaluation,

    therefore, in fact ( F G ) F F ,

    39

  • 8/12/2019 Logic for Cs Notes

    40/61

    therefore, ( F G) can be safely removed from the disjunct (we saythat ( F G ) is subsumed by F ),

    due to the associativity of this can be generalized (i.e. F and Gcan stand in for conjunctions of literals).

    Example 40 (DNF transformation, with contradiction checking.) . Transform thefollowing formula into its DNF:

    (F (G H )) (F G).

    (F (G H )) distr

    (F G ) ((( F (G H )) F )

    assoc and ann((F (G H ))

    distrG ))

    ((F G ) (F H )) distr

    G )) ((F G G )

    ann(F H G )))

    (F H G ).Remark. Note that applying after each transformation a check for contradic-tion (i.e. looking to apply the annihilation law for ) can lead to much shorterderivations.

    DNF and satisability

    Given a formula in DNF, the formula is satisable precisely if one of itsdisjuncts is satisable,

    a DNF disjunct (which is a conjunction) is satisable precisely if it doesnot contain complementary literals,

    therefore, transformation into DNF represents a method to establish sat-isablity of propositional formulae,

    however, in general, DNF does not offer a simple way to establish validity.

    CNF TransformationCNF Transformation

    Transformation to CNFAn arbitrary propositional formula can be transformed in an equivalent DNFby carrying out the following steps:

    bring the formula into NNF;

    repeatedly apply the tautologies:

    F (G H ) (F G) (F H ),

    (F G) H (F H ) (G H ),starting with the outermost , until the normal form is reached.

    40

  • 8/12/2019 Logic for Cs Notes

    41/61

    When transforming into CNF, one should check at each step for valid con- juncts , i.e. disjunctions that contain complementary subformulae. Remark.DNF and CNF transformations are similarExample 41 (CNF transformation) . Transform the following formula into itsCNF:

    (F (G H )) (F G).The formula is already in NNF.

    (F (G H )) distr

    (F G ) ((( F (G H )) F )

    assoc and ann((F (G H ))

    distrG ))

    ((F G ) (F H )) distr

    G )) ((F G G )

    ann(F H G )))

    (F H G ).

    CNF and validity

    Given a formula in CNF, the formula is valid iff each conjunct is valid,

    i.e. each disjunction contains complementary literals.

    If discarding of valid conjuncts is performed, then a formula is valid iff itsCNF equivalent is .

    However, in general, it is not easy to establish satisability, given a CNFformula.

    In fact, the SAT problem (boolean satisability problem) is formulated asthe decision whether a CNF formula is satisable,

    and SAT is the rst problem proved to be NP complete (see [Gallier, 2003],pp. 5054 for a discussion on NP and SAT).

    DNF and CNF: Sharing Transformations

    due to the De Morgan laws, the CNF of a formula can be obtained directlyfrom the DNF of its negation, by switching s for s, and complement-ing the literals (i.e. positive literals become negative, and vice-versa).

    this allows sharing code for the normal form transformations, if these areimplemented on a computer.

    Start with a formula, and its negation,

    bring them both to equivalent NNF,

    then transform them both to DNF,

    and nally, ip the s and s in the DNF of the negation, and thencomplement the literals.

    41

  • 8/12/2019 Logic for Cs Notes

    42/61

    11.4 Logical Consequence

    We are interested in showing whether some statement follows from some otherstatements.

    Denition 42 (Propositional Logical Consequence) . Let F 1 , . . . , F n , G be propo-sitional formuale. G is a (propositional) logical consequence of F 1 , . . . , F n iff, forall truth valuations (interpretations) T , if F 1 T = . . . = F n T = T , thenG T = T .

    Example 43. Let F and G be propositional formulae. Then G is a propositionalconsequence of F and F G .

    F G F GT T T

    T F F

    F T T

    F F T

    Deduction Theorem

    Theorem 44 (deduction theorem for propositional logic) . Let F 1 , . . . , F n , Gbe propositional formulae. G is a propositional consequence of F 1 , . . . , F n iff ((F 1 . . . F n ) G ) is valid.

    Proof. (the direct implication).To prove the implication,

    assume G is a logical consequence of F 1 , . . . , F n , andshow ((F 1 . . . F n ) G ) is valid, i.e. show that for every truth valuation

    T ,

    ((F 1 . . . F n ) G) T = T .For this, take T 0 arbitrary but xed truth valuation, and show

    ((F 1 . . . F n ) G ) T 0 = T .

    By the denition of truth value under truth valuation,

    ((F 1 . . . F n ) G) T 0 =B ( (F 1 . . . F n ) T 0 , G T 0 ) =B (B ( F 1 T 0 , . . . , F n T 0 ), G T 0 ),

    i.e. we have to show

    B (B ( F 1 T 0 , . . . , F n T 0 ), G T 0 ) = T . ( )

    Two cases are possible:

    Case: F 1 T 0 = . . . = F n T 0 = T .Since G is a logical consequence of F 1 , . . . , F n , G T 0 = T , andB ( F 1 T 0 , . . . , F n T 0 ) = T , therefore ( ) holds (B (T , T ) = T ).

    42

  • 8/12/2019 Logic for Cs Notes

    43/61

    Case: not ( F 1 T 0 = . . . = F n T 0 = T ).B ( F

    1T

    0, . . . , F n T

    0) = F , therefore ( ) holds (B (F , G T

    0) = T ).

    Proof. (the inverse implication).To prove the implication,

    assume (( F 1 . . . F n ) G ) is valid, andshow G is a propositional logical consequence of F 1 , . . . , F n .

    For this, take an arbitrary but xed truth valuation T 0 ,assume F 1 T 0 = . . . = F n T 0 = T , andshow G T 0 = T .

    From the assumption, we have

    ((F 1 . . . F n ) G ) T 0 = T .

    But ((F 1 . . . F n ) G ) T 0 =B ( (F 1 . . . F n ) T 0 , G T 0 ) =B (B ( F 1 T 0 , . . . , F n T 0 ), G T 0 ) =B (B (T , . . . , T ), G T 0 ) =B (T , G T 0 ),

    therefore, B (T , G T 0 ) = T .By the denition of B this means G T 0 = T .

    Theorem 45 (alternative characterization of propositional consequences) . Let F 1 , . . . , F n , G be propositional formulae. G is a propositional consequence of F 1 , . . . , F n iff (F 1 . . . F n G ) is inconsistent.

    Proof. Exercise.

    The signicance of the Deduction Theorem

    the deduction theorem is signicant, in that it tells:

    that any logic equivalence in propositional logic can be decided bydeciding the validity of a formula, for example by using reasoning (i.e.manipulation of formulae); this aspect represents the completenessof propositional logic .

    if a method for reasoning establishes the validity of a certain for-mula, then we have logical consequence: this is the correctness of

    propositional logic . the alternative characterization tells us that deciding logical consequence

    can also be done by establishing inconsistancy (unsatisability),e.g. byreasoning (i.e. manipulation of formulae).

    all we need is a method to do reasoning in propositional logic.

    43

  • 8/12/2019 Logic for Cs Notes

    44/61

    12 The Resolution Method in Propositional Logic

    12.1 Clause Form of Propositional FormulaeClause Form of Formulae

    Propositional resolution is a method for deciding the satisability of propo-sitions or whether a proposition is a logical consequence of a set of others.

    Propositional resolution works on representation of formulae, called clauseforms, which are equivalent to CNF.

    Denition 46 (Propositional Clause Set) .

    K is a propositional clause set iff K is a set of propositional clauses.

    C is a propositional clause iff C is a nite set of propositional literals.

    L is a propositional literal iff L is an atom, or the negation of an atom.

    Example 47 (Propositional Clause Set) . K = {C 1 , C 2 , C 3}, where

    C 1 = {F 1 , F 2}, C 2 = {F 2}, C 3 = {F 1 , F 2 , F 3}.

    Notation. Let K, C be a propositional clause set, propositional clause, re-spectively. We denote K , C , the propositional formula detedmined by K, C respectively.

    Denition 48 (Formula Determined by a Clause Set) .

    If C = {L 1 , . . . , L m } is a propositional clause, then C = L 1 . . . L m .

    If K = {C 1 , . . . , C n } is a propositional clause set then K = C 1 . . . C n .

    Remark. The denition above introduces formulae that are not uniquely de-ned (because elements in sets are not ordered). However, these are uniquemodulo the equivalence of formulae. We want to identify clauses that containthe same literals, in possibly different order, and possibly different number of occurences.Example 49 (Formula determined by a clause set) .

    Let K = {C 1 , C 2 , C 3}, where C 1 = {F 1 , F 2}, C 2 = {F 2},C 3 = {F 1 , F 2 , F 3}.

    K = C 1 C 2 C 3 = ( F 1 F 2) (F 2) (F 1 F 2 F 3).

    Example 50 (Particular clause sets and their corresponding formulae) .

    {} i.e. the empty clause set is a clause set (the set containing a nitenumber of clauses, 0),

    {{}}, i.e. { } is a clause set (the set containing one empty clause).Since no propositional variable occurs in these clause sets, the correspond-ing formulae should be chosen from those propositions that do not containany variables, i.e. , . The question is how to make the assignment (seebelow, propositional resolution method).

    44

  • 8/12/2019 Logic for Cs Notes

    45/61

    Clause Set Corresponding to a Propositional Formula

    From any formula, we can obtain, in a natural way, its clause set form,by transforming it into CNF, and reading the clauses directly from thedisjuncts.

    The clause set determined by a set of formulae can be obtained by unionof the clause sets corresponding to each formula.

    Properties of propositions extend in a natural way to their clause setform: a clause set is satisable (valid, inconsistent), iff the propositiondetermined by the clause set is satisable (valid, inconsistent).

    12.2 Propositional ResolutionCorrectness of a Propositional Resolution Step

    Lemma 51 (Correctness of a propositional resolution step) . Let B1 , B 2 , C be propositional formulae. Then B1 B 2 is a propositional consequence of C B 1and C B 2 .

    Proof. Let T be an arbitrary thruth valuation such that

    C B 1 T = T , (1) C B 2 T = T . (2)

    Case B 1 T = T , then B 1 B 2 T = T .

    Case B 1 T = F , then, from (1), C T = T ,i.e. C T = F , i.e. B 2 T = T(from (2)),i.e. B 1 B 2 T = T .

    Propositional Resolvents

    Denition 52 (Complementary literals) . Two propositional literals L 1 , L 2 arecomplementary iff L 1 is an atom and L 2 is its negation (or viceversa).

    Denition 53 (Propositional resolvent) . Let C = {L 1 , . . . , L m }, C = {L 1 , . . . , L m }be two propositional clauses such that L 1 , L 1 are complementary literals. ThenC is a propositional resolvent of C and C iff

    C = {L 2 , . . . , L m , L 2 , . . . , L m }.

    Example 54 (Propositional resolvent) . {F 2 , F 3} is a propositional resolvent (infact the only propositional resolvent) of {F 1 , F 2} and {F 1 , F 3}.

    45

  • 8/12/2019 Logic for Cs Notes

    46/61

    Propositional Resolution

    Theorem 55 (Propositional Resolution Method) . Consider the following prob-lem:

    Given: K, a propositional clause set,

    Question: Is K satisable?

    This problem can be solved by the following algorithm:

    Propositional resolution

    K := K

    while exists C such that

    C is a propositional resolvent of two clauses in K and C K

    do

    if C = then answer: Not Satisable

    else K := K {C}

    answer: Satisable.

    Proof Sketch. We have to show:

    1. The algorithm terminates;

    2. If the algorithm terminates with the answer Not Satisable, then K isnot satisable;

    3. If the algorithm terminates with the answer Satisable, then K is sat-isable.

    1. TerminationThe algorithm terminates because from nitely many literals occuring in the

    initial clause K one can form only nitely many clauses.(If there are n distinct variables in K, then at most 4 n many clauses - in-

    cluding many redundant ones - can be formed (why?)).

    2. Answer Not Satisable.

    This answer is produced only when the clause is generated by a resol-vent.

    This clause can only be generated by clauses of the form {L }, {L }, wherethe literals L , L are complementary.

    By the lemma of the correctness of a propositional resolution step, eachclause produced by the application of the algorithm is a propositionalconsequence of K.

    46

  • 8/12/2019 Logic for Cs Notes

    47/61

    Hence {L }, {L } are propositional consequences of K. Therefore, if atruth valuation T satised K, then it would satisfy both L , L . This is acontradiction to the fact that L , L are complementary.

    Remark. Returning to the question of formulae attached to the empty clauseset and the empty clause, it is now clear, from the algorithm that

    the formula corresponding to {} (the empty clause set) is ,

    the formula corresponding to {{}} (the clause set containing the emptyset) is .

    3. Answer Satisable.

    Idea: if the answer is Satisable, one can construct a satisfying truthvaluation for K from the nal clause set,

    start with the shortest clauses, construct for them a partial satisfyingtruth valuation, then propagate the truth valuation towards K. (seeExamples, satisable case).

    Propositional Resolution: Examples

    Example 56. Decide by resolution whether the following set of formulae is sat-isable, and if it is, construct a satisfying truth valuation:

    (a)

    (1) F

    1 F

    2 ,(2) F 1 F 3 ,(3) F 1 F 3 ,(4) F 1 F 2 ,(5) F 3 F 2 ,(6) F 3 F 2 .

    Solution: See [Buchberger, 1991], pag. 66, Example 2.84. (Note that thereis no transformation into clause form there. However the transformationmakes a potential implementation easier: it is easier to operate on setsthan to operate on formulae).

    (b)(1) F 1 F 2 ,(2) F 2 ,(3) F 1 F 2 F 3 .

    Solution: See [Buchberger, 1991], pag. 67, Example 2.85. (Again notransformation. However, the corresponding clause set formulation shouldnot be hard to see).

    47

  • 8/12/2019 Logic for Cs Notes

    48/61

  • 8/12/2019 Logic for Cs Notes

    49/61

    I. the 1-literal rule (unit propagation):

    if a single literal L appears in a clause set, remove any instances of L from the other clauses of K; remove any instances of clauses containing L, including the clause

    itself,

    II. the pure literal rule: If a literal occurs only positively or negatively in theclause set, delete all clauses containing it;

    III. resolution: on the remaining clauses, apply propositional resolution.

    DP returns the answer Satisable when none of the rules can be applied,and Not Satisable when the empty clause is generated.Example 58 (revisited) . Solution by DP:

    The clause set:(1) {F 1 , F 2},(2) {F 1 , F 3},(3) {F 2 , F 3},(4) {F 1 , F 2},(5) {F 2 , F 3},(6) {F 1 , F 3}.

    Rule I and II are not applicable, do resolution, and check after each stepwhether I, II are applicable

    (7) {F 2 , F 2} from (1) and (4), tautology!(8) {F 1 , F 3} from (1) and (5), I, II not applicable(9) {F 2 , F 3} from (1) and (6), I, II not applicable(10) {F 1} from (2) and (8), I. applicable!!!

    Apply I (unit propagation) with {F 1}:

    erase F 1 from (4),(6); delete (1), (2), (8), (10).

    The clause set becomes:

    (3) {F 2 , F 3},(4) {F 2},(5) {F 2 , F 3},(6) {F 3},(9) {F 2 , F 3}.

    Rule I (unit propagation) is applicable with {F 2}:

    erase F 2 from (3), (9);

    49

  • 8/12/2019 Logic for Cs Notes

    50/61

    delete (4), (5),

    The clause set becomes:(3) {F 3},(6) {F 3},(9) {F 3}.

    Rule I (unit propagation) is applicable with {F 3}:

    erase F 3 from (6), (9) STOP, these both become {}, i.e. ,

    Answer: Not Satisable.

    Improvements of Resolution: Davis Putnam Logemann Loveland

    Davis Putnam Logemann Loveland method - DPLL (1962)DP could (and it used to) run out of memory. DPLL replaces resolution withthe splitting rule

    I. the 1-literal rule (unit propagation):

    if a single literal L appears in a clause set, remove any instances of L from the other clauses of K;

    remove any instances of clauses containing L, including the clauseitself,

    II. the pure literal rule: If a literal occurs only positively or negatively in theclause set, delete all clauses containing it;

    III. splitting: The satisability of K (the current set of clauses, when I. andII. are no longer applicable) is reduced to the satisability of K { L}, K{L}, where L is a literal from K (K is satisable exactly if one of thetwo is).

    DPLL returns the answer Not Satisable when for all subproblems gen-erated by applications of the splitting rule, the empty clause is generated.It returns the answer Satisable if at least for one of the subproblems gener-ated by the splitting rule no rules are applicable. This, in fact, amounts to thesituation when the empty clause set is generated, i.e. no clauses are left. Thisalways happens, as the splitting rule can be applied as long as there are clausesleft in the clause set. Therefore: Attention!!! . The empty clause set gives theanswer Satisable, whereas the empty clause gives the answer Unsatisable(if it is generated for all subproblems).Example 59 (revisited, again) . Solution by DPLL:

    50

  • 8/12/2019 Logic for Cs Notes

    51/61

    The clause set:(1) {F 1 , F 2},(2) {F 1 , F 3},(3) {F 2 , F 3},(4) {F 1 , F 2},(5) {F 2 , F 3},(6) {F 1 , F 3}.

    Since none of the rules I and II are applicable, we apply III (splitting)using F 1 :

    adding (7) {F 1} to the clause set: unit propagation (I) is applicable with F 1 : delete F 1 from (4),(6), then delete clauses (1), (2), (7): the clause set becomes :

    (3) {F 2 , F 3},(4) {F 2},(5) {F 2 , F 3},(6) {F 3},

    apply (I) with F 2 , delete F 2 from (3), delete clauses (4),(5),yieding

    (3) {F 3},(6) {F 3}.

    a last application of (I) yields . Answer: Not Satisable. adding (7) {F 1} to the clause set: Exercise (it will also yield the

    empty clause ( ) not surprisingly).

    Comparing DP, DPLL to resolution

    All the methods return the answer Not Satisable when an empty clause( ) is generated;

    The empty clause ( ) is generated in the case of DP, DPLL by the 1-literalrule;

    As opposed to the method presented for resolution, DP and DPLL do notkeep the initial clause set, rules I (1-literal), II (pure literal) have as aneffect the deletion of clauses.

    DP, DPLL return the answer Satisable iff none of the rules are appli-cable. (In particular, DPLL will be applied as long as there are literals).

    For each of the methods, choice plays an important role: for resolution,which clauses to be resolved, for DP, DPLL which literal clause should bepropagated. A good choice will make the algorithm produce an answerquicly. Bad choices will lead to very lengthy executions (and possiblymemory consuming, for instance for DP).

    51

  • 8/12/2019 Logic for Cs Notes

    52/61

  • 8/12/2019 Logic for Cs Notes

    53/61

    The formula corresponding to f is:

    F = ( A1 A2 A3 ) (A1 A2 A3 ) (A1 A2 A3 ) ( A1 A2 A3 ).

    13.2 Complete Set of Boolean OperatorsComplete Set of Boolean Operators

    DNF, CNF show us that we can transform any propositional formula intoequivalent forms expressed only in terms of { , , } ;

    in fact, due to De Morgans rules, we can do better: any formula can beexpressed only in terms of { , } , or only in terms of { , } ;

    these are called complete sets of boolean operators (since they are sufficientto express any formula);

    another example of complete set of boolean operators is {, } (exercise!);

    can we do better?

    other complete sets of boolean connectives: {|} (NAND), { } (NOR),where, for all formulae F, G :

    F |G = (F G ),F G = (F G ).

    13.3 Digital Circuit DesignCombinatorial Digital Circuits

    digital circuits are elctronic circuits whose inputs and outputs are electricsignals (different voltage levels, usually 2);

    combinatorial digital circuits are digital circuits whose output is deter-mined solely by the values of their inputs;

    examples of combinatorial digital circuits: arithmetic-logical operations,memory addressing;

    boolean values can be used to express these voltage levels ( T - high voltage,F - low voltage);

    therefore, digital circuits can be represented as boolean functions;

    a circuit is given by a circuit diagram which is described as a collection of gates and their interconnections;

    each gate is a boolean function of its inputs;

    each circuit (diagram) can be represented as a propositional formula;

    53

  • 8/12/2019 Logic for Cs Notes

    54/61

  • 8/12/2019 Logic for Cs Notes

    55/61

  • 8/12/2019 Logic for Cs Notes

    56/61

    Figure 5: Circuit simplication.

    for circuit transformation (equivalence transformations): start with theDNF form from the specication, then transform the circuit to one usingonly one type of gate;

    for correctness of circuits (show that a fast circuit, e.g. with signicantlyfewer gates, is equivalent to one that is known to be correct, e.g. one that

    is obtained from a DNF directly from specication - use resolution, DP,DPLL);

    circuits today are integrated on chips on a very large scale (hundreds of millions of transistors on a modern CPU, i.e. same class of magnitude forthe number of gates), therefore efficient implementations of propositionallogic reasoning methods are essential.

    14 Propositional Logic: Deduction in NaturalStyle

    14.1 SummarySummary

    Let F 1 , . . . , F n , G be propositions.

    We introduced the syntax of propositional logic (wffs);

    We introduced the semantics of propositional logic, i.e. the meaning of proposition:

    truth valuation, truth value under truth valuation, valid formulae, consistent/satisable formulae,

    inconsistent (unsatisable) formulae;

    We are interested in establishing:

    whether propositional formulae are logical equivalent,

    56

  • 8/12/2019 Logic for Cs Notes

    57/61

    whether some formula is a logical consequence of other formulae

    Notation.Let F 1 , . . . , F n , G be propositional formulae. We denote the fact thatG is a logical consequence of F 1 , . . . , F n by F 1 , . . . , F n G .

    Recall: Reasoning

    The purpose of reasoning is to derive new, true statements from given(true) ones, i.e.

    F 1 , . . . , F n G .

    axioms initial statements considered to be true, theorems statements that are derived from true statements (theorems

    or axioms), by carrying out reasoning steps, i.e. manipulation of formulae;

    Recall, reasoning must be:

    abstract [only operations on syntactic constructs (formulae)], veriable [small steps], correct [soundness of the rules], general [complete, for the universe of discourse].

    Reasoning by Resolution

    Deduction theorem: F 1 , . . . , F n G iff (F 1 . . . F n ) G is valid;

    Corollary: F 1 , . . . , F n G iff F 1 . . . F n G is inconsistent;

    But resolution can decide inconsistency, and resolution (and related meth-ods) is reasoning (abstract, veriable, correct, general);

    However, although resolution is suitable for implementation on computers,it is hard for (untrained) humans to understand, and perhaps not intuitive;

    In the following we illustrate (in an informal manner) how reasoning inpropositional logic can be done in a manner familiar to the humans, i.e.in natural style.

    Propositional Calculi

    A calculus is a logical system which is used to prove valid formulae (the-orems);

    A calculus consists of:

    a set of axioms (empty, nite, innite);

    57

  • 8/12/2019 Logic for Cs Notes

    58/61

    inference rules;

    NotationWe denote by F 1 , . . . , F n G the fact that G is inferred from F 1 , . . . , F n .

    Completeness: everything that is true can be proved in the calculus, i.e.if K G then K G ;

    Soundness: reasoning steps are correct, i.e. if something is derived usingthe inference rules, then it is true, i.e. if K G then K G ,

    where K is the current knowledge base (axioms + theorems), and G is thegoal.

    14.2 A Hilbert-style Propositional Calculus

    A Hilbert-style Propositional Calculus: Natural Deduction no axioms (empty axiom set);

    derivations (proofs): lists of numbered lines, with a single wff and a justi-cation on each line; premises are placed at the top, with a p indicating this(instead of a justication), the goal being the last ;

    inference rules ( F,G,H any propositional formulae):

    1. ( E): From F , infer F ;2. ( I): From F and G , infer F G ;3. ( E): From ( F G ), infer F and G ;4. ( I): From F , infer (F G ) and ( G F );

    5. ( E): From ( F G ), (F H ) and ( G H ), infer H ;6. ( I): From ( F G ) and ( G F ), infer ( F G );7. ( E): From ( F G ), infer ( F G ) and ( G F );8. Modus Ponens (MP): From F and ( F G ), infer G ;9. Conditional Proof: If G can be derived while assuming F , infer ( F G );

    10. Reductio Ab Absurdum: If we can derive both G, G while assuming F ,infer F .

    Example 66. Prove F F .

    Proof.

    (1) F p,(2) F F from (1) by I,(3) (F F ) F from (1) and (2) by I,(4) F from (3) by conjunction elimination,(5) F F summary (1) through (4),(6) F F from (5) by conditional proof,

    58

  • 8/12/2019 Logic for Cs Notes

    59/61

    14.3 A Gentzen-style Propositional Calculus (Informal)

    A Gentzen-style Propositional Calculus

    In Gentzen-style calculi, proving is stepwise arranging of proof situa-tions;

    A proof situation consist of the current knowledge base and a sentence,goal, that should be proven;

    The proof is complete, when we arrive at a point where the proof situationis trivial, i.e. the goal occurs in the knowledge base;

    We give here an informal description of such a calculus.

    We follow [Buchberger, 1991], and we will extend this for predicate logic.

    Four Basic Approaches for ProvingTo prove a sentence A , do the following:

    Try to prove A. If successful, be happy. Otherwise:

    Assume A and try to derive a contradiction. If successful, be happy ( Ais proved). Otherwise:

    Try to prove A. If successful, be happy (you have a result). Otherwise:

    Assume A and try to derive a contradiction. If successful, be happy ( Ais proved). Otherwise:

    Repeat: try to prove A (by now more insight into the problem is accumu-lated, chances of success are higher).

    Basic Proof Rules

    Prove A B : For proving A B , prove A and prove B ;

    Use A B : If we know A B , we know A and we know B ;

    Prove A B : To prove A B , assume A and prove B (or assume Band prove A );

    Use A B : If A B is known, and we have to prove C , assume A andprove C , then assume B and prove C (prove by cases, case A, and caseB );

    Prove A B : For proving A B , assume A , and prove B .

    Use A B : As a general strategy, if B has to be proved, look for sentencesof the kind A B and prove A .

    59

  • 8/12/2019 Logic for Cs Notes

    60/61

    Prove A B : For proving A B , assume A and prove B , then assumeB and prove A ;

    Use A B : In a situation where C [A] has to be proved, it may be helpfulto look for sentences of the kind A B and try to prove C [B ] (Notation:C [A] means A is a subformula in C )

    Example 67 (Revisited) . Prove F F .

    Proof. To prove F F ,Assume F ,and prove F .Since we already know F , we are done.

    60

  • 8/12/2019 Logic for Cs Notes

    61/61

    References

    [Buchberger, 1991] Bruno Buchberger, Logic for Computer Science,Unpublished Lecture Notes, Copyright Bruno Buchberger, 1991.

    [Gallier, 2003] Jean H. Gallier, Logic for Computer Science, Foundations of Automatic Theorem Proving Copyright 2003, Jean H. Gallier.

    [Kleinberg, Tardos 2006] Jon Kleinberg, Eva Tardos, Algorithm Design PearsonInternational, Inc., ISBN 0-321-37291-3, 2006.

    [Manna, Waldinger 1985] Zohar Manna, Richard Waldinger, The Logical Basisfor Computer Programming, Volume I Deductive Reasoning, Addison-Wesley Publishing Company, Inc., ISBN 0-201-18260-2 (v.1), 1985.

    [Shannon, 1938] Claude Elwood Shannon, A Symbolic Analysis of Relay and

    Switching Circuits, Transactions American Institute of Electrical Engi-neers, Vol. 57 (1938), pp. 713-723. (Received March 1, 1938.)

    [Tanenbaum, 1999] Andrew S. Tanenbaum, Structured Computer Organization(Fourth Edition), Prentice Hall International, ISBN 0-13-020435-8, 1999.