yin-yang of programs and three-valued logics

24
Yin-Yang of Programs and Three-Valued Logics Jerzy Tyszkiewicz Instytut Informatyki UW

Upload: cachez

Post on 02-Feb-2016

31 views

Category:

Documents


0 download

DESCRIPTION

Yin-Yang of Programs and Three-Valued Logics. Jerzy Tyszkiewicz Instytut Informatyki UW. Three-valued logics. Programs. Three-Valued Logics for Programs. Explicit SQL Datalog with negation Implicit Every regular programming language Conditional expressions. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Yin-Yang of Programs and  Three-Valued Logics

Yin-Yang of Programs and Three-Valued Logics

Jerzy TyszkiewiczInstytut Informatyki UW

Page 2: Yin-Yang of Programs and  Three-Valued Logics

Programs

Three-valued logics

Page 3: Yin-Yang of Programs and  Three-Valued Logics

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

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

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

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

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

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

Conditionals

Page 10: Yin-Yang of Programs and  Three-Valued Logics

Conditionals G-N-W

COND 0 1 $

0 $ 0 0

1 $ 1 $

$ $ $ $

Page 11: Yin-Yang of Programs and  Three-Valued Logics

Conditional S-A-C

COND 0 1 $

0 $ 0 0

1 $ 1 1

$ $ $ $

Page 12: Yin-Yang of Programs and  Three-Valued Logics

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

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

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

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

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

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

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

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

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

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

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

My co-authors

Piotr Chrząstowski-WachtelAchim HoffmannArthur Ramer

Page 24: Yin-Yang of Programs and  Three-Valued Logics

Thank

you!