GitHubGitHub Stars

This is a static showcase, not a live editor. Unlike sibling project kUML's playground, kTRIZ has no hosted execution service here — ktriz-script, the Kotlin scripting host behind ktriz run, is deliberately unsandboxed by design (arbitrary Kotlin code, full JVM access), which is exactly right for a local CLI tool and exactly wrong to expose to arbitrary input from the public internet. Run these examples yourself locally instead:

ktriz run example.ktriz.kts

Contradiction — chassis weight vs. strength

The core lookup: two engineering parameters in tension, resolved against the classical 39×39 contradiction matrix. An invented parameter name would fail to compile, not fail at runtime.

Code
import dev.ktriz.core.EngineeringParameter
import dev.ktriz.core.contradiction
import dev.ktriz.core.resolve

val problem =
    contradiction(
        improving = EngineeringParameter.WEIGHT_OF_MOVING_OBJECT,
        worsening = EngineeringParameter.STRENGTH,
    )

println("Contradiction: ${problem.improving.labelEn} up vs. ${problem.worsening.labelEn} down")
problem.resolve().forEach { p -> println("  #${p.id}  ${p.labelEn}") }
Output
Contradiction: Weight of moving object up vs. Strength down
  #28  Mechanics substitution
  #27  Cheap short-living objects
  #18  Mechanical vibration
  #40  Composite materials

Function model — engine cooling loop

A second small DSL for TRIZ function analysis: which components exist, and which functions connect them, judged useful, harmful, insufficient or excessive.

Code
import dev.ktriz.function.functionModel

val fm = functionModel {
    val engine = component("Engine")
    val coolant = component("Coolant")
    val block = component("Cylinder block")
    useful(from = coolant, to = engine, verb = "cools")
    harmful(from = engine, to = block, verb = "overheats")
    insufficient(from = coolant, to = engine, verb = "circulates")
}

println("${fm.components.size} components, ${fm.edges.size} functions")
fm.edges.forEach { e -> println("  ${e.from.name} --[${e.quality}]--> ${e.to.name} (${e.verb})") }
Output
3 components, 3 functions
  Coolant --[USEFUL]--> Engine (cools)
  Engine --[HARMFUL]--> Cylinder block (overheats)
  Coolant --[INSUFFICIENT]--> Engine (circulates)

Rendering the function model as SVG

Same model, rendered to a standalone SVG document via kUML's layout engine (used purely for node placement and edge routing — kTRIZ writes its own SVG markup). Stroke style encodes quality: solid for useful, wavy for harmful, dashed for insufficient, doubled for excessive.

Code
import dev.ktriz.function.functionModel
import dev.ktriz.render.kuml.renderSvg

val fm = functionModel {
    val engine = component("Engine")
    val coolant = component("Coolant")
    val block = component("Cylinder block")
    useful(from = coolant, to = engine, verb = "cools")
    harmful(from = engine, to = block, verb = "overheats")
    insufficient(from = coolant, to = engine, verb = "circulates")
}

println(fm.renderSvg())
Rendered SVG
Function model diagram: Coolant cools and circulates into Engine, Engine overheats into Cylinder block

Substance-field (Su-Field) model — grinding tool

A third DSL for TRIZ substance-field analysis: an object substance S1, an optional second substance S2, an interaction field, and a five-way completeness/quality judgement.

Code
import dev.ktriz.sufield.FieldType.MECHANICAL
import dev.ktriz.sufield.SuFieldQuality.INSUFFICIENT
import dev.ktriz.sufield.suField

val sf = suField {
    val workpiece = component("Workpiece")
    val tool = component("Grinding wheel")
    s1(workpiece)
    s2(tool)
    field(MECHANICAL)
    quality(INSUFFICIENT)
}

println("${sf.s1.name} -[${sf.field}]-> ${sf.s2?.name} (${sf.quality})")
Output
Workpiece -[MECHANICAL]-> Grinding wheel (INSUFFICIENT)

Rendering the Su-Field triangle as SVG

The classical S1-S2-field triangle: F at the apex, S1 bottom-left, S2 bottom-right. Fixed, deterministic geometry — no layout engine involved, because a Su-Field triangle always has exactly three nodes in a fixed arrangement.

Code
import dev.ktriz.sufield.FieldType
import dev.ktriz.sufield.SuFieldQuality
import dev.ktriz.sufield.suField
import dev.ktriz.render.kuml.renderSvg

val sf = suField {
    val workpiece = component("Workpiece")
    val tool = component("Grinding wheel")
    s1(workpiece)
    s2(tool)
    field(FieldType.MECHANICAL)
    quality(SuFieldQuality.INSUFFICIENT)
}

println(sf.renderSvg())
Rendered SVG
Su-Field triangle diagram: F (mechanical) at the apex, Workpiece (S1) and Grinding wheel (S2) at the base, dashed action line for insufficient quality

Standard solution classes — the 5-group structure

The coarse classification of Altshuller's 76 standard solutions for substance-field analysis, as an enum with five members (13/23/6/17/17 solutions, summing to 76).

Code
import dev.ktriz.sufield.StandardSolutionClass

val cls = StandardSolutionClass.ofId(1)
println("${cls.labelEn} (${cls.solutionCount} solutions)")
Output
Building and destruction of Su-Fields (13 solutions)

Standard solution — lookup by classical code

All 76 individual classical standard solutions, each with its dot-numbered code, owning class, and a short "what to do" statement — looked up by the code used throughout the TRIZ literature.

Code
import dev.ktriz.sufield.StandardSolution

val solution = StandardSolution.ofCode("1.1.1")
println("${solution.code} (${solution.standardClass.labelEn}): ${solution.labelEn}")
Output
1.1.1 (Building and destruction of Su-Fields): Complete an incomplete model. If there is only an object S1, add a second object S2 and an interaction (field) F.

MCP tool — resolve_contradiction

The same deterministic matrix lookup as the first example, but as a Model Context Protocol call instead of Kotlin code — with structured errors instead of compile errors, for LLM agents that cannot query a Kotlin compiler at runtime, but can query a tool.

Code
./ktriz-cli/build/install/ktriz/bin/ktriz mcp
MCP request
{"name": "resolve_contradiction", "arguments": {"improving": "WEIGHT_OF_MOVING_OBJECT", "worsening": "STRENGTH"}}
MCP response (abridged)
{
  "principles": [
    {"rank": 1, "id": 28, "symbol": "MECHANICS_SUBSTITUTION"},
    {"rank": 2, "id": 27, "symbol": "CHEAP_SHORT_LIVING_OBJECTS"},
    {"rank": 3, "id": 18, "symbol": "MECHANICAL_VIBRATION"},
    {"rank": 4, "id": 40, "symbol": "COMPOSITE_MATERIALS"}
  ],
  "empty": false,
  "kotlin": "contradiction(\n    improving = EngineeringParameter.WEIGHT_OF_MOVING_OBJECT,\n    worsening = EngineeringParameter.STRENGTH,\n)"
}

Physical contradiction — landing gear (separation in time)

One element, two opposite demands: the landing gear must be present (landing) and absent (drag in flight). Unlike a technical contradiction, it concerns a single property and is resolved by one of the four classical separation principles. kTRIZ deliberately offers no mapping from separation principles to the 40 inventive principles. Well-formedness is checked when the object is built.

Code
val pc =
    physicalContradiction {
        element("Landing gear")
        property("Presence")
        state("present", because = "needed for landing")
        oppositeState("absent", because = "causes drag in flight")
        separation(SeparationPrinciple.IN_TIME)
    }

println("Element: ${pc.element.name}")
println("State: ${pc.state} / Opposite state: ${pc.oppositeState}")
println("Separation: ${pc.separation!!.labelEn} / ${pc.separation!!.labelDe}")
Output
Element: Landing gear
State: present / Opposite state: absent
Separation: Separation in time / Trennung in der Zeit

MCP tools — standard solutions and physical contradictions

Two more of the twelve tools offered by `ktriz mcp`: lookup_standard_solution (one of the 76 standard solutions by code) and build_physical_contradiction (the example above as a tool call). Both responses were captured from a real JSON-RPC session and are abridged: the text content, a few catalog fields and the JSON-RPC envelope are omitted.

Code
./ktriz-cli/build/install/ktriz/bin/ktriz mcp
MCP request
{"name": "lookup_standard_solution", "arguments": {"code": "1.1.1"}}

{"name": "build_physical_contradiction", "arguments": {
  "element": "Landing gear", "property": "Presence",
  "state": "present", "stateBecause": "needed for landing",
  "oppositeState": "absent", "oppositeStateBecause": "causes drag in flight",
  "separation": "IN_TIME"}}
MCP response (abridged)
// lookup_standard_solution (abridged)
{
  "count": 1,
  "solution": {
    "code": "1.1.1",
    "symbol": "COMPLETE_INCOMPLETE_MODEL",
    "standardClass": {"id": 1, "labelDe": "Aufbau und Zerstörung von Su-Feldern", "solutionCount": 13},
    "labelEn": "Complete an incomplete model. If there is only an object S1, add a second object S2 and an interaction (field) F."
  }
}

// build_physical_contradiction (abridged)
{
  "element": {"name": "Landing gear"},
  "property": "Presence",
  "state": "present",
  "oppositeState": "absent",
  "separation": {"id": 2, "symbol": "IN_TIME", "labelEn": "Separation in time", "labelDe": "Trennung in der Zeit"},
  "kotlin": "physicalContradiction {\n    element(\"Landing gear\")\n    property(\"Presence\")\n    state(\"present\", because = \"needed for landing\")\n    oppositeState(\"absent\", because = \"causes drag in flight\")\n    separation(SeparationPrinciple.IN_TIME)\n}"
}