I'm digressing a bit, but what language is used here? A skim-over looks like Prolog, but recommendation links at the bottom say Scala. Are the functions (when, and) predefined and not part of the language itself?
case class And(contract1: Contract, contract2: Contract) extends Contract
case class When(date: LocalDate, contract: Contract) extends Contract
It's basically a DSL on top of Scala.