improved computation of clause normal forms in higher ...€¦ · 5.2 pattern matching in scala . ....

32
Bachelor thesis at the Institute of Computer Science Research group Leo-III Improved Computation of CNF in Higher-Order Logics Kim Kern Matriculation number: 4467609 [email protected] Supervisor: PD Dr. Christoph Benzm¨ uller Second examiner: Prof. Dr. Elfriede Fehr Berlin, 19.05.2015 Abstract The computation of clause normal forms (CNF) is an essential pre- processing step in automated reasoning. With effective methods, not only the computation itself, but also its results, can be improved in terms of their complexity, and therefore allow for shorter proofs. Al- though research in first-order contexts has already shown the potential of such techniques, little has been published about this in higher-order logics thus far. This thesis provides a basic implementation of the conjunctive nor- mal form computation in a higher-order context. Therefore, a common first-order approach is examined for possible portability; some combin- able improving techniques are presented as well.

Upload: others

Post on 21-Sep-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Improved Computation of Clause Normal Forms in Higher ...€¦ · 5.2 Pattern Matching in Scala . . . . . . . . . . . . . . . . . . . .19 6 Conclusion 21 7 Appendix 22 Bibliography

Bachelor thesis at the Institute of Computer Science

Research group Leo-III

Improved Computation of CNF

in Higher-Order Logics

Kim KernMatriculation number: 4467609

[email protected]

Supervisor: PD Dr. Christoph Benzmuller

Second examiner: Prof. Dr. Elfriede Fehr

Berlin, 19.05.2015

Abstract

The computation of clause normal forms (CNF) is an essential pre-processing step in automated reasoning. With effective methods, notonly the computation itself, but also its results, can be improved interms of their complexity, and therefore allow for shorter proofs. Al-though research in first-order contexts has already shown the potentialof such techniques, little has been published about this in higher-orderlogics thus far.

This thesis provides a basic implementation of the conjunctive nor-mal form computation in a higher-order context. Therefore, a commonfirst-order approach is examined for possible portability; some combin-able improving techniques are presented as well.

Page 2: Improved Computation of Clause Normal Forms in Higher ...€¦ · 5.2 Pattern Matching in Scala . . . . . . . . . . . . . . . . . . . .19 6 Conclusion 21 7 Appendix 22 Bibliography

Acknowledgment

I’d like to thank my supervisor, Dr. Christoph Benzmueller, and the wholeteam around Leo-III, namely Max Wisniewski and Alexander Steen, for theirgreat support and encouragement.

Declaration of authorship

I hereby certify, that I have written this thesis entirely on my own and thatI have not used any other materials than the ones referred to. This thesisor parts of it have not been submitted for a degree at this or any otheruniversity.

19.05.2015

Kim Kern

Page 3: Improved Computation of Clause Normal Forms in Higher ...€¦ · 5.2 Pattern Matching in Scala . . . . . . . . . . . . . . . . . . . .19 6 Conclusion 21 7 Appendix 22 Bibliography

Contents

1 Introduction 1

1.1 Historical Context . . . . . . . . . . . . . . . . . . . . . . . . 1

1.2 Higher-Order Logics . . . . . . . . . . . . . . . . . . . . . . . 1

1.3 Leo-III . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

1.4 Motivation and Aims of Thesis . . . . . . . . . . . . . . . . . 2

2 Preliminaries 4

3 Standard CNF Algorithm 7

3.1 Simplification . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

3.2 Negation Normal Form . . . . . . . . . . . . . . . . . . . . . . 8

3.3 Miniscoping . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

3.4 Variable Renaming . . . . . . . . . . . . . . . . . . . . . . . . 9

3.5 Skolemization . . . . . . . . . . . . . . . . . . . . . . . . . . 10

3.6 Clause Normal Form . . . . . . . . . . . . . . . . . . . . . . . 10

3.7 Clause Simplification . . . . . . . . . . . . . . . . . . . . . . . 11

4 Techniques for Higher-Order CNF 12

4.1 Context Splitting . . . . . . . . . . . . . . . . . . . . . . . . . 12

4.2 Bounded Argument Depth . . . . . . . . . . . . . . . . . . . . 13

4.3 Quantifier Extraction . . . . . . . . . . . . . . . . . . . . . . . 14

4.4 Formula Renaming . . . . . . . . . . . . . . . . . . . . . . . . 15

5 CNF Implementation in Leo-III 19

5.1 Data structure . . . . . . . . . . . . . . . . . . . . . . . . . . 19

5.2 Pattern Matching in Scala . . . . . . . . . . . . . . . . . . . . 19

6 Conclusion 21

7 Appendix 22

Bibliography 27

List of Tables 29

Page 4: Improved Computation of Clause Normal Forms in Higher ...€¦ · 5.2 Pattern Matching in Scala . . . . . . . . . . . . . . . . . . . .19 6 Conclusion 21 7 Appendix 22 Bibliography

1 Introduction Kim Kern

1 Introduction

1.1 Historical Context

The research of logics goes way back to Ancient Greece with Aristoteles (384-322 BC) and his Syllogisms [AvK08]. The concept of formalizing argumentshas remained present during history and has been utilized by other import-ant philosophers such as Leibniz (1646-1716). Leibniz was following the ideaof the interaction of a formal language (Characteristica universalis) and areasoning system (Calculus ratiocinator) to describe philosophical problemsand then calculate their correctness [Lei65].

This was followed by a milestone for modern logics in 1879, when GottlobFrege (1848-1925) published his work Begriffsschrift [Fre64]. In that Gottlobintroduced the first formalization of a second order (and therefore higher-order) predicate logic. Later Russell’s Paradox (1901) showed that untypedquantification over predicates as in the Begriffsschrift results in inconsisten-cies. But Frege also established the theory of Logicism which fascinated alot of mathematicians and lead to the Principia Mathematica (1910-1913)[WR12] by Alfred Whitehead and Betrand Russell. They pursued the aimto derive all mathematical truths from a logical system, which was laterproven impossible by Kurt Godel’s (1906-1978) famous incompleteness the-orems (1931) [God31]. It was shown that any sufficiently complex systemis either incomplete or unsound, by which the mathematical communityaround David Hilbert (1862-1943) was shaken.

In 1940 Alonzo Church presented his Simple Theory of Types [Chu40], whichis much simpler and more general than Russell’s type theory. Although it isoften referred to as classical higher-order logic [oP15], it was still strugglingwith the incompleteness issue. Leon Henkin’s (1921-2006) research in 1950allowed for the first complete calculus in higher-order logic introducing themore general Henkin semantics [Hen50].

1.2 Higher-Order Logics

As previously mentioned, Russell created a paradox, with that he construc-ted a contradiction by defining a set which both does and does not containitself. So, he could show that the untyped lambda calculus is inconsistentbecause of its expressiveness.

That’s why higher-order logics (HOL) are based on Church’s Simple Theoryof Types [Chu40]. Here not only is the paradox avoided, it’s also guaranteedthat every term has a βη-normal form — a unique representation for a for-mula. The expressiveness is increased through quantification over functions,sets and relations of any types and unnamed functions, sets and relations

1

Page 5: Improved Computation of Clause Normal Forms in Higher ...€¦ · 5.2 Pattern Matching in Scala . . . . . . . . . . . . . . . . . . . .19 6 Conclusion 21 7 Appendix 22 Bibliography

1.3 Leo-III Kim Kern

[BM14]. Therewith, for example, one can express the following conditionwhich is not expressible in a first-order context: “It exists a function withtwo zeros.”, however with the gained expressiveness comes the incomplete-ness of all calculi for full Simple Type Theory in standard semantics [God31].Conversely, the usage of the more general Henkin semantics [Hen50] allowedfor the definition of already several complete calculi.

That’s why this work is developed for higher-order logics with Henkin se-mantics. Additionally, the Axiom of Choice [And72, BM14] is assumed. Thischoice corresponds to the theory framework of the THF0 TPTP language[BRS08, Sut09].

Higher-order logics are used in philosophy (e.g. formal proof for Godel’s on-tological proof [God95]), formal software verification or automated proof val-idation for paper reviews. Also, other logics such as modal logics (e.g. quan-tified conditional logics [Ben13]) — for which no automated provers exist sofar — can be simulated in higher-order logics.

Still research in higher-order logics is not as advanced as for first-order logics,however interesting work has already been published and there is bound tobe more to follow.

1.3 Leo-III

Leo-III1 is an automated proving system for higher-order logics [WSB14].Earlier versions of the Leo HOL prover already had implemented cooperationto external systems, as for example E [Sch04] for first-order proofs in Leo-II[BTPF08]. Also Leo-II was embedded in the proof assistant system ISA-BELLE [NPW02]. Leo-III will now increase the cooperation between proversby implementing massive parallelism (And/Or-Parallelism, Multisearch) witha multi-agent blackboard architecture [Wis14]. With it, other existing proofsystems and the TPTP infrastructure [Sut09] are reused. It also featuresa much more expressive data structure, which supports type polymorphism[Ste14].

1.4 Motivation and Aims of Thesis

A conjunctive normal form or clause normal form (CNF) is a conjunctionof clauses where clauses consist of disjunctions of literals, which can also berepresented as a set of sets of literals. The CNF normalization of a formulais a preprocessing step in automated reasoning to improve the efficiency ofproof finding procedures.

1Leo-III website: http://page.mi.fu-berlin.de/lex/leo3/

2

Page 6: Improved Computation of Clause Normal Forms in Higher ...€¦ · 5.2 Pattern Matching in Scala . . . . . . . . . . . . . . . . . . . .19 6 Conclusion 21 7 Appendix 22 Bibliography

1.4 Motivation and Aims of Thesis Kim Kern

As Peter Andrews points out, the repeated use of the distributive law inthe computation of clause normal forms can cause “wild proliferation ofliterals” [And81]. Hence, optimization techniques must be found to reducethe application of the distributive law and therewith the resulting number ofclauses. Therefore, some existing methods in first-order context are checkedfor possible portability to higher-order logics and new practises are presentedto motivate the various possibilities for improvements.

Although the research on higher-order provers is getting increasingly moresophisticated, still no publications exist on CNF computation in a higher-order context.

The algorithm provided in this thesis has a dominantly modular structure,thus making use of the agent-based framework in Leo-III. Thereby the po-tential parallelization can be applied and single modules can be reused. Fur-thermore, the implementation can be augmented by the usage of flags andalso eventually machine learning concepts to improve the effect by takingdifferent measures such as problem size, domain or structure into account.

3

Page 7: Improved Computation of Clause Normal Forms in Higher ...€¦ · 5.2 Pattern Matching in Scala . . . . . . . . . . . . . . . . . . . .19 6 Conclusion 21 7 Appendix 22 Bibliography

2 Preliminaries Kim Kern

2 Preliminaries

Simple Type Theory (STT), for which higher-order logics are used as asynonym from now on, is based on Church’s simply typed λ-calculus [Chu40]and usually uses the basic set of types T = {o, ι}, where type o denotesBooleans and ι a domain of individuals.

Types The simple set of types T is constructed with the function type con-structor →, such that it is the smallest set containing the basic types in Tand all type expressions (γ → τ), where γ and τ are type expressions them-selves [BM14]. For better readability, the type α → (β → γ) is denotedwith the left-associative notation γβα, following common conventions. Inthis thesis, the types of the formulae are omitted if they can be inferred oraren’t required for the understanding.

Terms A typed term is constructed from the following sets and operations:

Xα Variablescα Constants and Parameters

(FβαBα)β Application(λYα.Aβ)βα λ-abstraction

Application associates to the left and abstraction to the right. The dot in(λYα.Aβ)βα means that the longest possible following part of the formula isin brackets without changing existing brackets. So λX.(F (λY.(A))) can bedenoted as λX.F (λY.A). Also note that the spine notation is used for theapplication of terms, hence (F X Y Z) represents (((F X)Y )Z) [CP03].

The names of bound variables in the λ-statements are interchangeable withregard to α-conversion. That’s why it’s common practice to use the namelessbinding mechanism called de Bruijn index for the implementation of boundvariables [DB72]. This means there is no longer the requirement to renameaccording to α-conversion.

Logical connectives The primitive logical connectives ¬oo (not), ∨oo (or)and Πo(oα) (quantification over type α) are used to construct formulae.

The following logical constants and connectives are defined as usual [Ben15].

>o (truth) ⇔ooo (equivalence)⊥o (falsehood) ∀ (universal quantification)∧oo (and) ∃ (existential quantification)⊃ooo (implication) =oαα (equality at type α)

Table 1: Defined logical connectives

4

Page 8: Improved Computation of Clause Normal Forms in Higher ...€¦ · 5.2 Pattern Matching in Scala . . . . . . . . . . . . . . . . . . . .19 6 Conclusion 21 7 Appendix 22 Bibliography

2 Preliminaries Kim Kern

For some logical standard functions the common infix notation is used, e.g.φ ∨ ψ standing for the application (∨ooo φo)ψo. In a higher-order context Πin combination with the λ-operator can be utilized to construct the universaland existential quantifiers. Because the λ-operator already offers a bindingmechanism, it can be reused for the quantification. So ∀X.φ is defined asΠαo(oα)λXα.φ and respectively ∃X.φ as ¬Πα

o(oα)λXα.¬φ.

Free variables All variables that occur in a formula φ shall be calledvars(φ). The set bound(φ) contains all bound variables in the formula φ. Avariable in φ is called bound if it is within the scope of a λ that binds it. Thefree variables of a formula φ are defined as free(φ) = vars(φ) \ bound(φ).

Replacing ω[φ/ψ] denotes the formula where all occurrences of φ in ω arereplaced by ψ. The formula obtained, when the subformula at position πof the formula ψ is replaced by φ, is labelled ψ[π/φ].

Equality Equality of terms is defined by the following conversions thatbuild a unique normal form:

α-conversion Rename bound variables

β-reduction ((λYβ.Aα)Bβ)→ A[Y/B]

η-reduction (λYα.(FβαY ))→ F, (Yα /∈ free(F ))

Polarity The polarity of a formula φ at position π is given by pol(φ, π),where φ ≡ ψ denotes that φ and ψ are equal:

pol(φ, ε) =

−1 if φ|0 ≡ ¬ or φ|0 ≡⊃0 if φ|0 ≡⇔1 else

pol(φ, π.i) =

−pol(φ, π) if φ|π0 ≡ ¬ or φ|π0 ≡⊃0 if φ|π0 ≡⇔pol(φ, π) else

Leibniz equality Leibniz equality Aτ.=τ Bτ for two terms over type τ is

defined by the formula ∀Poτ .P A ⊃ P B [Ben15]. So two terms are equalif all predicates over that type result in the same value. It is sufficient toprove only one direction for equality.

Boolean extensionality Boolean extensionality P ⇔ Q ⊃ P.=o Q states

that two Booleans are equal if they are equivalent. [BBK04]

5

Page 9: Improved Computation of Clause Normal Forms in Higher ...€¦ · 5.2 Pattern Matching in Scala . . . . . . . . . . . . . . . . . . . .19 6 Conclusion 21 7 Appendix 22 Bibliography

2 Preliminaries Kim Kern

Functional extensionality Functional extensionality (∀X.F X .= GX) ⊃

F.=γτ G applies if and only if for any argument the corresponding function

value is the same.

Positions A position π is a sequence of natural numbers. All possiblepositions of a formula φ are in the set pos(φ). ψ[φ]π is short for ψ|π = φand ψ[π/φ] stands for the formula ψ where the subformula at position πwas replaced by φ.

The formula φ|π at position π of the formula φ is defined as follows:

π φ|π

ε φ

τ0

F , if φ|τ = (F Xn) and Xn = x1 . . . xn

A, if φ|τ = λY.A

ψ, if φ|τ = ∀X.ψ or φτ = ∃X.ψ

τi xi, if φ|τ = (F Xn) and Xn = x1 . . . xn

Table 2: Positions π

This can be illustrated with a short example: Let φ = ∃X.¬Z ∨ (X ∧ Y )and ψ = (F X Y Z) be two formulae. Amongst others the subformulaeφ|021 = X ∧ Y , φ|00 = ¬, ψ0 = F and ψ1 = X can now be addressed.

Depth The maximum length of a formula’s position is called its depth.depth(φ) = max{|π| |π ∈ pos(π)}

6

Page 10: Improved Computation of Clause Normal Forms in Higher ...€¦ · 5.2 Pattern Matching in Scala . . . . . . . . . . . . . . . . . . . .19 6 Conclusion 21 7 Appendix 22 Bibliography

3 Standard CNF Algorithm Kim Kern

3 Standard CNF Algorithm

This section describes to what extent the basic algorithm given for first-orderproblems in [NW01] can be applied to higher-order logics.

First, unnecessary redundancies are removed in the simplification algorithm.The negation normal form guarantees that negations can only be found infront of literals. As a preprocessing step for the following Skolemization,miniscoping and variable renaming ensure, that quantifiers only appear ata innermost position and bound variables have distinct representations. Ex-istential quantifiers are then removed using Skolemization. Finally, all uni-versal quantifiers are removed and a clause normal form is constructed, onwhich a clause simplification is performed.

3.1 Simplification

The simplification algorithm removes unnecessary redundancies and obvi-ous tautologies. The procedure provides simple replacement rules that canbe exhaustively applied to higher-order formulae in any order. The rulesare equivalence preserving and always terminate since the left hand side issmaller.

The algorithm can be applied in a higher-order context without any prob-lems. The easiest way to implement this is by traversing the formula top-down and check for the rule conditions on every level.

φ ∧ φ → φ φ ∨ φ → φφ ∧ ¬φ → ⊥ φ ∨ ¬φ → >φ⇔ φ → > φ ⊃ φ → >¬> → ⊥ ¬ ⊥ → >

φ ∧ > → φ φ ∨ > → >φ∧ ⊥ → ⊥ φ∨ ⊥ → φφ ⊃ > → > > ⊃ φ → φφ ⊃⊥ → ¬φ ⊥ ⊃ φ → >φ⇔ > → φ φ⇔ ⊥ → ¬φ

∀X.φ→ φ, if x /∈ free(φ)∃X.φ→ φ, if x /∈ free(φ)

Table 3: Simplification

7

Page 11: Improved Computation of Clause Normal Forms in Higher ...€¦ · 5.2 Pattern Matching in Scala . . . . . . . . . . . . . . . . . . . .19 6 Conclusion 21 7 Appendix 22 Bibliography

3.2 Negation Normal Form Kim Kern

3.2 Negation Normal Form

For the negation normal form equivalences ⇔, implications ⊃ and doublenegations ¬¬ need to be removed while making sure that negations ¬ areonly found in front of atoms. The given rules are again terminating andequivalence preserving. The removal of equivalences is polarity dependent sothat the construction of tautologies can be avoided.

ψ[φ1 ⇔ φ2]π → ψ[π/(φ1 ⊃ φ2) ∧ (φ2 ⊃ φ1)] if pol(ψ, π) = 1ψ[φ1 ⇔ φ2]π → ψ[π/(φ1 ∧ φ2) ∨ (¬φ1 ∧ ¬φ2)] if pol(ψ, π) = −1

¬(φ ∧ ψ) → ¬φ ∨ ¬ψ ¬(φ ∨ ψ) → ¬φ ∧ ¬ψ¬∀X.φ → ∃X.¬φ ¬(∃X.φ) → ∀X.¬φφ ⊃ ψ → ¬φ ∨ ψ ¬¬φ → φ

Table 4: Negation normal form

The initial polarity of the formula φ must be considered because it has animpact on the whole formula. If the polarity of φ is pol(φ) = −1, thealgorithm should be run with ¬φ.

3.3 Miniscoping

Before existential quantifiers are removed (see Skolemization, section 3.5),all quantifiers shall be moved the furthest inwards. This minimizes the arityof the Skolem functions, which will be explained in the coming passages.

∃X.φ ∧ ψ → (∃X.φ) ∧ ψ if X /∈ free(ψ)∃X.φ ∨ ψ → (∃X.φ) ∨ ψ if X /∈ free(ψ)∀X.φ ∧ ψ → (∀X.φ) ∧ ψ if X /∈ free(ψ)∀X.φ ∨ ψ → (∀X.φ) ∨ ψ if X /∈ free(ψ)

∃X.φ ∨ ψ → (∃X.φ) ∨ (∃X.ψ) if X ∈ free(φ) andX ∈ free(ψ)∀X.φ ∧ ψ → (∀X.φ) ∧ (∀X.ψ) if X ∈ free(φ) andX ∈ free(ψ)

Table 5: Miniscoping

It is not obvious why quantifiers wouldn’t be moved inwards in function ap-plications. The following illustrates why that wouldn’t be sound in general.The formula ∃X.f(X) is considered where X is of type ι and f a functionof type αι. If the quantifier is moved inwards, the argument of the functionwould be of type o, and thus not match the signature any more.

8

Page 12: Improved Computation of Clause Normal Forms in Higher ...€¦ · 5.2 Pattern Matching in Scala . . . . . . . . . . . . . . . . . . . .19 6 Conclusion 21 7 Appendix 22 Bibliography

3.4 Variable Renaming Kim Kern

If a naive application of those rules is performed, formulae might be en-countered, where at first glance none of the above rules seem to apply. Butwhen a small equivalence preserving transformation is applied, it may helpto move the quantifiers further inwards.

Consider the formula φ = ∀X.p(X) ∧ (q(X) ∧ p(Y )). Since for both subfor-mulae φ1 = φ|01 and φ2 = φ|02 holds X ∈ free(φi), i = 1, 2 none of the rulesstated before can be applied. But if the formula is transformed according tothe associative law to ∀X.(p(X)∧ p(X))∧ p(Y ) it can make use of the rulesas follows:

∀X.(p(X) ∧ q(X)) ∧ p(Y )

(∀X.p(X) ∧ q(X)) ∧ p(Y )

((∀X.p(X)) ∧ (∀X.q(X))) ∧ p(Y )

Also the order of the quantifiers may make a difference. This can be demon-strated with the formula φ = ∀X.∀Y.f(X,Y ) ∧ f(Y, Y ). Since again forboth subformulae φ1 = φ|001 and φ2 = φ|002 X ∈ free(φi), i = 1, 2 applies,the quantifier ∀Y can’t be moved further inwards. If one switches the twoquantifiers however, it can be proceeded as follows:

∀Y.∀X.f(X,Y ) ∧ f(Y, Y )→ ∀Y.(∀X.f(X,Y )) ∧ f(Y, Y )

3.4 Variable Renaming

The Miniscoping algorithm in section 3.3 duplicates quantifiers and thusalso their bound variables. Since the universal quantifiers will be movedoutwards for the Clause Normal Form in section 3.6, we would run intoa name conflict. Yet, variable bindings in Leo-III are represented using deBruijn indices [DB72]. Because of their nameless representation, those nameconflicts can be avoided in a very elegant manner and therefore make thisstep unnecessary. However, it is crucial to keep track of the indices andpossibly raise or decrease them, when changing the positions of the bindingquantifiers.

It should be kept in mind though that, in general, existential and universalquantifiers are not arbitrarily interchangeable ∀X.∃Y.φ 6≡ ∃Y.∀X.φ.

9

Page 13: Improved Computation of Clause Normal Forms in Higher ...€¦ · 5.2 Pattern Matching in Scala . . . . . . . . . . . . . . . . . . . .19 6 Conclusion 21 7 Appendix 22 Bibliography

3.5 Skolemization Kim Kern

3.5 Skolemization

Skolemization is used to obtain a formula without existential quantifiers. Forthat, a new Skolem function is introduced for each existentially quantifiedvariable which depends on the free variables in the scope of the correspond-ing quantifier. If there are no free variables in the scope of the existentialquantifier, the thus created Skolem function with arity 0 is referred to as aSkolem constant.

φ[∃X.ψ]π → φ[π/φ[X/f(Y1, ..., Yn)]]

where free(φ) = {Y1, ..., Yn}f new skolemfunction of arity n

Table 6: Skolemization

Skolemization doesn’t preserve equivalence but satisfiability.

Without the prior application of miniscoping, the proof complexity mayincrease. The following example illustrates, how miniscoping can reduce thearity of the Skolem functions.

∃X.X ∨ Y Skolemization=⇒ f(Y ) ∨ Y

∃X.X ∨ Y miniscoping=⇒ (∃X.X) ∨ Y Skolemization

=⇒ a ∨ Y

In a higher-order context Skolemization can be applied as proposed in thefirst-order solution. The type of the introduced Skolem function or constantmust match the type of the quantified variable.

3.6 Clause Normal Form

In this section, all accessible universal quantifiers are moved outwards anddisjunctions are moved inwards, utilising the following three rules:

(∀X.φ) ∧ ψ → ∀X.φ ∧ ψ if X /∈ free(ψ)(∀X.φ) ∨ ψ → ∀X.φ ∨ ψ if X /∈ free(ψ)

φ ∨ (ψ1 ∧ ψ2) → (φ ∨ ψ1) ∧ (φ ∨ ψ2)

Table 7: Clause normal form

10

Page 14: Improved Computation of Clause Normal Forms in Higher ...€¦ · 5.2 Pattern Matching in Scala . . . . . . . . . . . . . . . . . . . .19 6 Conclusion 21 7 Appendix 22 Bibliography

3.7 Clause Simplification Kim Kern

In higher-order logics a quantifier might still occur inside of an applicationand can therefore not be moved further outwards, e.g. fαo(∀X.φ). The sameapplies to disjunctions, e.g. f(a ∧ b) ∨ c. In section 4.2, a mechanism isdescribed that replaces function arguments to reduce their depth to zero,and thus resolve the problem.

Furthermore in Leo-III, where de Bruijn indices [DB72] are used as bind-ing mechanism, the condition if X /∈ free(ψ) is in this case always true.However, indices might have to be lifted when the quantifiers are movedoutwards.

3.7 Clause Simplification

In first-order logics all universal quantifiers are removed, since they are all atthe very outermost of the formula and all free variables are just considered tobe universally quantified. In higher-order logics however, it is not guaranteedthat no quantifiers can be found at positions π 6= ε, because a quantifiermight still be inside of an application like for instance in f(∀X.φ). A methodto move quantifiers the furthest outwards after all can be found in section4.3.

A clause can be removed if it is a tautology, i.e. if a clause contains a literaland its corresponding negation.

11

Page 15: Improved Computation of Clause Normal Forms in Higher ...€¦ · 5.2 Pattern Matching in Scala . . . . . . . . . . . . . . . . . . . .19 6 Conclusion 21 7 Appendix 22 Bibliography

4 Techniques for Higher-Order CNF Kim Kern

4 Techniques for Higher-Order CNF

The computation of a clause normal form can result in a bloated set ofclauses. Hence, in this section some techniques are presented, to reduce thenumber and size of the returned clauses.

4.1 Context Splitting

Context splitting [RV01] is used to decrease the problem size by splittingproblems into subproblems. Therefore, it reduces the proof complexity andrenders further parallelization possible. A disjunction ω = φ∨ψ (conjunctionω = φ∧ψ) is split into two separate proofs, if their sets of free variables aredisjoint. The initial problem ω is true if one (both) of the subproblems is(are) true.

φ ∧ ψ → t1 ∧ t2 if free(φ) ∩ free(ψ) = ∅

φ ∨ ψ → t1 ∨ t2 if free(φ) ∩ free(ψ) = ∅

Table 8: Context splitting

Context splitting should be applied after miniscoping, since additional pos-sibilities for further splittings may emerge as illustrated in the followingexample.

∀X.f(X) ∧ g(X) where free(f(X)) ∩ free(g(X)) = {X}

⇓ miniscoping

∀X.f(X) ∧ ∀X.g(X) where free(∀X.f(X)) ∩ free(∀X.g(X)) = ∅

Because in the miniscoping algorithm, formulae must be checked for theirfree variables already, the two techniques can be combined for the imple-mentation. The reduced computational expense comes at the price of adecreased encapsulation.

The proof search might also benefit from a splitting which is performed evenbefore the normalization, since the normalization itself and the processingof the resulting problems can be parallelized. Further research is needed todetermine appropriate indicators which suggest an effective application fora particular formula.

12

Page 16: Improved Computation of Clause Normal Forms in Higher ...€¦ · 5.2 Pattern Matching in Scala . . . . . . . . . . . . . . . . . . . .19 6 Conclusion 21 7 Appendix 22 Bibliography

4.2 Bounded Argument Depth Kim Kern

4.2 Bounded Argument Depth

In a higher-order context the arguments of applications can have an un-restricted depth, which leads to several difficulties. The problem shall beillustrated with the following example of a resolution proof:

poo(a) ∧ p(b) ⊃ p(a ∧ b) (1)

⇓ normalization

{¬p(a), ¬p(b), p(a ∧ b)}

⇓ resolution steps

� ∨ p(a)?= p(a ∧ b) dec

=⇒ � ∨ a ?= (a ∧ b)

� ∨ p(b) ?= p(a ∧ b) dec

=⇒ � ∨ b ?= (a ∧ b)

After the decompositions, it can be seen that a basic unification algorithm[Hue75] would not be able to solve this problem and it would get stuck. Butif a new normalization step is added, where the arguments’ depth for allarguments of type o is reduced, a solution can easily be found. So everyargument φo where depth(φ) > 1 is replaced with a new definition t = φ andthe definition is added to the set of clauses. With the unification constraintφ

?= ψ, respectively as ¬(φ = ψ) and Boolean extensionality, the procedure

results in the formulae t⇔ φ and φ⇔ ¬ψ [BBK04]:

f(φo) and depth(φ) > 1

⇓ t is a new symbol

f(φ)[φ/t] and addNewClause(t = φ)

φo?= ψo =⇒ addNewClause(¬φ⇔ ψ).

Now the described procedure is applied to the given example. In a first nor-malization step t⇔ a∧b is added to the clauses set and then replaced p(a∧b)by p(t). After the decomposition this forms the unification constraints a

?= t

resp. b?= t, which are both added to the clauses set as stated before. The set

of clauses now contains the subset S = {(t ⇔ a ∧ b), (¬t ⇔ a), (¬t ⇔ b)}It’s obvious that S can be refuted, and thus the conjecture (1) has beenproven.

The algorithm could be lifted to arbitrary argument types, such as oo, be-cause functional extensionality can be applied. So in the function p(f(a, b)oo)

13

Page 17: Improved Computation of Clause Normal Forms in Higher ...€¦ · 5.2 Pattern Matching in Scala . . . . . . . . . . . . . . . . . . . .19 6 Conclusion 21 7 Appendix 22 Bibliography

4.3 Quantifier Extraction Kim Kern

the argument can be replaced by too = f(a, b). Now functional extension-ality can be applied so that ∀X.t(X) ⇔ f(a, b)(X) is obtained, which canbe appended to the set of clauses. It might be expedient to restrict this totypes with a cardinality smaller than a still to be determined maximum.

Future works can evaluate whether building up an additional auxiliary struc-ture as a constraint store to keep track of the newly created clauses canfurther improve the process by separating it from the rest of the proof andtherefore enabling parallelism in problems with a reduced complexity.

4.3 Quantifier Extraction

In higher-order logics quantified formulae can be the argument of an ap-plication like in f(∀X.φ) or g((∃X.φ)Y ). Therefore, they can’t be movedoutwards by standard normalization techniques. If the procedure describedin the former section 4.2 is applied though, quantifiers can be moved toan outermost position and completely removed as explained in section 3.7.Contrary to the more general Bounded Argument Depth, the Quantifier Ex-traction can be performed prior to any presented normalization step.

In the following example, it is assumed that φ no longer contains any quanti-fiers at a position other than the outermost, because it has been normalizedalready. In the first step the application’s argument is renamed according tothe previous section. Since a quantified formula has been renamed, the newconstant t is of type o. Thus, Boolean extensionality can be applied on thedefinition to = ∀X.φ so that t ⇔ ∀X.φ is obtained. Then the formula canbe further normalized such that the quantifiers are moved to the outermostposition after all. Since by this procedure all quantifiers inside of applica-tions in φ could have been moved outwards as well, this is a general way toextract all quantifiers from within applications.

ψ[f(∀X.φ)]π

⇓ renamearg.

ψ[f(t) ∧ (to = ∀X.φ)]π

⇓ Boolean ext.

ψ[f(t) ∧ (t⇔ ∀X.φ)]π

⇓ normalize

quantifier can bemoved outwards

If the condition free(∀X.φ) = ∅ applies for the argument in ψ|π = f(∀X.φ),the definition t = ∀X.φ can be added at the top level of ψ: ψ[π/f(t)] ∧

14

Page 18: Improved Computation of Clause Normal Forms in Higher ...€¦ · 5.2 Pattern Matching in Scala . . . . . . . . . . . . . . . . . . . .19 6 Conclusion 21 7 Appendix 22 Bibliography

4.4 Formula Renaming Kim Kern

(t ⇔ ∀X.φ) Therewith, possible applications of the distributivity law canbe avoided and thus the number of resulting clauses reduced. This can’tbe applied if free(∀X.φ) 6= ∅ because in general ∃X.f(a (∀Y.X ∧ Y )) 6≡(∃X.f(a t)) ∧ (t⇔ X ∧ Y ).

4.4 Formula Renaming

Formula renaming is an optimization concept proposed also in [NW01] toreduce the number of produced clauses before the normalization. Whenthe conjunctive normal form is constructed, the number of clauses mightexplode due to the repetitive application of the distributive law. A formulaω = φ ∨ ψ, where φ is normalized to n clauses and ω|π = ψ to m clauses,the normalization of ω results in n∗m clauses. If ψ at position π is replacedby a definition r such that ω′ = (φ ∨ r(X1, ..., Xn)) ∧ def(π, ω, r) wherefree(ψ) = {X1, ..., Xn} and the normalization of def(π, ω, r) yields in kclauses, ω′ only generates n ∗ 1 + k clauses. How can be determined whenthe condition n ∗m > n+ k applies, hence a renaming reduces the numberof clauses and what should the definition def(π, ω, r) look like?

If ψ is a formula and φ = ψ|π the formula to be renamed, the formulaψ[π/r(X1, ..., Xn)] ∧ def(π, ψ, r) is a formula renaming where r is a newpredicate and free(φ) = {X1, ..., Xn}.

def(π, ψ, r) =

∀X1, ..., Xn.[r(X1, ..., Xn) ⊃ φ] if pol(ψ, π) = 1

∀X1, ..., Xn.[φ ⊃ r(X1, ..., Xn)] if pol(ψ, π) = −1

∀X1, ..., Xn.[r(X1, ..., Xn)⇔ φ] if pol(ψ, π) = 0

Because of the chosen polarity-dependent definition, which further reducesthe quantity of clauses, formula renaming is satisfiability preserving only.

The number of clauses generated by a formula can be calculated with thecalculations p(ψ) and p(ψ) = (p(¬ψ) given in table 9.

15

Page 19: Improved Computation of Clause Normal Forms in Higher ...€¦ · 5.2 Pattern Matching in Scala . . . . . . . . . . . . . . . . . . . .19 6 Conclusion 21 7 Appendix 22 Bibliography

4.4 Formula Renaming Kim Kern

ψ p(ψ) p(ψ)

φ1 ∧ φ2 p(φ1) + p(φ2) p(φ1)p(φ2)

φ1 ∨ φ2 p(φ1)p(φ2) p(φ1) + p(φ2)

φ1 ⊃ φ2 p(φ1)p(φ2) p(φ1) + p(φ2)

φ1 ⇔ φ2 p(φ1)p(φ2) + p(φ1)p(φ2) p(φ1)p(φ2) + p(φ1)p(φ2)

∀X.φ1 p(φ1) p(φ1)

∃X.φ1 p(φ1) p(φ1)

¬φ1 p(φ1) p(φ1)

p(X1, ..., Xn) 1 1

Table 9: Computation of p and p

With that, the condition for a formula renaming can be stated as:

p(ψ) ≥ p(ψ[π/r(X1, ..., Xn)]) + p(def(π, ψ, r))

However, a top-down implementation of p would be exponentially inefficientin computation time. Therefore, two coefficients aψπ and bψπ are presented,which only consider the changed subformulae to compare the number ofclauses of both changed and unchanged formulae. Also, intermediate res-ults are stored using dynamic programming principles, and thus avoidingredundant computations. The coefficients aψπ and bψπ are defined in table 10on the facing page.

Using the newly introduced coefficients the condition can now be formulatedas

aψπp(φ) + bψπ p(φ) ≥ aψπ + bψπ + p(def(π, ψ, r))

Since the coefficient aψπ (bψπ ) stands for the multiplication of p(ψ|π) (p(ψ|π)),

aψπ (bψπ ) is always 0, if pol(ψ, π) = −1 (pol(ψ, π) = 1). Thus, the conditioncan be split into three inequalities:

aψπp(φ) ≥ aψπ + p(φ) if pol(ψ, π) = 1

bψπ p(φ) ≥ bψπ + p(φ) if pol(ψ, π) = −1

aψπp(φ) + bψπ p(φ) ≥ aψπ + bψπ + p(φ) + p(φ) if pol(ψ, π) = 0

16

Page 20: Improved Computation of Clause Normal Forms in Higher ...€¦ · 5.2 Pattern Matching in Scala . . . . . . . . . . . . . . . . . . . .19 6 Conclusion 21 7 Appendix 22 Bibliography

4.4 Formula Renaming Kim Kern

π ψ|τ aψπ bψπ

τ.i φ1 ∧ φ2 aψτ bψτ∏j 6=i p(φj)

τ.i φ1 ∨ φ2 aψτ∏j 6=i p(φj) bψτ

τ.1 φ1 ⊃ φ2 bψτ aψτ p(φ2)

τ.2 φ1 ⊃ φ2 aψτ p(φ2) bψτ

τ.1 φ1 ⇔ φ2 aψτ p(φ2) + bψτ p(φ2) aψτ p(φ2) + bψτ p(φ2)

τ.2 φ1 ⇔ φ2 aψτ p(φ1) + bψτ p(φ1) aψτ p(φ1) + bψτ p(φ1)

τ.1 ¬φ1 bψτ aψτ

τ.1 ∀X.φ1 aψτ bψτ

τ.1 ∃X.φ1 aψτ bψτ

ε ψ 1 0

Table 10: Computation of aψπ and bψπ

def(π, ψ, r) can be replaced according to the definition of p and the polarity

of φ. By reordering and the two abbreviations pa = (aψπ − 1)(p(φ)− 1) and

pb = (bψπ − 1)(p(φ)− 1) the conditions are:

pa ≥ 1 if pol(ψ, π) = 1

pb ≥ 1 if pol(ψ, π) = −1

pa ≥ 2 ∨ pb ≥ 2 ∨ (pa ≥ 1 ∧ pb ≥ 1) if pol(ψ, π) = 0

To check this condition it is sufficient to know whether aψπ , bψπ , p(φ) and p(φ)are strictly greater than 1, 2 or 3.

p(ψ) > 1

∃π.φ[ω]π ω = φ1 ⇔ φ2

∃π.φ[ω]π and pol(φ, π) = 1 ω = φ1 ∧ φ2

∃π.φ[ω]π and pol(φ, π) = −1 ω = φ1 ∨ φ2

∃π.φ[ω]π and pol(φ, π) = −1 ω = φ1 ⊃ φ2

Table 11: Computation of p(ψ) > 1

17

Page 21: Improved Computation of Clause Normal Forms in Higher ...€¦ · 5.2 Pattern Matching in Scala . . . . . . . . . . . . . . . . . . . .19 6 Conclusion 21 7 Appendix 22 Bibliography

4.4 Formula Renaming Kim Kern

ψ p(ψ) > 2

φ1 ∧ φ2 p(φ1) > 1 ∨ p(φ2) > 1

φ1 ∨ φ2 p(φi) > 2 or p(φ1) > 1 ∧ p(φ2) > 1

Table 12: Computation of p(ψ) > 2

ψ p(ψ) > 3

φ1 ∧ φ2 p(φi) > 2

φ1 ∨ φ2 p(φi) > 3 or p(φi) > 2 ∧ p(φ−i) > 1

Table 13: Computation of p(ψ) > 3

π ψ|τ aψπ > 1

τ.i φ1 ∧ φ2 aψτ > 1

τ.i φ1 ∨ φ2 aψτ > 1 or p(φj) > 1 for some j

Table 14: Computation of aψπ > 1

The other cases can be deduced analogously from the given definitions.

This calculation can be applied in higher-order logics as well. To increasethe impact, the technique presented in section 4.2 should be performed first.

18

Page 22: Improved Computation of Clause Normal Forms in Higher ...€¦ · 5.2 Pattern Matching in Scala . . . . . . . . . . . . . . . . . . . .19 6 Conclusion 21 7 Appendix 22 Bibliography

5 CNF Implementation in Leo-III Kim Kern

5 CNF Implementation in Leo-III

This section points out some main features about the implementation of theconjunctive normal form in the project Leo-III.

The code for Leo-III can be found in a GitHub repository2. At the time ofthis thesis’s publication, the repository is not yet public, however access canbe granted on request.

Test output excerpts of the CNF implementation in Leo-III can be found inthe appendix (section 7).

5.1 Data structure

Since with de Bruijn indices a nameless representation of bindings waschosen, formulae are always in α-normal form. Furthermore, the data struc-ture ensures that all formulae are represented in a βη-normal form which isuseful for instance in the implementation of section 3.5 Skolemization. Theformula ∃.φ ∨ 1 is considered, where 1 is a de Bruijn index referencing theexistential quantifier. Let sko be the new Skolem constant, then the quan-tifier can be removed and the Skolem constant applied to the abstraction ofthe remaining formula (λ.φ ∨ 1) sko which after the β-normalization resultsin the desired φ ∨ sko. Because the β-normalization can also take care ofthe decrementation of the de Bruijn indices, this is a very elegant way toreplace quantifiers.

The data structure underlying the representation of terms in Leo-III has aterm ordering implemented. Therewith the commutativity law is automat-ically taken care of. For example in the simplification step (section 3.1) aformula (φ ∧ ψ) ∨ ¬(ψ ∧ φ) is not detected by the rule φ ∨ ¬φ → >, as-suming the test for equivalence doesn’t consider commutativity itself. Withterm ordering it’s guaranteed that the order in the representation of bothsubformulae is always the same so that the formula can be simplified.

5.2 Pattern Matching in Scala

Scala offers a very powerful pattern matching capability which can be usedto traverse formulae. With those, complex structural requirements can bechecked and corresponding rules applied. In listing 1 a code snippet of theSkolemization algorithm implementation can be found. When the patternof interest occurs, in this case Exists in line 2, the transformation of theformula is performed. If the pattern of interest can occur within subformu-lae, the procedure is performed recursively as in lines 14, 15, 16, 17, 18 or

2Leo-III repository: https://github.com/kiwikern/Leo-III

19

Page 23: Improved Computation of Clause Normal Forms in Higher ...€¦ · 5.2 Pattern Matching in Scala . . . . . . . . . . . . . . . . . . . .19 6 Conclusion 21 7 Appendix 22 Bibliography

5.2 Pattern Matching in Scala Kim Kern

19. Since the pattern for application, denoted by ·, in line 17 also includes∧ and ∨, many different cases can be subsumed if no further distinction isneeded. The recursion anchors appear in lines 12 and 13 where literals areleft unchanged.

To avoid unnecessary pattern tests, cases that can’t occur should be omitted,so that the cases vary in different algorithms. For instance a λ-abstractioncan’t be a directly quantified formula: ∃X.(φ) =⇒ φ 6≡ λX.ψ.

Listing 1: Skolemization in Leo-III

1 def skolemize(formula: Term): Term = formula match {

2 case Exists(ty :::> t) => {

3 val t1 = skolemize(t)

4 val defConst: Set[Term] = formula.symbols.map(x

=> mkAtom(Signature.get(x).key))

5 val freeVar: Seq[Term] = freeVariables (\(ty)(t1)

).toSeq

6 val types = freeVar.map(x => x.ty)

7 val skoType = Type.mkFunType(types , ty)

8 val skoVar = mkTermApp(mkAtom(Signature.get.

freshSkolemVar(skoType)), freeVar)

9 val t2 = replaceExistentialBound(t1, skoVar)

10 decrementDeBruijn(t2)

11 }

12 case s@Symbol(_) => s

13 case s@Bound(_, _) => s

14 case s @@@ t => mkTermApp(skolemize(s), skolemize(

t))

15 case s @@@@ ty => mkTypeApp(skolemize(s), ty)

16 case Forall(ty :::> s) => Forall (\(ty)(skolemize(s

)))

17 case f · args => Term.mkApp(skolemize(f), args.map(

_.fold({ t => Left(skolemize(t))}, Right(_))))

18 case ty :::> s => mkTermAbs(ty, skolemize(s))

19 case TypeLambda(t) => mkTypeAbs(skolemize(t))

20 case x => throw new IllegalArgumentException("

Unknown Pattern for: " + x.pretty)

21 }

20

Page 24: Improved Computation of Clause Normal Forms in Higher ...€¦ · 5.2 Pattern Matching in Scala . . . . . . . . . . . . . . . . . . . .19 6 Conclusion 21 7 Appendix 22 Bibliography

6 Conclusion Kim Kern

6 Conclusion

This thesis demonstrated that a conjunctive normal form can be computedin higher-order logics using very similar algorithms as in a first-order context,both theoretically and practically. Some optimizations applied in FOL areportable as well.

But, it also reveals a wide field for potential new improvements, especiallydue to the nested structure of arguments in applications (see section 4.2).Since no research regarding higher-order CNF has been published yet, newtechniques can be found, and the given ones further evaluated in futureworks. In particular the modular structure in Leo-III allows for elaborateexperiments to find an optimal composition and parametrization. There-with, the interaction of different mechanisms and boundaries for an effectiveapplication can be determined.

The implementation and evaluation of the clause normal form in Leo-III isstill an ongoing work. Because the calculus in Leo-III is not yet implemented,other higher-order automated theorem provers like Leo-II can be used forboth validation and evaluation. On that note, open questions that canbe practically examined are, for example, whether bounded argument depthshould only be applied for functions of certain types to reduce complexity,or if formula renaming loses its positive effect with greater formula depth.

In general, the effect of different improvement methods might also depend onthe problem domain and can potentially be improved using machine learningtechniques. For that, the TPTP problem library3 can be used which offersa variety of already categorized problems.

Due to the computation of a clause normal form, proofs can become verylarge, and thus hard to reconstruct for humans. Yet, an important taskfor automated theorem provers is to return a comprehensible proof object.Improvements in the CNF algorithm may improve the clarity of such proofobjects.

3TPTP website: http://www.tptp.org

21

Page 25: Improved Computation of Clause Normal Forms in Higher ...€¦ · 5.2 Pattern Matching in Scala . . . . . . . . . . . . . . . . . . . .19 6 Conclusion 21 7 Appendix 22 Bibliography

7 Appendix Kim Kern

7 Appendix

Listing 2: Simplification test output in Leo-III

Simplicifcation: ’<=> · (p · (⊥);$false · (⊥);⊥)’ was

simplified to ’~ · (p · (⊥);⊥)’Simplicifcation: ’| · (p · (⊥);$true · (⊥);⊥)’ was

simplified to ’$true · (⊥)’Simplicifcation: ’=> · (p · (⊥);$false · (⊥);⊥)’ was

simplified to ’~ · (p · (⊥);⊥)’Simplicifcation: ’! · ($o;λ[$o}]. (p · (⊥));⊥)’ was

simplified to ’p · (⊥)’Simplicifcation: ’~ · ($false · (⊥);⊥)’ was simplified

to ’$true · (⊥)’Simplicifcation: ’| · (p · (⊥);$false · (⊥);⊥)’ was

simplified to ’p · (⊥)’Simplicifcation: ’& · (p · (⊥);~ · (p · (⊥);⊥);⊥)’ was

simplified to ’$false · (⊥)’Simplicifcation: ’? · ($o;λ[$o}]. (p · (⊥));⊥)’ was

simplified to ’p · (⊥)’Simplicifcation: ’& · (p · (⊥);$false · (⊥);⊥)’ was

simplified to ’$false · (⊥)’Simplicifcation: ’=> · (p · (⊥);p · (⊥);⊥)’ was

simplified to ’$true · (⊥)’Simplicifcation: ’=> · (p · (⊥);$true · (⊥);⊥)’ was

simplified to ’$true · (⊥)’Simplicifcation: ’<=> · (p · (⊥);$true · (⊥);⊥)’ was

simplified to ’p · (⊥)’Simplicifcation: ’| · (p · (⊥);p · (⊥);⊥)’ was

simplified to ’p · (⊥)’Simplicifcation: ’| · (p · (⊥);~ · (p · (⊥);⊥);⊥)’ was

simplified to ’$true · (⊥)’Simplicifcation: ’=> · ($false · (⊥);p · (⊥);⊥)’ was

simplified to ’$true · (⊥)’Simplicifcation: ’& · (p · (⊥);p · (⊥);⊥)’ was

simplified to ’p · (⊥)’Simplicifcation: ’<=> · (p · (⊥);p · (⊥);⊥)’ was

simplified to ’$true · (⊥)’Simplicifcation: ’~ · ($true · (⊥);⊥)’ was simplified

to ’$false · (⊥)’Simplicifcation: ’! · ($o;λ[$o}]. (<=> · (p · (1 · (⊥);⊥

);p · (1 · (⊥);⊥);⊥));⊥)’ was simplified to ’$true ·(⊥)’

Simplicifcation: ’=> · ($true · (⊥);p · (⊥);⊥)’ was

simplified to ’p · (⊥)’

22

Page 26: Improved Computation of Clause Normal Forms in Higher ...€¦ · 5.2 Pattern Matching in Scala . . . . . . . . . . . . . . . . . . . .19 6 Conclusion 21 7 Appendix 22 Bibliography

7 Appendix Kim Kern

Listing 3: Negation normal form test output in Leo-III

Negation:

’~ · (<=> · (r · (⊥);s · (⊥);⊥);⊥)’ was normalized to

’& · (| · (~ · (r · (⊥);⊥);~ · (s · (⊥);⊥);⊥);| · (r · (⊥);s · (⊥);⊥);⊥)’.

success

Negation:

’~ · (? · ($o;λ[$o}]. (r · (⊥));⊥);⊥)’ was normalized

to

’! · ($o;λ[$o}]. (~ · (r · (⊥);⊥));⊥)’.success

Negation:

’=> · (r · (⊥);s · (⊥);⊥)’ was normalized to

’| · (~ · (r · (⊥);⊥);s · (⊥);⊥)’.success

Negation:

’<=> · (r · (⊥);s · (⊥);⊥)’ was normalized to

’& · (| · (~ · (r · (⊥);⊥);s · (⊥);⊥);| · (~ · (s · (⊥);⊥);r · (⊥);⊥);⊥)’.

success

Negation:

’~ · (! · ($o;λ[$o}]. (r · (⊥));⊥);⊥)’ was normalized

to

’? · ($o;λ[$o}]. (~ · (r · (⊥);⊥));⊥)’.success

Negation:

’~ · (~ · (r · (⊥);⊥);⊥)’ was normalized to

’r · (⊥)’.success

Negation:

’~ · (| · (r · (⊥);s · (⊥);⊥);⊥)’ was normalized to

’& · (~ · (r · (⊥);⊥);~ · (s · (⊥);⊥);⊥)’.success

Negation:

’~ · (& · (r · (⊥);s · (⊥);⊥);⊥)’ was normalized to

’| · (~ · (r · (⊥);⊥);~ · (s · (⊥);⊥);⊥)’.success

23

Page 27: Improved Computation of Clause Normal Forms in Higher ...€¦ · 5.2 Pattern Matching in Scala . . . . . . . . . . . . . . . . . . . .19 6 Conclusion 21 7 Appendix 22 Bibliography

7 Appendix Kim Kern

Listing 4: Miniscoping test output in Leo-III

##############################

## miniscoping 1

##############################

Formula :’! · ($o;λ[$o}]. (? · ($o;λ[$o}]. (! · ($o;λ[$o}]. (& · (r · (3 · (⊥);3 · (⊥);⊥);| · (| · (p · (2 · (

⊥);⊥);r · (3 · (⊥);2 · (⊥);⊥);⊥);q · (3 · (⊥);⊥);⊥);⊥));⊥));⊥));⊥)’

was normalized to: ’& · (! · ($o;λ[$o}]. (r · (1 · (⊥);1· (⊥);⊥));⊥);! · ($o;λ[$o}]. (| · (| · (? · ($o;λ[$o

}]. (p · (1 · (⊥);⊥));⊥);? · ($o;λ[$o}]. (r · (2 · (⊥);1 · (⊥);⊥));⊥);⊥);q · (1 · (⊥);⊥);⊥));⊥);⊥)’

Success

##############################

## miniscoping 2

##############################

Formula :’! · ($o;λ[$o}]. (& · (1 · (⊥);2 · (⊥);⊥));⊥)’was normalized to: ’& · (! · ($o;λ[$o}]. (1 · (⊥));⊥);1· (⊥);⊥)’

Success

##############################

## miniscoping 3 - remove unnecessary quantifiers

##############################

Formula :’! · ($o;λ[$o}]. (! · ($o;λ[$o}]. (? · ($o;λ[$o}]. (! · ($o;λ[$o}]. (! · ($o;λ[$o}]. (3 · (⊥));⊥));⊥));⊥));⊥));⊥)’

was normalized to: ’? · ($o;λ[$o}]. (1 · (⊥));⊥)’Success

##############################

## miniscoping 4

##############################

Formula :’! · ($o;λ[$o}]. (! · ($o;λ[$o}]. (r · (2 · (⊥);2 · (⊥);⊥));⊥));⊥)’

was normalized to: ’! · ($o;λ[$o}]. (r · (1 · (⊥);1 · (⊥);⊥));⊥)’

Success

##############################

## miniscoping 5

##############################

Formula :’! · ($o;λ[$o}]. (| · (| · (p · (2 · (⊥);⊥);r ·(2 · (⊥);1 · (⊥);⊥);⊥);q · (1 · (⊥);⊥);⊥));⊥)’

was normalized to: ’! · ($o;λ[$o}]. (| · (| · (p · (2 · (

⊥);⊥);r · (2 · (⊥);1 · (⊥);⊥);⊥);q · (1 · (⊥);⊥);⊥));⊥)’

Success

24

Page 28: Improved Computation of Clause Normal Forms in Higher ...€¦ · 5.2 Pattern Matching in Scala . . . . . . . . . . . . . . . . . . . .19 6 Conclusion 21 7 Appendix 22 Bibliography

7 Appendix Kim Kern

Listing 5: Skolemization test output in Leo-III

##############################

## SYN993 ^1.p

##############################

Formula "| · (? · ($i;λ[$i}]. (! · ($i;λ[$i}]. (100 · (2 ·(⊥);1 · (⊥);⊥));⊥));⊥);? · ($i;λ[$i}]. (! · ($i;λ[$

i}]. (~ · (100 · (1 · (⊥);2 · (⊥);⊥);⊥));⊥));⊥);⊥)"was skolemized to: "| · (! · ($i;λ[$i}]. (99 · (sk1 · (99

· (⊥);⊥);1 · (⊥);⊥));⊥);! · ($i;λ[$i}]. (~ · (99 ·(1 · (⊥);sk2 · (99 · (⊥);⊥);⊥);⊥));⊥);⊥)".

success

##############################

## SYN994 ^1.p

##############################

Formula "? · ($i;λ[$i}]. (! · ($i;λ[$i}]. (! · ($i;λ[$i}]. (| · (100 · (2 · (⊥);1 · (⊥);⊥);~ · (100 · (2 · (⊥);3 · (⊥);⊥);⊥);⊥));⊥));⊥));⊥)"

was skolemized to: "! · ($i;λ[$i}]. (! · ($i;λ[$i}]. (| ·(99 · (2 · (⊥);1 · (⊥);⊥);~ · (99 · (2 · (⊥);sk1 ·

(99 · (⊥);⊥);⊥);⊥);⊥));⊥));⊥)".success

##############################

## SYN996 ^1.p

##############################

Formula "=> · (! · ($i;λ[$i}]. (? · ($i;λ[$i}]. (100 · (2

· (⊥);1 · (⊥);⊥));⊥));⊥);? · ($i -> $i;λ[$i -> $i}]. (! · ($i;λ[$i}]. (100 · (1 · (⊥);2 · (1 · (⊥);⊥);⊥));⊥));⊥);⊥)"

was skolemized to: "=> · (! · ($i;λ[$i}]. (99 · (1 · (⊥);sk1 · (99 · (⊥);1 · (⊥);⊥);⊥));⊥);! · ($i;λ[$i}].(99 · (1 · (⊥);sk2 · (99 · (⊥);1 · (⊥);⊥);⊥));⊥);⊥)".

success

##############################

## SYN997 ^1.p

##############################

Formula "? · (($i -> $o) -> $i;λ[($i -> $o) -> $i}]. (!

· ($i -> $o;λ[$i -> $o}]. (=> · (? · ($i;λ[$i}]. (2 ·(1 · (⊥);⊥));⊥);1 · (2 · (1 · (⊥);⊥);⊥);⊥));⊥));⊥)"

was skolemized to: "! · ($i -> $o;λ[$i -> $o}]. (=> · (1

· (sk1 · (1 · (⊥);⊥);⊥);1 · (sk2 · (1 · (⊥);⊥);⊥);⊥));⊥)".

success

25

Page 29: Improved Computation of Clause Normal Forms in Higher ...€¦ · 5.2 Pattern Matching in Scala . . . . . . . . . . . . . . . . . . . .19 6 Conclusion 21 7 Appendix 22 Bibliography

7 Appendix Kim Kern

Listing 6: Prenex normal form test output in Leo-III

##############################

## Prenex 1

##############################

The Term ’& · (! · ($o;λ[$o}]. (1 · (⊥));⊥);sk1 · (⊥);⊥)’

was normalized to ’! · ($o;λ[$o}]. (& · (1 · (⊥);sk1 ·(⊥);⊥));⊥)’.

##############################

## Prenex 2

##############################

The Term ’& · (sk1 · (⊥);! · ($o;λ[$o}]. (1 · (⊥));⊥);⊥)’

was normalized to ’! · ($o;λ[$o}]. (& · (sk1 · (⊥);1 ·(⊥);⊥));⊥)’.

##############################

## Prenex 3

##############################

The Term ’& · (! · ($o;λ[$o}]. (1 · (⊥));⊥);! · ($o;λ[$o}]. (1 · (⊥));⊥);⊥)’

was normalized to ’! · ($o;λ[$o}]. (! · ($o;λ[$o}]. (& ·(2 · (⊥);1 · (⊥);⊥));⊥));⊥)’.

Listing 7: Clause normal form test output in Leo-III

##############################

## ClauseForm 1

##############################

Term ’1 · (⊥)’was normalized to ’[[1 · (⊥)] = T] ’

##############################

## ClauseForm 2

##############################

Term ’~ · (p · (⊥);⊥)’was normalized to ’[[p · (⊥)] = F] ’

##############################

## ClauseForm 3

##############################

Term ’| · (1 · (⊥);| · (p · (⊥);q · (⊥);⊥);⊥)’was normalized to ’[[1 · (⊥)] = T , [p · (⊥)] = T , [q

· (⊥)] = T] ’

##############################

## ClauseForm 4

##############################

Term ’& · (& · (1 · (⊥);| · (q · (⊥);p · (⊥);⊥);⊥);| · (p

· (⊥);q · (⊥);⊥);⊥)’was normalized to ’[[1 · (⊥)] = T] [[q · (⊥)] = T , [

p · (⊥)] = T] [[p · (⊥)] = T , [q · (⊥)] = T] ’

26

Page 30: Improved Computation of Clause Normal Forms in Higher ...€¦ · 5.2 Pattern Matching in Scala . . . . . . . . . . . . . . . . . . . .19 6 Conclusion 21 7 Appendix 22 Bibliography

Bibliography Kim Kern

Bibliography

[And72] Peter B Andrews. General models, descriptions, and choice intype theory. Journal of symbolic logic, pages 385–394, 1972. 1.2

[And81] Peter B. Andrews. Theorem proving via general matings. J.ACM, 28(2):193–214, April 1981. 1.4

[AvK08] Aristoteles and Julius H von Kirchmann. Organon: DeutscheUbersetzung von Julius Heinrich von Kirchmann (1876):[Klas-siker]. GRIN-Verlag, 2008. 1.1

[BBK04] Christoph Benzmuller, Chad E Brown, and Michael Kohlhase.Higher-order semantics and extensionality. The Journal of Sym-bolic Logic, 69(04):1027–1088, 2004. 2, 4.2

[Ben13] Christoph Benzmuller. Automating quantified conditional logicsin HOL. In Francesca Rossi, editor, 23rd International JointConference on Artificial Intelligence (IJCAI-13), pages 746–753,Beijing, China, 2013. 1.2

[Ben15] Christoph Benzmuller. Higher-order automated theorem provers.In David Delahaye and Bruno Woltzenlogel Paleo, editors, Allabout Proofs, Proof for All, Mathematical Logic and Foundations,pages 171–214. College Publications, London, UK, 2015. 2, 2

[BM14] Christoph Benzmuller and Dale Miller. Automation of higher-order logic. In Dov M. Gabbay, Jorg H. Siekmann, , and JohnWoods, editors, Handbook of the History of Logic, Volume 9 —Computational Logic, pages 215–254. North Holland, Elsevier,2014. 1.2, 2

[BRS08] Christoph Benzmuller, Florian Rabe, and Geoff Sutcliffe. THF0– the core of the TPTP language for classical higher-order logic.In Alessandro Armando, Peter Baumgartner, and Gilles Dowek,editors, Automated Reasoning, 4th International Joint Confer-ence, IJCAR 2008, Sydney, Australia, August 12-15, 2008, Pro-ceedings, volume 5195 of LNCS, pages 491–506. Springer, 2008.1.2

[BTPF08] Christoph Benzmuller, Frank Theiss, Lawrence Paulson, and Ar-naud Fietzke. LEO-II - a cooperative automatic theorem proverfor higher-order logic (system description). In Alessandro Ar-mando, Peter Baumgartner, and Gilles Dowek, editors, Auto-mated Reasoning, 4th International Joint Conference, IJCAR2008, Sydney, Australia, August 12-15, 2008, Proceedings, vol-ume 5195 of LNCS, pages 162–170. Springer, 2008. 1.3

27

Page 31: Improved Computation of Clause Normal Forms in Higher ...€¦ · 5.2 Pattern Matching in Scala . . . . . . . . . . . . . . . . . . . .19 6 Conclusion 21 7 Appendix 22 Bibliography

Bibliography Kim Kern

[Chu40] Alonzo Church. A formulation of the simple theory of types. Thejournal of symbolic logic, 5(02):56–68, 1940. 1.1, 1.2, 2

[CP03] Iliano Cervesato and Frank Pfenning. A linear spine calculus.Journal of Logic and Computation, 13(5):639–688, 2003. 2

[DB72] Nicolaas Govert De Bruijn. Lambda calculus notation with name-less dummies, a tool for automatic formula manipulation, withapplication to the church-rosser theorem. In Indagationes Mathe-maticae (Proceedings), volume 75, pages 381–392. Elsevier, 1972.2, 3.4, 3.6

[Fre64] Gottlob Frege. Begriffsschrift und andere Aufsatze. Georg OlmsVerlag, 1964. 1.1

[God31] Kurt Godel. Uber formal unentscheidbare satze der principiamathematica und verwandter systeme i. Monatshefte fur mathe-matik und physik, 38(1):173–198, 1931. 1.1, 1.2

[God95] Kurt Godel. Ontological proof. Kurt Godel collected works,3:403–404, 1995. 1.2

[Hen50] Leon Henkin. Completeness in the theory of types. The Journalof Symbolic Logic, 15(02):81–91, 1950. 1.1, 1.2

[Hue75] Gerard P. Huet. A unification algorithm for typed λ-calculus.Theoretical Computer Science, 1(1):27–57, 1975. 4.2

[Lei65] Gottfried Wilhelm Leibniz. Characteristica universalis. Diephilosophischen Schriften von Gottfried Wilhelm Leibniz. Hrsg.v. CJ Gerhardt. Nachdruck. Hildesheim, pages 184–189, 1965.1.1

[NPW02] Tobias Nipkow, Lawrence C Paulson, and Markus Wenzel. Is-abelle/HOL: a proof assistant for higher-order logic, volume 2283.Springer Science & Business Media, 2002. 1.3

[NW01] Andreas Nonnengart and Christoph Weidenbach. Computingsmall clause normal forms. Handbook of automated reasoning,1:335–367, 2001. 3, 4.4

[oP15] Stanford Encylcopedia of Philosophy. Church’s type the-ory, http://plato.stanford.edu/entries/type-theory-church/, 03-05 2015. 1.1

[RV01] Alexandre Riazanov and Andrei Voronkov. Splitting withoutbacktracking. In IJCAI, pages 611–617. Citeseer, 2001. 4.1

28

Page 32: Improved Computation of Clause Normal Forms in Higher ...€¦ · 5.2 Pattern Matching in Scala . . . . . . . . . . . . . . . . . . . .19 6 Conclusion 21 7 Appendix 22 Bibliography

List of Tables Kim Kern

[Sch04] Stephan Schulz. System description: E 0.81. In Automated Rea-soning, pages 223–228. Springer, 2004. 1.3

[Ste14] Alexander Steen. Efficient Data Structures for Automated The-orem Proving in Expressive Higher-Order Logics. PhD thesis,fu-berlin, 2014. 1.3

[Sut09] Geoff Sutcliffe. The tptp problem library and associated infras-tructure. Journal of Automated Reasoning, 43(4):337–362, 2009.1.2, 1.3

[Wis14] Max Wisniewski. Agent-based Blackboard Architecture for aHigher-Order Theorem Prover. PhD thesis, fu-berlin, 2014. 1.3

[WR12] Alfred North Whitehead and Bertrand Russell. Principia math-ematica, volume 2. University Press, 1912. 1.1

[WSB14] Max Wisnieski, Alexander Steen, and Christoph Benzmuller. TheLeo-III project. In Alexander Bolotov and Manfred Kerber, edi-tors, Joint Automated Reasoning Workshop and Deduktionstref-fen, page 38, 2014. 1.3

List of Tables

1 Defined logical connectives . . . . . . . . . . . . . . . . . . . . 4

2 Positions π . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

3 Simplification . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

4 Negation normal form . . . . . . . . . . . . . . . . . . . . . . 8

5 Miniscoping . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

6 Skolemization . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

7 Clause normal form . . . . . . . . . . . . . . . . . . . . . . . 10

8 Context splitting . . . . . . . . . . . . . . . . . . . . . . . . . 12

9 Computation of p and p . . . . . . . . . . . . . . . . . . . . . 16

10 Computation of aψπ and bψπ . . . . . . . . . . . . . . . . . . . . 17

11 Computation of p(ψ) > 1 . . . . . . . . . . . . . . . . . . . . 17

12 Computation of p(ψ) > 2 . . . . . . . . . . . . . . . . . . . . 18

13 Computation of p(ψ) > 3 . . . . . . . . . . . . . . . . . . . . 18

14 Computation of aψπ > 1 . . . . . . . . . . . . . . . . . . . . . . 18

29