Abstrakte Wikipedia/Beispiele/Funktionszusammensetzung

This page is a translated version of the page Abstract Wikipedia/Examples/Function composition and the translation is 100% complete.

Abstrakte Wikipedia über Mailingliste Abstrakte Wikipedia auf IRC Wikifunctions auf Telegram Wikifunctions auf Mastodon Wikifunctions auf Twitter Wikifunctions auf Facebook Wikifunctions auf Youtube Website von Wikifunctions Translate

Die Beispiele für Funktionskompositionen und Funktionsdeklarationen auf dieser Seite zeigen links die auf Englisch beschrifteten ZObjekte und rechts die tatsächliche Darstellung (unter Verwendung von ZIDs).

Boolesche Negation

Ein Argument, das eine einzelne integrierte Funktion (Z802/wenn) verwendet.

Z12401/Negation (Funktion)

{
  "type": "Function",
  "arguments": [{
    "type": "Argument declaration",
    "argument type": "Boolean",
    "key": "Z12401K1",
    "label": {
      "type": "Multilingual text",
      "texts": [{
        "type": "Monolingual text",
        "language": "en",
        "text": "x"
      }]
    }
  }],
  "return type": "Boolean",
  "testers": [],
  "implementations": [
    "negation implementation"
  ],
  "identity": "negation"
}
{
  "Z1K1": "Z8",
  "Z8K1": [{
    "Z1K1": "Z17",
    "Z17K1": "Z40",
    "Z17K2": "Z12401K1",
    "Z17K3": {
      "Z1K1": "Z12",
      "Z12K1": [{
        "Z1K1": "Z11",
        "Z11K1": "en",
        "Z11K2": "x"
      }]
    }
  }],
  "Z8K2": "Z40",
  "Z8K3": [],
  "Z8K4": [
    "Z12402"
  ],
  "Z8K5": "Z12401"
}

Z12402/Negationsimplementierung (Implementierung)

{
  "type": "Implementation",
  "function": "negation",
  "composition": {
    "type": "Function call",
    "function": "if",
    "condition": {
      "type": "Argument reference",
      "argument": "x"
    },
    "consequent": "false",
    "alternative": "true"
  }
}
{
  "Z1K1": "Z14",
  "Z14K1": "Z12401",
  "Z14K2": {
    "Z1K1": "Z7",
    "Z7K1": "Z802",
    "Z802K1": {
      "Z1K1": "Z18",
      "Z18K1": "Z12401K1"
    },
    "Z802K2": "Z42",
    "Z803K3": "Z41"
  }
}

Boolesches und

Zwei Argumente, aber immer noch mit nur einer einzigen integrierten Funktion (Z802/wenn). Gibt Argumente auf zwei verschiedene Arten zurück, einmal direkt, einmal als Ergebnis einer integrierten Funktion.

Z12411/und (Funktion)

{
  "type": "Function",
  "arguments": [{
    "type": "Argument declaration",
    "argument type": "Boolean",
    "key": "Z12411K1",
    "label": {
      "type": "Multilingual text",
      "texts": [{
        "type": "Monolingual text",
        "language": "en",
        "text": "left"
      }]
    }
  }, {
    "type": "Argument declaration",
    "argument type": "Boolean",
    "key": "Z12411K2",
    "label": {
      "type": "Multilingual text",
      "texts": [{
        "type": "Monolingual text",
        "language": "en",
        "text": "right"
      }]
    }
  }],
  "return type": "Boolean",
  "testers": [],
  "implementations": [
    "and implementation"
  ],
  "identity": "and"
}
{
  "Z1K1": "Z8",
  "Z8K1": [{
    "Z1K1": "Z17",
    "Z17K1": "Z40",
    "Z17K2": "Z12411K1",
    "Z17K3": {
      "Z1K1": "Z12",
      "Z12K1": [{
        "Z1K1": "Z11",
        "Z11K1": "en",
        "Z11K2": "left"
      }]
    }
  }, {
    "Z1K1": "Z17",
    "Z17K1": "Z40",
    "Z17K2": "Z12411K2",
    "Z17K3": {
      "Z1K1": "Z12",
      "Z12K1": [{
        "Z1K1": "Z11",
        "Z11K1": "en",
        "Z11K2": "right"
      }]
    }
  }],
  "Z8K2": "Z40",
  "Z8K3": [],
  "Z8K4": [
    "Z12412"
  ],
  "Z8K5": "Z12411"
}

Z12412/und-Implementierung (Implementierung)

{
  "type": "Implementation",
  "function": "and",
  "composition": {
    "type": "Function call",
    "function": "if",
    "condition": {
      "type": "Argument reference",
      "argument": "left"
    },
    "consequent": {
      "type": "Argument reference",
      "argument": "right"
    },
    "alternative": "false"
  }
}
{
  "Z1K1": "Z14",
  "Z14K1": "Z12411",
  "Z14K2": {
    "Z1K1": "Z7",
    "Z7K1": "Z802",
    "Z802K1": {
      "Z1K1": "Z18",
      "Z18K1": "Z12411K1"
    },
    "Z802K2": {
      "Z1K1": "Z18",
      "Z18K1": "Z12411K2"
    },
    "Z803K3": "Z42"
  }
}

Boolesches oder

Zwei Argumente wie zuvor. Aber dieses Mal haben wir zwei Implementierungen, beide Kompositionen, und eine davon führt verschachtelte Funktionsaufrufe an die beiden vorherigen Funktionen durch.

Z12421/oder (Funktion)

{
  "type": "Function",
  "arguments": [{
    "type": "Argument declaration",
    "argument type": "Boolean",
    "key": "Z12401K1",
    "label": {
      "type": "Multilingual text",
      "texts": [{
        "type": "Monolingual text",
        "language": "en",
        "text": "left"
      }]
    }
  }, {
    "type": "Argument declaration",
    "argument type": "Boolean",
    "key": "Z12401K2",
    "label": {
      "type": "Multilingual text",
      "texts": [{
        "type": "Monolingual text",
        "language": "en",
        "text": "right"
      }]
    }
  }],
  "return type": "Boolean",
  "testers": [],
  "implementations": [
    "or implementation",
    "or implementation with builtins"
  ],
  "identity": "or"
}
{
  "Z1K1": "Z8",
  "Z8K1": [{
    "Z1K1": "Z17",
    "Z17K1": "Z40",
    "Z17K2": "Z12421K1",
    "Z17K3": {
      "Z1K1": "Z12",
      "Z12K1": [{
        "Z1K1": "Z11",
        "Z11K1": "en",
        "Z11K2": "left"
      }]
    }
  }, {
    "Z1K1": "Z17",
    "Z17K1": "Z40",
    "Z17K2": "Z12421K2",
    "Z17K3": {
      "Z1K1": "Z12",
      "Z12K1": [{
        "Z1K1": "Z11",
        "Z11K1": "en",
        "Z11K2": "right"
      }]
    }
  }],
  "Z8K2": "Z40",
  "Z8K3": [],
  "Z8K4": [
    "Z12422",
    "Z12423"
  ],
  "Z8K5": "Z12421"
}

Z12422/oder-Implementierung (Implementierung)

{
  "type": "Implementation",
  "function": "or",
  "composition": {
    "type": "Function call",
    "function": "negation",
    "x": {
      "type": "Function call",
      "function": "and",
      "left": {
        "type": "Function call",
        "function": "negation",
        "x": {
          "type": "Argument reference",
          "argument": "left"
        }
      },
      "right": {
        "type": "Function call",
        "function": "negation",
        "x": {
          "type": "Argument reference",
          "argument": "right"
        }
      }
    }
  }
}
{
  "Z1K1": "Z14",
  "Z14K1": "Z12421",
  "Z14K2": {
    "Z1K1": "Z7",
    "Z7K1": "Z12401",
    "Z12401K1": {
      "Z1K1": "Z7",
      "Z7K1": "Z12411",
      "Z12411K1": {
        "Z1K1": "Z7",
        "Z7K1": "Z12401",
        "Z12401K1": {
          "Z1K1": "Z18",
          "Z18K1": "Z12421K1"
        }
      },
      "Z12411K2": {
        "Z1K1": "Z7",
        "Z7K1": "Z12401",
        "Z12401K1": {
          "Z1K1": "Z18",
          "Z18K1": "Z12421K2"
        }
      }
    }
  }
}

Z12423/oder-Implementierung mit Builtins (Implementierung)

{
  "type": "Implementation",
  "function": "or",
  "composition": {
    "type": "Function call",
    "function": "if",
    "condition": {
      "type": "Argument reference",
      "argument": "left"
    },
    "consequent": "true",
    "alternative": {
      "type": "Argument reference",
      "argument": "right"
    }
  }
}
{
  "Z1K1": "Z14",
  "Z14K1": "Z12411",
  "Z14K2": {
    "Z1K1": "Z7",
    "Z7K1": "Z802",
    "Z802K1": {
      "Z1K1": "Z18",
      "Z18K1": "Z12411K1"
    },
    "Z802K2": "Z41",
    "Z803K3": {
      "Z1K1": "Z18",
      "Z18K1": "Z12411K2"
    }
  }
}

Identität

Dies funktioniert bei Z8/Funktionen. Es könnte auch auf Z1/Objekt funktionieren, d. h. bei allem. Dabei wurde Z8 verwendet, um den Kombinator I im Lambda-Kalkül auszurichten.


Z12001/Identität (Funktion)

{
  "type": "Function",
  "arguments": [
    {
      "type": "Argument declaration",
      "argument type": "Function",
      "key": "Z12001K1",
      "label": {
        "type": "Multilingual text",
        "texts": [
          {
            "type": "Monolingual text",
            "language": "en",
            "text": "f"
          }
        ]
      }
    }
  ],
  "return type": "Function",
  "testers": [],
  "implementations": [
    "identity implementation"
  ],
  "identity": "identity"
}
{
  "Z1K1": "Z8",
  "Z8K1": [
    {
      "Z1K1": "Z17",
      "Z17K1": "Z8",
      "Z17K2": "Z12001K1",
      "Z17K3": {
        "Z1K1": "Z12",
        "Z12K1": [
          {
            "Z1K1": "Z11",
            "Z11K1": "en",
            "Z11K2": "f"
          }
        ]
      }
    }
  ],
  "Z8K2": "Z8",
  "Z8K3": [],
  "Z8K4": [
    "Z12002"
  ],
  "Z8K5": "Z12001"
}

Z12002/Identitätsimplementierung (Implementierung)

{
  "type": "Implementation",
  "function": "identity",
  "composition": {
    "type": "Argument reference",
    "argument": "f"
  }
}
{
  "Z1K1": "Z14",
  "Z14K1": "Z12001",
  "Z14K2": {
    "Z1K1": "Z18",
    "Z18K1": "Z12001K1"
  }
}

Selbstanwendung

Dies ist eine Funktion, die eine Funktion annimmt und diese Funktion auf sich selbst anwendet.

Verwendet zum ersten Mal einen lokalen Schlüssel für ein Argument (siehe K1 in der Implementierung).

Als erweitertes Ziel sollte Z12011, angewendet auf Z12011, erkennen, dass es sich selbst produziert und somit ein Fixpunkt ist, und sollte dann diesen Fixpunkt zurückgeben (d. h. das Ergebnis von Z12011(Z12011) sollte Z12011(Z12011) sein).

Z12011/Selbstanwendung (Funktion)

{
  "type": "Function",
  "arguments": [{
    "type": "Argument declaration",
    "argument type": "Function",
    "key": "Z12011K1",
    "labels": {
      "type": "Multilingual text",
      "texts": [{
        "type": "Monolingual text",
        "language": "en",
        "text": "f"
      }]
    }
  }],
  "return type": "Function",
  "testers": [],
  "implementations": [
    "self application implementation"
  ],
  "identity": "self application"
}
{
  "Z1K1": "Z8",
  "Z8K1": [{
    "Z1K1": "Z17",
    "Z17K1": "Z8",
    "Z17K2": "Z12011K1",
    "Z17K3": {
      "Z1K1": "Z12",
      "Z12K1": [{
        "Z1K1": "Z11",
        "Z11K1": "en",
        "Z11K2": "f"
      }]
    }
  }],
  "Z8K2": "Z8",
  "Z8K3": [],
  "Z8K4": [
    "Z12012"
  ],
  "Z8K5": "Z12011"
}

Z12012/Selbstanwendungsimplementierung (Implementierung)

{
  "type": "Implementation",
  "function": "self application",
  "composition": {
    "type": "Function call",
    "function": {
      "type": "Argument reference",
      "argument": "f"
    },
    "K1": {
      "type": "Argument reference",
      "argument": "f"
    }
  }
}
{
  "Z1K1": "Z14",
  "Z14K1": "Z12011",
  "Z14K2": {
    "Z1K1": "Z7",
    "Z7K1": {
      "Z1K1": "Z18",
      "Z18K1": "Z12011K1"
    },
    "K1": {
      "Z1K1": "Z18",
      "Z18K1": "Z12011K1"
    }
  }
}

K-Kombinator

Dies ist eine Funktion, die eine Funktion X annimmt und eine Funktion zurückgibt, die eine Funktion annimmt, aber die zuvor gegebene Funktion X zurückgibt, unabhängig von der Eingabe. Dies wird als K-Kombinator bezeichnet (K wie Konstante). Das sorgt für einen Abschluss.

Überprüft, ob die Alpha-Konvertierung funktioniert. Erstellt als Ergebnis auch eine Funktion mit einer integrierten Implementierung.

Z12021/K-Kombinator (Funktion)

{
  "type": "Function",
  "arguments": [{
    "type": "Argument declaration",
    "argument type": "Function",
    "key": "Z12021K1",
    "labels": {
      "type": "Multilingual text",
      "texts": [{
        "type": "Monolingual text",
        "language": "en",
        "text": "f"
      }]
    }
  }],
  "return type": "Function",
  "testers": [],
  "implementations": [
    "k combinator implementation"
  ],
  "identity": "k combinator"
}
{
  "Z1K1": "Z8",
  "Z8K1": [{
    "Z1K1": "Z17",
    "Z17K1": "Z8",
    "Z17K2": "Z12021K1",
    "Z17K3": {
      "Z1K1": "Z12",
      "Z12K1": [{
        "Z1K1": "Z11",
        "Z11K1": "en",
        "Z11K2": "argument"
      }]
    }
  }],
  "Z8K2": "Z8",
  "Z8K3": [],
  "Z8K4": [
    "Z12022"
  ],
  "Z8K5": "Z12021"
}

Z12022/K-Kombinator (Implementierung)

{
  "type": "Implementation",
  "function": "k combinator",
  "composition": {
    "type": "Function",
    "arguments": [{
      "type": "Argument declaration",
      "argument type": "Function",
      "key": "K1",
      "labels": {
        "type": "Multilingual text",
        "texts": [{
          "type": "Monolingual text",
          "language": "en",
          "text": "x"
        }]
      }
    }],
    "return type": "Function",
    "testers": [],
    "implementations": [{
      "type": "Implementation",
      "function": {
        "type": "Function call",
        "function": "k combinator",
        "f": {
          "type": "Argument reference",
          "reference": "f"
        }
      },
      "composition": {
        "type": "Argument reference",
        "reference": "f"
      }
    }],
    "identity": {
      "type": "Function call",
      "function": "k combinator",
      "f": {
        "type": "Argument reference",
        "reference": "f"
      }
    }
  }
}
{
  "Z1K1": "Z14",
  "Z14K1": "Z12021",
  "Z14K2": {
    "Z1K1": "Z8",
    "Z8K1": [{
      "Z1K1": "Z17",
      "Z17K1": "Z8",
      "Z17K2": "K1",
      "Z17K3": {
        "Z1K1": "Z12",
        "Z12K1": [{
          "Z1K1": "Z11",
          "Z11K1": "en",
          "Z11K2": "argument"
        }]
      }
    }],
    "Z8K2": "Z8",
    "Z8K3": [],
    "Z8K4": [{
      "Z1K1": "Z14",
      "Z14K1": {
        "Z1K1": "Z7",
        "Z7K1": "Z12021",
        "Z12021K1": {
          "Z1K1": "Z18",
          "Z18K1": "Z12021K1"
        }
      },
      "Z14K2": {
        "Z1K1": "Z18",
        "Z18K1": "Z12021K1"
      }
    }],
    "Z8K5": {
      "Z1K1": "Z7",
      "Z7K1": "Z12021",
      "Z12021K1": {
        "Z1K1": "Z18",
        "Z18K1": "Z12021K1"
      }
    }
  }
}