Class: Axiom::Function::Proposition
- Inherits:
-
Axiom::Function
- Object
- Axiom::Function
- Axiom::Function::Proposition
- Includes:
- Connective::Conjunction::Methods, Connective::Disjunction::Methods, Connective::Negation::Methods, Singleton
- Defined in:
- lib/axiom/function/proposition.rb,
lib/axiom/function/proposition/tautology.rb,
lib/axiom/function/proposition/contradiction.rb
Overview
Abstract base class for logical propositions
Direct Known Subclasses
Defined Under Namespace
Classes: Contradiction, Tautology
Class Method Summary collapse
-
.coerce(object) ⇒ Proposition
Coerce a boolean into a proposition.
-
.type ⇒ Class<Types::Boolean>
Return the type returned from #call.
Instance Method Summary collapse
-
#call ⇒ Boolean
Evaluate the proposition.
-
#inverse ⇒ Proposition
Return the inverse proposition.
-
#rename(_aliases) ⇒ self
A no-op when receiving #rename message.
Methods included from Connective::Conjunction::Methods
Methods included from Aliasable
Methods included from Connective::Disjunction::Methods
Methods included from Connective::Negation::Methods
Methods inherited from Axiom::Function
extract_value, rename_attributes, #type
Methods included from Visitable
Class Method Details
.coerce(object) ⇒ Proposition
Coerce a boolean into a proposition
37 38 39 40 41 42 43 44 45 |
# File 'lib/axiom/function/proposition.rb', line 37 def self.coerce(object) case object when Proposition then object when true then Tautology.instance when false then Contradiction.instance else fail ArgumentError, "Invalid object #{object.inspect}" end end |
.type ⇒ Class<Types::Boolean>
Return the type returned from #call
22 23 24 |
# File 'lib/axiom/function/proposition.rb', line 22 def self.type Types::Boolean end |
Instance Method Details
#call ⇒ Boolean
Evaluate the proposition
55 56 57 |
# File 'lib/axiom/function/proposition.rb', line 55 def call(*) self.class.call end |
#inverse ⇒ Proposition
Return the inverse proposition
81 82 83 |
# File 'lib/axiom/function/proposition.rb', line 81 def inverse self.class.inverse.instance end |
#rename(_aliases) ⇒ self
A no-op when receiving #rename message
69 70 71 |
# File 'lib/axiom/function/proposition.rb', line 69 def rename(_aliases) self end |