Computational Logic for Computer Science

Similar documents
Formalization of Rewriting in PVS

Applied Logic for Computer Scientists. Answers to Some Exercises

Natural Deduction. Formal Methods in Verification of Computer Systems Jeremy Johnson

Using the Prover I: Lee Pike. June 3, NASA Langley Formal Methods Group Using the Prover I:

Propositional and Predicate Logic - V

Computational Logic. Davide Martinenghi. Spring Free University of Bozen-Bolzano. Computational Logic Davide Martinenghi (1/30)

Introduction to Intuitionistic Logic

185.A09 Advanced Mathematical Logic

Chapter 3: Propositional Calculus: Deductive Systems. September 19, 2008

Propositional Logic: Deductive Proof & Natural Deduction Part 1

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

Automation of Termination: Abstracting Calling Contexts through Matrix-Weighted Graphs

CS 512, Spring 2016, Handout 02 Natural Deduction, and Examples of Natural Deduction, in Propositional Logic

General methods in proof theory for modal logic - Lecture 1

Natural Deduction for Propositional Logic

Learning Goals of CS245 Logic and Computation

Write your own Theorem Prover

Propositional Logic Language

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

The semantics of propositional logic

The Curry-Howard Isomorphism

Propositional Logic: Gentzen System, G

Propositions as Types

Teaching Natural Deduction as a Subversive Activity

Computer-Checked Meta-Logic

Interpolation via translations

LOGIC PROPOSITIONAL REASONING

Between proof theory and model theory Three traditions in logic: Syntactic (formal deduction)

Outline. Overview. Syntax Semantics. Introduction Hilbert Calculus Natural Deduction. 1 Introduction. 2 Language: Syntax and Semantics

Logical Preliminaries

Rules and derivations in an elementary logic course arxiv: v1 [cs.lo] 7 Jan 2016

Evaluation Driven Proof-Search in Natural Deduction Calculi for Intuitionistic Propositional Logic

Consequence Relations and Natural Deduction

NICTA Advanced Course. Theorem Proving Principles, Techniques, Applications

Propositional Calculus - Hilbert system H Moonzoo Kim CS Division of EECS Dept. KAIST

Classical Propositional Logic

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

Sequent calculus for predicate logic

Uniform Schemata for Proof Rules

CHAPTER 10. Gentzen Style Proof Systems for Classical Logic

Mathematical Logic and Linguistics

3 Propositional Logic

Formalising the Completeness Theorem of Classical Propositional Logic in Agda (Proof Pearl)

02 The Axiomatic Method

Propositional and Predicate Logic - XIII

1 Completeness Theorem for Classical Predicate

Introduction to Metalogic

Existence and Consistency in Bounded Arithmetic

Temporal Logic - Soundness and Completeness of L

Chapter 11: Automated Proof Systems (1)

Structuring Logic with Sequent Calculus

Implementing Proof Systems for the Intuitionistic Propositional Logic

Human-Readable Machine-Verifiable Proofs for Teaching Constructive Logic

Model Theory MARIA MANZANO. University of Salamanca, Spain. Translated by RUY J. G. B. DE QUEIROZ

SKETCHY NOTES FOR WEEKS 7 AND 8

On the Complexity of the Reflected Logic of Proofs

Automated Synthesis of Tableau Calculi

Forcing-based cut-elimination for Gentzen-style intuitionistic sequent calculus

Overview. I Review of natural deduction. I Soundness and completeness. I Semantics of propositional formulas. I Soundness proof. I Completeness proof.

Example. Lemma. Proof Sketch. 1 let A be a formula that expresses that node t is reachable from s

On some Metatheorems about FOL

On sequent calculi vs natural deductions in logic and computer science

Intuitionistic Proof Transformations and their Application to Constructive Program Synthesis

The logic of Σ formulas

Propositions and Proofs

The Skolemization of existential quantifiers in intuitionistic logic

Marie Duží

The Calculus of Inductive Constructions

Preuves de logique linéaire sur machine, ENS-Lyon, Dec. 18, 2018

Propositional Logic: Evaluating the Formulas

15414/614 Optional Lecture 1: Propositional Logic

First-Order Logic. 1 Syntax. Domain of Discourse. FO Vocabulary. Terms

Hypersequent Calculi for some Intermediate Logics with Bounded Kripke Models

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

Propositional logic. Programming and Modal Logic

Fundamentals of Software Engineering

cse371/mat371 LOGIC Professor Anita Wasilewska Fall 2018

3.17 Semantic Tableaux for First-Order Logic

Software Engineering using Formal Methods

Propositional Logic. CS 3234: Logic and Formal Systems. Martin Henz and Aquinas Hobor. August 26, Generated on Tuesday 31 August, 2010, 16:54

A Connection Based Proof Method for Intuitionistic Logic

Predicate Logic - Deductive Systems

Propositional Reasoning

Requirements Validation. Content. What the standards say (*) ?? Validation, Verification, Accreditation!! Correctness and completeness

Lecture Notes on Linear Logic

ACLT: Algebra, Categories, Logic in Topology - Grothendieck's generalized topological spaces (toposes)

- Introduction to propositional, predicate and higher order logics

03 Propositional Logic II

Beyond First-Order Logic

Cut-elimination for Provability Logic GL

A Note on Bootstrapping Intuitionistic Bounded Arithmetic

Fundamentals of Software Engineering

TR : Tableaux for the Logic of Proofs

CHAPTER 11. Introduction to Intuitionistic Logic

Agent-Based HOL Reasoning 1

Hoare Logic: Reasoning About Imperative Programs

Propositional Calculus - Deductive Systems

A simple proof that super-consistency implies cut elimination

07 Practical Application of The Axiomatic Method

Lecture Notes on Cut Elimination

Transcription:

Motivation: formalization - proofs & deduction Computational proofs - logic & deduction Formal proofs Pr Computational Logic for Computer Science Mauricio Ayala-Rinco n & Fla vio L.C. de Moura Grupo de Teoria da Computac a o, Universidade de Brası lia (UnB) Brası lia D.F., Brazil Research funded by Brazilian Research Agencies: CNPq, CAPES and FAPDF 11o Semina rio Informal (+ Formal!) GTC/UnB Brası lia, Nov 28th, 29th 2013

Talk s Plan Motivation: formalization - proofs & deduction Computational proofs - logic & deduction Deduction Natural Deduction à la Gentzen Formal proofs Proofs in the Prototype Verification System - PVS Formalizations versus programs A very very simple case study: insertion sort Conclusions and Future Work

Motivation: classic teaching approach Propositional logic Semantic entailment vs deduction - completeness Predicate logic Semantic entailment vs deduction - completeness Undecidability Compactness and Löwenheim-Skolem theorems Resolution The focus on understanding formal logic notions gives no time for a careful analysis of deduction technologies and their usefulness in CS.

Motivation: computational teaching approach Propositional and Predicate logic Semantic entailment vs deduction - completeness Tableaux Sat solvers Resolution Model cheking Formal Verification The focus on teaching a variety of deduction approaches gives no time for assimilating the related technologies - the more..., the less...

Motivation: computational logic for CS Induction and recursion Classical and Intiutionistic Propositional and Predicate logic Semantic entailment vs deduction - completeness Natural deduction vs Gentzen Calculus Program verification with induction and first-order deduction Restricting computational logic to understand deduction and how this is applied in programming languages and program verification increases interest of CS and engineer students.

Computational proofs - logic & deduction Table : Natural deduction for intuitionistic propositonal logic introduction rules ϕ ψ ϕ ψ ( i ) elimination rules ϕ ψ ϕ ( e ) ϕ ϕ ψ ( i ) ϕ ψ [ϕ] u. χ χ [ψ] v. χ ( e ) u, v [ϕ] u. ψ ϕ ψ ( i ) u ϕ ϕ ψ ψ ( e ) [ϕ] u. ϕ ( i ) u ϕ ϕ ( e )

Computational proofs - logic & deduction Table : Natural deduction for classical predicate logic introduction rules ϕ{x/x 0 } ( i ) x ϕ where x 0 cannot occur free in any open assumption. elimination rules [ ϕ] u. (PBC) u ϕ x ϕ ϕ{x/t} ( e ) [ϕ{x/x 0 }] u ϕ{x/t} x ϕ ( i ) x ϕ χ. χ ( e ) u where x 0 cannot occur free in any open assumption on the right and in χ.

Mathematical proofs - logic & deduction Table : Encoding - Rules of natural deduction for classical logic introduction rules [ϕ] u. ϕ ( i), u elimination rules ϕ ϕ ( e) [ϕ] u. ϕ ( i), u ϕ ϕ ( e)

Mathematical proofs - logic & deduction Interchangeable rules: φ φ ( e) φ φ (LEM) [ φ] u. φ (PBC) u

Mathematical proofs - logic & deduction Examples of deductions. Assuming ( e ), (LEM) holds: [ (φ φ)] x [ (φ φ)] x φ φ φ (φ φ) φ φ [φ] u φ φ ( i) ( e ) ( i ) u ( i ) ( e ) ( i ) x ( e ) Notation: φ φ φ

Mathematical proofs - logic & deduction A derivation of Peirce s law, ((φ ψ) φ) φ: [ φ] u x [((φ ψ) φ)] φ [ φ] u ψ φ ( i ) [ ψ] v φ ((φ ψ) φ) φ φ ψ φ ψ ( e ) [φ] w ( e ) (PBC) v ( i ) w ( e ) ( e ) (PBC) u ( i ) x Notation: ((φ ψ) φ) φ

Mathematical proofs - logic & deduction More examples. A derivation for x φ x φ [ φ{x/x 0 }] u ( x φ i ) [ x φ] v ( e ) φ{x/x 0 } (PBC) u ( x φ i ) x φ ( e ) x φ (PBC) v A derivation for x φ x φ x φ [ x φ] v [ φ{x/x 0 }] u φ{x/x 0 } ( e) e x φ ( i) v ( x φ e ) u

Mathematical proofs - logic & deduction More examples. A derivation for x φ x φ [ φ{x/x 0 }] u ( x φ i ) x φ ( e ) φ{x/x 0 } ( i) u ( x φ i ) A derivation for x φ x φ [ x φ ] u x φ φ{x/x 0 } ( e) [ φ{x/x 0 } ] v ( e ) v x φ ( i) u ( e )

Gentzen Calculus sequents: Γ antecedent succedent

Gentzen Calculus Table : Rules of deduction à la Gentzen for predicate logic left rules Axioms: right rules Γ, ϕ ϕ, (Ax), Γ (L ) Structural rules: Γ ϕ, Γ (LW eakening) Γ Γ, ϕ ϕ, ϕ, Γ ϕ, Γ (LContraction) Γ, ϕ, ϕ Γ, ϕ (RW eakening) (RContraction)

Gentzen Calculus Table : Rules of deduction à la Gentzen for predicate logic left rules Logical rules: right rules ϕ i {1,2}, Γ Γ, ϕ Γ, ψ ϕ 1 ϕ 2, Γ (L ) Γ, ϕ ψ (R ) ϕ, Γ ψ, Γ ϕ ψ, Γ (L ) Γ, ϕ i {1,2} Γ, ϕ 1 ϕ 2 (R ) Γ, ϕ ψ, Γ ϕ ψ, Γ (L ) ϕ, Γ, ψ Γ, ϕ ψ (R ) ϕ[x/t], Γ x ϕ, Γ (L ) Γ, ϕ[x/y] Γ, x ϕ (R ), y fv(γ, ) ϕ[x/y], Γ x ϕ, Γ (L ), y fv(γ, ) Γ, ϕ[x/t] Γ, x ϕ (R )

Gentzen Calculus Derivation of the Peirce s law: (RW ) ϕ ϕ (Ax) ϕ ϕ, ψ (R ) ϕ, ϕ ψ ϕ ϕ (Ax) (R ) (ϕ ψ) ϕ ϕ (L ) ((ϕ ψ) ϕ) ϕ

Gentzen Calculus Cut rule: Γ, ϕ ϕ, Γ ΓΓ (Cut)

Gentzen Calculus Example of application of (Cut): (ψ ψ). ψ ψ, (Ax) (R ) ψ, ψ ψ ψ, ψ (R ) ψ ψ, ψ ψ (R ) (RC) ψ ψ (Ax) ψ ψ ψ ψ (L ) (R ) ψ ψ, (ψ ψ) (R ) ψ ψ (ψ ψ) (Cut) (ψ ψ)

The Prototype Verification System - PVS PVS is a verification system, developed by the SRI International Computer Science Laboratory, which consists of 1 a specification language: based on higher-order logic; a type system based on Church s simple theory of types augmented with subtypes and dependent types. 2 an interactive theorem prover: based on Gentzen sequent calculus.

The Prototype Verification System - PVS Libraries NASA LaRC PVS library includes Structures, analysis, algebra, Graphs, Digraphs, real arithmetic, floating point arithmetic, groups, interval arithmetic, linear algebra, measure integration, metric spaces, orders, probability, series, sets, topology, term rewriting systems, unification, etc. etc.

Sequent calculus Sequents of the form: Γ. Interpretation: from Γ one obtains. A 1, A 2,..., A n B 1, B 2,..., B m interpreted as A 1 A 2... A n B 1 B 2... B m. Inference rules Premises and conclusions are simultaneously constructed. Γ Example: Γ Goal:.

Sequent calculus in PVS Representation of A 1, A 2,..., A n B 1, B 2,..., B m : [-1] A 1. [-n] A n ---------- [1] B 1. [n] B n Proof tree: each node is labelled by a sequent. A PVS proof command (R) corresponds to the reverse application of an inference rule. In general: Γ (R) Γ 1 1...Γ n n

Some inference rules in PVS Structural: Γ, Γ, Γ (hide) (W ) Γ, Γ, Γ, Γ, Γ,, (copy) (C) Axioms: Γ, A A, (Ax) (Ax) Γ, FALSE (False ) (L ) Γ TRUE, ; ( True) (L )

Some inference rules in PVS Logical (propositional) rules: Γ, ψ ϕ Γ,, ψ, ϕ (flatten) (R ) ψ ϕ, Γ, ψ, ϕ, Γ (flatten) (L ) Γ, ψ ϕ ψ, Γ, ϕ (flatten) (R )

Some inference rules in PVS Logical (propositional) rules: ψ ϕ, Γ ψ, Γ ϕ, Γ (split) (L ) Γ, ψ ϕ Γ, ψ Γ, ϕ (split) (L ) ψ ϕ, Γ ϕ, Γ Γ, ψ (split) (L )

Some inference rules in PVS Logical (classical) rules: x ψ, Γ ψ[x/t], Γ (inst) (L ) Γ, x ψ Γ, ψ[x/t] (inst) (R ) Γ, x ψ Γ, ψ[x/x 0 ] (skolem) (R ) x ψ, Γ ψ[x/x 0 ], Γ (skolem) (L )

PVS vs Gentzen Rules (flatten) (split) (inst) (skolem) (L ) (R ) (L ) (R ) (L ) (R ) (L ) (R ) (L ) (R )

PVS propositional derivation example Derivation of the Peirce s law: (R ) ϕ ϕ, ψ (Ax) ϕ, ϕ ψ ϕ ϕ (Ax) (ϕ ψ) ϕ ϕ ((ϕ ψ) ϕ) ϕ (R ) (L ) (flatten) ((ϕ ψ) ϕ) ϕ (flatten) (ϕ ψ) ϕ ϕ (split) ϕ, ϕ ψ ϕ ϕ, ψ (Ax) ϕ ϕ (Ax)

Additional rules in PVS Case: Corresponds to the rule (Cut). Conditional: IF-THEN-ELSE. Γ Γ, A Γ A, (Case A ) Γ, A B Γ, A C Γ, IF(A, B, C) (split) Γ, A B Γ, A C Γ IF(A, B, C) (split)

Case Study: insertion sort insert(x : N, l : list[n]) : RECURSIVE list[n] = if null?(l) then cons(x, null) else if x car(l) then cons(x, l) else cons(car(l), insert(x, cdr(l))) end end MEASURE length(l)

Case Study: insertion sort in sort(l : list[n]) : RECURSIVE list[n] = if null?(l) then null else insert(car(l), in sort(cdr(l))) end MEASURE length(l)

Insertion sort correctness insert preserves order : LEMMA (l : list[nat], x : nat) : is sorted?(l) is sorted?(insert(x, l)) insertion sort works : LEMMA (l : list[nat]) : is sorted?(in sort(l)) permutations(l, in sort(l))

Insertion sort correctness formalization The proof is by induction on l. Induction hypothesis (IH): (l, x ) : l < l (is sorted?(l ) is sorted?(insert(x, l )) Sequent: (l, x ) : l < l (is sorted?(l ) is sorted?(insert(x, l )) is sorted?(l) is sorted?(insert(x, l))... two interesting sequents should be proved: null?(l), is sorted?(l), IH is sorted?(l), IH and is sorted?(insert(x, l)) null?(l), is sorted?(insert(x, l))

Insertion sort correctness formalization The former sequent is easily proved. For the latter sequent, insert is expanded obtaining: is sorted?(l), IH null?(l), is sorted?( if x car(l) then cons(x, l) else cons(car(l), insert(x, cdr(l)))) Applying logical commands such as (lift-if) and (prop), that guided an application of the (Cut) rule by the guard x car(l) of the if-then-else command this gives two sequents: x car(l), is sorted?(l), IH null?(l), is sorted?(cons(x, l)) and is sorted?(l), IH null?(l), x car(l), is sorted?(cons(car(l), insert(x, cdr(l))))

Insertion sort correctness formalization The former sequent is easily proved. For the latter one, the IH is used by applying the PVS instantiation command (inst) which corresponds to (L ), obtaining the sequent: is sorted?(l), cdr(l) < l (is sorted?(cdr(l)) is sorted?(insert(x, cdr(l))) null?(l), x car(l) is sorted?(cons(car(l), insert(x, cdr(l))))

Insertion sort correctness formalization By applications of the command (prop), guided applications of (L ) by the premises of the implications in the antecedent, that is, cdr(l) < l and is sorted?(cdr(l)), are done, obtaining the interesting sequent below that follows easily. is sorted?(l), cdr(l) < l, is sorted?(cdr(l)), is sorted?(insert(x, cdr(l))) null?(l), x car(l) is sorted?(cons(car(l), insert(x, cdr(l))))

Conclusions Nowadays, computational logic is intensively applied in formal methods. In computer sciences, a useful training on computational logic should focus on derivation/proof techniques. Understanding proof theory is essential to mastering proof assistants: to provide mathematical proofs of robustness of computational systems and well-accepted quality certificates.

Motivation: formalization - proofs & deduction Computational proofs - logic & deduction Formal proofs Pr Work in Progress Textbook on truly computational logic with concrete applications. M.Ayala-Rinco n & F.L.C.de Moura Applied Logic for Computer Scientists: computational deduction and formal proofs, 2014, UTiCS series, Springer. GTC at the Universidade de Brası lia.