Equations and Logic on Words
Total Page:16
File Type:pdf, Size:1020Kb
Equations and logic on words Sam van Gool Utrecht University TACL, Nice 17 June 2019 Overview Logic on words Duality Equations between words Equations between languages 1 / 26 Overview Logic on words Duality Equations between words Equations between languages 1 / 26 I Solution 1: a (deterministic) automaton A: 0 1 1 0 q0 q1 q2 1 0 Answer yes iff A accepts w. ∗ I Solution 2: a homomorphism ': f0; 1g ! S3 defined by 0 7! (1 2); 1 7! (0 1): Answer yes iff the permutation '(w) sends 0 to 1. Regular languages: example I A programming problem: given a natural number in binary, w 2 f0; 1g∗, determine if w is congruent 1 modulo 3. 2 / 26 ∗ I Solution 2: a homomorphism ': f0; 1g ! S3 defined by 0 7! (1 2); 1 7! (0 1): Answer yes iff the permutation '(w) sends 0 to 1. Regular languages: example I A programming problem: given a natural number in binary, w 2 f0; 1g∗, determine if w is congruent 1 modulo 3. I Solution 1: a (deterministic) automaton A: 0 1 1 0 q0 q1 q2 1 0 Answer yes iff A accepts w. 2 / 26 Regular languages: example I A programming problem: given a natural number in binary, w 2 f0; 1g∗, determine if w is congruent 1 modulo 3. I Solution 1: a (deterministic) automaton A: 0 1 1 0 q0 q1 q2 1 0 Answer yes iff A accepts w. ∗ I Solution 2: a homomorphism ': f0; 1g ! S3 defined by 0 7! (1 2); 1 7! (0 1): Answer yes iff the permutation '(w) sends 0 to 1. 2 / 26 Regular languages: example I A programming problem: given a natural number in binary, w 2 f0; 1g∗, determine if w is congruent 1 modulo 3. I Solution 1: a (deterministic) automaton A: 0 1 1 0 q0 q1 q2 1 0 Answer yes iff A accepts w. I Solution 3: an MSO sentence ': 9Q09Q19Q2(Q0(first) ^ Q1(last)^ 8x[0(x) ^ Q0(x) ! Q0(Sx)] ^ [1(x) ^ Q0(x) ! Q1(Sx)] ^ ::: ): Answer yes iff w satisfies the formula '. 2 / 26 Regular languages Regular languages are subsets L ⊆ Σ∗ which are ... I recognizable by a finite automaton; I invariant under a finite index monoid congruence; I definable by a monadic second order sentence. Myhill-Nerode 1958; Büchi 1960 3 / 26 I Semantics. A word w = a1 ::: an gives a structure W . I The underlying set of W is f1;:::; ng. W I The natural linear order < interprets the binary predicate <. W I For every letter a 2 Σ, a := fi 2 f1;:::; ng: ai = ag. Logic on words I Syntax. Monadic Second Order (MSO) logic over <, Σ. I Basic propositional connectives: ^, :. I Quantification over first-order variables x, y, . and monadic second-order variables P, Q, ::: . I Relational signature: x < y, a(x) for a 2 Σ. 4 / 26 Logic on words I Syntax. Monadic Second Order (MSO) logic over <, Σ. I Basic propositional connectives: ^, :. I Quantification over first-order variables x, y, . and monadic second-order variables P, Q, ::: . I Relational signature: x < y, a(x) for a 2 Σ. I Semantics. A word w = a1 ::: an gives a structure W . I The underlying set of W is f1;:::; ng. W I The natural linear order < interprets the binary predicate <. W I For every letter a 2 Σ, a := fi 2 f1;:::; ng: ai = ag. 4 / 26 Logic on words I Syntax. Monadic Second Order (MSO) logic over <, Σ. I Semantics. A word w = a1 ::: an gives a structure W . ∗ I For a sentence ', L' := fw 2 Σ j w j= 'g. I A language L is regular iff L = L' for some ' in MSO. I Shortcuts such as S(x), first, last, ⊆, ... are MSO-definable. 5 / 26 I aaaa j= ', but aaaaa 6j= '. I W j= ' iff W has even length. : 9P 9xP (x) ^ P ⊆ a ^ 8y (8x[P(x) ! x < y]) ! b(y) . I aacbaccaabbb j= ', but aacbaccaabbc 6j= '. I W j= ' iff W has a non-empty subset of a-positions after which there are only b-positions. 0 : 9x a(x) ^ 8y[x < y ! (:a(y) ^ b(y))] . I “There is a last a-position, with only b-positions after that.” and 0 are equivalent, and 0 is first order. Question. Does such an equivalent first order formula exist for '? Logic on words: examples ': 9P P(first) ^ :P(last) ^ 8x(P(x) $ :P(S(x)) . 6 / 26 j= ', but aaaaa 6j= '. I W j= ' iff W has even length. : 9P 9xP (x) ^ P ⊆ a ^ 8y (8x[P(x) ! x < y]) ! b(y) . I aacbaccaabbb j= ', but aacbaccaabbc 6j= '. I W j= ' iff W has a non-empty subset of a-positions after which there are only b-positions. 0 : 9x a(x) ^ 8y[x < y ! (:a(y) ^ b(y))] . I “There is a last a-position, with only b-positions after that.” and 0 are equivalent, and 0 is first order. Question. Does such an equivalent first order formula exist for '? Logic on words: examples ': 9P P(first) ^ :P(last) ^ 8x(P(x) $ :P(S(x)) . I aaaa 6 / 26 but aaaaa 6j= '. I W j= ' iff W has even length. : 9P 9xP (x) ^ P ⊆ a ^ 8y (8x[P(x) ! x < y]) ! b(y) . I aacbaccaabbb j= ', but aacbaccaabbc 6j= '. I W j= ' iff W has a non-empty subset of a-positions after which there are only b-positions. 0 : 9x a(x) ^ 8y[x < y ! (:a(y) ^ b(y))] . I “There is a last a-position, with only b-positions after that.” and 0 are equivalent, and 0 is first order. Question. Does such an equivalent first order formula exist for '? Logic on words: examples ': 9P P(first) ^ :P(last) ^ 8x(P(x) $ :P(S(x)) . I aaaa j= ', 6 / 26 : 9P 9xP (x) ^ P ⊆ a ^ 8y (8x[P(x) ! x < y]) ! b(y) . I aacbaccaabbb j= ', but aacbaccaabbc 6j= '. I W j= ' iff W has a non-empty subset of a-positions after which there are only b-positions. 0 : 9x a(x) ^ 8y[x < y ! (:a(y) ^ b(y))] . I “There is a last a-position, with only b-positions after that.” and 0 are equivalent, and 0 is first order. Question. Does such an equivalent first order formula exist for '? Logic on words: examples ': 9P P(first) ^ :P(last) ^ 8x(P(x) $ :P(S(x)) . I aaaa j= ', but aaaaa 6j= '. I W j= ' iff W has even length. 6 / 26 I aacbaccaabbb j= ', but aacbaccaabbc 6j= '. I W j= ' iff W has a non-empty subset of a-positions after which there are only b-positions. 0 : 9x a(x) ^ 8y[x < y ! (:a(y) ^ b(y))] . I “There is a last a-position, with only b-positions after that.” and 0 are equivalent, and 0 is first order. Question. Does such an equivalent first order formula exist for '? Logic on words: examples ': 9P P(first) ^ :P(last) ^ 8x(P(x) $ :P(S(x)) . I aaaa j= ', but aaaaa 6j= '. I W j= ' iff W has even length. : 9P 9xP (x) ^ P ⊆ a ^ 8y (8x[P(x) ! x < y]) ! b(y) . 6 / 26 j= ', but aacbaccaabbc 6j= '. I W j= ' iff W has a non-empty subset of a-positions after which there are only b-positions. 0 : 9x a(x) ^ 8y[x < y ! (:a(y) ^ b(y))] . I “There is a last a-position, with only b-positions after that.” and 0 are equivalent, and 0 is first order. Question. Does such an equivalent first order formula exist for '? Logic on words: examples ': 9P P(first) ^ :P(last) ^ 8x(P(x) $ :P(S(x)) . I aaaa j= ', but aaaaa 6j= '. I W j= ' iff W has even length. : 9P 9xP (x) ^ P ⊆ a ^ 8y (8x[P(x) ! x < y]) ! b(y) . I aacbaccaabbb 6 / 26 but aacbaccaabbc 6j= '. I W j= ' iff W has a non-empty subset of a-positions after which there are only b-positions. 0 : 9x a(x) ^ 8y[x < y ! (:a(y) ^ b(y))] . I “There is a last a-position, with only b-positions after that.” and 0 are equivalent, and 0 is first order. Question. Does such an equivalent first order formula exist for '? Logic on words: examples ': 9P P(first) ^ :P(last) ^ 8x(P(x) $ :P(S(x)) . I aaaa j= ', but aaaaa 6j= '. I W j= ' iff W has even length. : 9P 9xP (x) ^ P ⊆ a ^ 8y (8x[P(x) ! x < y]) ! b(y) . I aacbaccaabbb j= ', 6 / 26 0 : 9x a(x) ^ 8y[x < y ! (:a(y) ^ b(y))] . I “There is a last a-position, with only b-positions after that.” and 0 are equivalent, and 0 is first order. Question. Does such an equivalent first order formula exist for '? Logic on words: examples ': 9P P(first) ^ :P(last) ^ 8x(P(x) $ :P(S(x)) . I aaaa j= ', but aaaaa 6j= '. I W j= ' iff W has even length. : 9P 9xP (x) ^ P ⊆ a ^ 8y (8x[P(x) ! x < y]) ! b(y) . I aacbaccaabbb j= ', but aacbaccaabbc 6j= '. I W j= ' iff W has a non-empty subset of a-positions after which there are only b-positions. 6 / 26 I “There is a last a-position, with only b-positions after that.” and 0 are equivalent, and 0 is first order. Question. Does such an equivalent first order formula exist for '? Logic on words: examples ': 9P P(first) ^ :P(last) ^ 8x(P(x) $ :P(S(x)) . I aaaa j= ', but aaaaa 6j= '. I W j= ' iff W has even length. : 9P 9xP (x) ^ P ⊆ a ^ 8y (8x[P(x) ! x < y]) ! b(y) .