Skip to content

Commit

Permalink
logic thoughts
Browse files Browse the repository at this point in the history
  • Loading branch information
fwbrasil committed Dec 22, 2023
1 parent fd54663 commit 4ddd1ad
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package kyo.llm.thoughts.logic

import kyo.llm.ais._

@desc(
p"""
The EquivalenceChecking thought guides the LLM in determining if two boolean expressions are equivalent.
- Involves step-by-step transformations and comparisons of the expressions.
- Each step includes descriptions and results of transformations.
- Continuously assesses the equivalence of the transformed expressions.
- Concludes with a final determination of equivalence.
"""
)
case class EquivalenceChecking(
initialExpr1: Expr,
initialExpr2: Expr,
equivalenceSteps: List[EquivalenceStep],
finalEquivalence: Boolean
)

case class EquivalenceStep(
stepDescription: String,
expr1Transformation: Expr,
expr2Transformation: Expr,
areEquivalent: Boolean
)
26 changes: 26 additions & 0 deletions kyo-llm/shared/src/main/scala/kyo/llm/thoughts/logic/Expr.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package kyo.llm.thoughts.logic

sealed trait Expr

sealed trait BooleanExpr extends Expr
object BooleanExpr {
case object True extends BooleanExpr
case object False extends BooleanExpr
case class Not(BooleanExpr: BooleanExpr) extends BooleanExpr
case class And(left: BooleanExpr, right: BooleanExpr) extends BooleanExpr
case class Or(left: BooleanExpr, right: BooleanExpr) extends BooleanExpr
case class Var(name: String) extends BooleanExpr
}

sealed trait MathExpr extends Expr

object MathExpr {
case class Constant(value: Double) extends MathExpr
case class Variable(name: String) extends MathExpr
case class Add(left: MathExpr, right: MathExpr) extends MathExpr
case class Subtract(left: MathExpr, right: MathExpr) extends MathExpr
case class Multiply(left: MathExpr, right: MathExpr) extends MathExpr
case class Divide(left: MathExpr, right: MathExpr) extends MathExpr
case class Power(base: MathExpr, exponent: MathExpr) extends MathExpr
case class Root(MathExpression: MathExpr, degree: MathExpr) extends MathExpr
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package kyo.llm.thoughts.logic

import kyo.llm.ais._

@desc(
p"""
The ExpressionOptimization thought process aims to simplify a boolean expression.
- Involves applying logical simplification steps to the expression.
- Each step aims to reduce the complexity and size of the expression.
- Results in an optimized expression that is logically equivalent to the original.
"""
)
case class ExpressionOptimization(
originalExpression: Expr,
optimizationSteps: List[OptimizationStep],
optimizedExpression: Expr
)

case class OptimizationStep(
stepDescription: String,
inputExpression: Expr,
outputExpression: Expr
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package kyo.llm.thoughts.logic

import kyo.llm.ais._

@desc(
p"""
The Boolean thought applies algebraic principles to simplify a boolean expression.
- Outlines each step of the reduction process with rule descriptions and expression transformations.
- Iteratively simplifies the expression using boolean algebra rules.
- Aimed at reducing the expression to True or False.
"""
)
case class Reduction(
initialExpression: Expr,
reductionSteps: List[ReductionStep],
finalOutcome: Expr
)

case class ReductionStep(
ruleDescription: String,
inputExpression: Expr,
outputExpression: Expr
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import kyo.llm.ais._

@desc(
p"""
The Constrain thought applies specific constraints to the AI's reasoning.
- Outlines constraints in the 'Apply specific constraints to the value generation' field.
- 'value' is where the AI applies these constraints in its process.
- Aims to enhance output precision and relevance.
- Example: Constrain["Adhere to ethical guidelines", EthicalReasoning] guides the AI to follow ethical standards.
The Constrain thought applies specific constraints to the AI's reasoning.
- Outlines constraints in the 'Apply specific constraints to the value generation' field.
- 'value' is where the AI applies these constraints in its process.
- Aims to enhance output precision and relevance.
- Example: Constrain["Adhere to ethical guidelines", EthicalReasoning] guides the AI to follow ethical standards.
"""
)
case class Constrain[C <: String, T](
Expand Down

0 comments on commit 4ddd1ad

Please sign in to comment.