From 05d53f2569d38dd4847af442d39fb35cb4592b16 Mon Sep 17 00:00:00 2001 From: SimonGuilloud <simon.guilloud@bluewin.ch> Date: Fri, 28 Oct 2022 13:08:56 +0200 Subject: [PATCH] Exercises for FV (#89) --- lisa-examples/src/main/scala/Exercise.scala | 102 ++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 lisa-examples/src/main/scala/Exercise.scala diff --git a/lisa-examples/src/main/scala/Exercise.scala b/lisa-examples/src/main/scala/Exercise.scala new file mode 100644 index 00000000..89e66734 --- /dev/null +++ b/lisa-examples/src/main/scala/Exercise.scala @@ -0,0 +1,102 @@ +import lisa.automation.kernel.SimplePropositionalSolver.* +import lisa.automation.kernel.SimpleSimplifier.* +import lisa.utils.Printer + +object Exercise extends lisa.Main { + + private val x = VariableLabel("x") + private val y = VariableLabel("y") + private val z = VariableLabel("z") + private val f = SchematicFunctionLabel("f", 1) + private val P = SchematicPredicateLabel("P", 1) + private val Q = SchematicPredicateLabel("Q", 2) + private val H = VariableFormulaLabel("H") + + ///////////////////////// + // Propositional Logic // + ///////////////////////// + + THEOREM("double_negation_elim") of "|- 'a ⇔ ¬¬'a" PROOF { + val hyp = have("'a |- 'a") by Hypothesis + + andThen("|- !'a; 'a") by RightNot + andThen("!!'a |- 'a") by LeftNot + val direction1 = andThen("|- !!'a ==> 'a") by RightImplies + + have("'a; !'a |- ") by LeftNot(hyp) + andThen(("'a |- !!'a")) by RightNot + val direction2 = andThen("|- !!'a ==> 'a") by RightImplies + + have("|- !!'a <=> 'a") by RightIff(direction1, direction2) + showCurrentProof() + } + show + + /* + THEOREM("pierce-law") of "|- ((('A ==> 'B) ==> 'A) ==> 'A)" PROOF { + ??? + } + show + */ + + /////////////////////// + // First Order Logic // + /////////////////////// + + /* + THEOREM("russel_Paradox") of "∀'x. 'Q('y, 'x) ↔ ¬'Q('x, 'x) ⊢" PROOF { + have("'Q('y, 'y) <=> !'Q('y, 'y) |- ") by Restate + andThen("∀'x. 'Q('y, 'x) <=> !'Q('x, 'x) |- ") by LeftForall(y) + } + show + + THEOREM("all-comm") of "|- (∀'x. ∀'y. 'Q('x, 'y)) ⇔ (∀'y. ∀'x. 'Q('x, 'y))" PROOF { + val base = have("'Q('x, 'y) |- 'Q('x, 'y)") by Hypothesis + + andThen ("∀'y. 'Q('x, 'y) |- 'Q('x, 'y)") by LeftForall(y) + andThen ("∀'x. ∀'y. 'Q('x, 'y) |- 'Q('x, 'y)") by LeftForall(x) + andThen ("∀'x. ∀'y. 'Q('x, 'y) |- ∀'x. 'Q('x, 'y)") by RightForall() + andThen ("∀'x. ∀'y. 'Q('x, 'y) |- ∀'y. ∀'x. 'Q('x, 'y)") by RightForall() + val direction1 = andThen ("|- (∀'x. ∀'y. 'Q('x, 'y)) ==> (∀'y. ∀'x. 'Q('x, 'y))") by Restate + + have ("∀'x. 'Q('x, 'y) |- 'Q('x, 'y)") by LeftForall(x)(base) + andThen ("∀'y. ∀'x. 'Q('x, 'y) |- 'Q('x, 'y)") by LeftForall(y) + andThen ("∀'y. ∀'x. 'Q('x, 'y) |- ∀'y. 'Q('x, 'y)") by RightForall() + andThen ("∀'y. ∀'x. 'Q('x, 'y) |- ∀'x. ∀'y. 'Q('x, 'y)") by RightForall() + val direction2 = andThen ("|- (∀'y. ∀'x. 'Q('x, 'y)) ==> (∀'x. ∀'y. 'Q('x, 'y))") by Restate + have ("|- (∀'x. ∀'y. 'Q('x, 'y)) <=> (∀'y. ∀'x. 'Q('x, 'y))") by RightIff(direction1, direction2) + } + show + */ + + /* + THEOREM("fixed_Point_Double_Application") of "∀'x. 'P('x) ⇒ 'P('f('x)) ⊢ 'P('x) ⇒ 'P('f('f('x)))" PROOF { + ??? + } + show + */ + + //////////////////// + // Set Theory // + //////////////////// + + /* + THEOREM("SubsetRefl") of " ⊢ subset_of('x, 'x)" PROOF { + have(subsetAxiom) + val r1 = andThen(() |- forall(z, in(z, x) ==> in(z, x)) <=> subset(x, x)) by InstantiateForallMultipleWithoutFormula(x, x) + have(() |- in(z, x) ==> in(z, x)) by Restate + andThen(() |- forall(z, in(z, x) ==> in(z, x))) by RightForall + andThen(applySubst(forall(z, in(z, x) ==> in(z, x)) <=> subset(x, x))) + Discharge(r1) + } + show + */ + + /* + THEOREM("SubsetRefl") of " subset_of('x, 'y); subset_of('y, 'z) ⊢ subset_of('x, 'z)" PROOF { + ??? + } + show + */ + +} -- GitLab