diff --git a/reasoning/proof-by-cases/README b/reasoning/proof-by-cases/README new file mode 100644 index 000000000..0258ee8ef --- /dev/null +++ b/reasoning/proof-by-cases/README @@ -0,0 +1,5 @@ +-------------- +Proof by cases +-------------- + +See https://en.wikipedia.org/wiki/Proof_by_exhaustion diff --git a/reasoning/proof-by-cases/example1-answer.n3 b/reasoning/proof-by-cases/example1-answer.n3 new file mode 100644 index 000000000..bd65b2749 --- /dev/null +++ b/reasoning/proof-by-cases/example1-answer.n3 @@ -0,0 +1,5 @@ +@prefix : . +@prefix var: . + +:theorem1 :isProvenFor var:X. +:theorem3 :isProvenFor var:X. diff --git a/reasoning/proof-by-cases/example1-proof.n3 b/reasoning/proof-by-cases/example1-proof.n3 new file mode 100644 index 000000000..ac54c74d7 --- /dev/null +++ b/reasoning/proof-by-cases/example1-proof.n3 @@ -0,0 +1,170 @@ +@prefix skolem: . +@prefix r: . +@prefix var: . +@prefix : . +@prefix n3: . +@prefix list: . +@prefix log: . + +skolem:proof a r:Proof, r:Conjunction; + r:component skolem:lemma1; + r:component skolem:lemma2; + r:gives { + @forSome var:X. :theorem1 :isProvenFor var:X. + @forSome var:X. :theorem3 :isProvenFor var:X. + }. + +skolem:lemma1 a r:Inference; + r:gives { + @forSome var:X. :theorem1 :isProvenFor var:X. + }; + r:evidence ( + skolem:lemma3 + ); + r:binding [ r:variable [ n3:uri "http://www.w3.org/2000/10/swap/var#x_0"]; r:boundTo [ n3:uri "urn:example:theorem1"]]; + r:binding [ r:variable [ n3:uri "http://www.w3.org/2000/10/swap/var#x_1"]; r:boundTo [ n3:uri "http://www.w3.org/2000/10/swap/var#X"]]; + r:rule skolem:lemma4. + +skolem:lemma2 a r:Inference; + r:gives { + @forSome var:X. :theorem3 :isProvenFor var:X. + }; + r:evidence ( + skolem:lemma5 + ); + r:binding [ r:variable [ n3:uri "http://www.w3.org/2000/10/swap/var#x_0"]; r:boundTo [ n3:uri "urn:example:theorem3"]]; + r:binding [ r:variable [ n3:uri "http://www.w3.org/2000/10/swap/var#x_1"]; r:boundTo [ n3:uri "http://www.w3.org/2000/10/swap/var#X"]]; + r:rule skolem:lemma4. + +skolem:lemma3 a r:Inference; + r:gives { + @forSome var:X. :theorem1 :isProvenFor var:X. + }; + r:evidence ( + skolem:lemma6 + skolem:lemma7 + [ a r:Fact; r:gives {@forSome var:X. ({ + ({ + var:X a :Negative. + } { + var:X a :Zero. + } { + var:X a :Positive. + }) list:member { + var:X a _:sk_0. + }. + } { + { + var:X a _:sk_0. + } => { + :theorem1 :isProvenFor var:X. + }. + }) log:forAllIn (() 1)}] + ); + r:binding [ r:variable [ n3:uri "http://www.w3.org/2000/10/swap/var#x_1"]; r:boundTo ({ + var:X a :Negative. + } { + var:X a :Zero. + } { + var:X a :Positive. + })]; + r:binding [ r:variable [ n3:uri "http://www.w3.org/2000/10/swap/var#x_0"]; r:boundTo [ n3:uri "http://www.w3.org/2000/10/swap/var#X"]]; + r:binding [ r:variable [ n3:uri "http://www.w3.org/2000/10/swap/var#x_2"]; r:boundTo [ n3:uri "urn:example:theorem1"]]; + r:binding [ r:variable [ n3:uri "http://www.w3.org/2000/10/swap/var#x_4"]; r:boundTo (() 1)]; + r:binding [ r:variable [ n3:uri "http://www.w3.org/2000/10/swap/var#x_3"]; r:boundTo [ a r:Existential; n3:nodeId "_:sk_0"]]; + r:rule skolem:lemma8. + +skolem:lemma4 a r:Extraction; + r:gives { + @forAll var:x_0, var:x_1. { + var:x_0 :isProvenFor var:x_1. + } => { + var:x_0 :isProvenFor var:x_1. + }. + }; + r:because [ a r:Parsing; r:source ]. + +skolem:lemma5 a r:Inference; + r:gives { + @forSome var:X. :theorem3 :isProvenFor var:X. + }; + r:evidence ( + skolem:lemma6 + skolem:lemma9 + [ a r:Fact; r:gives {@forSome var:X. ({ + ({ + var:X a :Negative. + } { + var:X a :Zero. + } { + var:X a :Positive. + }) list:member { + var:X a _:sk_1. + }. + } { + { + var:X a _:sk_1. + } => { + :theorem3 :isProvenFor var:X. + }. + }) log:forAllIn (() 1)}] + ); + r:binding [ r:variable [ n3:uri "http://www.w3.org/2000/10/swap/var#x_1"]; r:boundTo ({ + var:X a :Negative. + } { + var:X a :Zero. + } { + var:X a :Positive. + })]; + r:binding [ r:variable [ n3:uri "http://www.w3.org/2000/10/swap/var#x_0"]; r:boundTo [ n3:uri "http://www.w3.org/2000/10/swap/var#X"]]; + r:binding [ r:variable [ n3:uri "http://www.w3.org/2000/10/swap/var#x_2"]; r:boundTo [ n3:uri "urn:example:theorem3"]]; + r:binding [ r:variable [ n3:uri "http://www.w3.org/2000/10/swap/var#x_4"]; r:boundTo (() 1)]; + r:binding [ r:variable [ n3:uri "http://www.w3.org/2000/10/swap/var#x_3"]; r:boundTo [ a r:Existential; n3:nodeId "_:sk_1"]]; + r:rule skolem:lemma8. + +skolem:lemma6 a r:Extraction; + r:gives { + @forSome var:X. (var:X) log:allPossibleCases ({ + var:X a :Negative. + } { + var:X a :Zero. + } { + var:X a :Positive. + }). + }; + r:because [ a r:Parsing; r:source ]. + +skolem:lemma7 a r:Extraction; + r:gives { + :theorem1 a :Theorem. + }; + r:because [ a r:Parsing; r:source ]. + +skolem:lemma8 a r:Extraction; + r:gives { + @forAll var:x_0, var:x_1, var:x_2, var:x_3, var:x_4. { + (var:x_0) log:allPossibleCases var:x_1. + var:x_2 a :Theorem. + ({ + var:x_1 list:member { + var:x_0 a var:x_3. + }. + } { + { + var:x_0 a var:x_3. + } => { + var:x_2 :isProvenFor var:x_0. + }. + }) log:forAllIn var:x_4. + } => { + var:x_2 :isProvenFor var:x_0. + }. + }; + r:because [ a r:Parsing; r:source ]. + +skolem:lemma9 a r:Extraction; + r:gives { + :theorem3 a :Theorem. + }; + r:because [ a r:Parsing; r:source ]. + diff --git a/reasoning/proof-by-cases/example1-query.n3 b/reasoning/proof-by-cases/example1-query.n3 new file mode 100644 index 000000000..7d16c58fa --- /dev/null +++ b/reasoning/proof-by-cases/example1-query.n3 @@ -0,0 +1,8 @@ +@prefix : . + +# query +{ + ?T :isProvenFor ?X. +} => { + ?T :isProvenFor ?X. +}. diff --git a/reasoning/proof-by-cases/example1.n3 b/reasoning/proof-by-cases/example1.n3 new file mode 100644 index 000000000..9032efa40 --- /dev/null +++ b/reasoning/proof-by-cases/example1.n3 @@ -0,0 +1,40 @@ +@prefix list: . +@prefix log: . +@prefix var: . +@prefix : . + +# closed set of possible cases +(var:X) log:allPossibleCases ( + { var:X a :Negative } + { var:X a :Zero } + { var:X a :Positive } +). + +# theorems +:theorem1 a :Theorem. +:theorem2 a :Theorem. +:theorem3 a :Theorem. + +# prove for possible cases +{ ?X a :Negative } => { :theorem1 :isProvenFor ?X }. +{ ?X a :Zero } => { :theorem1 :isProvenFor ?X }. +{ ?X a :Positive } => { :theorem1 :isProvenFor ?X }. + +{ ?X a :Negative } => { :theorem2 :isProvenFor ?X }. +{ ?X a :Positive } => { :theorem2 :isProvenFor ?X }. + +{ ?X a :Negative } => { :theorem3 :isProvenFor ?X }. +{ ?X a :Zero } => { :theorem3 :isProvenFor ?X }. +{ ?X a :Positive } => { :theorem3 :isProvenFor ?X }. + +# proof by cases +{ + (?X) log:allPossibleCases ?Y. + ?T a :Theorem. + ( + { ?Y list:member { ?X a ?Z } } + { { ?X a ?Z } => { ?T :isProvenFor ?X } } + ) log:forAllIn ?SCOPE. +} => { + ?T :isProvenFor ?X. +}. diff --git a/reasoning/proof-by-cases/test b/reasoning/proof-by-cases/test new file mode 100755 index 000000000..11f7da378 --- /dev/null +++ b/reasoning/proof-by-cases/test @@ -0,0 +1,3 @@ +#!/bin/bash +eye --quiet --skolem-genid 8b98b360-9a70-4845-b52c-c675af60ad01 --wcache https://eyereasoner.github.io/eye/reasoning .. --nope https://eyereasoner.github.io/eye/reasoning/proof-by-cases/example1.n3 --query https://eyereasoner.github.io/eye/reasoning/proof-by-cases/example1-query.n3 --output example1-answer.n3 +eye --quiet --skolem-genid 8b98b360-9a70-4845-b52c-c675af60ad01 --wcache https://eyereasoner.github.io/eye/reasoning .. https://eyereasoner.github.io/eye/reasoning/proof-by-cases/example1.n3 --query https://eyereasoner.github.io/eye/reasoning/proof-by-cases/example1-query.n3 --output example1-proof.n3