Skip to content

Commit 4e82d80

Browse files
committed
Remove debugging statements.
1 parent 4ca460a commit 4e82d80

File tree

8 files changed

+3
-112
lines changed

8 files changed

+3
-112
lines changed

src/conjunctive_normal_form.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function get_conjunctive_normal_form(formula)
1111
"""
1212
Get equivalent formula with no negation in non-literal formulas.
1313
"""
14-
function collapse_negations(formula)
14+
function collapse_negations(formula)
1515
@match formula begin
1616
f::Negation => begin
1717
@match f.formula begin

src/helpers.jl

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export @debug
2-
# reshape
32

43
function bracketsplit(str)
54
parts = []
@@ -49,10 +48,7 @@ end
4948

5049
function powerset(x)
5150
result = [Set()]
52-
# println("collect(x) ", collect(x))
5351
for element in collect(x), idx = 1:length(result)
54-
# println("element ", element)
55-
# println("idx ", idx)
5652
newsubset = union(result[idx], Set([element]))
5753
push!(result, newsubset)
5854
end
@@ -87,19 +83,6 @@ function dispatch_applyrecursively(functionexpr, objectexpr,
8783
end
8884
end
8985

90-
# function dispatch_applyrecursively(functionexpr, objectexpr,
91-
# objecttype::Type{Val{:monotone_fields}})
92-
# fsymbol, fargs = functionexpr.args[1],
93-
# functionexpr.args[2:end]
94-
# quote
95-
# typeof($(esc(objectexpr)))(
96-
# [$fsymbol(
97-
# [arg == :_ ? field : arg
98-
# for arg in $(esc(fargs))]...)
99-
# for field in getfield.($(esc(objectexpr)), fieldnames($(esc(objectexpr))))]...)
100-
# end
101-
# end
102-
10386
macro debug(variable)
10487
Expr(:call,
10588
:println,
@@ -111,7 +94,6 @@ macro debug(variable)
11194
"\n"
11295
)
11396
end
114-
print(args...) = println(args...)
11597

11698
let nextfreesymbol = 0
11799
global getnextfreesymbol
@@ -124,28 +106,3 @@ let nextfreesymbol = 0
124106
nextfreesymbol = 0
125107
end
126108
end
127-
128-
# function reshape(formula::String, form::FormulaForm)
129-
# form == string ? String(Formula(formula)) : reshape(Formula(formula))
130-
# end
131-
132-
# function reshape(formula::Formula, form::FormulaForm)
133-
# @match form begin
134-
# string => String(formula)
135-
# formula => formula
136-
# quantifiedvariables => get_quantified_variables_form(formula)
137-
# prenex => get_prenex_normal_form(formula)
138-
# skolem => get_prenex_normal_form(
139-
# get_skolem_normal_form(formula)
140-
# )
141-
# removedquantifier => get_removed_quantifier_form(formula)
142-
# conjunctive => get_conjunctive_normal_form(formula)
143-
# resolutionready => get_conjunctive_normal_form(
144-
# get_removed_quantifier_form(
145-
# get_skolem_normal_form(
146-
# get_prenex_normal_form(
147-
# get_quantified_variables_form(
148-
# Formula(formula)))))
149-
# )
150-
# end
151-
# end

src/parser.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ Formula(str::AbstractString) = begin
5959
"|" => return Disjunction(Formula(formula1), Formula(formula2))
6060
end
6161
end
62-
end
62+
end

src/renamed_quantifiers_form.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ function get_renamed_quantifiers_form(formula, replacements=Dict{Variable, Varia
1111
)
1212
f::AFormula || f::EFormula => begin
1313
replacements[f.variable] = Variable(getnextfreesymbol())
14-
# println("got next symbol, ", replacements[f.variable])
1514
typeof(f)(
1615
replacements[f.variable],
1716
get_renamed_quantifiers_form(f.formula, copy(replacements)),

src/resolution.jl

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ function get_most_general_unifier(unifiables::Set{<:Unifiable})
44
unifier = Substitution()
55
unified = first(unifiables)
66
for unifiable in collect(unifiables)[2:end]
7-
# @debug unifier
87
most_general_unifier!(unifier, unified, unifiable)
98
substitute(unified, unifier)
109
end
@@ -14,8 +13,6 @@ end
1413
function most_general_unifier!(unifier!::Substitution, unifiable1::Unifiable, unifiable2::Unifiable)
1514
substituted_unifiable1 = substitute(unifiable1, unifier!)
1615
substituted_unifiable2 = substitute(unifiable2, unifier!)
17-
# @debug String(substituted_unifiable1)
18-
# @debug String(substituted_unifiable2)
1916
@match substituted_unifiable1 begin
2017
u1::Literal => begin
2118
# Two clauses A and B can only be unified if the
@@ -70,7 +67,6 @@ end
7067

7168
# Apply substitution in order.
7269
function substitute(formula::Union{Term, Formula, Literal, Clause}, substitution::Substitution)
73-
# @debug substitution
7470
substituted_formula = formula
7571
for (substitutee, substituter) in substitution
7672
substituted_formula = substitute(substituted_formula, substitutee, substituter)
@@ -79,8 +75,6 @@ function substitute(formula::Union{Term, Formula, Literal, Clause}, substitution
7975
end
8076

8177
function substitute(formula::Union{Term, Formula, Literal, Clause}, substitutee, substituter)
82-
# println("substitute")
83-
# @debug formula
8478
@match formula begin
8579
f::CNF => @applyrecursively substitute(:_, substitutee, substituter) f CNF
8680
f::Clause => @applyrecursively substitute(:_, substitutee, substituter) f Clause
@@ -141,27 +135,17 @@ function rename_all_variables(formula, replacements=Dict{Variable, Variable}())
141135
end
142136

143137
function get_maybe_unifiable_literals(clause1::Clause, clause2::Clause)
144-
# println("get_mabye_unifiable_literals")
145-
# println(clause1)
146-
# println(clause2)
147138
maybe_unifiable_literals = Set{Set{Literal}}()
148139
all_literals = union(clause1, clause2)
149140
literal_names = Set(map(l -> l.formula.name, all_literals))
150141
for literal_name in literal_names
151-
# println("literal_name ", literal_name)
152142
for (c1, c2) in ((clause1, clause2), (clause2, clause1))
153-
# println("c1 ", string(c1))
154-
# println("c2 ", string(c2))
155143
positive_literals_in_c1 =
156144
filter(l -> l.formula.name == literal_name && !l.negative, c1)
157145
negative_literals_in_c2 =
158146
filter(l -> l.formula.name == literal_name && l.negative, c2)
159147
positive_literals_combinations = powerset(positive_literals_in_c1)
160148
negative_literals_combinations = powerset(negative_literals_in_c2)
161-
# println("positive_literals_in_c1 ", positive_literals_in_c1)
162-
# println("positive_literals_combinations ", positive_literals_combinations)
163-
# println("negative_literals_in_c2 ", negative_literals_in_c2)
164-
# println("negative_literals_combinations ", negative_literals_combinations)
165149
for positive_literals in positive_literals_combinations
166150
for negative_literals in negative_literals_combinations
167151
if length(positive_literals) > 0 && length(negative_literals) > 0
@@ -172,37 +156,24 @@ function get_maybe_unifiable_literals(clause1::Clause, clause2::Clause)
172156
end
173157
end
174158
end
175-
# println("maybe_unifiable_literals ", maybe_unifiable_literals)
176159
maybe_unifiable_literals
177160
end
178161

179162
function is_satisfiable(clauses::CNF; maxsearchdepth=Inf)
180-
# @debug maxsearchdepth
181-
# @debug length(clauses)
182163
if maxsearchdepth == 0
183164
throw(OverMaxSearchDepthError())
184165
end
185166
renamed = rename_all_variables.(collect(clauses))
186167
clauses = CNF(renamed)
187-
# @debug String(clauses)
188168
newclauses = CNF()
189169
for clause1 in clauses
190-
# @debug clause1
191170
for clause2 in clauses
192-
# @debug String(clause1)
193-
# @debug String(clause2)
194171
groups_of_maybe_unifiable_literals = get_maybe_unifiable_literals(clause1, clause2)
195-
# @debug String(groups_of_maybe_unifiable_literals)
196172
for maybe_unifiable_literals in groups_of_maybe_unifiable_literals
197-
# @debug String(maybe_unifiable_literals)
198173
try
199174
unifier = get_most_general_unifier(maybe_unifiable_literals)
200175
newclause = setdiff(union(clause1, clause2), maybe_unifiable_literals)
201-
# @debug unifier
202-
# @debug String(newclause)
203176
substituted_newclause = substitute(newclause, unifier)
204-
# @debug unifier
205-
# @debug String(substituted_newclause)
206177
push!(newclauses, substituted_newclause)
207178
catch
208179
continue
@@ -211,7 +182,6 @@ function is_satisfiable(clauses::CNF; maxsearchdepth=Inf)
211182
end
212183
end
213184
union!(clauses, newclauses)
214-
# @debug String(clauses)
215185
if Clause([]) in clauses
216186
false
217187
else

src/skolem_normal_form.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ function get_skolem_normal_form(formula, replacements=Dict{Variable, Function}()
88
end
99
f::EFormula => begin
1010
replacements[f.variable] = Function(FunctionSymbol(getnextfreesymbol()), all_quantifiers)
11-
# @debug replacements[f.variable]
1211
get_skolem_normal_form(f.formula, replacements, all_quantifiers)
1312
end
1413
f::Conjunction || f::Disjunction => typeof(f)(get_skolem_normal_form(f.formula1, replacements), get_skolem_normal_form(f.formula2, replacements))

src/testing_helpers.jl

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,4 @@
11
using Base.Test
2-
# import Base.Test: record, finish
3-
# using Base.Test: AbstractTestSet, Result, Pass, Fail, Error
4-
# using Base.Test: get_testset_depth, get_testset
5-
# using Base.Test
6-
7-
# export FirstOrderLogicTest
8-
9-
# type FirstOrderLogicTest <: AbstractTestSet
10-
# description::AbstractString
11-
# executed_tests::Int
12-
# results::Vector
13-
# FirstOrderLogicTest(description::String, executed_tests=0) =
14-
# new(description, executed_tests, [])
15-
# end
16-
17-
# record(ts::FirstOrderLogicTest, child::AbstractTestSet) = push!(ts.results, child)
18-
# record(testset::FirstOrderLogicTest, result::Result) = begin
19-
# testset.executed_tests += 1
20-
# push!(testset.results, result)
21-
# println("$(testset.executed_tests): $(result.orig_expr)")
22-
# resetfreesymbols()
23-
# end
24-
25-
# function finish(ts::FirstOrderLogicTest)
26-
# # just record if we're not the top-level parent
27-
# if get_testset_depth() > 0
28-
# record(get_testset(), ts)
29-
# end
30-
# ts
31-
# end
322

333
export @customtest,
344
@customtest_throws

src/types.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export Term,
1616
Substitution,
1717
Unifiable,
1818
OverMaxSearchDepthError
19-
# FormulaForm
2019

2120
abstract type Term end
2221
abstract type Formula end
@@ -73,10 +72,9 @@ end
7372
end
7473

7574
const Clause = Set{Literal}
76-
const CNF = Set{Clause}
75+
const CNF = Set{Clause} # Conjunctive xnormal form
7776
const Substitution = Vector{Pair{Variable, Term}}
7877
const Unifiable = Union{Literal, Term}
79-
# Conjunctive normal form
8078

8179
String(x::PredicateSymbol) = x.symbol
8280
String(x::FunctionSymbol) = x.symbol
@@ -113,5 +111,3 @@ end
113111

114112
type NotUnifiableError <: Exception
115113
end
116-
117-
# @enum FormulaForm string formula quantifiedvariables prenex skolem removedquantifier conjunctive resolutionready

0 commit comments

Comments
 (0)