All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.aiddl.common.scala.reasoning.constraint.Constraint.scala Maven / Gradle / Ivy

Go to download

Provides common types and algorithm implementations for the fast prototyping integrative AI systems with the AIDDL framework.

The newest version!
package org.aiddl.common.scala.reasoning.constraint

import org.aiddl.core.scala.representation.*

case class Constraint(term: Tuple) {
  def arity: Int = term(0).length
  def scope: Tuple = term(0).asTup

  def satisfiedBy(assignment: Tuple): Boolean = {
    if term(1).isInstanceOf[CollectionTerm]
    then {
      val r = if assignment.isGround
      then term(1).asCol.contains(assignment)
      else term(1).asCol.exists(x => assignment.unifiable(x))
      r
    } else {
      try {
        term(1)(assignment).boolVal
      } catch {
        case _ => true
      }
    }
  }

  def satisfiedBy(substitution: Substitution): Boolean =
    this.satisfiedBy((scope \ substitution).asTup)

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy