A conjunctive normal form of a logical expression.

Introduced properties

fun &(o: CNF): CNF

logic :: CNF :: &

Merge two CNF
fun data: Set[Set[LExpr]]

logic :: CNF :: data

The conjunction of disjunction of units.
protected fun data=(data: Set[Set[LExpr]])

logic :: CNF :: data=

The conjunction of disjunction of units.
fun simplify: CNF

logic :: CNF :: simplify

Simplify self by removing some useless clauses.

Redefined properties

redef fun ==(o: nullable Object): Bool

logic $ CNF :: ==

Have self and other the same value?
redef type SELF: CNF

logic $ CNF :: SELF

Type of this instance, automatically specialized in every class
redef fun hash: Int

logic $ CNF :: hash

The hash code of the object.
redef fun to_s: String

logic $ CNF :: to_s

User readable representation of self.

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun &(o: CNF): CNF

logic :: CNF :: &

Merge two CNF
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
fun data: Set[Set[LExpr]]

logic :: CNF :: data

The conjunction of disjunction of units.
protected fun data=(data: Set[Set[LExpr]])

logic :: CNF :: data=

The conjunction of disjunction of units.
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun hash: Int

core :: Object :: hash

The hash code of the object.
init init

core :: Object :: init

fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
fun simplify: CNF

logic :: CNF :: simplify

Simplify self by removing some useless clauses.
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_s: String

core :: Object :: to_s

User readable representation of self.
package_diagram logic::CNF CNF core::Object Object logic::CNF->core::Object

Parents

interface Object

core :: Object

The root of the class hierarchy.

Class definitions

logic $ CNF
# A conjunctive normal form of a logical expression.
class CNF
	# The conjunction of disjunction of units.
	var data = new Set[Set[LExpr]]

	# Simplify `self` by removing some useless clauses.
	#
	# * trivially clauses (with both a variable and its negation)
	# * subsumed clauses
	fun simplify: CNF
	do
		var cs2 = new Set[Set[LExpr]]

		# First pass to remove clauses with a variable and its negation.
		# These clauses become trivially `true`, thus useless in the conjunction.
		for c in data do
			for i in c do
				var nn = ~i
				if c.has(nn) then continue label
			end
			cs2.add c
		end label

		# Second pass to remove clauses subsumed by an other one.
		var cs3 = new Set[Set[LExpr]]
		for c in cs2 do
			for c2 in cs2 do
				if c2 != c and c2.has_all(c) then continue label
			end
			cs3.add c
		end label

		var res = new CNF
		res.data = cs3
		return res
	end

	# Merge two CNF
	fun &(o: CNF): CNF
	do
		var res = new CNF
		res.data.add_all self.data
		res.data.add_all o.data
		return res
	end

	redef fun to_s do return [for c in data do "(" + c.join("|") + ")"].join(" & ")

	redef fun ==(o) do return o isa CNF and data == o.data
	redef fun hash do return data.hash
end
lib/logic/lexpr.nit:329,1--379,3