Yin-Yang of Programs and Three-Valued Logics
description
Transcript of Yin-Yang of Programs and Three-Valued Logics
![Page 1: Yin-Yang of Programs and Three-Valued Logics](https://reader035.fdocuments.net/reader035/viewer/2022062809/56815967550346895dc6a60c/html5/thumbnails/1.jpg)
Yin-Yang of Programs and Three-Valued Logics
Jerzy TyszkiewiczInstytut Informatyki UW
![Page 2: Yin-Yang of Programs and Three-Valued Logics](https://reader035.fdocuments.net/reader035/viewer/2022062809/56815967550346895dc6a60c/html5/thumbnails/2.jpg)
Programs
Three-valued logics
![Page 3: Yin-Yang of Programs and Three-Valued Logics](https://reader035.fdocuments.net/reader035/viewer/2022062809/56815967550346895dc6a60c/html5/thumbnails/3.jpg)
Three-Valued Logics for Programs
• Explicito SQLo Datalog with negation
• Implicito Every regular programming languageo Conditional expressions
![Page 4: Yin-Yang of Programs and Three-Valued Logics](https://reader035.fdocuments.net/reader035/viewer/2022062809/56815967550346895dc6a60c/html5/thumbnails/4.jpg)
SQL, Heyting-Kleene-Łukasiewicz,Goodman-Nguyen-Walker
OR 0 1 NULL
0 0 1 NULL
1 1 1 1
NULL NULL 1 NULL
AND 0 1 NULL
0 0 0 0
1 0 1 NULL
NULL 0 NULL NULL
![Page 5: Yin-Yang of Programs and Three-Valued Logics](https://reader035.fdocuments.net/reader035/viewer/2022062809/56815967550346895dc6a60c/html5/thumbnails/5.jpg)
Sobociński, Schay-Adams-Calabrese
OR 0 1 $
0 0 1 0
1 1 1 1
$ 0 1 $
AND 0 1 $
0 0 0 0
1 0 1 1
$ 0 1 $
![Page 6: Yin-Yang of Programs and Three-Valued Logics](https://reader035.fdocuments.net/reader035/viewer/2022062809/56815967550346895dc6a60c/html5/thumbnails/6.jpg)
Strict evaluation, Bochvar
OR 0 1 $
0 0 1 $
1 1 1 $
$ $ $ $
AND 0 1 $
0 0 0 $
1 0 1 $
$ $ $ $
![Page 7: Yin-Yang of Programs and Three-Valued Logics](https://reader035.fdocuments.net/reader035/viewer/2022062809/56815967550346895dc6a60c/html5/thumbnails/7.jpg)
Lazy evaluation
OR 0 1 $
0 0 1 $
1 1 1 1
$ $ $ $
AND 0 1 $
0 0 0 0
1 0 1 $
$ $ $ $
![Page 8: Yin-Yang of Programs and Three-Valued Logics](https://reader035.fdocuments.net/reader035/viewer/2022062809/56815967550346895dc6a60c/html5/thumbnails/8.jpg)
Conditionals
• An object can red r, yellow y or blue b• Pr(r)=Pr(y)=Pr(b)=1/3
• What is the probability, that it is b, given that if it is not r, then it is b?
• Pr(b |(b |¬ r))• Not a well-defined expression
![Page 9: Yin-Yang of Programs and Three-Valued Logics](https://reader035.fdocuments.net/reader035/viewer/2022062809/56815967550346895dc6a60c/html5/thumbnails/9.jpg)
Conditionals
![Page 10: Yin-Yang of Programs and Three-Valued Logics](https://reader035.fdocuments.net/reader035/viewer/2022062809/56815967550346895dc6a60c/html5/thumbnails/10.jpg)
Conditionals G-N-W
COND 0 1 $
0 $ 0 0
1 $ 1 $
$ $ $ $
![Page 11: Yin-Yang of Programs and Three-Valued Logics](https://reader035.fdocuments.net/reader035/viewer/2022062809/56815967550346895dc6a60c/html5/thumbnails/11.jpg)
Conditional S-A-C
COND 0 1 $
0 $ 0 0
1 $ 1 1
$ $ $ $
![Page 12: Yin-Yang of Programs and Three-Valued Logics](https://reader035.fdocuments.net/reader035/viewer/2022062809/56815967550346895dc6a60c/html5/thumbnails/12.jpg)
Datalog
q(X, Y) ← edge(X, Y)q(X, Z) ← edge(X, Y), q(Y, Z)
Computation stabilises eventually, if started from empty intentional relation q.
The resulting q is two-valued.
![Page 13: Yin-Yang of Programs and Three-Valued Logics](https://reader035.fdocuments.net/reader035/viewer/2022062809/56815967550346895dc6a60c/html5/thumbnails/13.jpg)
Datalog with negation
q(X, Y) ← r(X, Y, Z), ¬q(Y, X)q(X, Y) ← s(X, Y, Z), r(X, Y, Z), q(X, Y), ¬q(Y, Y)
Relation q need not stabilise during computation.
![Page 14: Yin-Yang of Programs and Three-Valued Logics](https://reader035.fdocuments.net/reader035/viewer/2022062809/56815967550346895dc6a60c/html5/thumbnails/14.jpg)
Datalog with negation
• Some tuples are almost always in q• Some tuples are almost always not in q• Some tuples continue changing status forever
![Page 15: Yin-Yang of Programs and Three-Valued Logics](https://reader035.fdocuments.net/reader035/viewer/2022062809/56815967550346895dc6a60c/html5/thumbnails/15.jpg)
Datalog with negation
The resulting relation is three-valued.
•Some tuples are in the computed q•Some tuples are not in the computed q•Some tuples are undecided
![Page 16: Yin-Yang of Programs and Three-Valued Logics](https://reader035.fdocuments.net/reader035/viewer/2022062809/56815967550346895dc6a60c/html5/thumbnails/16.jpg)
Mutual definability of conditional algebras
•Are the connectives of SAC and GNW algebras definable in each other?
![Page 17: Yin-Yang of Programs and Three-Valued Logics](https://reader035.fdocuments.net/reader035/viewer/2022062809/56815967550346895dc6a60c/html5/thumbnails/17.jpg)
Mutual definability of conditional algebras
•The main question is equivalent to defibability of certain three-valued functions by composition of other functions.
•We use programs to enumerate all possible two-argument compositions of the basic connectives.
![Page 18: Yin-Yang of Programs and Three-Valued Logics](https://reader035.fdocuments.net/reader035/viewer/2022062809/56815967550346895dc6a60c/html5/thumbnails/18.jpg)
Mutual definability of conditional algebras
Theorem 1. An n-argument connective f : {0,1,$} →{0,1,$} is definable in SAC iff f($,...,$) =$.There are 6561 of binary ones.In particular, all connectives of GNW aredefinable in SAC.
![Page 19: Yin-Yang of Programs and Three-Valued Logics](https://reader035.fdocuments.net/reader035/viewer/2022062809/56815967550346895dc6a60c/html5/thumbnails/19.jpg)
Mutual definability of conditional algebras
I could pretend not using computer in the proof of Theorem 1.
![Page 20: Yin-Yang of Programs and Three-Valued Logics](https://reader035.fdocuments.net/reader035/viewer/2022062809/56815967550346895dc6a60c/html5/thumbnails/20.jpg)
Mutual definability of conditional algebras
Theorem 2. The conjunction and disjunction of SACare not definable in GNW.COND of SAC is definable in GNW.There are only 849 two-argument connectives definable in GNW.
![Page 21: Yin-Yang of Programs and Three-Valued Logics](https://reader035.fdocuments.net/reader035/viewer/2022062809/56815967550346895dc6a60c/html5/thumbnails/21.jpg)
Mutual definability of conditional algebras
At present I could not give a proof of Theorem 2 without reference to the computer.
![Page 22: Yin-Yang of Programs and Three-Valued Logics](https://reader035.fdocuments.net/reader035/viewer/2022062809/56815967550346895dc6a60c/html5/thumbnails/22.jpg)
Internal structure of conditional algebras
Theorem 3. SAC an GNW have Sheffer-like definable connectives: ones that are definable and suffice alone to define all other connectives.
![Page 23: Yin-Yang of Programs and Three-Valued Logics](https://reader035.fdocuments.net/reader035/viewer/2022062809/56815967550346895dc6a60c/html5/thumbnails/23.jpg)
My co-authors
Piotr Chrząstowski-WachtelAchim HoffmannArthur Ramer
![Page 24: Yin-Yang of Programs and Three-Valued Logics](https://reader035.fdocuments.net/reader035/viewer/2022062809/56815967550346895dc6a60c/html5/thumbnails/24.jpg)
Thank
you!