Sha256: ad5ee7ba19a11b2aef6a01e1674a6ffe6bfe3192cd0b4a6b8ff3ee453d11bc6b

Contents?: true

Size: 1.94 KB

Versions: 1

Compression:

Stored size: 1.94 KB

Contents

require 'minitest_helper'

class TestPropositionalLogic < TestInterpreterBase
  def setup
    $world.clear!
  end

  # TODO: opposite
  def assert_iq_equal(output, input)
    assert_equal(output, Hilbert::Iq.execute(input))
  end

  def test_general
    assert_iq_equal('Defined: A is TRUE', 'A')
    assert_iq_equal('Evaluate: A is TRUE', 'A?')
    assert_iq_equal('Evaluate: B is UNDEFINED', 'B?')
    assert_iq_equal('Defined: A->B is TRUE', "A->B")
    assert_iq_equal('Evaluate: B is TRUE', 'B?')
  end

  def test_syllogisms
    assert_iq_equal('Evaluate: A is UNDEFINED', 'A?')
    assert_iq_equal('Evaluate: A -> C  is UNDEFINED', 'A -> C ?')
    assert_iq_equal('Defined: A -> B is TRUE', 'A -> B')
    assert_iq_equal('Defined: B -> C is TRUE', 'B -> C')
    assert_iq_equal('Evaluate: A -> C  is TRUE', 'A -> C ?')
  end

  def test_paradox?
    assert_iq_equal('Defined: A is TRUE', 'A')
    assert_iq_equal('Defined: ~A is TRUE', '~A')
  end
    # assert_iq_equal('Defined: P(1) is true', "P(1)")
    # assert_iq_equal('Evaluate: P(1) is true', 'P?(1)')
    # assert_iq_equal('Evaluate: P(2) is undefined', 'P?(2)')
    # assert_iq_equal('Evaluate: Q(1) is undefined', 'Q?(1)')
    # assert_equal(
    #   "Defined: A[x] P(x) -> A[x] Q(x) is true",
    #   $world.truth.def_impli(['P', :all, true], ['Q', :all, true])
    # )
    # assert_iq_equal('Evaluate: Q(1) is true', 'Q?(1)')
    #
    # assert_iq_equal('Evaluate: Q(2) is undefined', 'Q?(2)')
    #
    # $world.truth.reset!
    # assert_iq_equal("Defined: Human('gogo1') is true", "Human('gogo1')")
    # assert_equal(
    #   "\"Defined: Human(\\'gogo1\\') -> WillDie(\\'gogo1\\') is true\"",
    #   $world.truth.def_impli(['Human', 'gogo1', true], ['WillDie', 'gogo1', true])
    # )
    # assert_iq_equal("Evaluate: WillDie('gogo1') is true", "WillDie?('gogo1')")
    # assert_iq_equal("Evaluate: WillDie('gogo2') is undefined", "WillDie?('gogo2')")
    # assert_iq_equal('Evaluate: Q(x) is true', 'Q?(x)')
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hilbert-0.0.2700100 test/interpreter/test_propositional_logic.rb