Evaluation Trees for Proposition Algebra

Similar documents
Propositional Calculus: Boolean Algebra and Simplification. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

CSC Discrete Math I, Spring Sets

Propositional Calculus. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

SAT-CNF Is N P-complete

CS 6110 S14 Lecture 38 Abstract Interpretation 30 April 2014

Propositional Calculus. Math Foundations of Computer Science

BOOLEAN ALGEBRA AND CIRCUITS

Software Engineering Lecture Notes

COMP combinational logic 1 Jan. 18, 2016

2. BOOLEAN ALGEBRA 2.1 INTRODUCTION

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages

3.4 Deduction and Evaluation: Tools Conditional-Equational Logic

3. According to universal addressing, what is the address of vertex d? 4. According to universal addressing, what is the address of vertex f?

Formal Methods of Software Design, Eric Hehner, segment 1 page 1 out of 5

Mathematical Logic Prof. Arindama Singh Department of Mathematics Indian Institute of Technology, Madras. Lecture - 9 Normal Forms

Introduction to Boolean Algebra

TA: Jade Cheng ICS 241 Recitation Lecture Notes #12 November 13, 2009

Introduction to Boolean Algebra

[Ch 6] Set Theory. 1. Basic Concepts and Definitions. 400 lecture note #4. 1) Basics

Safe Stratified Datalog With Integer Order Does not Have Syntax

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Sections p.

Lecture 5. Logic I. Statement Logic

An Evolution of Mathematical Tools

Lower Bounds for Cutting Planes (Extended Abstract)

Foundations of AI. 9. Predicate Logic. Syntax and Semantics, Normal Forms, Herbrand Expansion, Resolution

Hoare Logic. COMP2600 Formal Methods for Software Engineering. Rajeev Goré

CSE 20 DISCRETE MATH. Fall

STABILITY AND PARADOX IN ALGORITHMIC LOGIC

Towards a Logical Reconstruction of Relational Database Theory

Deductive Methods, Bounded Model Checking

Programming Methods. Part 4 4 November Alban Ponse. Programming Research Group Faculty of Science University of Amsterdam

arxiv: v1 [cs.pl] 26 Sep 2008

Formal Systems and their Applications

Propositional Calculus. Math Foundations of Computer Science

Logic and its Applications

Review. EECS Components and Design Techniques for Digital Systems. Lec 05 Boolean Logic 9/4-04. Seq. Circuit Behavior. Outline.

Built-in Module BOOL. Lecture Note 01a

Logic and Computation

Propositional Theories are Strongly Equivalent to Logic Programs

Functional Logic Programming: From Theory to Curry

15-819M: Data, Code, Decisions

Discrete Mathematics Lecture 4. Harper Langston New York University

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions):

Integrated Math I. IM1.1.3 Understand and use the distributive, associative, and commutative properties.

Computing Fundamentals 2 Introduction to CafeOBJ

Informatics 1 - Computation & Logic: Tutorial 3

Programming Languages Third Edition

Rigidity, connectivity and graph decompositions

== is a decent equivalence

Chapter 3: Propositional Languages

Binary Decision Diagrams

CS40-S13: Functional Completeness

HOL DEFINING HIGHER ORDER LOGIC LAST TIME ON HOL CONTENT. Slide 3. Slide 1. Slide 4. Slide 2 WHAT IS HIGHER ORDER LOGIC? 2 LAST TIME ON HOL 1

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions):

Handout 9: Imperative Programs and State

Propositional Calculus: Boolean Functions and Expressions. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

2.2 Set Operations. Introduction DEFINITION 1. EXAMPLE 1 The union of the sets {1, 3, 5} and {1, 2, 3} is the set {1, 2, 3, 5}; that is, EXAMPLE 2

The semantics of a programming language is concerned with the meaning of programs, that is, how programs behave when executed on computers.

Mathematically Rigorous Software Design Review of mathematical prerequisites

Basic Elements of Computer Algebra in MIZAR

Permutation Matrices. Permutation Matrices. Permutation Matrices. Permutation Matrices. Isomorphisms of Graphs. 19 Nov 2015

Modal logic of the planar polygons

Derivation of a Pattern-Matching Compiler

Introduction to Computer Architecture

Propositional Logic. Part I

Introduction to Denotational Semantics. Brutus Is An Honorable Man. Class Likes/Dislikes Survey. Dueling Semantics

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Chapter p. 1/27

Introduction to Axiomatic Semantics (1/2)

Semantic Characterizations of XPath

Lecture 2: NP-Completeness

NP-Completeness. Algorithms

VLSI System Design Part II : Logic Synthesis (1) Oct Feb.2007

Overview. CS389L: Automated Logical Reasoning. Lecture 6: First Order Logic Syntax and Semantics. Constants in First-Order Logic.

Propositional Logic. Andreas Klappenecker

Lecture Notes on Ints

Model Checking I Binary Decision Diagrams

Conceptual modeling of entities and relationships using Alloy

Combinational Circuits Digital Logic (Materials taken primarily from:

Diagonalization. The cardinality of a finite set is easy to grasp: {1,3,4} = 3. But what about infinite sets?

CONTENTS Equivalence Classes Partition Intersection of Equivalence Relations Example Example Isomorphis

An Introduction to Programming and Proving in Agda (incomplete draft)

Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 6 Outline. Unary Relational Operations: SELECT and

6. Hoare Logic and Weakest Preconditions

Introduction to Denotational Semantics. Class Likes/Dislikes Survey. Dueling Semantics. Denotational Semantics Learning Goals. You re On Jeopardy!

CSE 20 DISCRETE MATH. Winter

Introduction to Homotopy Type Theory

Propositional Calculus

BDDC v2 A basic bdd-based logical calculator

Mixed Integer Linear Programming

Finite Model Generation for Isabelle/HOL Using a SAT Solver

Definition: A context-free grammar (CFG) is a 4- tuple. variables = nonterminals, terminals, rules = productions,,

Multi-paradigm Declarative Languages

Interpretations and Models. Chapter Axiomatic Systems and Incidence Geometry

CS February 17

The Formal Semantics of Programming Languages An Introduction. Glynn Winskel. The MIT Press Cambridge, Massachusetts London, England

Decision Procedures in the Theory of Bit-Vectors

4&5 Binary Operations and Relations. The Integers. (part I)

CS2104 Prog. Lang. Concepts

Operational Semantics 1 / 13

Inductive Definitions, continued

Transcription:

Evaluation Trees for Proposition Algebra Alban Ponse joined work with Jan A. Bergstra section Theory of Computer Science Informatics Institute, University of Amsterdam https://staff.fnwi.uva.nl/a.ponse/ ERO 60 - September 9, 2015

1. Introduction Short-circuit evaluation (SE) in imperative programming: if ( not(j==0) && (i/j > 17) ) then (..) else (..) Clearly, SE is sequential and && (Logical and) is not commutative... Questions: Q1. For conditions as above: which are the logical laws that characterize SE? Q2. As Q1, but restricting to atoms that evaluate to either true or false (either exclude atoms as (i/j > 17), or require such evalutions) Q3. As Q2, but involving constants T and F for true and false Alban Ponse (TCS, UvA) Evaluation Trees for Proposition Algebra ERO 60 - September 9, 2015 2 / 18

An example that falsifies idempotency of && (programmable in Perl): 1) For program variable i, atom (i==k) with k Z is a test, and 2) Boolean evaluation of assignment (i=e) yields false iff e s value is 0. Then, if i has initial value 2, (i=i+1) && (i==3) evaluates to true, and ((i=i+1) && (i=i+1)) && (i==3) evaluates to false Wrt. Q2 and Q3, some logical laws that are not valid: (equational) Idempotency, thus x && x = x and x x = x, where represents Logical or Distributivity, e.g. x && (y z) = (x && y) (x && z) Absorption, e.g. x && (x y) = x Alban Ponse (TCS, UvA) Evaluation Trees for Proposition Algebra ERO 60 - September 9, 2015 3 / 18

Towards a systematic answer of Q2 and Q3: Involve Hoare s conditional (1985), a ternary connective characterized by P Q R if Q then P else R With the conditional, one can define negation and the (binary) propositional connectives that prescribe SE: x = F x T x && y = y x F x y = T x y Fact: basic equational axioms for the conditional imply x = x (DNS), associativity of the propositional connectives, and De Morgan s laws. Alban Ponse (TCS, UvA) Evaluation Trees for Proposition Algebra ERO 60 - September 9, 2015 4 / 18

2. Evaluation trees CProp(A), Conditional Propositions with atoms in A: P ::= a T F P P P (a A). T A, Evaluation trees over A, provide a simple semantics for CProp(A): X ::= T F X a X (a A). a Pictorial representation: for X a Y X Y Thus: binary trees with leaves in {T, F} and internal nodes in A, e.g. b a F OR (T b F ) a F T F Alban Ponse (TCS, UvA) Evaluation Trees for Proposition Algebra ERO 60 - September 9, 2015 5 / 18

Idea: For (i=i+1) && (i==3), thus for (i==3) (i=i+1) F, an evaluation is a complete path in the evaluation tree (i=i+1) (i==3) F where T F the evaluation starts in the root node (i=i+1), and continues in the left branch if (i=i+1) evaluates to true, and otherwise in the right branch evaluation in the internal node (i==3) proceeds likewise leaves represent the final evaluation value Alban Ponse (TCS, UvA) Evaluation Trees for Proposition Algebra ERO 60 - September 9, 2015 6 / 18

Leaf replacement in X T A, notation X [T Y, F Z ] is defined by T [T Y, F Z ] = Y F [T Y, F Z ] = Z (X 1 a X 2 ) [T Y, F Z ] = a X 1 [T Y, F Z ] X 2 [T Y, F Z ] Alban Ponse (TCS, UvA) Evaluation Trees for Proposition Algebra ERO 60 - September 9, 2015 7 / 18

The short-circuit interpretation function se : CProp(A) T A is defined by se(t ) = T se(f) = F se(a) = T a F se(p Q R) = se(q) [T se(p), F se(r)] Example: se(f a T ) = (T a F ) [T F, F T ] = F a T = F a T Thus, se(f a T ) models the evaluation of a, and we can involve negation by se( P) = se(p) [T F, F T ] Alban Ponse (TCS, UvA) Evaluation Trees for Proposition Algebra ERO 60 - September 9, 2015 8 / 18

CP, a set of axioms for...... (Proposition algebra [BP10]): x T y = x x F y = y T x F = x x (y z u) v = (x y v) z (x u v) Example: CP F (F x T ) T = (F F T ) x (F T T ) = T x F = x and thus with x = F x T we find DNS: x = x. Theorem. CP P = Q se(p) = se(q) Proof. Easy (incl. se-equality is a congruence). Note. se-equality is further called Free valuation congruence (FVC). Alban Ponse (TCS, UvA) Evaluation Trees for Proposition Algebra ERO 60 - September 9, 2015 9 / 18

Evaluation trees for expressions with, &&, and : se( P) = se(p) [T F, F T ] = se(f P T ) se(p && Q) = se(p) [T se(q)] = se(q P F) se(p Q) = se(p) [F se(q)] = se(t P Q) Example: for a, b, c A we find se(a && (b && c)) = se((a && b) && c) = ((T c F) b ) a F FVC-axioms (thus, valid wrt. se-equality) not mentioned before: F = T T && x = x x && T = x F && x = F x && F = x && F (x && F) y = (x T ) && y (x && y) (z && F ) = (x (z && F )) && (y (z && F )) Alban Ponse (TCS, UvA) Evaluation Trees for Proposition Algebra ERO 60 - September 9, 2015 10 / 18

Theorem (Staudt, 2012). Short-circuit logic for Free VC For propositional formulae over A, T, F,, &&,, FVC is axiomatized by the seven axioms listed on the previous slide, and x = x x y = ( x && y) (DNS) (def. of, implying DM s laws) (x && y) && z = x && (y && z) (implying assoc. of ) say E, thus E P = Q se(p) = se(q). Proof. Soundness (incl. congruence property) is easy. Completeness is non-trivial (20 + pages) and depends on: normal forms, decomposition properties of evaluation trees for && and, and the existence of an inverse g of se for normal forms: g(se(p)) = P Alban Ponse (TCS, UvA) Evaluation Trees for Proposition Algebra ERO 60 - September 9, 2015 11 / 18

3. Valuation Congruences FVC (equationally axiomatized by CP) Repetition-proof VC: equationally axiomatized by CP + two axiom schemes over A Contractive VC: equationally axiomatized by CP + two axiom schemes over A Memorizing VC: equationally axiomatized by CP + one axiom typical properties: x && x = x x y z = (y && x) ( y && z) Static VC sequential propositional logic : equationally axiomatized by CP + two axioms These VC s are defined by varieties of Valuation algebra s [BP10]. [BP15]: RpVC MVC also have simple semantics: transformations on evaluation trees (cf. the use of truth tables in Propositional Logic). Alban Ponse (TCS, UvA) Evaluation Trees for Proposition Algebra ERO 60 - September 9, 2015 12 / 18

Contractive VC: Subsequent occurrences of the same atom are contracted; equational axiomatization: CP cr (A) = CP {(x a y) a z = x a z, x a (y a z) = x a z a A} Example: a && (a x) = (T a x) a F = T a F = a se(a && (a P)) and its contracted evaluation tree: a a F cr() T a F T se(p) The transformation cr : T A T A is the contraction function, and recursively traverses the tree. Alban Ponse (TCS, UvA) Evaluation Trees for Proposition Algebra ERO 60 - September 9, 2015 13 / 18

A more concrete example for Contractive VC. Programming with n Boolean registers. For 1 i n consider registers R i with for B {T, F}, the atom (set:i:b) can have a side effect: it sets R i to value B and evaluates in each state to true the atom (eq:i:b) has no side effect and evaluates to true if R i has value B, and otherwise to false Then all instances of CP cr (A) are valid, but not all instances of the stronger equation x && x = x (valid under MVC): Let t = (eq:1:f) && (set:1:t) { t evaluates to true and assume R 1 has initial value F, then t && t evaluates to false Note. Not all valid eq s are derivable, e.g., (eq:1:f) && (eq:1:f) = F. Alban Ponse (TCS, UvA) Evaluation Trees for Proposition Algebra ERO 60 - September 9, 2015 14 / 18

Theorem [BP15, BP10]. CP cr (A) P = Q cr(se(p)) = cr(se(q)) Corollary. Short-circuit logic for Contractive VC For propositional formulae over A, T, F,, &&,, x = F x T, x && y = y x F, CP cr (A) P = Q cr(se(p)) = cr(se(q)) x y = T x y Open question. Does a finite, equational axiomatization of CVC exist without the use of......? (An approach as in [Staudt12] seems not possible.) Note. Wrt. Repetition-proof VC we have a similar Theorem, Corollary, and open question. Alban Ponse (TCS, UvA) Evaluation Trees for Proposition Algebra ERO 60 - September 9, 2015 15 / 18

4. Remarks and conclusions 4.1 Hoare s conditional (1985): Original approach: characterization of Propositional Logic Original definition: P Q R = (P Q) ( Q R) However, wrt. side effects the alternative, intuitive reading P Q R if Q then P else R, is preferable: it suggests/prescribes a sequential, short-circuited interpretation With this intuition AND the naturalness of se() AND the definitions of it is evident that CP is most basic., &&,, Alban Ponse (TCS, UvA) Evaluation Trees for Proposition Algebra ERO 60 - September 9, 2015 16 / 18

4.2 Sequential, propositional connectives: T,, and && (and/or definable counterparts) seem primitive: For example, strict (complete) sequential evaluation of conjunction, notation &, is defined by x & y = (x (y && F)) && y (one more argument to include T (and F) in this setting) BUT, a sequential version of XOR, notation, is defined by x y = y x y and cannot be defined modulo Free, Repetition-proof, or Contractive VC with T,, and && only Hence:...... is a convenient primitive, and the possible side effects of the atoms of interest determine an appropriate VC. Alban Ponse (TCS, UvA) Evaluation Trees for Proposition Algebra ERO 60 - September 9, 2015 17 / 18

4.3 Transformations on Evaluation trees for more identifying VC s: Transformation to a Repetition-proof evaluation tree is natural and simple (cf. [ERO60]); semantics by term rewriting is not easy in this case, e.g. (x a F) a F (x a x) a F Transformation to a Contractive or Memorizing evaluation tree is also N&S (see [BP15]) Transformation to a static evaluation tree is more complicated and requires an ordering of the atoms [Hoare85 + BP15] 4.4 Extensions of...... to many-valued logic s are easily defined (and seq. evaluation often provides good intuitions): E.g., Belnap s 4VL [PZ07], or 5VL [BP99] = Belnap s 4VL + Bochvar s constant M which majorizes all truth values Alban Ponse (TCS, UvA) Evaluation Trees for Proposition Algebra ERO 60 - September 9, 2015 18 / 18