Вы находитесь на странице: 1из 27

University of Manchester

Department of Computer Science

MSc Project Report


Automatically Compute First-Order from
Correspondence Property for Modal Axioms

Student Name: Hussein El-Naggar


Student number: 7101638

Supervisor: Dr. Renate Schmidt


Index

Title Page

Introduction and project description -- -- -- -- -- -- 1


Background -- -- -- -- -- -- -- -- -- -- 1
Rules of translating modal formulae to first-order logic -- -- 2
Summary of paper by Renate Schmidt, 2008 - - -- -- -- 2
Modal logic correspondence properties and their axioms -- -- 3
Table of Ackermann rules -- -- -- -- -- -- -- 4
Summary of Ackermann calculi -- -- -- -- -- -- 4
Example of using Ackermann calculi against “D” axiom -- -- 5
Project Description (Research methods) -- -- -- -- -- 5
Java programming -- -- -- -- -- -- -- -- 5
Outline of processing - - -- -- -- -- -- -- -- 6
Details of Design -- -- -- -- -- -- -- -- -- 7
System component-1 - - -- -- -- -- -- -- -- 7
Function Procedures -- -- -- -- -- -- -- -- 7
System component-2 - - -- -- -- -- -- -- -- 10
Main Procedure - - -- -- -- -- -- -- -- -- 10
Input stage - - -- -- -- -- -- -- -- -- 10
Validation stage - - -- -- -- -- -- -- -- 11
Parsing the formula -- -- -- -- -- -- -- 11
Elimination process -- -- -- -- -- -- -- 12
Produce required output - - -- -- -- -- -- -- 13
Convert the formula to FOL -- -- -- -- -- -- 13
Implementation plan -- -- -- -- -- -- -- -- 13
References -- -- -- -- -- -- -- -- -- -- 14
FOL translation chart -- -- -- -- -- -- -- -- 14
Diagram of the structure of the system -- -- -- -- -- 15
Appendices -- -- -- -- -- -- -- -- -- -- 16
(1) Glossary -- -- -- -- -- -- -- -- -- 16
(2) Redundancy and sample rewrite rules -- -- -- -- 18
(3) Example of data structure -- -- -- -- -- -- 18
(4) Screen layout -- -- -- -- -- -- -- -- 19
(5) Table of FOL conversion -- -- -- -- -- -- 20
(6) Substitution table - - -- -- -- -- -- -- -- 20
(7) Implementation tasks and Gant chart -- -- -- -- 23

i
Abstract
The aim of this project is to develop a computational system for the elimination of
second order quantifiers from modal logic formulae. An application of second-order
quantifier elimination is correspondence theory in modal logic.
The second-order quantifier elimination problem is in general undecidable. This
means that in general the computational system is not guaranteed to succeed to
successfully eliminate all the second-order quantifiers selected by the user.
In short, the required system is to receive a modal-logic formula containing second-
order quantifiers and attempt to eliminate some or all of the quantifiers, and returns an
equivalent formula in first-order logic. This system would be very helpful and time saver
for researchers in the field of logic. The system is based on the correspondence theory
explained above, and the paper by [Schmidt, 2008] titled “The Ackermann Approach for
Modal Logic, Correspondence Theory and Second and Second Order Reduction”
summarised in the following paragraphs.

ii
1. Introduction and project description
The aim of the computational system is to provide a service for logicians through
their personal computer and enable them to eliminate second-order quantifiers from
modal formulae. A logician will be able to key-in a formula, pass it to the new system,
and get an answer back. If the elimination is successful, the answer will be an equivalent
formula in first-order logic. If the system could not perform the elimination, it returns a
message informing the user that the solution to the problem is unknown.
The input to the system is a modal logic formula with modal logic operators, keyed
in by the user or saved by the system from a previous run.
The output is either a first order logic formula corresponds to the original input
formula or a message informing the user that the system is not able to handle the
elimination. The output may also contain details of the steps taken to perform the
elimination, if the user wishes to. The output is displayed on the screen, or it can be
printed as a document, and/or saved as a file on disk.
The design of the structure of the system has taken into consideration the fact that
the system may be easily altered in the future. The alteration may include addition of new
rules, or changes to the way application of a rule is performed.
The structure would consist of three steps. Each step executes only if the previous
step succeeds. The first step receives the input formula and validates its syntax. The input
may either be keyed-in by the user or extracted from a file. By syntax validation we mean
that the input character string does not contain illegal characters, the formula is correctly
and legally formed, and the symbols are all valid modal logic symbols. The user should
also enter the following:
- The symbols to be eliminated (non-base symbols).
- The required form of output. This may contain display and/or print, deduction steps,
and the result of processing.
The second step performs the elimination process, based on the Ackermann
Calculus introduced by [Schmidt 2008]. This step starts only if the validation step
indicates that the input doesn’t contain any error.
The third step produces the output as specified by the user.
The rest of this document contains background, detailed description of the system,
programming specification, and the implementation plan.

2. Background
Logicians consume very long time to verify the satisfiability of a logic formula. For
this reason it is necessary to develop a computer software system to save their time.
Several software systems were developed before, for the same reason, to support new
research ideas such as ICOM, SPASS, and others. ICOM is used to design and produce
Entity-Relationship diagrams, and SPASS is an automated theorem prover for first-order
formula.

1
All the previous software was developed each for a particular problem. The
software or any part of it can’t be used for any problem other than the one it was designed
for. However, the system described in this document, is designed using the open oriented
techniques and will be implemented using the Java programming language, described
below. Parts of the system could be used in the future to develop systems for other
purposes.
For example, developing part of the software to parse the formula and produce a
data structure that could be easily used to store and to process the formula. The same
structure could be used in the future to process formulae for other purposes.
The process of translating a modal formula to a first-order formula is based on
semantics of modal operators, correspondence theory, and Ackermann Approach detailed
in the paper by [Schmidt, 2008]. It uses the standard translation rules shown in the table
in figure 1 below.
We assume ‘P’ is a set of propositional symbols, and every ‘p’ in ‘P’ is mapped to a
unary predicate symbol ‘Q p’ of first-order logic. In addition, ‘R’ denotes a binary
predicate symbol which represents the accessibility relation in a Kripke model. A
function π is defined to take a modal formula and a first-order variable as arguments and
returns a first-order formula so that:
π
(φ, x) FO formula

Seq Modal formula First-order formula


1 π (p, x) Qp(x)
2 π (⊤, x) ⊤
3 π (⊥, x) ⊥
4 π (¬φ, x) ¬ π (φ, x)
5 π (φ ∧ ψ, x) π (φ, x) ∧ π (ψ, x)
6 π (φ ∨ ψ, x) π (φ, x) ∨ π (ψ, x)
7 π (φ ⇨ ψ, x) π (φ, x) ⇨ π (ψ, x)
8 π (φ ⇔ ψ, x) π (φ, x) ⇔ π (ψ, x)
9 π (☐φ, x) ∀ y. R(x, y) ⇨ π (φ, x)
10 π ( ⃟φ , x) ∃y. R(x, y) ∧ π (φ, x)
Figure 1: Rules of translating modal formulae to first-order logic.

In modal logic, correspondence theory is the study of the relationship between


modal formulae and properties of the accessibility relation. Figure 2 below is the table of
the correspondence properties of the accessibility relations for an accessibility relation
‘R’ over a set of worlds ‘W’, and figure 3 is the visual representation of the properties.

The system proposed to develop in this project is to use computers to perform the
elimination of non-base symbols as explained in the paper by [Schmidt, 2008]. Schmidt
specified in the paper that it is possible to compute correspondence properties for all
Sahlqvist formulae.

2
Property Description Axiom
1 Reflexive iff for all x ∊ W, (x, x) ∊ R ☐p ⇨p
2 Irreflexive iff for all x ∊ W, (x, x) ∉ R ☐p ⇨¬p
3 Serial iff for all x ∊ W, some y ∊ W exists
☐p ⇨ ⃟p
such that (x, y) ∊ R
4 Syemmetric iff for all x, y ∊ W, if (x, y) ∊ R
p ⇨ ⃟☐p
then (y, x) ∊ R
5 Transitive iff for all x, y, z ∊ W, if (x, y) ∊ R
☐p ⇨☐☐p
and (y, z) ∊ R, then (x, z) ∊ R
6 euclidean iff for all x, y, z ∊ W, if (x, y) ∊ R
⃟p ⇨☐ ⃟p
and (x, z) ∊ R, then (y, z) ∊ R
Figure 2: Table of the correspondence properties of the accessibility relations for an accessibility
relation ‘R’ over a set of worlds ‘W’,

x x y x y

Reflexive Serial Symmetrical

y
x y z
x

z
Transitive Euclidean
Figure 3: Visual representation of the properties

Sahlqvist formulae are a special class of modal formulae with remarkable


properties. The Sahlqvist correspondence theorem states that every Sahlqvist formula
corresponds to a first-order definable class of Kripke frames.
Schmidt, in the paper, employs the logic K (m)n(⌣,π+), where: ⌣ indicates forward
and backward looking modalities, n indicates nominals, and π+ indicates second-order
quantification over propositional symbols. This logic is an extension to the multi-modal
tense logic K (m) (⌣) with second-order quantification and nominals.
Axiomatization of traditional modal logic without second-order quantifiers can be
defined in terms of modal axioms and rules. As defined in the paper by [Schmidt, 2008],
a modal rule is a pair Δ/Δ’ of sets of modal formulae without second-order quantifiers. A
modal axiom is a modal rule in which Δ is empty. The semantics of a rule is: for any
model M, ∀ ṕ[M ⊨ Λα∈Δ α → M ⊨ Ⅴβ∈Δ’ ], where ṕ denotes the sequence of
propositional symbols occurring in Δ and Δ’.
The input to the calculi is a set of K (m) (⌣)-formulae. The goal is to eliminate the
specified non-base symbols and end up with a formula containing only base symbols. The
logic of the calculi is K (m) (⌣), that is, without second-order quantifiers. This is because it
is implicitly assumed that the non-base symbols are existentially quantified without loss
3
of generality. The calculi are based on Ackermann calculi that are governed by the rules
in figure 4 below. The table shows the format of the input formula (the premise), the
conditions that must be satisfied before the rule is applied, and the substitution formula
(conclusion).
The notations: ↑ ( ) = superscript, ↓ ( ) = subscript are used in the following table.
Elimination rules
Ackermann { α1 ∨ p, … ,αn ∨ p } ∪ (N↑(p)↓(~α1∨ … ~αn)↑(¬¬α1,
p = non-base symbol N(p) … ,¬¬αn)
N = negative wrt p ↓(α1, … ,αn)
p = max wrt each αi
Purify N(p) (N↑(p)↓(¬⊤) )↑(¬¬⊤)↓(⊤)
p = non-base symbol
N = negative wrt p
Surfacing N ∪ {α ∨ ∨↑(σ) β(p) } N ∪ { ∨↑(σ,⌣) α ∨ β(p) }
p = mx non-base sym
symbol which
occurs
in α∨∨↑(σ)β
p not in α
∨↑(σ)β = positive
wrt p
Skolemization N ∪ {¬α ∨ ¬∨↑(σ) N ∪ { ¬α ∨ ¬ ∨↑(σ) ¬b, ¬ b ∨
p = mx non-base sym β(p) } ~ β(p) }
which occurs
in ¬α∨¬∨↑(σ)β
¬∨↑(σ)β = positive
wrt p
b = new nominal
Clausify N ∪ {¬ ( α ∨ β ) } N ∪ { ~ α, ~ β }
Sign switching N(p) (N↑(p)↓(¬p) )↑( ¬ ¬ p)↓(p)
N closed wrt other
rules
P = mx non-base in N
Sign switching
wrt p hasn’t been
performed before
Figure 4: Main rules used by Ackermann calculi.

The calculi are summarized as follows: try to apply each rule in sequence. For each
rule the current formula is scanned, and try to find if any part of the formula matches the
premise of the rule. If no match found continue with next rule. If match found, check if
all pre-conditions of the rule are satisfied. If any is not satisfied continue with next rule. If
all rules are satisfied, apply the transformation specified by the rule and continue with the
next rule. After attempting all the rules, if any change occurred to the formula, repeat the
above trying all the rules again to the changed formula.

4
If the elimination of a non-base symbol is successful, repeat and try to eliminate the
next non-base symbol if any remaining. Repeat until all non-base symbols are eliminated.
The following is an example of processing the modal axiom “D”: ☐p ⇨ ⃟p , and
eliminating the non-base symbol “p”:
01. ∨ p ⇨ ⃟ p % Input ‘D’ axiom
% p implies ⇨ ∀ p
02. ¬ (∨ p ⇨ ⃟ p) % negate, so that ¬ ∀ p ≡ ∃ p
03. ¬ (¬ ∨ p ∨ ⃟ p) % ∨p ⇨ = ¬ ∨p ∨
04. (¬¬ ∨ p ∧ ¬ ⃟ p) % ¬ (p ∨) = (¬ p ∧)
05. (∨ p ∧ ∨ ¬ p) %¬ ⃟p=∨¬p
06.¬ a ∨(∨ p ∧ ∨ ¬ p) % join with ¬ a ∨
6.1. ¬ a ∨ ∨ p % split around
6.2. ¬ a ∨ ∨ ¬ p % the ∧ symbol
Apply Ackermann to 6.1 Apply Ackermann to 6.2
07. Ackermann (6.1) 12. Ackermann (6.2)
08. Check conditions 13. Check conditions
(6.1): Don’t hold (6.2 & 11): hold
14. Substitute ¬ a ∨∨∨⌣ ¬ a
Apply Surfacing to 6.1 Apply Surfacing to 6.2
9. Surfacing (6.1) 15. Surfacing (6.2)
10. Check conditions 16. Check conditions
Conditions don’t hold Conditions don’t hold
11. Substitute: ☐⌣ ¬ a ∨ p
17. Final Formula: (¬ a ∨ ☐☐⌣ ¬ a)
Figure 5: example of non-base symbol elimination

If the elimination failed to remove any of the non-base symbols, start again from the
beginning but after changing the sequence in which non-base symbols are selected for
elimination. If all sequences failed, the elimination is not possible. If a sequence succeeds
convert the final formula that contains only base symbols to first-order logic. See
example of non-base symbol elimination in figure 5 above.

3. Project Description (Research methods)


Java programming language
Java is a programming language developed by Sun Microsystems. The language has
a simple object model and few low-level facilities. Java applications are typically
compiled to byte code that can run on any Java virtual machine (JVM) regardless of
computer architecture. The language has five important characteristics:

5
1. Simple, object oriented and familiar.
2. Robust and secure.
3. Architecture neutral and portable.
4. Executes with high performance.
5. It is interpreted, threaded, and dynamic.
The portability characteristic is very important in Java, and means that computer
programs written in the Java language may be run similarly on any supported
hardware/operating-system platform. One should be able to write a program once,
compile it once, and run it anywhere. This is achieved by compiling the Java language
code, not to machine code but to Java bytecode – instructions analogous to machine code
but intended to be interpreted by a virtual machine (VM) written specifically for the host
hardware. The Java Standard Edition platforms are Microsoft Windows, Linux, Mac OS
X, and Solaris. Alternative Java environments are available through a network

Outline of processing
Once the modal formula is entered, whether from a file or keyed in by the user, the
user will be able to click a button to start processing.
- Validate the input (current) formula. The initial validation would include making sure
that the formula does not contain any illegal characters, parentheses and brackets are
balanced, and briefly the formula is correctly and legally formed. The current formula
also should contain all non-base symbols selected by the user.
- If any error found, display error message and stop.
- If no errors found, start the elimination process. Apply the Surfacing, Skolemization,
and Clausify rules recursively. Before applying any rule, check if the formula contains
the premise of the rule, and if the pre-conditions to apply the rule are satisfied. After
applying the three rules, check if the formula was altered or not.
- If altered, loop back and try to re-apply the three rules again.
- If no change to the formula, continue with next step. Apply Ackermann and Purify
rules only once for the non-base symbol being eliminated.
- At this point of processing, the elimination of a non-base symbol is complete. Check
that the current formula doesn’t contain any occurrence of the symbol just eliminated.
If any occurrence exists, issue an error message and stop. If the non-base symbol has
disappeared from the current formula, try to eliminate the next one if any remaining.
- If all non-base symbols eliminated successfully, display the current formula, a success
message, and any requested print.
- If the user clicks the terminate button, close the application. If the user clicks the
continue button, clear the screen areas, and allow the user to process another formula.
The main six rules used in the elimination are: Ackermann, Surfacing, Clausify,
Purify, Skolemization, Sign-switch, and are detailed in figure 4 above. Other rules are
also used for simplification such as: Deletions, Replacement, Redundancy eliminations,
and Reductions, and are detailed in Appendix (2) below.

6
The code could be made as one big program, or a main procedure and several
external sub-programs. The latter is recommended so that it would be easier to do any
future alteration to the system if any addition is needed. Each part of the system should
be implemented in one procedure.
The term “procedure” refers to a piece of code. Depending on the programming
language, it could be a sub-program, or a sub-routine. For Java language, which is the
recommended language to develop the system, the term refers to a method within a class,
or an external class packaged with the main class in the same package. All the required
procedures are explained next at the system component section. It is recommended that
each procedure should be developed on a Java class on its own. This means that
additional procedures could be added, and existing procedures could be updated without
or with minimum change to the main class.

4. Details of design.
4.1 System Component-1
In this section, parts of the system and processing in each part are discussed. As
mentioned above in the recommendation that the system should consist of a main
procedure, and several procedures one for each function.
Function procedures
The function procedures are explained first, followed by the main procedure.
Function procedures can be performed repeatedly to perform certain functions. It is
recommended that each of the procedures below should be in one separate sub-program.
Using Java language, a separate class should be used for every procedure, and all classes
should be packaged into one package.
In order to clarify the function of each procedure below, the following is a sample
formula that will be referred in the procedures below.
☐x ( ( ( ( F1 ∧ F2 ) ∧ ( F3 ∨ F4 ) ) ∧ y⃟ ( F6 ⇨ F7 ) ) ⇔ F8 )
Where:
☐ and ⃟ = modal quantifiers box and diamond
x, y = variables
F1 – F7 = sub-Formulae of the original formula

Procedure 01: Scan input (current) formula and build


a data structure for the formula.
Scan the current formula and find logic symbols, brackets and texts. Build a two
rows array, one row symbols and one row for the position of each symbol. For the above
sample formula, the map would look like this:
☐ x (1 (2 (3 (4 F1 ∧ F2 )4 ∧ (5 F3 ∨ F4 )5 =>
1 2 3 4 5 6 7 9 10 12 13 14 15 17 18 20 =>
=> )3 ∧ ⃟ y (6 F5 ⇨ F6 )6 )2 ⇔ F7 )1
=> 21 22 23 24 25 26 28 29 31 32 33 34 36
Spaces are used to separate fields, but not to be put in the table.
Notice that the formula could be re-built from the table.
7
Procedure 02: Scan input formula and locate ⇨, ⇔.
Scan the current formula and find ⇨ and ⇔ symbols. For each symbol, locate and
identify sub-formulae before and after it, and build the data structure:
F5 ⇨ F6 … ( ( ( F1 ∧ F2 ) ∧ ( F3 ∨ F4 ) ∧ ⃟y ( F5 ⇨ F6 ) ) ) ⇔ F7
13 28 29 … 04 33 34
This structure will be used when eliminating “⇨” and “⇔”.
Procedure 03: Scan input formula and locate open and close brackets.
Scan the current formula and locate open and close brackets. Build the data
structure as above. On the top row, each open bracket should be followed by a number
representing its sequence between all open brackets in the formula. The corresponding
close bracket should be followed by the same number:
(01 (02 (03 (04 )04 (05 )05 )03 (06 )06 )02 )01
03 04 05 06 12 14 20 21 25 31 32 36

This structure will be used when dealing with brackets in simplification, and trying
to reduce brackets. It is also used when pushing symbols such as “¬” and quantifiers
inside brackets. “10 10”
Procedure 04: Scan input formula and locate “∧”, “ ⃟”, and “⊥”.
Scan current formula, locate “∧”, “ ⃟”, and “⊥”, build data structure as above
F1 ∧ F2 … ( F1 ∧ F2 ) ∧ ( F3 ∨ F4 ) … =>
07 09 10 … 06 13 14 … =>
=> ( ( F1 ∧ F2 ) ∧ ( F3 ∨ F4 ) ) ∧ ⃟ y ( F5 ⇨ F6)
=> 05 22 23 24 25
This structure will be used to eliminate “∧”, “ ⃟”, and “⊥”.
Procedure 05: Scan the formula, locate “¬” and build a data structure
Scan the formula and locate any “¬”: ¬ (… )
For example ¬(… ), the data structure would be: 98 99
Procedure 06: Scan the formula, and apply the basic
simplification rules.
Scan the formula and apply the following basic simplification:
Obvious Simplification Obvious Simplification
α∨α α α∨¬⊤ α
α∨¬α ⊤ ☐⊤ ⊤
α∨⊤ ⊤
These rules are part of the substitution table at appendix (06).
Procedure 07: Scan the formula, and eliminate redundancies.
Scan the message and eliminate any redundant part. Redundancies are shown in the
substitution table in Appendix(06).

8
Procedure 08: Rearrange Formula; so that
all sub-formulae with non-base follow each other.
Scan formula and rearrange sub-formulae so that those not containing a non-base
symbol come first, and those containing a non-base symbol selected for elimination come
last. This is required to check if the formula is suitable for any of the elimination rules.
Procedure 09: Try to segment the formula for Ackermann rule.
Scan the formula and try to segment it into segments that satisfy the premise of
Ackermann rule; {α1∨p,..,αn∨p} ∪ N(p), and check that the Ackermann pre-conditions
are all satisfied. If any segment was found in the formula, return the formula in the new
format, with a data structure showing the position of the start and end of each segment.
Procedure 10: Try to segment the formula for Purify rule.
Scan the formula and try to segment it into segments that satisfy the premise of the
Purify rule: N(p), and check that the Purify pre-conditions are all satisfied. If any segment
was found in the formula, return the formula in the new format, with a data structure
showing the position of the start and end of each segment.
Procedure 11: Try to segment the formula for Surfacing rule.
Scan the formula and try to segment it into segments that satisfy the premise of
Surfacing rule: N ∪ {α ∨ ☐↑(σ) β(p) }, and check that the Surfacing pre-conditions are
all satisfied. If any segment was found in the formula, return the formula in the new
format, with a data structure showing the position of the start and end of each segment.
Procedure 12: Try to segment the formula for Skolemization rule.
Scan the formula and try to segment it into segments that satisfy the premise of
Skolemization rule: N ∪ {¬α∨¬☐↑(σ)β(p)}, and check that Skolemization pre-conditions
are satisfied. If any segment was found in the formula, return the formula in the new
format, with a data structure showing the position of the start and end of each segment.
Procedure 13: Try to segment the formula for Clausify rule.
Scan the formula and try to segment it into segments that satisfy the premise of
Clausify rule: N ∪ {¬ ( α ∨ β ) }, and check that the Clausify pre-conditions are satisfied.
If any segment was found in the formula, return the formula in the new format, with a
data structures showing the position of the start and end of each segment.
Procedure 14: Try to segment the formula for Sign-Switch rule.
Scan the formula and try to segment it into segments that satisfy the premise of
Sign-Switch rule: N(p), and check that the Sign-Switch pre-conditions are satisfied. If
any segment was found in the formula, return the formula in the new format, with a data
structure showing the position of the start and end of each segment.
Procedure 15: Try to segment the formula for Delete rule.
Scan the formula and try to segment it into segments that satisfy the premise of
Delete rule: N(p), and check that Delete pre-conditions are satisfied. If any segment was
found in the formula, return the formula in the new format, with a data structure showing
the position of the start and end of each segment.

9
Procedure 16: Try to segment the formula for Replace rule.
Scan the formula and try to segment it into segments that satisfy the premise of
Replace rule: N(p), and check that the Replace pre-conditions are satisfied. If any
segment was found in the formula, return the formula in the new format, with a data
structure showing the position of the start and end of each segment.
Procedure 17: Try to segment the formula for Reduce rule.
Scan the formula and try to segment it into segments that satisfy the premise of
Reduce rule: N(p), and check that the Reduce pre-conditions are satisfied. If any segment
was found in the formula, return the formula in the new format, with a data structure
showing the position of the start and end of each segment.

4.2 System Component-2


Main procedure
See diagram in Figure 7 below.
Input stage
Upon starting the application, the user would get the first screen displayed. The
layout of the screen is shown in Appendix (04). On this screen, several areas are
displayed for different reasons. These areas are:
• Area-01: to enable the user to enter the symbols to be eliminated (non-base symbols).
• Area-02: to enable the user to either key-in the formula, or select a file in which the
formula was previously saved. To the side of this area, there will be a list of all
possible logic symbols and connectors such as; forall(∀), exists(∃), and(⋀), or(⋁),
identical(≡), .. etc. if the user decides to key-in the formula, the user can click a
symbol and the symbol would get displayed in the area where the cursor stands. If the
user keys-in both a file name and a formula, the system would use the file name to
retrieve the formula and display it. The system in this case ignores the formula keyed
in by the user.
• Area-03: for displaying messages. This includes success messages, warning messages
and error messages.
• Area-04: for displaying the result of the elimination process. If the elimination
succeeds the resulted formula is displayed, and its equivalent first-order logic (FOL)
formula. In addition, if the user requested the production of the elimination steps, the
details are also displayed, with the facility to browse forward and backward if the area
is not enough to display all details. If the elimination was not successful, an
informational message is displayed and the details of the steps performed would be
displayed.
• Area-05: contains a set of buttons to enable the user to control the application.

Validation stage
Once the formula is entered, whether from a file or keyed in by the user, the user
will be able to click a button to start processing.
• Validate the input formula. The validation should include ensuring the formula is
legally formed. The following paragraphs detail the validation process.

10
The basic modal logic is the propositional logic plus the two operators ☐ (box)
and ⃟ (diamond). If P = {p, q, r …}, where p, q, and r are propositional symbols, also
known as propositional variables, the modal formulae of the basic modal logic over P
are defined by:
- Each of p, q, and r is a modal formula.
- The symbols p, q, and r are names and may consist of several characters.
- ⊤ (true) and ⊥ (false) are modal formulae.
- If φ and ψ are modal formulae, then so are:
¬ φ (not φ) and ¬ ψ (not ψ)
(φ ∨ ψ) (φ or ψ) and (φ ∧ ψ) (φ and ψ)
(φ ⇨ ψ) (φ implies ψ) and (φ ⇔ ψ) (φ is equivalent to ψ)
⃞ φ (box φ) and ⃟ φ (diamond φ)
• The basic modal operators are: ¬, ∨, ∧, ⃞, ⃟, ⊤, ⊥, ⇨, and ⇔. The following steps
should be followed to check the legality of the formula:
¬ (not): must be followed by: ‘(’, a formula, a variable, ,⃞ ⃟, ⊤, ⊥, ⇨, or ⇔.
may be preceded by: ‘(’, ∨, ∧, ⇨, or ⇔.
∨, ∧ (or, and): must be preceded by: ‘)’, a formula, a variable, ⊤, or ⊥,
must be followed by: ¬, ‘(’, a formula, a variable, ⊤, or ⊥.
⃞, ⃟ (box, diamond): must be followed by: ¬, ‘(’, a formula, variable, ⊤, or ⊥,
may be preceded by: ¬, ‘(’, ∨ or ∧.
⊤, ⊥ (true, false): may be preceded by: ¬, ‘(’, a formula, a variable, ∨, ∧, ⇨, or ⇔,
may be followed by: ‘)’, ∨, ∧, ⇨, or ⇔.
⇨, ⇔ (implies, equivalent): must be pre ceded by: ‘)’, a formula, a variable, ⊤, or
⊥,
must be followed by: ¬, ‘(’, a formula, variable,
⊤, or ⊥.
If any error found, display error message and stop.

Parsing the formula


• If no errors found, the parsing process starts. The processing in this stage produces a
data structure that represents the formula, and is easy to use to process the formula.
• The formula is scanned left to right. The scan operation looks for: logic operators,
open and close brackets, and variables identified by an alpha at the first or only
position of their name. The output from the operation consists of two arrays. The
elements of the two arrays are corresponding to each others, first to first, second to
second … etc, the first array is the indexes array and the second is the values array.
• The index denotes the number of a character in the formula relative to the beginning
of the formula. The first character of a formula has index 1.
• Both types of brackets consist o one and only one character. The logic operators
usually consist of one character, but may be more if the have super/sub-script.
Variable names may be any number of alphanumeric characters, the first of which
must be alpha character.

11
• Spaces are not extracted or stored, but used as separators.
• The scan operation, if it detects any of the above, it processes it as follows:
- For an open bracket, the index is stored in the next entry of the index array, and the
bracket is stores in the corresponding entry of the values array followed by the
relative number of open brackets in the input formula.
- For a close bracket, the index is stored in the next entry of the index array, and the
bracket is stores in the corresponding entry of the values array followed by the
number of the corresponding open bracket.
- For logic operators the index is stored in the next entry of the index array and the
logic operator in the corresponding entry of the values array.
- For variables, the index of the first character of the variable name is stored in the
next entry of the index array and the whole of the variable name is stored in the
corresponding entry of the values array. The end of a variable name may be a
space, open or close bracket or a logic operator.
• The two arrays created in the previous step compose the structure of the formula.
• Each entry in the indexes array contains the index of the first or only character in the
corresponding entry of the values array.
• Each entry of the values array contains a character string which is; a logic symbol, a
bracket and its relative number, or the name of a variable or predicate. An open
bracket is followed by its relative number between left brackets in the formula, and a
right bracket if followed by the number of the corresponding left bracket.
• Note that after the two arrays representing the data structure are built, the formula
could be re-established from the two arrays. Examples of data structures for different
purposes required by this system are shown in Appendix (03).

Elimination processing.
• If the parsing process completes successfully and without any errors, the elimination
process starts.
• The sequence of elimination of non-base symbols should be performed in any
sequence. If one sequence fails, another sequence should be tried, until one sequence
completes successfully. If all sequences are tried and all failed, the elimination
process is not possible; in this case a suitable error message should be displayed.
• Apply the Surfacing, Skolemization, and Clausify rules recursively. Before
performing any rule, check if the formula contains the premise of the rule, and if the
pre-conditions of applying the rule are satisfied. After performing the three rules,
check if the formula was altered or not.
• If changed, loop back and re-apply the three rules again. Continue looping until no
change to the formula is detected.
• If no change to the formula, continue with next step. Otherwise apply Ackermann and
Purify rules only once.
• This should complete the elimination process of one non-base symbol.

12
• If there is any remaining non-base symbol to eliminate, select the next one in
sequence and loop back at the elimination process.
• If no more non-base symbols left, at this point of processing, the elimination is
complete. Check that the current formula doesn’t contain any of the non-base
symbols.
• If any of the non-base symbols still exists, issue a notification message and stop. If all
the non-base symbols have disappeared from the current formula, display the final
formula in FOL format and display a success message.
Produce required output
• Produce any requested print.
• If the user clicks the terminate button, close the application.
• If the user clicks the continue button, clear all areas of the screen, and start again.
Convert the formula to FOL
Processing in this part of the system, which converts the formula to FOL format,
could be used with any other system where the conversion is needed. Any other system
developed in Java could import the classes covering this part of processing and use them
for conversion.
To start with, the formula should be broken down into its simplest sub-formulae.
The data structure of the formula should be used to identify the sub-formulae of the
formula. The system would use the data structure and the FOL conversion table in
Appendix (05) to perform the following steps:
• If the first character of the sub-formula is the symbol “⊤”, return ⊤.
• If the first character of the sub-formula is the symbol “⊥”, return ⊥.
• If “¬” precedes the sub-formula, on the format “¬F”, extract sub-formula “F” and
return ¬ π ( F, x)
• If “∨” precedes the sub-formula, on the format “∨F”, extract the sub-formula “F” and
return ∀y R(x, y) ⇨ π (F, x)
• If “ ⃟” precedes the sub-formula, on the format “ ⃟F”, extract the sub-formula “F” and
return ∃y R(x, y) ∧ π ( F, x)
• If “∀” precedes the sub-formula, on the format “∀α”, extract the sub-formula “α”
and return ∀Pi [ π ( α, x)]
• See diagram in Figure 6 below.

5. Implementation plan
See implementation task list and implementation Gant chart in Appendix (7).

6. References
Modal Logic,
[Patrick Blackburn, Maarten de Rijke and Yde Venema, 2001]
Second-order quantifier elimination,
[Gabbay, Dov M., Schmidt Renate A., Szalas, Andrzej, 2008].
The Theory of Parsing, Translation, and Compiling
13
[Aho, Alfred V., Ullman, Jeffrey D., 1972]
Compiler: Principles, Techniques, and Tools
[Aho, Alfred V., Sehi,Ravi J., 1986]
COMP60161 module lecture notes, Manchester University,
[Schmidt, Renate A., Ulster, U., 2008]
Paper: The Ackermann Approach for Modal Logic, Correspondence Theory and
Second-OrderReduction [Schmidt, Renate A., 2008]

Start

1st = ⊤ Substitute ⊤
yes.

no

1st=⊥ Substitute ⊥
yes.

no
Extract Formula “F”
¬F Return ¬ π ( F, x)
yes.

no
Extract Formula “F”
☐F Return ∀y R(x, y) ⇨
yes π ( F, x)
no

no Extract Formula “F”


⃟F yes Return ∃y R(x, y) ∧
π ( F, x)

no

1st = ∀ Extract Formula “α”


rd th
3 4 = ps Return ∀Pi [ π ( α, x)]
yes

no
s is a subscript eg ps
End

Figure 6: FOL translation chart

14
Receive input formula
e. g. D axiom:
☐p ⇨ ⃟p
Simplify
Make the Steps 1 => 6, example page 6,
formula have then split into formula at 6.1
only operators
¬, ☐, ⃟, ∧, ∨
and formula 6.2

1
Steps 07 => 11 applied to formula at 6.1
Steps 12 => 16 applied to formula at 6.2
Ackermann rule Ackermann conditions Apply Ackermann
is formula suitable? Do they hold? Indicate formula
Yes: Yes: Changed
No: continue No: continue Return
Return

Surfacing rule Surfacing conditions Apply Surfacing


is formula suitable? Do they hold? Indicate formula
Yes: Yes: changed
No: continue No: continue Return
Return

Repeat all rules

Formula changed
No changes

Go convert final formula to FOL


Figure: 7 Structure of the System

15
APPENDIX (01)
Glossary

The notations: ↑ ( ) = superscript, ↓ ( )


Throughout this document:
↑( ) = superscript: Px is written P↑(x), and
↓( ) = subscript: Px is written P↓(x).

Logic
A logic is a triple: L = 〈 F, I, ⊨ 〉, where:
F is a non-empty set called the set of formulae, OR called also the language of logic L.
(it often assumed that True , False ∊ F).
I is a non-empty set of admissible interpretations.
⊨⊆ F × I is a relation called the satisfiability relation, assigning truth values for
formulae under interpretation.

Zero-order logic, OR propositional logic


Given a non-empty set V0 called the set of propositional or zero-order variables
ranging over {True, False}, AND
A non-empty set C of propositional connectives, with each C ∊ C we associate the
arity of C that is a natural number. Connectives of arity 1 called unary and of arity 2
called binary, then:
F is defined inductively to be the smallest set containing V0 and closed under
propositional connectives, i.e. if C ∊ C is a connective of arity n and; α1, .. , αn ∊ F
then C(α1, .. ,αn) ∊ F.

First-order logic
Any logic 〈 F, I, ⊨ 〉, which is an extension of zero-order logic, with additionally:
A non-empty set V1 called the set of individual variables, a non-empty set Fun of
function symbols, and a non-empty set Rel of relation symbols. With each f ∈ Fun and
R ∈ Rel we associate the arity of f/R which is a natural number, AND a set of terms;
Terms, defined inductively as the smallest set containing individual variables and
constants and closed under applications of function symbols, i.e., if f ∈ Fun is a
function symbol of arity n and t1, t2, .. , tn ∈ Terms then f(t1m t2, .. , tn) ∈ Terms.
Atomic formulae are expressions of the form R(t1, .. , tn) where R ∊ Rel is an n-ary
relation symbol and t1, .. , tn ∊ Terms.

16
F is defined inductively to be the smallest set containing propositional formulae,
atomic formulae and closed under propositional connectives and first-order quantifiers
∀x, and ∃x, i.e., ∀x[α1], ∃x[α1] ∊ F.
The quantifier ∀x is called universal and ∃x is called existential.
Second-order logic
Any logic 〈 F, I, ⊨ 〉, which is an extension of any first-order logic, with additionally:
A non-empty set V2 called the set of second-order variables representing formulae,
AND
F is defined inductively to be the smallest set containing first-order formulae, second-
order variables and closed under propositional connectives, first-order, and second-
order quantifiers,
i.e. if C ∊ C is a connective of arity n, c ∊ V1, X ∊ V2 and α1, .. , αn ∊ F then:
C(α1, .. , αn), ∀x[α1], ∃x[α1], ∀X[α1], ∃X[α1] ∊ F.
The quantifier ∀X is called universal and ∃X is called existential.

Literal
A positive literal is either an atom P(t1, .. , tn) or t1 ≈ t2, where P is an n-ary relation
symbol and t1, .. , tn are terms.
A negative literal is either an atom ¬P(t1, .. , tn) or t1 ≉ t2, where
An atom t1 ≈ t2 is also called an equation
A negative atom t1 ≉ t2 is also called an inequation

Clause
Clauses are multi-sets of literals. A multi-set over a set L is a mapping C from L to the
natural numbers.
L ∊ C if C(L) > 0for a literal L.
A sub-clause of a clause C is a sub-multi-set of C.
An empty clause is denoted by ⊥.
A positive/negative clause contains only positive/negative literals.
In logic, a clause is a disjunction of literals.

17
Appendix (02)
Rule name Rule Condition
Deletion N ∪ {α} / N α is redundant wrt N

Replacement N∪{α}/N∪{β} M ⊨ α iff M ⊨ β, for any


K(m)n (⌣)-model M, and
α≻β
Reduction N ∪ {α, β } / N ∪ {α, γ } M ⊨ α ∧ β iff M ⊨ α ∧ γ, for
any K(m)n (⌣)-model M, and
β≻γ
Redundancy elimination rules
Rule name Rules Rules
Eliminate α ↔ β ⇨ ¬ (¬ (~ α ∨ β) ∨ α→β⇨~α∨β
⇔,⇨, ∧, σ⃟ , ⊥ ¬ (~β ∨ α) ) ¬ (α → β) ⇨ ~ α ∨ ~ β
¬ (α ↔ β) ⇨ ¬ (~ α ∨ β) ∨ ⃟ α ⇨ ¬ σ⃞ ~ α
σ

¬ (~β ∨ α) ¬ σ⃟ α ⇨ σ⃞ ~ α
α ∧ β ⇨ ¬ (~ α ∨ ~β) ⊥⇨ ¬⊤
¬ (α ∧σ β) ⇨ ~ ασ ∨ ~β ¬⊥⇨ ⊤
Distributivity of ¬ (¬ ⃞ α ∨ ¬ ⃞ β) ⇨ ¬ (α ∨ β) ∨ γ ⇨ ¬ (¬ (~ α ∨ γ) ∨
∨ , σ⃞ , over ∧ ⃞ ¬ (~ α ∨ ~β)
σ
¬ (~β ∨ γ)
Simplification involving ¬ α ∨ ¬ σ⃞ ( σ,⃞ ⌣ ¬ α ∨ α) ¬ α ∨ ¬ σ⃞ ¬ ( σ,⃞ ⌣ ¬ α ∨ α)
⃞ and σ,⃞ ⌣
σ
⇨ ¬ α ∨ ¬ σ⃞ α ¬ α ∨ ¬ σ⃞ ¬ α
¬ α ∨ σ⃞ ( σ,⃞ ⌣ ¬ α ∨ α) ¬ α ∨ ¬ σ⃞ ¬ ( σ,⃞ ⌣ ¬ ⊤ ∨ α)
⇨ ¬ α ∨ σ⃞ α α ∨ σ⃞ ⃞σ,⌣ α ⇨ α ∨ σ⃞ ¬⊤
Sample rewrite rules for the replace rule

Appendix (03)
Examples of data structures
A data structure, in this system, is a table that put each part of a formula and the
relative position in the formula in a table, which could be used to re-establish the formula
again from the table:
Example-01
☐↑(K) α ☐↑(K) α: (☐K α) =>
01 06
Example-02
☐x ( ( F1 ∧ F2 ) ) => ☐ x (01 (02 F1 ∧ F2 )01 )02
01 02 03 04 05 07 08 10 11

18
Appendix (04)
Screen Layout
Area-01: Non-base symbols to be deleted
Enter non-base symbols to eliminate separated
by commas

Area-02: Formula entry


Formula to be processed: Top - - - ⊤
File containing formula: - ⊥
Bottom ∨
-- ∧
Key in formula: Or - - - - ☐
- ⃟
And - - - ⇨
- ⇔
Box - - -
¬
--
σ
Diamon
α
d-
β
Imply - -

--
Equivale

nt
Not -- -
--

Area-03: Messages

Area-04: Result of processing

Area-05: Buttons

Proces Print Continu Termina


s e te

19
Appendix (05)
Table of FOL Conversion
Non-FOL FOL
π (p↓(i), x) P↓(i)(x)
π (⊤, x) ⊤
π (a↓(j), x) x ≈ c↓(j)
π (¬ α, x) ¬ π (α, x)
π (α ∧ β , x) π (α, x) ∧ π (β , x)
π (☐↑(K) α, x) ∀ y [R↑(K) (x, y) ⇨π (α, y)]
π (∀ p↓(i) [α], x) ∀ Pi [π (α, x)]
x = First-order variable
y = Fresh first-order variable whenever required
P↓(i): pi = Predicate symbols uniquely associated with
constants p↓(i): pi
a↓(j): aj = Nominal uniquely associated with constant cj
R↑(K): Rk = binary predicate symbol representing the
accessibility relation associated with ☐↑(K,⌣): ☐k,⌣
The symbol ≈ denotes the first-order equality predicate

Appendix (06)
Substitution tables
↑ ( ) = superscript ↓ ( ) = subscript
Elimination of ⇔, ⇨, ∧, ☐ and ⊥
01 Equivalent (⇔) α⇔β ¬ (¬ (~ α ∨ β ) ∨ ¬ (~ β ∨ α )
02 ¬(α⇔β) )¬ (~ α ∨ β ) ∨ ¬ ( ~ β ∨ α )
03 Implies (⇨) α⇨β ~α∨β
04 ¬(α⇨β) ¬ (~ α ∨ β )
05 And (∧) α∧β ¬(~α∨~β)
06 ¬(α∧β) ~α∨~β
07 Diamond ( ⃟) ⃟α ¬☐~α
08 ¬ ⃟α ☐~α
09 Bottom (⊥) ⊥ ¬⊤
10 ¬⊥ ⊤

20
Distributivity of ∨, ☐, over ∧
11 Or (∨) ¬(α∨β)∨ɣ ¬(¬(~α∨ɣ)∨¬(~β∨
12 Box σ (☐ ↑(σ) ¬ ( ¬ ☐ ↑(σ) α ∨ ¬ ☐↑(σ) ɣ☐↑(σ)
) ) ¬ (~ α ∨ ~ β )
β)
Obvious Simplification
13 α∨α α
14 α∨¬α ⊤
15 α∨⊤ ⊤
16 α∨¬⊤ α
17 ☐⊤ ⊤

Conversion to FOL
17 π (p↓(i), x) P↓(i)(x)
18 π (⊤, x) ⊤
19 x ≈ c↓(j)
20 ¬ π (α, x)
21 π (a↓(j), x) π (α, x) ∧ π (β , x)
22 π (¬ α, x) ∀ y [R↑(K) (x, y) ⇨π (α, y)]
23 π (∀ p↓(i) [α], x) ∀ Pi [π (α, x)]

x = First-order variable
y = Fresh first-order variable whenever required
P↓(i): pi = Predicate symbols uniquely associated
with
constants p↓(i): pi
aj = Nominal uniquely associated with constant cj
R↑(K): Rk = binary predicate symbol
representing the accessibility relation
associated with ☐↑(K,⌣): ☐k,⌣

The symbol ≈ denotes the first-order equality


predicate

Simplifications involving ☐ σ, ☐ σ,⌣


24 ¬ α ∨ ¬ ☐↑(σ) (☐↑(σ, ⌣) ¬ α ∨ α ) ¬ α ∨ ¬ ☐↑(σ) α
25 α ∨ ☐↑(σ) ☐↑(σ, ⌣) α α ∨ ☐↑(σ) ¬ ⊤
26 ¬ α ∨ ☐↑(σ) (☐↑(σ, ⌣) ¬ α ∨ α ) ¬ α ∨ ☐↑(σ) α
27 ¬ α ∨ ¬ ☐↑(σ) ¬ (☐↑(σ, ⌣) ¬ α ∨ ¬ α ∨ ¬ ☐↑(σ) ¬ α
28 α
¬α ) ∨ ¬ ☐↑(σ) ¬ (☐↑(σ, ⌣) ¬ ⊤ ∨ α ¬ α ∨ ¬ ☐↑(σ) ¬ α
29 )¬ ¬ α α

21
Redundancy
30 Delete N∪{α} N
α is redundant wrt N
31 Replace N∪{α} N∪{β}
M ⊨ α iff M ⊨ β for any
K↑(n,⌣)↓((m)) , Model M
α≻β
32 Reduce N∪{α,β} N∪{α,ɣ}
M ⊨ α ∧ β iff M ⊨ α ∧ ɣ ,
for any K↑(n,⌣)↓((m)) model

Elimination rules
33 Ackermann { α1 ∨ p, … ,αn ∨ p } ∪ (N↑(p)↓(~α1∨ … ~αn)
p = non-base symbol N(p) ↑(¬¬α1 , … ,¬¬αn)
N = negative wrt p ↓(α1, … ,αn)
p = max wrt each αi
34 Purify N(p) (N↑(p)↓(¬⊤) )↑(¬¬⊤)↓(⊤)
p = non-base symbol
N = negative wrt p
35 Surfacing N ∪ {α ∨ ☐↑(σ) β(p) } N ∪ { ☐↑(σ,⌣) α ∨ β(p) }
p = max non-base sym
symbol which
occurs
in α∨☐↑(σ)β
p not in α
☐↑(σ)β = positive wrt
p
36 Skolemization N ∪ {¬α ∨ ¬☐↑(σ) N ∪ { ¬α ∨ ¬ ☐↑(σ) ¬b,
p = max non-base sym β(p)} ¬ b ∨ ~ β(p) }
symbol which
occurs
in ¬α∨¬☐↑(σ)β
¬☐↑(σ)β = positive
wrt p
b = new nominal
37 Clausify N ∪ {¬ ( α ∨ β ) } N ∪ { ~ α, ~ β }
38 Sign switching N(p) (N↑(p)↓(¬p) )↑( ¬ ¬ p)↓(p)
N closed wrt other
rules
P = max non-base in N
Sign switching wrt p
hasn’t been performed
before

22
Appendix (07)
Implementation tasks and Gant chart
Tasks days
1 Design of how each of the function procedures should be coded, including input and output parameters. This step 15
may combine processing of more than one procedure together into one
2 Design of the way each function procedure would be tested, and preparation the test date required to test each. 10
3 Design of the way the main procedure would be coded, and how it will be tested, and preparation of test data. 5
4 Coding and testing function procedures. 20
5 Coding and testing the main procedure. 10
6 Overall testing of the whole system. 10
7 Produce final documentation and user guide. 10
TOTAL 80
Implementation task list

Tasks w01 w02 w03 w04 w05 w06 w07 w08 w09 w10 w11 w12 w13 w14 w15 w16
Design func procs code
Design func procs test -- -- --
Design main proc code -- -- -- -- --
Code / test func procs -- -- -- -- -- --
Code / test main proc -- -- -- -- -- -- -- -- -- --
Test the whole system. -- -- -- -- -- -- -- -- -- -- -- --
Produce docs / user guide -- -- -- -- -- -- -- -- -- -- -- -- -- --
Implementation Gant chart

23

Вам также может понравиться