modus-ponens (python sample)๏ƒ

Tags: modus-ponens python sample

This page shows how to infer new statements in a theory-derivation by applying the modus-ponens inference-rule.

Usage๏ƒ

Call the infer_statement method from the inference-rule inclusion class listed in the i (unabridged inference_rules ) property of the theory-derivation :

u = pu.create_universe()
t = u.t()
...
# some theory derivation code
...
t.i.modus_ponens.infer_statement(...)

Sample code๏ƒ

import punctilious as pu

# Create a universe-of-discourse with basic objects for the sake of this example.
u = pu.UniverseOfDiscourse(echo=True)
o1 = u.o.declare()
o2 = u.o.declare()
o3 = u.o.declare()
r1 = u.c1.declare(arity=2, signal_proposition=True)
r2 = u.c1.declare(arity=1, signal_proposition=True)
axiom = u.a.declare(natural_language='Dummy axiom for demonstration purposes')

# Elaborate a dummy theory with a set of propositions necessary for our demonstration
t1 = u.t.declare(echo=True)
theory_axiom = t1.include_axiom(a=axiom)
p_implies_q = t1.i.axiom_interpretation.infer_formula_statement(a=theory_axiom, p=r1(o1, o2) | u.c1.implies | r2(o3),
    lock=False)
p = t1.i.axiom_interpretation.infer_formula_statement(a=theory_axiom, p=r1(o1, o2), lock=True)

# And finally, use the modus-ponens inference-rule:
proposition_of_interest = t1.i.modus_ponens.infer_formula_statement(p_implies_q=p_implies_q, p=p,
    subtitle='The proposition of interest')

Code output๏ƒ

๐–ซ๐–พ๐— โŒœ๐’ฐโ‚†โ‚€โŒ ๐–ป๐–พ ๐–บ ๐‘ข๐‘›๐‘–๐‘ฃ๐‘’๐‘Ÿ๐‘ ๐‘’-๐‘œ๐‘“-๐‘‘๐‘–๐‘ ๐‘๐‘œ๐‘ข๐‘Ÿ๐‘ ๐‘’.

๐–ซ๐–พ๐— โŒœ๐’ฏโ‚โŒ ๐–ป๐–พ ๐–บ ๐‘กโ„Ž๐‘’๐‘œ๐‘Ÿ๐‘ฆ-๐‘‘๐‘’๐‘Ÿ๐‘–๐‘ฃ๐‘Ž๐‘ก๐‘–๐‘œ๐‘› ๐—‚๐—‡ ๐’ฐโ‚†โ‚€.

๐—”๐˜…๐—ถ๐—ผ๐—บ (๐’ฏโ‚.๐ดโ‚): ๐–ซ๐–พ๐— ๐‘Ž๐‘ฅ๐‘–๐‘œ๐‘š ๐’œโ‚ โŒœ๐˜‹๐˜ถ๐˜ฎ๐˜ฎ๐˜บ ๐˜ข๐˜น๐˜ช๐˜ฐ๐˜ฎ ๐˜ง๐˜ฐ๐˜ณ ๐˜ฅ๐˜ฆ๐˜ฎ๐˜ฐ๐˜ฏ๐˜ด๐˜ต๐˜ณ๐˜ข๐˜ต๐˜ช๐˜ฐ๐˜ฏ ๐˜ฑ๐˜ถ๐˜ณ๐˜ฑ๐˜ฐ๐˜ด๐˜ฆ๐˜ดโŒ ๐–ป๐–พ ๐—‚๐—‡๐–ผ๐—…๐—Ž๐–ฝ๐–พ๐–ฝ (๐—‰๐—ˆ๐—Œ๐—๐—Ž๐—…๐–บ๐—๐–พ๐–ฝ) ๐—‚๐—‡ ๐’ฏโ‚.

๐—œ๐—ป๐—ณ๐—ฒ๐—ฟ๐—ฒ๐—ป๐—ฐ๐—ฒ ๐—ฟ๐˜‚๐—น๐—ฒ (๐‘Ž๐‘ฅ๐‘–๐‘œ๐‘š-๐‘–๐‘›๐‘ก๐‘’๐‘Ÿ๐‘๐‘Ÿ๐‘’๐‘ก๐‘Ž๐‘ก๐‘–๐‘œ๐‘›): ๐–ซ๐–พ๐— ๐‘–๐‘›๐‘“๐‘’๐‘Ÿ๐‘’๐‘›๐‘๐‘’-๐‘Ÿ๐‘ข๐‘™๐‘’ ๐‘Ž๐‘ฅ๐‘–๐‘œ๐‘š-๐‘–๐‘›๐‘ก๐‘’๐‘Ÿ๐‘๐‘Ÿ๐‘’๐‘ก๐‘Ž๐‘ก๐‘–๐‘œ๐‘› ๐–ฝ๐–พ๐–ฟ๐—‚๐—‡๐–พ๐–ฝ ๐–บ๐—Œ โŒœ(๐“, ๐ โŠข ๐)โŒ ๐–ป๐–พ ๐—‚๐—‡๐–ผ๐—…๐—Ž๐–ฝ๐–พ๐–ฝ ๐–บ๐—‡๐–ฝ ๐–ผ๐—ˆ๐—‡๐—Œ๐—‚๐–ฝ๐–พ๐—‹๐–พ๐–ฝ ๐—๐–บ๐—…๐—‚๐–ฝ ๐—‚๐—‡ ๐’ฏโ‚.

๐—ฃ๐—ฟ๐—ผ๐—ฝ๐—ผ๐˜€๐—ถ๐˜๐—ถ๐—ผ๐—ป (๐’ฏโ‚.๐‘ƒโ‚): (๐‘Ÿโ‚(๐‘œโ‚, ๐‘œโ‚‚) โŸน ๐‘Ÿโ‚‚(๐‘œโ‚ƒ)). ๐—ฃ๐—ฟ๐—ผ๐—ผ๐—ณ: โŒœ๐˜‹๐˜ถ๐˜ฎ๐˜ฎ๐˜บ ๐˜ข๐˜น๐˜ช๐˜ฐ๐˜ฎ ๐˜ง๐˜ฐ๐˜ณ ๐˜ฅ๐˜ฆ๐˜ฎ๐˜ฐ๐˜ฏ๐˜ด๐˜ต๐˜ณ๐˜ข๐˜ต๐˜ช๐˜ฐ๐˜ฏ ๐˜ฑ๐˜ถ๐˜ณ๐˜ฑ๐˜ฐ๐˜ด๐˜ฆ๐˜ดโŒ ๐—‚๐—Œ ๐—‰๐—ˆ๐—Œ๐—๐—Ž๐—…๐–บ๐—๐–พ๐–ฝ ๐–ป๐—’ ๐—ฎ๐˜…๐—ถ๐—ผ๐—บ (๐ดโ‚). (๐‘Ÿโ‚(๐‘œโ‚, ๐‘œโ‚‚) โŸน ๐‘Ÿโ‚‚(๐‘œโ‚ƒ)) ๐—‚๐—Œ ๐–บ ๐—‰๐—‹๐—ˆ๐—‰๐—ˆ๐—Œ๐—‚๐—๐—‚๐—ˆ๐—‡๐–บ๐—… ๐–ฟ๐—ˆ๐—‹๐—†๐—Ž๐—…๐–บ ๐—‚๐—‡๐—๐–พ๐—‹๐—‰๐—‹๐–พ๐—๐–พ๐–ฝ ๐–ฟ๐—‹๐—ˆ๐—† ๐—๐—๐–บ๐— ๐–บ๐—‘๐—‚๐—ˆ๐—†. ๐–ณ๐—๐–พ๐—‹๐–พ๐–ฟ๐—ˆ๐—‹๐–พ, ๐–ป๐—’ ๐—๐—๐–พ ๐‘Ž๐‘ฅ๐‘–๐‘œ๐‘š-๐‘–๐‘›๐‘ก๐‘’๐‘Ÿ๐‘๐‘Ÿ๐‘’๐‘ก๐‘Ž๐‘ก๐‘–๐‘œ๐‘› ๐—‚๐—‡๐–ฟ๐–พ๐—‹๐–พ๐—‡๐–ผ๐–พ ๐—‹๐—Ž๐—…๐–พ: (๐“, ๐ โŠข ๐), ๐—‚๐— ๐–ฟ๐—ˆ๐—…๐—…๐—ˆ๐—๐—Œ ๐—๐—๐–บ๐— (๐‘Ÿโ‚(๐‘œโ‚, ๐‘œโ‚‚) โŸน ๐‘Ÿโ‚‚(๐‘œโ‚ƒ)). โˆŽ

๐—ฃ๐—ฟ๐—ผ๐—ฝ๐—ผ๐˜€๐—ถ๐˜๐—ถ๐—ผ๐—ป (๐’ฏโ‚.๐‘ƒโ‚‚): ๐‘Ÿโ‚(๐‘œโ‚, ๐‘œโ‚‚). ๐—ฃ๐—ฟ๐—ผ๐—ผ๐—ณ: โŒœ๐˜‹๐˜ถ๐˜ฎ๐˜ฎ๐˜บ ๐˜ข๐˜น๐˜ช๐˜ฐ๐˜ฎ ๐˜ง๐˜ฐ๐˜ณ ๐˜ฅ๐˜ฆ๐˜ฎ๐˜ฐ๐˜ฏ๐˜ด๐˜ต๐˜ณ๐˜ข๐˜ต๐˜ช๐˜ฐ๐˜ฏ ๐˜ฑ๐˜ถ๐˜ณ๐˜ฑ๐˜ฐ๐˜ด๐˜ฆ๐˜ดโŒ ๐—‚๐—Œ ๐—‰๐—ˆ๐—Œ๐—๐—Ž๐—…๐–บ๐—๐–พ๐–ฝ ๐–ป๐—’ ๐—ฎ๐˜…๐—ถ๐—ผ๐—บ (๐ดโ‚). ๐‘Ÿโ‚(๐‘œโ‚, ๐‘œโ‚‚) ๐—‚๐—Œ ๐–บ ๐—‰๐—‹๐—ˆ๐—‰๐—ˆ๐—Œ๐—‚๐—๐—‚๐—ˆ๐—‡๐–บ๐—… ๐–ฟ๐—ˆ๐—‹๐—†๐—Ž๐—…๐–บ ๐—‚๐—‡๐—๐–พ๐—‹๐—‰๐—‹๐–พ๐—๐–พ๐–ฝ ๐–ฟ๐—‹๐—ˆ๐—† ๐—๐—๐–บ๐— ๐–บ๐—‘๐—‚๐—ˆ๐—†. ๐–ณ๐—๐–พ๐—‹๐–พ๐–ฟ๐—ˆ๐—‹๐–พ, ๐–ป๐—’ ๐—๐—๐–พ ๐‘Ž๐‘ฅ๐‘–๐‘œ๐‘š-๐‘–๐‘›๐‘ก๐‘’๐‘Ÿ๐‘๐‘Ÿ๐‘’๐‘ก๐‘Ž๐‘ก๐‘–๐‘œ๐‘› ๐—‚๐—‡๐–ฟ๐–พ๐—‹๐–พ๐—‡๐–ผ๐–พ ๐—‹๐—Ž๐—…๐–พ: (๐“, ๐ โŠข ๐), ๐—‚๐— ๐–ฟ๐—ˆ๐—…๐—…๐—ˆ๐—๐—Œ ๐—๐—๐–บ๐— ๐‘Ÿโ‚(๐‘œโ‚, ๐‘œโ‚‚). โˆŽ

๐—œ๐—ป๐—ณ๐—ฒ๐—ฟ๐—ฒ๐—ป๐—ฐ๐—ฒ ๐—ฟ๐˜‚๐—น๐—ฒ (๐‘š๐‘œ๐‘‘๐‘ข๐‘ -๐‘๐‘œ๐‘›๐‘’๐‘›๐‘ ): ๐–ซ๐–พ๐— ๐‘–๐‘›๐‘“๐‘’๐‘Ÿ๐‘’๐‘›๐‘๐‘’-๐‘Ÿ๐‘ข๐‘™๐‘’ ๐‘š๐‘œ๐‘‘๐‘ข๐‘ -๐‘๐‘œ๐‘›๐‘’๐‘›๐‘  ๐–ฝ๐–พ๐–ฟ๐—‚๐—‡๐–พ๐–ฝ ๐–บ๐—Œ โŒœ((๐โ‚ โŸน ๐โ‚), ๐โ‚ โŠข ๐โ‚)โŒ ๐–ป๐–พ ๐—‚๐—‡๐–ผ๐—…๐—Ž๐–ฝ๐–พ๐–ฝ ๐–บ๐—‡๐–ฝ ๐–ผ๐—ˆ๐—‡๐—Œ๐—‚๐–ฝ๐–พ๐—‹๐–พ๐–ฝ ๐—๐–บ๐—…๐—‚๐–ฝ ๐—‚๐—‡ ๐’ฏโ‚.

๐—ฃ๐—ฟ๐—ผ๐—ฝ๐—ผ๐˜€๐—ถ๐˜๐—ถ๐—ผ๐—ป (๐’ฏโ‚.๐‘ƒโ‚ƒ) - The proposition of interest: ๐‘Ÿโ‚‚(๐‘œโ‚ƒ). ๐—ฃ๐—ฟ๐—ผ๐—ผ๐—ณ: (๐‘Ÿโ‚(๐‘œโ‚, ๐‘œโ‚‚) โŸน ๐‘Ÿโ‚‚(๐‘œโ‚ƒ)) ๐–ฟ๐—ˆ๐—…๐—…๐—ˆ๐—๐—Œ ๐–ฟ๐—‹๐—ˆ๐—† ๐—ฝ๐—ฟ๐—ผ๐—ฝ. (๐‘ƒโ‚).๐‘Ÿโ‚(๐‘œโ‚, ๐‘œโ‚‚) ๐–ฟ๐—ˆ๐—…๐—…๐—ˆ๐—๐—Œ ๐–ฟ๐—‹๐—ˆ๐—† ๐—ฝ๐—ฟ๐—ผ๐—ฝ. (๐‘ƒโ‚‚). ๐–ณ๐—๐–พ๐—‹๐–พ๐–ฟ๐—ˆ๐—‹๐–พ, ๐–ป๐—’ ๐—๐—๐–พ ๐‘š๐‘œ๐‘‘๐‘ข๐‘ -๐‘๐‘œ๐‘›๐‘’๐‘›๐‘  ๐—‚๐—‡๐–ฟ๐–พ๐—‹๐–พ๐—‡๐–ผ๐–พ ๐—‹๐—Ž๐—…๐–พ: ((๐โ‚ โŸน ๐โ‚), ๐โ‚ โŠข ๐โ‚), ๐—‚๐— ๐–ฟ๐—ˆ๐—…๐—…๐—ˆ๐—๐—Œ ๐—๐—๐–บ๐— ๐‘Ÿโ‚‚(๐‘œโ‚ƒ). โˆŽ