Module: PropLogic::Functions

Included in:
PropLogic, PropLogic, Term
Defined in:
lib/prop_logic/functions.rb

Overview

Utility methods for PropLogic.

Class Method Summary collapse

Class Method Details

.all_and(*args) ⇒ Term

Combine all terms with and.

Parameters:

  • terms (Term)

    to combine

Returns:

  • (Term)

    combined term



19
20
21
# File 'lib/prop_logic/functions.rb', line 19

def all_and(*args)
  Term.get AndTerm, *args
end

.all_or(*args) ⇒ Term

Combine all terms with or.

Parameters:

  • terms (Term)

    to combine

Returns:

  • (Term)

    combined term



12
13
14
# File 'lib/prop_logic/functions.rb', line 12

def all_or(*args)
  Term.get OrTerm, *args
end

.new_variable(*args) ⇒ Object

Create new variable.



24
25
26
# File 'lib/prop_logic/functions.rb', line 24

def new_variable(*args)
  Variable.new(*args)
end

.sat_loop(initial_term) {|Term, IncrementalSolver| ... } ⇒ Object

loop while satisfiable. Note: Loop continues infinitely if no addition was given inside the loop.

Yields:

  • (Term, IncrementalSolver)

    yield for each term.



31
32
33
34
35
36
37
38
# File 'lib/prop_logic/functions.rb', line 31

def sat_loop(initial_term)
  incremental = PropLogic.incremental_solver.new initial_term
  loop do
    sat = incremental.sat?
    break unless sat
    yield sat, incremental
  end
end