Automata-Based String Analysis

Size: px
Start display at page:

Download "Automata-Based String Analysis"

Transcription

1 1 / 46 Automata-Based String Analysis Model Counting Tevfik Bultan, Abdulbaki Aydin, Lucas Bang Verification Laboratory Department of Computer Science

2 Overview

3 Overview String Constraints

4 Overview String Constraints Model Counter

5 2 / 46 Overview String Constraints Model Counter Number of Solutions

6 Can you solve it, Will Hunting? 3 / 46

7 Can you solve it, Will Hunting? 4 / 46

8 5 / 46 Outline Motivation and Background Model Counting Boolean Formulas String Model Counting Automata-Based Methods Non-Automata-Based Method String Model Counting Benchmarks

9 6 / 46 A Motivating Example An adversary learns a password. User must select a new password.

10 6 / 46 A Motivating Example An adversary learns a password. User must select a new password. Policy for selecting a new password.

11 6 / 46 A Motivating Example An adversary learns a password. User must select a new password. Policy for selecting a new password. 1 public Boolean NewPWCheck(String new_p, old_p){ 2 if( old_p.contains(new_p)... 3 new_p.contains(old_p)... 4 old_p.reverse().contains(new_p))... 5 new_p.contains(old_p.reverse()) ){ 6 System.out.println("Too similar."); 7 return false; 8 } else 9 return true; 10 }

12 7 / 46 A Motivating Example Suppose an adversary knows old_p = "abc-16"

13 7 / 46 A Motivating Example Suppose an adversary knows old_p = "abc-16" and knows the policy.

14 7 / 46 A Motivating Example Suppose an adversary knows old_p = "abc-16" and knows the policy. Constraints on possible values of NEW_P (not (contains (tolower NEW_P) "abc-16")) (not (contains (tolower NEW_P) "61-cba")) (not (contains "abc-16" (tolower NEW_P))) (not (contains "61-cba" (tolower NEW_P)))

15 7 / 46 A Motivating Example Suppose an adversary knows old_p = "abc-16" and knows the policy. Constraints on possible values of NEW_P (not (contains (tolower NEW_P) "abc-16")) (not (contains (tolower NEW_P) "61-cba")) (not (contains "abc-16" (tolower NEW_P))) (not (contains "61-cba" (tolower NEW_P))) If password length = n, then there are Σ n possible passwords.

16 7 / 46 A Motivating Example Suppose an adversary knows old_p = "abc-16" and knows the policy. Constraints on possible values of NEW_P (not (contains (tolower NEW_P) "abc-16")) (not (contains (tolower NEW_P) "61-cba")) (not (contains "abc-16" (tolower NEW_P))) (not (contains "61-cba" (tolower NEW_P))) If password length = n, then there are Σ n possible passwords. If adversary knows old_p and the policy... how much is the reduction in search space? what is the probability of guessing the new password?

17 8 / 46 Motivation In general, we want to answer questions regarding probability of program behaviors, number of inputs that cause an error, amount of information flow, information leakage, other, as yet unforeseen, applications...

18 8 / 46 Motivation In general, we want to answer questions regarding probability of program behaviors, number of inputs that cause an error, amount of information flow, information leakage, other, as yet unforeseen, applications... These are quantitative questions which require model counting.

19 9 / 46 Motivation Techniques for model counting for other theories Boolean Logic Formulas DPLL Random sampling based Approximations

20 9 / 46 Motivation Techniques for model counting for other theories Boolean Logic Formulas DPLL Random sampling based Approximations Linear Integer Arithmetic: LattE Barvinok

21 10 / 46 Motivation String manipulating programs are pervasive security critical functions, server side sanitization functions, databases, dynamic code generation.

22 10 / 46 Motivation String manipulating programs are pervasive security critical functions, server side sanitization functions, databases, dynamic code generation. We need model counting for strings in order to make quantitative guarantees about these types of programs.

23 10 / 46 Motivation String manipulating programs are pervasive security critical functions, server side sanitization functions, databases, dynamic code generation. We need model counting for strings in order to make quantitative guarantees about these types of programs. Software for string constraint model counting Automata-Based Model Counter (ABC) [Aydin, et. al. CAV 2015] String Model Counter (SMC) [Luu, et. al. PLDI 2014 ] S3# [Trinh, et. al. CAV 2017]

24 11 / 46 Outline Motivation and Background Model Counting Boolean Formulas String Model Counting Automata-Based Methods Non-Automata-Based Method String Model Counting Benchmarks

25 12 / 46 Model Counting Recall the classic (boolean) SAT problem Given a formula φ from propositional logic, is it possible to assign all variables the values T (true) or F (false) so that the formula is true?

26 12 / 46 Model Counting Recall the classic (boolean) SAT problem Given a formula φ from propositional logic, is it possible to assign all variables the values T (true) or F (false) so that the formula is true? Example: φ = (x y) ( x z) (z w) x (y v)

27 12 / 46 Model Counting Recall the classic (boolean) SAT problem Given a formula φ from propositional logic, is it possible to assign all variables the values T (true) or F (false) so that the formula is true? Example: φ = (x y) ( x z) (z w) x (y v) φ is satisfiable by setting (x, y, z, w, v) = (T, F, T, F, T ).

28 12 / 46 Model Counting Recall the classic (boolean) SAT problem Given a formula φ from propositional logic, is it possible to assign all variables the values T (true) or F (false) so that the formula is true? Example: φ = (x y) ( x z) (z w) x (y v) φ is satisfiable by setting (x, y, z, w, v) = (T, F, T, F, T ). A satisfying assignment is called a model for φ.

29 13 / 46 Model Counting The model counting problem Given a formula φ over some theory (Boolean, LIA, Strings,... ) how many models are there for φ?

30 13 / 46 Model Counting The model counting problem Given a formula φ over some theory (Boolean, LIA, Strings,... ) how many models are there for φ? Difficulty of Model Counting Model counting is at least as hard as satisfiability check.

31 13 / 46 Model Counting The model counting problem Given a formula φ over some theory (Boolean, LIA, Strings,... ) how many models are there for φ? Difficulty of Model Counting Model counting is at least as hard as satisfiability check. φ > 0 φ is satisfiable

32 14 / 46 Model Counting Boolean SAT x y z w v F F F F F F F T F F T T F T F T F F F T F T F T T T F T T F F T F T T T T T T F F F F T T F F T F T T F T F F T T F T T F T T T F F T T T T F T T T T T T F T T T T T T T φ = (x y) ( x z) (z w) x (y v)

33 14 / 46 Model Counting Boolean SAT x y z w v F F F F F F F T F F T T F T F T F F F T F T F T T T F T T F F T F T T T T T T F F F F T T F F T F T T F T F F T T F T T F T T T F F T T T T F T T T T T T F T T T T T T T φ = (x y) ( x z) (z w) x (y v) φ has 6 models.

34 14 / 46 Model Counting Boolean SAT x y z w v F F F F F F F T F F T T F T F T F F F T F T F T T T F T T F F T F T T T T T T F F F F T T F F T F T T F T F F T T F T T F T T T F F T T T T F T T T T T T F T T T T T T T φ = (x y) ( x z) (z w) x (y v) φ has 6 models. Truth table method is θ(2 n ).

35 [1] Birnbaum, et. al. The good old Davis-Putnam procedure helps counting models. JAIR / 46 Model Counting Boolean SAT x y z w v F F F F F F F T F F T T F T F T F F F T F T F T T T F T T F F T F T T T T T T F F F F T T F F T F T T F T F F T T F T T F T T T F F T T T T F T T T T T T F T T T T T T T φ = (x y) ( x z) (z w) x (y v) φ has 6 models. Truth table method is θ(2 n ). DPLL method is O(2 n ), but is faster in practice. 1

36 15 / 46 Outline Motivation and Background Model Counting Boolean Formulas String Model Counting Automata-Based Methods Non-Automata-Based Method String Model Counting Benchmarks

37 16 / 46 Model Counting Strings A formula over the theory of strings can involve

38 16 / 46 Model Counting Strings A formula over the theory of strings can involve Word Equations: X U = Y Z

39 16 / 46 Model Counting Strings A formula over the theory of strings can involve Word Equations: X U = Y Z Length Constraints: 4 < Length(X) < 10

40 16 / 46 Model Counting Strings A formula over the theory of strings can involve Word Equations: X U = Y Z Length Constraints: 4 < Length(X) < 10 Regular Language Membership: X (a b)

41 16 / 46 Model Counting Strings A formula over the theory of strings can involve Word Equations: X U = Y Z Length Constraints: 4 < Length(X) < 10 Regular Language Membership: X (a b) and more complex constraints: (X = substring(y, i, j),... )

42 16 / 46 Model Counting Strings A formula over the theory of strings can involve Word Equations: X U = Y Z Length Constraints: 4 < Length(X) < 10 Regular Language Membership: X (a b) and more complex constraints: (X = substring(y, i, j),... )

43 17 / 46 Model Counting Strings Q: How many solutions for X? X (0 (1(01 0) 1))

44 17 / 46 Model Counting Strings X (0 (1(01 0) 1)) Q: How many solutions for X? A: Infinitely many!

45 17 / 46 Model Counting Strings X (0 (1(01 0) 1)) Q: How many solutions for X? A: Infinitely many! Q: How many solutions for X of length k?

46 17 / 46 Model Counting Strings X (0 (1(01 0) 1)) Q: How many solutions for X? A: Infinitely many! Q: How many solutions for X of length k? A counting sequence for language L encodes a k = {s : s L, len(s) = k}

47 17 / 46 Model Counting Strings X (0 (1(01 0) 1)) Q: How many solutions for X? A: Infinitely many! Q: How many solutions for X of length k? A counting sequence for language L encodes a k = {s : s L, len(s) = k}

48 17 / 46 Model Counting Strings X (0 (1(01 0) 1)) Q: How many solutions for X? A: Infinitely many! Q: How many solutions for X of length k? A counting sequence for language L encodes a k = {s : s L, len(s) = k} a 0 = 1 k X a k 0 ε 1

49 17 / 46 Model Counting Strings X (0 (1(01 0) 1)) Q: How many solutions for X? A: Infinitely many! Q: How many solutions for X of length k? A counting sequence for language L encodes a k = {s : s L, len(s) = k} a 0 = 1, a 1 = 1 k X a k 0 ε

50 17 / 46 Model Counting Strings X (0 (1(01 0) 1)) Q: How many solutions for X? A: Infinitely many! Q: How many solutions for X of length k? A counting sequence for language L encodes a k = {s : s L, len(s) = k} a 0 = 1, a 1 = 1, a 2 = 1 k X a k 0 ε

51 17 / 46 Model Counting Strings X (0 (1(01 0) 1)) Q: How many solutions for X? A: Infinitely many! Q: How many solutions for X of length k? A counting sequence for language L encodes a k = {s : s L, len(s) = k} a 0 = 1, a 1 = 1, a 2 = 1, a 3 = 1 k X a k 0 ε

52 17 / 46 Model Counting Strings X (0 (1(01 0) 1)) Q: How many solutions for X? A: Infinitely many! Q: How many solutions for X of length k? A counting sequence for language L encodes a k = {s : s L, len(s) = k} a 0 = 1, a 1 = 1, a 2 = 1, a 3 = 1, a 4 = 3 k X a k 0 ε , 1100,

53 Model Counting Strings X (0 (1(01 0) 1)) Q: How many solutions for X? A: Infinitely many! Q: How many solutions for X of length k? A counting sequence for language L encodes a k = {s : s L, len(s) = k} a 0 = 1, a 1 = 1, a 2 = 1, a 3 = 1, a 4 = 3, a 5 = 5,... k X a k 0 ε , 1100, , 10101, 11000, 11011, / 46

54 18 / 46 Outline Motivation and Background Model Counting Boolean Formulas String Model Counting Automata-Based Methods Non-Automata-Based Method String Model Counting Benchmarks

55 Deterministic Finite Automata 19 / 46

56 19 / 46 Deterministic Finite Automata X (0 (1(01 0) 1))

57 19 / 46 Deterministic Finite Automata X (0 (1(01 0) 1))

58 19 / 46 Deterministic Finite Automata X (0 (1(01 0) 1)) {s : s L, len(s) = k} {π : π is accepting path of length k}

59 19 / 46 Deterministic Finite Automata X (0 (1(01 0) 1)) {s : s L, len(s) = k} {π : π is accepting path of length k} String Counting Path Counting

60 20 / 46 Deterministic Finite Automata How to count paths of length k?

61 20 / 46 Deterministic Finite Automata How to count paths of length k? Dynamic Programming

62 20 / 46 Deterministic Finite Automata How to count paths of length k? Dynamic Programming a k

63 20 / 46 Deterministic Finite Automata How to count paths of length k? Dynamic Programming s a k (s) =

64 20 / 46 Deterministic Finite Automata How to count paths of length k? Dynamic Programming s s a k (s) = a k 1 (s )

65 20 / 46 Deterministic Finite Automata How to count paths of length k? Dynamic Programming s s a k (s) = a k 1 (s )

66 20 / 46 Deterministic Finite Automata How to count paths of length k? Dynamic Programming s 1 s 2 s s 3 a k (s) = a k 1 (s )

67 20 / 46 Deterministic Finite Automata How to count paths of length k? Dynamic Programming s 1 s 2 s s 3 a k (s) = a k 1 (s ) s s

68 20 / 46 Deterministic Finite Automata How to count paths of length k? Dynamic Programming s 1 s 2 s Initial Conditions s 3 a k (s) = a k 1 (s ) s s

69 20 / 46 Deterministic Finite Automata How to count paths of length k? Dynamic Programming s 1 s 2 s 3 s Initial Conditions a 0 (0) = 1 a k (s) = a k 1 (s ) s s

70 20 / 46 Deterministic Finite Automata How to count paths of length k? Dynamic Programming s 1 s 2 s 3 s Initial Conditions a 0 (0) = 1, a 0 (1) = 0, a 0 (2) = 0 a k (s) = a k 1 (s ) s s

71 20 / 46 Deterministic Finite Automata How to count paths of length k? Dynamic Programming s 1 s 2 s 3 s Initial Conditions a 0 (0) = 1, a 0 (1) = 0, a 0 (2) = 0 a k (s) = a k 1 (s ) s s System of Recurrences a k (0) = a k 1 (0) + a k 1 (1)

72 20 / 46 Deterministic Finite Automata How to count paths of length k? Dynamic Programming s 1 s 2 s 3 s Initial Conditions a 0 (0) = 1, a 0 (1) = 0, a 0 (2) = 0 a k (s) = a k 1 (s ) s s System of Recurrences a k (0) = a k 1 (0) + a k 1 (1) a k (1) = a k 1 (0) + a k 1 (2) a k (2) = a k 1 (1) + a k 1 (2)

73 21 / 46 Deterministic Finite Automata How to count paths of length k?

74 21 / 46 Deterministic Finite Automata How to count paths of length k? System of Recurrences a k (0) = a k 1 (0) + a k 1 (1) a k (1) = a k 1 (0) + a k 1 (2) a k (2) = a k 1 (1) + a k 1 (2)

75 21 / 46 Deterministic Finite Automata How to count paths of length k? System of Recurrences a k (0) = a k 1 (0) + a k 1 (1) a k (1) = a k 1 (0) + a k 1 (2) a k (2) = a k 1 (1) + a k 1 (2) a 0(k) a 1 (k) = a 0(k 1) a 1 (k 1) a 2 (k) a 2 (k 1)

76 21 / 46 Deterministic Finite Automata How to count paths of length k? Matrix Exponentiation System of Recurrences a k (0) = a k 1 (0) + a k 1 (1) a k (1) = a k 1 (0) + a k 1 (2) a k (2) = a k 1 (1) + a k 1 (2) a 0(k) a 1 (k) = a 2 (k) k a 0(k) a 1 (k) = a 0(k 1) a 1 (k 1) a 2 (k) a 2 (k 1)

77 21 / 46 Deterministic Finite Automata How to count paths of length k? Matrix Exponentiation System of Recurrences a k (0) = a k 1 (0) + a k 1 (1) a k (1) = a k 1 (0) + a k 1 (2) a k (2) = a k 1 (1) + a k 1 (2) a 0(k) a 1 (k) = a 2 (k) k a 0(k) a 1 (k) = a 0(k 1) a 1 (k 1) a 2 (k) a 2 (k 1) a k = (A k ) 0,F

78 21 / 46 Deterministic Finite Automata How to count paths of length k? Matrix Exponentiation System of Recurrences a k (0) = a k 1 (0) + a k 1 (1) a k (1) = a k 1 (0) + a k 1 (2) a k (2) = a k 1 (1) + a k 1 (2) a 0(k) a 1 (k) = a 2 (k) k a 0(k) a 1 (k) = a 0(k 1) a 1 (k 1) a 2 (k) a 2 (k 1) a k = (A k ) 0,F a 4 = (A 4 ) 0,0 = 3

79 22 / 46

80 Generating functions are a way to compactly represent (possibly infinite) sequences. 22 / 46

81 22 / 46 Generating functions are a way to compactly represent (possibly infinite) sequences. g(z) = 1 (1 z) 3

82 22 / 46 Generating functions are a way to compactly represent (possibly infinite) sequences. 1 g(z) = (1 z) 3 = a k z k k=0

83 22 / 46 Generating functions are a way to compactly represent (possibly infinite) sequences. 1 g(z) = (1 z) 3 = a k z k k=0 g(z) = 1z 0 + 3z 1 + 6z z z

84 22 / 46 Generating functions are a way to compactly represent (possibly infinite) sequences. 1 g(z) = (1 z) 3 = a k z k k=0 g(z) = 1z 0 + 3z 1 + 6z z z g(z) = a 0 z 0 + a 1 z 1 + a 2 z 2 + a 3 z 3 + a 4 z

85 22 / 46 Generating functions are a way to compactly represent (possibly infinite) sequences. 1 g(z) = (1 z) 3 = a k z k k=0 g(z) = 1z 0 + 3z 1 + 6z z z g(z) = a 0 z 0 + a 1 z 1 + a 2 z 2 + a 3 z 3 + a 4 z Sequence element a k is the k th Taylor series coefficient of g(z).

86 23 / 46 The Taylor series of a function g(z) that is differentiable at 0 is the power series g(0) + g (0) 1! x + g (0) 2! x 2 + g (0) x !

87 23 / 46 The Taylor series of a function g(z) that is differentiable at 0 is the power series g(0) + g (0) 1! x + g (0) 2! x 2 + g (0) x ! which can be written in the more compact sigma notation as n=0 g (n) (a) n! (x a) n where n! denotes the factorial of n and g(n) (a) denotes the n-th derivative of f evaluated at the point a.

88 X (0 (1(01 0) 1)) 24 / 46

89 24 / 46 X (0 (1(01 0) 1)) A generating function for language L encodes a k = {s : s L, len(s) = k}

90 24 / 46 X (0 (1(01 0) 1)) A generating function for language L encodes a k = {s : s L, len(s) = k} g(z) =

91 24 / 46 X (0 (1(01 0) 1)) A generating function for language L encodes a k = {s : s L, len(s) = k} g(z) = 1z 0 k X a k 0 ε 1

92 24 / 46 X (0 (1(01 0) 1)) A generating function for language L encodes a k = {s : s L, len(s) = k} g(z) = 1z 0 + 1z 1 k X a k 0 ε

93 24 / 46 X (0 (1(01 0) 1)) A generating function for language L encodes a k = {s : s L, len(s) = k} g(z) = 1z 0 + 1z 1 + 1z 2 k X a k 0 ε

94 24 / 46 X (0 (1(01 0) 1)) A generating function for language L encodes a k = {s : s L, len(s) = k} g(z) = 1z 0 + 1z 1 + 1z 2 + 1z 3 k X a k 0 ε

95 24 / 46 X (0 (1(01 0) 1)) A generating function for language L encodes a k = {s : s L, len(s) = k} g(z) = 1z 0 + 1z 1 + 1z 2 + 1z 3 + 3z 4 k X a k 0 ε , 1100,

96 24 / 46 X (0 (1(01 0) 1)) A generating function for language L encodes a k = {s : s L, len(s) = k} g(z) = 1z 0 + 1z 1 + 1z 2 + 1z 3 + 3z 4 + 5z k X a k 0 ε , 1100, , 10101, 11000, 11011,

97 25 / 46 Deterministic Finite Automata How to count paths of length k?

98 25 / 46 Deterministic Finite Automata How to count paths of length k? Generating Functions A = g(z) = det(i za : i, j) ( 1) n det(i za)

99 25 / 46 Deterministic Finite Automata How to count paths of length k? Generating Functions A = g(z) = det(i za : i, j) ( 1) n det(i za) g(z) = 1 z z 2 (z 1) (2z 2 + z 1)

100 25 / 46 Deterministic Finite Automata How to count paths of length k? Generating Functions A = g(z) = det(i za : i, j) ( 1) n det(i za) g(z) = 1 z z 2 (z 1) (2z 2 + z 1) g(z) = 1z 0 + 1z 1 + 1z 2 + 1z 3 + 3z 4 + 5z

101 Good job, Will Hunting!!! 26 / 46

102 Automata-Based Model Counter (ABC) CAV 2015: Automata-Based Model Counting for String Constraints. Abdulbaki Aydin, Lucas Bang, Tevfik Bultan.

103 Automata-Based Model Counter (ABC) CAV 2015: Automata-Based Model Counting for String Constraints. Abdulbaki Aydin, Lucas Bang, Tevfik Bultan. String Constraints ABC Counting Function f (k)

104 Automata-Based Model Counter (ABC) CAV 2015: Automata-Based Model Counting for String Constraints. Abdulbaki Aydin, Lucas Bang, Tevfik Bultan. String Length, k String Constraints ABC Counting Function f (k)

105 27 / 46 Automata-Based Model Counter (ABC) CAV 2015: Automata-Based Model Counting for String Constraints. Abdulbaki Aydin, Lucas Bang, Tevfik Bultan. String Length, k String Constraints ABC Counting Function f (k) Number of solutions of length k

106 27 / 46 Automata-Based Model Counter (ABC) CAV 2015: Automata-Based Model Counting for String Constraints. Abdulbaki Aydin, Lucas Bang, Tevfik Bultan. String Length, k String Constraints ABC Counting Function f (k) Number of solutions of length k Idea: Convert string constraints to DFA. Count paths in DFA.

107 28 / 46 Password Changing Policy Constraint on NEW_P (declare-fun NEW_P () String) (not (contains (tolower NEW_P) "abc-16")) (not (contains "abc-16" (tolower NEW_P))) (not (contains (tolower NEW_P) "61-cba")) (not (contains "61-cba" (tolower NEW_P))) (check-sat) (model-count)

108 0 A, a 6 1 B, b 5 - C, c B, b 1 - C, c C, c - C, c - - C, c [NUL-,], [.-0], [2-5], [7-@] `, [D-G], [d-g], [H-O], [h-o] [P-_], [p-253] 6 12 B, b A, a - [NUL-5], [7-@], `, C, c, [D-G] [d-g], [H-O], [h-o], [P-_] [p-253] 1 [NUL-0], [2-5], [7-@], `, [B-C] [b-c], [D-G], [d-g], [H-O] [h-o], [P-_], [p-253] C, c [NUL-,], [.-5], [7-@], `, [B-C] [b-c], [D-G], [d-g], [H-O] [h-o], [P-_], [p-253] B, b [NUL-5], [7-@], `, B, b, [D-G] [d-g], [H-O], [h-o], [P-_] [p-253] 28 [NUL-5], [7-@], `, B, b, [D-G] [d-g], [H-O], [h-o], [P-_] [p-253] [NUL-0], [2-5], [7-@], `, B b, [D-G], [d-g], [H-O], [h-o] [P-_], [p-253] [NUL-,], [.-5], [7-@], `, C c, [D-G], [d-g], [H-O], [h-o] [P-_], [p-253] 11 [NUL-,], [.-5], [7-@], `, [B-C] [b-c], [D-G], [d-g], [H-O] [h-o], [P-_], [p-253] [NUL-5], [7-@], `, B, b, [D-G] [d-g], [H-O], [h-o], [P-_] [p-253] [NUL-,], [.-5], [7-@], `, [B-C] [b-c], [D-G], [d-g], [H-O] [h-o], [P-_], [p-253] [NUL-,], [.-5], [7-@], `, [B-C] [b-c], [D-G], [d-g], [H-O] [h-o], [P-_], [p-253] 6 [NUL-0], [2-5], [7-@], `, [B-C] [b-c], [D-G], [d-g], [H-O] [h-o], [P-_], [p-253] [NUL-5], [7-@], `, B, b, [D-G] [d-g], [H-O], [h-o], [P-_] [p-253] [NUL-5], [7-@], `, C, c, [D-G] [d-g], [H-O], [h-o], [P-_] [p-253] B, b 6 6 A, a [NUL-0], [2-5], [7-@], `, [B-C] [b-c], [D-G], [d-g], [H-O] [h-o], [P-_], [p-253] [NUL-5], [7-@], `, [B-C], [b-c] [D-G], [d-g], [H-O], [h-o] [P-_], [p-253] 14 [NUL-5], [7-@], `, C, c, [D-G] [d-g], [H-O], [h-o], [P-_] [p-253] [NUL-5], [7-@], `, [B-C], [b-c] [D-G], [d-g], [H-O], [h-o] [P-_], [p-253] [NUL-5], [7-@], `, [B-C], [b-c] [D-G], [d-g], [H-O], [h-o] [P-_], [p-253] [NUL-0], [2-5], [7-@], `, [B-C] [b-c], [D-G], [d-g], [H-O] [h-o], [P-_], [p-253] [NUL-5], [7-@], `, [B-C], [b-c] [D-G], [d-g], [H-O], [h-o] [P-_], [p-253] 6 6 [NUL-5], [7-@], `, C, c, [D-G] [d-g], [H-O], [h-o], [P-_] [p-253] A, a A, a [NUL-5], [7-@], `, [B-C], [b-c] [D-G], [d-g], [H-O], [h-o] [P-_], [p-253] A, a A, a A, a A, a A, a 6 1 [NUL-0], [2-5], [7-@], `, [B-C] [b-c], [D-G], [d-g], [H-O] [h-o], [P-_], [p-253] A, a A, a A, a A, a A, a A, a [NUL-,], [.-5], [7-@], `, [B-C] [b-c], [D-G], [d-g], [H-O] [h-o], [P-_], [p-253] 6 9 A, a A, a [NUL-5], [7-@], `, B, b, [D-G] [d-g], [H-O], [h-o], [P-_] [p-253] 1 6 A, a A, a A, a A, a [NUL-5], [7-@], `, C, c, [D-G] [d-g], [H-O], [h-o], [P-_] [p-253] 21 6 [NUL-5], [7-@], `, C, c, [D-G] [d-g], [H-O], [h-o], [P-_] [p-253] A, a - [NUL-5], [7-@], `, [B-C], [b-c] [D-G], [d-g], [H-O], [h-o] [P-_], [p-253] 6 B, b [NUL-5], [7-@], `, B, b, [D-G] [d-g], [H-O], [h-o], [P-_] [p-253] A, a A, a C, c [NUL-,], [.-5], [7-@], `, [B-C] [b-c], [D-G], [d-g], [H-O] [h-o], [P-_], [p-253] 6 [NUL-0], [2-5], [7-@], `, [B-C] [b-c], [D-G], [d-g], [H-O] [h-o], [P-_], [p-253] A, a 29 6 [NUL-5], [7-@], `, [B-C], [b-c] [D-G], [d-g], [H-O], [h-o] [P-_], [p-253] A, a B, b 6 A, a B, b A, a A, a 22 A, a C, c A, a / Password Changing Policy Figure: Solution DFA for all possible values of NEWP.

109 Password Changing Policy Figure: Transition matrix for DFA for all possible values of NEWP. 30 / 46

110 Password Changing Policy Figure: Transition matrix for DFA for all possible values of NEWP. 31 / 46

111 32 / 46 Password Changing Policy Generating function which enumerates NEW_P: g(z) = 8096z z z z 7 16z 6 256z z z z z z z z 3 247z 2

112 32 / 46 Password Changing Policy Generating function which enumerates NEW_P: g(z) = 8096z z z z 7 16z 6 256z z z z z z z z 3 247z 2 g(z) = 247z z z z z

113 32 / 46 Password Changing Policy Generating function which enumerates NEW_P: g(z) = 8096z z z z 7 16z 6 256z z z z z z z z 3 247z 2 g(z) = 247z z z z z To answer our quantitative question: Brute force searching for password length = 6: = 2 48 passwords.

114 32 / 46 Password Changing Policy Generating function which enumerates NEW_P: g(z) = 8096z z z z 7 16z 6 256z z z z z z z z 3 247z 2 g(z) = 247z z z z z To answer our quantitative question: Brute force searching for password length = 6: = 2 48 passwords. If adversary knows old_p and the policy: passwords.

115 32 / 46 Password Changing Policy Generating function which enumerates NEW_P: g(z) = 8096z z z z 7 16z 6 256z z z z z z z z 3 247z 2 g(z) = 247z z z z z To answer our quantitative question: Brute force searching for password length = 6: = 2 48 passwords. If adversary knows old_p and the policy: passwords. Reduces search space by about factor of

116 33 / 46 Outline Motivation and Background Model Counting Boolean Formulas String Model Counting Automata-Based Methods Non-Automata-Based Method String Model Counting Benchmarks

117 34 / 46 SMC Model Counting PLDI 2014: A Model Counter For Constraints Over Unbounded Strings. Luu, Shinde, Saxena, Demsky. SMC Tool Online: String Length, k String Constraints SMC Generating Function, g(z) Number of strings of length k

118 34 / 46 SMC Model Counting PLDI 2014: A Model Counter For Constraints Over Unbounded Strings. Luu, Shinde, Saxena, Demsky. SMC Tool Online: String Length, k String Constraints SMC Generating Function, g(z) Number of strings of length k Idea: go directly from constraints to g(z) using transformations.

119 35 / 46 SMC Model Counting For a regular expression constraint, generating function can be derived recursively.

120 35 / 46 SMC Model Counting For a regular expression constraint, generating function can be derived recursively. ε 1z 0

121 35 / 46 SMC Model Counting For a regular expression constraint, generating function can be derived recursively. ε 1z 0 c 1z 1

122 35 / 46 SMC Model Counting For a regular expression constraint, generating function can be derived recursively. ε 1z 0 c 1z 1 A B A(z) + B(z)

123 35 / 46 SMC Model Counting For a regular expression constraint, generating function can be derived recursively. ε 1z 0 c 1z 1 A B A(z) + B(z) A B A(z) B(z)

124 35 / 46 SMC Model Counting For a regular expression constraint, generating function can be derived recursively. ε 1z 0 c 1z 1 A B A(z) + B(z) A B A(z) B(z) A 1/(1 A(z))

125 Regular Expressions X (0 (1(01 0) 1))

126 Regular Expressions X (0 (1(01 0) 1)) z 1

127 Regular Expressions X (0 (1(01 0) 1)) z 0 1

128 Regular Expressions X (0 (1(01 0) 1)) z z 0 1

129 Regular Expressions X (0 (1(01 0) 1)) z 1 z 0 1

130 Regular Expressions X (0 (1(01 0) 1)) z 0 z 1 z 0 1

131 Regular Expressions X (0 (1(01 0) 1)) 0 1 z 2 1 z

132 Regular Expressions X (0 (1(01 0) 1)) z2 1 z 1 z 0 0 1

133 Regular Expressions X (0 (1(01 0) 1)) 0 z 1 z 1 z2 1 z

134 Regular Expressions X (0 (1(01 0) 1)) z 0 z 2 1 z2 1 z

135 Regular Expressions X (0 (1(01 0) 1)) z + z2 1 z2 1 z

136 36 / 46 Regular Expressions 1 1 z z2 1 1 z z2 X (0 (1(01 0) 1))

137 Regular Expressions X (0 (1(01 0) 1)) Generating Function: g(z) = 1 1 z z2 1 1 z z

138 Regular Expressions X (0 (1(01 0) 1)) Generating Function: g(z) = 1 1 z z2 1 1 z z2 = 1 z z 2 (z 1)(2z 2 +z 1) 0 1

139 Regular Expressions X (0 (1(01 0) 1)) Generating Function: g(z) = 1 1 z z2 1 1 z z2 = 1 z z 2 (z 1)(2z 2 +z 1) 0 1 g(z) = 1z 0 +1z 1 +1z 2 +1z 3 +3z 4 +5z

140 37 / 46 Other operations in SMC Specialized transformations for other operations

141 37 / 46 Other operations in SMC Specialized transformations for other operations contains(s 1, s 2 ) z n (1 Mz)(z n +(1 Mz)c(z))

142 37 / 46 Other operations in SMC Specialized transformations for other operations contains(s 1, s 2 ) z n (1 Mz)(z n +(1 Mz)c(z)) F 1 F 2 [max(l 1 (z), L 2 (z)), min(u 1 (z) + U 2 (z), G(z))]

143 37 / 46 Other operations in SMC Specialized transformations for other operations contains(s 1, s 2 ) z n (1 Mz)(z n +(1 Mz)c(z)) F 1 F 2 [max(l 1 (z), L 2 (z)), min(u 1 (z) + U 2 (z), G(z))] Also handle substring, length, negation, conjunction,..., with upper and lower bounds.

144 38 / 46 Outline Motivation and Background Model Counting Boolean Formulas String Model Counting Automata-Based Methods Non-Automata-Based Method String Model Counting Benchmarks

145 39 / 46 Experimental Comparison Table: Log scaled comparison between SMC and ABC bound SMC SMC ABC lower bound upper bound count nullhttpd ghttpd csplit grep wc obscure

146 40 / 46 Experimental Comparison JavaScript Benchmarks Kaluza benchmarks, extracted from JavaScript code via DSE, [Saxena, SSP 2010]

147 40 / 46 Experimental Comparison JavaScript Benchmarks Kaluza benchmarks, extracted from JavaScript code via DSE, [Saxena, SSP 2010] Small Constraints (19,731): ABC: 19,731 constraints, average 0.32 seconds per constraint SMC: 17,559 constraints, average 0.26 seconds per constraint.

148 40 / 46 Experimental Comparison JavaScript Benchmarks Kaluza benchmarks, extracted from JavaScript code via DSE, [Saxena, SSP 2010] Small Constraints (19,731): ABC: 19,731 constraints, average 0.32 seconds per constraint SMC: 17,559 constraints, average 0.26 seconds per constraint. Big Constraints (1,587): ABC: 1,587 constraints, average 0.34 seconds per constraint SMC: 1,342 constraints, average 5.29 seconds per constraint

149 ABC Bonus: Model Counting Linear Integer Arithmetic 41 / 46

150 41 / 46 ABC Bonus: Model Counting Linear Integer Arithmetic What is this language? X (0 (1(01 0) 1))

151 41 / 46 ABC Bonus: Model Counting Linear Integer Arithmetic What is this language? X (0 (1(01 0) 1)) L(X) = {s s is a binary number divisible by 3}

152 41 / 46 ABC Bonus: Model Counting Linear Integer Arithmetic What is this language? X (0 (1(01 0) 1)) L(X) = {s s is a binary number divisible by 3}

153 41 / 46 ABC Bonus: Model Counting Linear Integer Arithmetic What is this language? X (0 (1(01 0) 1)) L(X) = {s s is a binary number divisible by 3} Idea: DFA can represent (some) relations on sets of binary integers. We can use similar techniques that we used for #String to solve #LIA.

154 42 / 46 Model Counting Linear Integer Arithmetic Quantifier-Free Linear Integer Arithmetic (Z, +, <).

155 42 / 46 Model Counting Linear Integer Arithmetic Quantifier-Free Linear Integer Arithmetic (Z, +, <). Constraints of the form: Ax < B, x Z n

156 42 / 46 Model Counting Linear Integer Arithmetic Quantifier-Free Linear Integer Arithmetic (Z, +, <). Constraints of the form: Ax < B, x Z n It is possible to represent the solutions to a set of LIA constraints as a binary multi-track DFA.

157 43 / 46 Binary Multi-track DFA Solution DFA for LIA constraints. Read bits of x and y from most to least significant. ( ) bx Alphabet is a tuple of bits: b y Solution DFA for the constraint x > y. ( ( 0 1, 0) 1) ( 1 0) = > ( 0 1) < ( ( ( ( ,,, 0) 1) 0) 1) ( ( ( ( ,,, 0) 1) 0) 1)

158 43 / 46 Binary Multi-track DFA Solution DFA for LIA constraints. Read bits of x and y from most to least significant. ( ) bx Alphabet is a tuple of bits: b y Solution DFA for the constraint x > y. ( ( 0 1, 0) 1) ( 1 0) = > ( 0 1) < ( ( ( ( ,,, 0) 1) 0) 1) ( ( ( ( ,,, 0) 1) 0) 1) Solutions of length n solutions within bound 2 n

159 44 / 46 Model Counting Summary Counting Techniques for Different Theories Boolean

160 44 / 46 Model Counting Summary Counting Techniques for Different Theories Boolean Truth Table (Brute Force) DPLL

161 44 / 46 Model Counting Summary Counting Techniques for Different Theories Boolean Truth Table (Brute Force) DPLL Strings DFA with Dynamic Programming, Matrix Multiplication, GFs Regular Expression with GFs

162 44 / 46 Model Counting Summary Counting Techniques for Different Theories Boolean Truth Table (Brute Force) DPLL Strings DFA with Dynamic Programming, Matrix Multiplication, GFs Regular Expression with GFs Linear Integer Arithmetic Binary Multi-track DFA

163 45 / 46 Related work on model counting Stanley. Enumerative Combinatorics Chapter Sedgwick. Analytic Combinatorics Chapter 5: Generating Functions Biere. Handbook of Satisfiability. Chapter 20: Model Counting Pugh. Counting Solutions to Presburger Formulas: How and Why Parker. An Automata-Theoretic Algorithm for Counting Solutions to Presburger Formulas. Compiler Construction 2004 Boigelot. Counting the solutions of Presburger equations without enumerating them. TCS Barvinok. A polynomial time algorithm for counting integral points in polyhedra when the dimension is fixed. Mathematics of Operations Research 1994 De Loerab. Effective lattice point counting in rational convex polytopes. JSC 2004 Verdoolaege. Counting integer points in parametric polytopes using Barvinoks s Rational Functions Kopf Symbolic Polytopes for Quantitative Interpolation and Verification. CAV 2015 Luu. A Model Counter For Constraints Over Unbounded Strings. PLDI 2014 Ravikumara. Weak minimization of DFA - an algorithm and applications.implementation and Application of Automata 2004 Chomsky. The Algebraic Theory of Context-Free Languages Phan. Model Counting Modulo Theories. PhD Thesis Birnbaum. The good old Davis-Putnam procedure helps counting models. JAIR 1999

164 Thank you. 46 / 46

Side Channel Analysis Using a Model Counting Constraint Solver and Symbolic Execution

Side Channel Analysis Using a Model Counting Constraint Solver and Symbolic Execution Side Channel Analysis Using a Model Counting Constraint Solver and Symbolic Execution Tevfik Bultan Computer Science Department University of California, Santa Barbara Joint work with: Abdulbaki Aydin,

More information

Automata Theory and Formal Grammars: Lecture 1

Automata Theory and Formal Grammars: Lecture 1 Automata Theory and Formal Grammars: Lecture 1 Sets, Languages, Logic Automata Theory and Formal Grammars: Lecture 1 p.1/72 Sets, Languages, Logic Today Course Overview Administrivia Sets Theory (Review?)

More information

Interpolation. Seminar Slides. Betim Musa. 27 th June Albert-Ludwigs-Universität Freiburg

Interpolation. Seminar Slides. Betim Musa. 27 th June Albert-Ludwigs-Universität Freiburg Interpolation Seminar Slides Albert-Ludwigs-Universität Freiburg Betim Musa 27 th June 2015 Motivation program add(int a, int b) { var x,i : int; l 0 assume(b 0); l 1 x := a; l 2 i := 0; while(i < b) {

More information

CSE 555 HW 5 SAMPLE SOLUTION. Question 1.

CSE 555 HW 5 SAMPLE SOLUTION. Question 1. CSE 555 HW 5 SAMPLE SOLUTION Question 1. Show that if L is PSPACE-complete, then L is NP-hard. Show that the converse is not true. If L is PSPACE-complete, then for all A PSPACE, A P L. We know SAT PSPACE

More information

First-Order Logic. 1 Syntax. Domain of Discourse. FO Vocabulary. Terms

First-Order Logic. 1 Syntax. Domain of Discourse. FO Vocabulary. Terms First-Order Logic 1 Syntax Domain of Discourse The domain of discourse for first order logic is FO structures or models. A FO structure contains Relations Functions Constants (functions of arity 0) FO

More information

Comp487/587 - Boolean Formulas

Comp487/587 - Boolean Formulas Comp487/587 - Boolean Formulas 1 Logic and SAT 1.1 What is a Boolean Formula Logic is a way through which we can analyze and reason about simple or complicated events. In particular, we are interested

More information

CS156: The Calculus of Computation

CS156: The Calculus of Computation CS156: The Calculus of Computation Zohar Manna Winter 2010 It is reasonable to hope that the relationship between computation and mathematical logic will be as fruitful in the next century as that between

More information

Representing Arithmetic Constraints with Finite Automata: An Overview

Representing Arithmetic Constraints with Finite Automata: An Overview Representing Arithmetic Constraints with Finite Automata: An Overview Bernard Boigelot Pierre Wolper Université de Liège Motivation Linear numerical constraints are a very common and useful formalism (our

More information

SMT BASICS WS 2017/2018 ( ) LOGIC SATISFIABILITY MODULO THEORIES. Institute for Formal Models and Verification Johannes Kepler Universität Linz

SMT BASICS WS 2017/2018 ( ) LOGIC SATISFIABILITY MODULO THEORIES. Institute for Formal Models and Verification Johannes Kepler Universität Linz LOGIC SATISFIABILITY MODULO THEORIES SMT BASICS WS 2017/2018 (342.208) Armin Biere Martina Seidl biere@jku.at martina.seidl@jku.at Institute for Formal Models and Verification Johannes Kepler Universität

More information

Space Complexity. The space complexity of a program is how much memory it uses.

Space Complexity. The space complexity of a program is how much memory it uses. Space Complexity The space complexity of a program is how much memory it uses. Measuring Space When we compute the space used by a TM, we do not count the input (think of input as readonly). We say that

More information

Optimal Metric Planning with State Sets in Automata Representation [3]

Optimal Metric Planning with State Sets in Automata Representation [3] Optimal Metric Planning with State Sets in Automata Representation [3] Björn Ulrich Borowsky Stefan Edelkamp Fakultät für Informatik, Technische Universität Dortmund, Germany 2008 (Slides by ) Goal and

More information

Lecturecise 22 Weak monadic second-order theory of one successor (WS1S)

Lecturecise 22 Weak monadic second-order theory of one successor (WS1S) Lecturecise 22 Weak monadic second-order theory of one successor (WS1S) 2013 Reachability in the Heap Many programs manipulate linked data structures (lists, trees). To express many important properties

More information

Topics in Model-Based Reasoning

Topics in Model-Based Reasoning Towards Integration of Proving and Solving Dipartimento di Informatica Università degli Studi di Verona Verona, Italy March, 2014 Automated reasoning Artificial Intelligence Automated Reasoning Computational

More information

Notes for Lecture 3... x 4

Notes for Lecture 3... x 4 Stanford University CS254: Computational Complexity Notes 3 Luca Trevisan January 14, 2014 Notes for Lecture 3 In this lecture we introduce the computational model of boolean circuits and prove that polynomial

More information

An Introduction to SAT Solving

An Introduction to SAT Solving An Introduction to SAT Solving Applied Logic for Computer Science UWO December 3, 2017 Applied Logic for Computer Science An Introduction to SAT Solving UWO December 3, 2017 1 / 46 Plan 1 The Boolean satisfiability

More information

LOGIC PROPOSITIONAL REASONING

LOGIC PROPOSITIONAL REASONING LOGIC PROPOSITIONAL REASONING WS 2017/2018 (342.208) Armin Biere Martina Seidl biere@jku.at martina.seidl@jku.at Institute for Formal Models and Verification Johannes Kepler Universität Linz Version 2018.1

More information

Recursive descent for grammars with contexts

Recursive descent for grammars with contexts 39th International Conference on Current Trends in Theory and Practice of Computer Science Špindleruv Mlýn, Czech Republic Recursive descent parsing for grammars with contexts Ph.D. student, Department

More information

Notes. Corneliu Popeea. May 3, 2013

Notes. Corneliu Popeea. May 3, 2013 Notes Corneliu Popeea May 3, 2013 1 Propositional logic Syntax We rely on a set of atomic propositions, AP, containing atoms like p, q. A propositional logic formula φ Formula is then defined by the following

More information

Exploring the infinite : an introduction to proof and analysis / Jennifer Brooks. Boca Raton [etc.], cop Spis treści

Exploring the infinite : an introduction to proof and analysis / Jennifer Brooks. Boca Raton [etc.], cop Spis treści Exploring the infinite : an introduction to proof and analysis / Jennifer Brooks. Boca Raton [etc.], cop. 2017 Spis treści Preface xiii I Fundamentals of Abstract Mathematics 1 1 Basic Notions 3 1.1 A

More information

Introduction to Language Theory and Compilation: Exercises. Session 2: Regular expressions

Introduction to Language Theory and Compilation: Exercises. Session 2: Regular expressions Introduction to Language Theory and Compilation: Exercises Session 2: Regular expressions Regular expressions (RE) Finite automata are an equivalent formalism to regular languages (for each regular language,

More information

an efficient procedure for the decision problem. We illustrate this phenomenon for the Satisfiability problem.

an efficient procedure for the decision problem. We illustrate this phenomenon for the Satisfiability problem. 1 More on NP In this set of lecture notes, we examine the class NP in more detail. We give a characterization of NP which justifies the guess and verify paradigm, and study the complexity of solving search

More information

COMP/MATH 300 Topics for Spring 2017 June 5, Review and Regular Languages

COMP/MATH 300 Topics for Spring 2017 June 5, Review and Regular Languages COMP/MATH 300 Topics for Spring 2017 June 5, 2017 Review and Regular Languages Exam I I. Introductory and review information from Chapter 0 II. Problems and Languages A. Computable problems can be expressed

More information

Foundations of Artificial Intelligence

Foundations of Artificial Intelligence Foundations of Artificial Intelligence 31. Propositional Logic: DPLL Algorithm Malte Helmert and Gabriele Röger University of Basel April 24, 2017 Propositional Logic: Overview Chapter overview: propositional

More information

Sri vidya college of engineering and technology

Sri vidya college of engineering and technology Unit I FINITE AUTOMATA 1. Define hypothesis. The formal proof can be using deductive proof and inductive proof. The deductive proof consists of sequence of statements given with logical reasoning in order

More information

Theory of Computation

Theory of Computation Theory of Computation Dr. Sarmad Abbasi Dr. Sarmad Abbasi () Theory of Computation / Lecture 3: Overview Decidability of Logical Theories Presburger arithmetic Decidability of Presburger Arithmetic Dr.

More information

Discrete Mathematics

Discrete Mathematics Discrete Mathematics Discrete mathematics is devoted to the study of discrete or distinct unconnected objects. Classical mathematics deals with functions on real numbers. Real numbers form a continuous

More information

UCLID: Deciding Combinations of Theories via Eager Translation to SAT. SAT-based Decision Procedures

UCLID: Deciding Combinations of Theories via Eager Translation to SAT. SAT-based Decision Procedures UCLID: Deciding Combinations of Theories via Eager Translation to SAT Sanjit A. Seshia SAT-based Decision Procedures Input Formula Input Formula Satisfiability-preserving Boolean Encoder Boolean Formula

More information

Introduction. Foundations of Computing Science. Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

Introduction. Foundations of Computing Science. Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR 1 Introduction Foundations of Computing Science Pallab Dasgupta Professor, Dept. of Computer Sc & Engg 2 Comments on Alan Turing s Paper "On Computable Numbers, with an Application to the Entscheidungs

More information

Packet #2: Set Theory & Predicate Calculus. Applied Discrete Mathematics

Packet #2: Set Theory & Predicate Calculus. Applied Discrete Mathematics CSC 224/226 Notes Packet #2: Set Theory & Predicate Calculus Barnes Packet #2: Set Theory & Predicate Calculus Applied Discrete Mathematics Table of Contents Full Adder Information Page 1 Predicate Calculus

More information

Logical Agents. Outline

Logical Agents. Outline Logical Agents *(Chapter 7 (Russel & Norvig, 2004)) Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence, validity, satisfiability

More information

Propositional Calculus

Propositional Calculus Propositional Calculus Dr. Neil T. Dantam CSCI-498/598 RPM, Colorado School of Mines Spring 2018 Dantam (Mines CSCI, RPM) Propositional Calculus Spring 2018 1 / 64 Calculus? Definition: Calculus A well

More information

Chapter 4: Classical Propositional Semantics

Chapter 4: Classical Propositional Semantics Chapter 4: Classical Propositional Semantics Language : L {,,, }. Classical Semantics assumptions: TWO VALUES: there are only two logical values: truth (T) and false (F), and EXTENSIONALITY: the logical

More information

An Introduction to Z3

An Introduction to Z3 An Introduction to Z3 Huixing Fang National Trusted Embedded Software Engineering Technology Research Center April 12, 2017 Outline 1 SMT 2 Z3 Huixing Fang (ECNU) An Introduction to Z3 April 12, 2017 2

More information

CS156: The Calculus of Computation Zohar Manna Autumn 2008

CS156: The Calculus of Computation Zohar Manna Autumn 2008 Page 3 of 52 Page 4 of 52 CS156: The Calculus of Computation Zohar Manna Autumn 2008 Lecturer: Zohar Manna (manna@cs.stanford.edu) Office Hours: MW 12:30-1:00 at Gates 481 TAs: Boyu Wang (wangboyu@stanford.edu)

More information

Course Runtime Verification

Course Runtime Verification Course Martin Leucker (ISP) Volker Stolz (Høgskolen i Bergen, NO) INF5140 / V17 Chapters of the Course Chapter 1 Recall in More Depth Chapter 2 Specification Languages on Words Chapter 3 LTL on Finite

More information

Inf2D 06: Logical Agents: Knowledge Bases and the Wumpus World

Inf2D 06: Logical Agents: Knowledge Bases and the Wumpus World Inf2D 06: Logical Agents: Knowledge Bases and the Wumpus World School of Informatics, University of Edinburgh 26/01/18 Slide Credits: Jacques Fleuriot, Michael Rovatsos, Michael Herrmann Outline Knowledge-based

More information

Classes of Boolean Functions

Classes of Boolean Functions Classes of Boolean Functions Nader H. Bshouty Eyal Kushilevitz Abstract Here we give classes of Boolean functions that considered in COLT. Classes of Functions Here we introduce the basic classes of functions

More information

Complexity Theory VU , SS The Polynomial Hierarchy. Reinhard Pichler

Complexity Theory VU , SS The Polynomial Hierarchy. Reinhard Pichler Complexity Theory Complexity Theory VU 181.142, SS 2018 6. The Polynomial Hierarchy Reinhard Pichler Institut für Informationssysteme Arbeitsbereich DBAI Technische Universität Wien 15 May, 2018 Reinhard

More information

Satisfiability Modulo Theories (SMT)

Satisfiability Modulo Theories (SMT) CS510 Software Engineering Satisfiability Modulo Theories (SMT) Slides modified from those by Aarti Gupta Textbook: The Calculus of Computation by A. Bradley and Z. Manna 1 Satisfiability Modulo Theory

More information

Outline. Complexity Theory EXACT TSP. The Class DP. Definition. Problem EXACT TSP. Complexity of EXACT TSP. Proposition VU 181.

Outline. Complexity Theory EXACT TSP. The Class DP. Definition. Problem EXACT TSP. Complexity of EXACT TSP. Proposition VU 181. Complexity Theory Complexity Theory Outline Complexity Theory VU 181.142, SS 2018 6. The Polynomial Hierarchy Reinhard Pichler Institut für Informationssysteme Arbeitsbereich DBAI Technische Universität

More information

Recap DFA,NFA, DTM. Slides by Prof. Debasis Mitra, FIT.

Recap DFA,NFA, DTM. Slides by Prof. Debasis Mitra, FIT. Recap DFA,NFA, DTM Slides by Prof. Debasis Mitra, FIT. 1 Formal Language Finite set of alphabets Σ: e.g., {0, 1}, {a, b, c}, { {, } } Language L is a subset of strings on Σ, e.g., {00, 110, 01} a finite

More information

Advanced topic: Space complexity

Advanced topic: Space complexity Advanced topic: Space complexity CSCI 3130 Formal Languages and Automata Theory Siu On CHAN Chinese University of Hong Kong Fall 2016 1/28 Review: time complexity We have looked at how long it takes to

More information

Scalable and Accurate Verification of Data Flow Systems. Cesare Tinelli The University of Iowa

Scalable and Accurate Verification of Data Flow Systems. Cesare Tinelli The University of Iowa Scalable and Accurate Verification of Data Flow Systems Cesare Tinelli The University of Iowa Overview AFOSR Supported Research Collaborations NYU (project partner) Chalmers University (research collaborator)

More information

1. Consider the conditional E = p q r. Use de Morgan s laws to write simplified versions of the following : The negation of E : 5 points

1. Consider the conditional E = p q r. Use de Morgan s laws to write simplified versions of the following : The negation of E : 5 points Introduction to Discrete Mathematics 3450:208 Test 1 1. Consider the conditional E = p q r. Use de Morgan s laws to write simplified versions of the following : The negation of E : The inverse of E : The

More information

Chapter 0 Introduction. Fourth Academic Year/ Elective Course Electrical Engineering Department College of Engineering University of Salahaddin

Chapter 0 Introduction. Fourth Academic Year/ Elective Course Electrical Engineering Department College of Engineering University of Salahaddin Chapter 0 Introduction Fourth Academic Year/ Elective Course Electrical Engineering Department College of Engineering University of Salahaddin October 2014 Automata Theory 2 of 22 Automata theory deals

More information

NP-Complete Problems. Complexity Class P. .. Cal Poly CSC 349: Design and Analyis of Algorithms Alexander Dekhtyar..

NP-Complete Problems. Complexity Class P. .. Cal Poly CSC 349: Design and Analyis of Algorithms Alexander Dekhtyar.. .. Cal Poly CSC 349: Design and Analyis of Algorithms Alexander Dekhtyar.. Complexity Class P NP-Complete Problems Abstract Problems. An abstract problem Q is a binary relation on sets I of input instances

More information

Propositional Logic: Evaluating the Formulas

Propositional Logic: Evaluating the Formulas Institute for Formal Models and Verification Johannes Kepler University Linz VL Logik (LVA-Nr. 342208) Winter Semester 2015/2016 Propositional Logic: Evaluating the Formulas Version 2015.2 Armin Biere

More information

Secret Sharing CPT, Version 3

Secret Sharing CPT, Version 3 Secret Sharing CPT, 2006 Version 3 1 Introduction In all secure systems that use cryptography in practice, keys have to be protected by encryption under other keys when they are stored in a physically

More information

Motivation. CS389L: Automated Logical Reasoning. Lecture 10: Overview of First-Order Theories. Signature and Axioms of First-Order Theory

Motivation. CS389L: Automated Logical Reasoning. Lecture 10: Overview of First-Order Theories. Signature and Axioms of First-Order Theory Motivation CS389L: Automated Logical Reasoning Lecture 10: Overview of First-Order Theories Işıl Dillig Last few lectures: Full first-order logic In FOL, functions/predicates are uninterpreted (i.e., structure

More information

Pythagorean Triples and SAT Solving

Pythagorean Triples and SAT Solving Pythagorean Triples and SAT Solving Moti Ben-Ari Department of Science Teaching Weizmann Institute of Science http://www.weizmann.ac.il/sci-tea/benari/ c 2017-18 by Moti Ben-Ari. This work is licensed

More information

Decidability (What, stuff is unsolvable?)

Decidability (What, stuff is unsolvable?) University of Georgia Fall 2014 Outline Decidability Decidable Problems for Regular Languages Decidable Problems for Context Free Languages The Halting Problem Countable and Uncountable Sets Diagonalization

More information

6.5.3 An NP-complete domino game

6.5.3 An NP-complete domino game 26 Chapter 6. Complexity Theory 3SAT NP. We know from Theorem 6.5.7 that this is true. A P 3SAT, for every language A NP. Hence, we have to show this for languages A such as kcolor, HC, SOS, NPrim, KS,

More information

Chapter 3. Regular grammars

Chapter 3. Regular grammars Chapter 3 Regular grammars 59 3.1 Introduction Other view of the concept of language: not the formalization of the notion of effective procedure, but set of words satisfying a given set of rules Origin

More information

2. Associative Law: A binary operator * on a set S is said to be associated whenever (A*B)*C = A*(B*C) for all A,B,C S.

2. Associative Law: A binary operator * on a set S is said to be associated whenever (A*B)*C = A*(B*C) for all A,B,C S. BOOLEAN ALGEBRA 2.1 Introduction Binary logic deals with variables that have two discrete values: 1 for TRUE and 0 for FALSE. A simple switching circuit containing active elements such as a diode and transistor

More information

Part I: Definitions and Properties

Part I: Definitions and Properties Turing Machines Part I: Definitions and Properties Finite State Automata Deterministic Automata (DFSA) M = {Q, Σ, δ, q 0, F} -- Σ = Symbols -- Q = States -- q 0 = Initial State -- F = Accepting States

More information

Notes on generating functions in automata theory

Notes on generating functions in automata theory Notes on generating functions in automata theory Benjamin Steinberg December 5, 2009 Contents Introduction: Calculus can count 2 Formal power series 5 3 Rational power series 9 3. Rational power series

More information

Turing machines and linear bounded automata

Turing machines and linear bounded automata and linear bounded automata Informatics 2A: Lecture 29 John Longley School of Informatics University of Edinburgh jrl@inf.ed.ac.uk 27 November 2015 1 / 15 The Chomsky hierarchy: summary Level Language

More information

Chapter 7 Propositional Satisfiability Techniques

Chapter 7 Propositional Satisfiability Techniques Lecture slides for Automated Planning: Theory and Practice Chapter 7 Propositional Satisfiability Techniques Dana S. Nau CMSC 722, AI Planning University of Maryland, Spring 2008 1 Motivation Propositional

More information

EECS 144/244: Fundamental Algorithms for System Modeling, Analysis, and Optimization

EECS 144/244: Fundamental Algorithms for System Modeling, Analysis, and Optimization EECS 144/244: Fundamental Algorithms for System Modeling, Analysis, and Optimization Discrete Systems Lecture: State-Space Exploration Stavros Tripakis University of California, Berkeley Stavros Tripakis:

More information

CSE 20 DISCRETE MATH. Fall

CSE 20 DISCRETE MATH. Fall CSE 20 DISCRETE MATH Fall 2017 http://cseweb.ucsd.edu/classes/fa17/cse20-ab/ Today's learning goals Describe and use algorithms for integer operations based on their expansions Relate algorithms for integer

More information

9 Nondeterministic Turing Machines

9 Nondeterministic Turing Machines Caveat lector: This is the zeroth (draft) edition of this lecture note. In particular, some topics still need to be written. Please send bug reports and suggestions to jeffe@illinois.edu. If first you

More information

Lecture Notes. Advanced Discrete Structures COT S

Lecture Notes. Advanced Discrete Structures COT S Lecture Notes Advanced Discrete Structures COT 4115.001 S15 2015-01-13 Recap Divisibility Prime Number Theorem Euclid s Lemma Fundamental Theorem of Arithmetic Euclidean Algorithm Basic Notions - Section

More information

Lecture 1: Finite State Automaton

Lecture 1: Finite State Automaton Lecture 1: Finite State Automaton Instructor: Ketan Mulmuley Scriber: Yuan Li January 6, 2015 1 Deterministic Finite Automaton Informally, a deterministic finite automaton (DFA) has finite number of s-

More information

Database Theory VU , SS Complexity of Query Evaluation. Reinhard Pichler

Database Theory VU , SS Complexity of Query Evaluation. Reinhard Pichler Database Theory Database Theory VU 181.140, SS 2018 5. Complexity of Query Evaluation Reinhard Pichler Institut für Informationssysteme Arbeitsbereich DBAI Technische Universität Wien 17 April, 2018 Pichler

More information

SOLUTION: SOLUTION: SOLUTION:

SOLUTION: SOLUTION: SOLUTION: Convert R and S into nondeterministic finite automata N1 and N2. Given a string s, if we know the states N1 and N2 may reach when s[1...i] has been read, we are able to derive the states N1 and N2 may

More information

Finish K-Complexity, Start Time Complexity

Finish K-Complexity, Start Time Complexity 6.045 Finish K-Complexity, Start Time Complexity 1 Kolmogorov Complexity Definition: The shortest description of x, denoted as d(x), is the lexicographically shortest string such that M(w) halts

More information

Turing machines and linear bounded automata

Turing machines and linear bounded automata and linear bounded automata Informatics 2A: Lecture 29 John Longley School of Informatics University of Edinburgh jrl@inf.ed.ac.uk 25 November, 2011 1 / 13 1 The Chomsky hierarchy: summary 2 3 4 2 / 13

More information

CS5371 Theory of Computation. Lecture 18: Complexity III (Two Classes: P and NP)

CS5371 Theory of Computation. Lecture 18: Complexity III (Two Classes: P and NP) CS5371 Theory of Computation Lecture 18: Complexity III (Two Classes: P and NP) Objectives Define what is the class P Examples of languages in P Define what is the class NP Examples of languages in NP

More information

Automata Theory for Presburger Arithmetic Logic

Automata Theory for Presburger Arithmetic Logic Automata Theory for Presburger Arithmetic Logic References from Introduction to Automata Theory, Languages & Computation and Constraints in Computational Logic Theory & Application Presented by Masood

More information

NODIA AND COMPANY. GATE SOLVED PAPER Computer Science Engineering Theory of Computation. Copyright By NODIA & COMPANY

NODIA AND COMPANY. GATE SOLVED PAPER Computer Science Engineering Theory of Computation. Copyright By NODIA & COMPANY No part of this publication may be reproduced or distributed in any form or any means, electronic, mechanical, photocopying, or otherwise without the prior permission of the author. GATE SOLVED PAPER Computer

More information

SYLLABUS. Introduction to Finite Automata, Central Concepts of Automata Theory. CHAPTER - 3 : REGULAR EXPRESSIONS AND LANGUAGES

SYLLABUS. Introduction to Finite Automata, Central Concepts of Automata Theory. CHAPTER - 3 : REGULAR EXPRESSIONS AND LANGUAGES Contents i SYLLABUS UNIT - I CHAPTER - 1 : AUT UTOMA OMATA Introduction to Finite Automata, Central Concepts of Automata Theory. CHAPTER - 2 : FINITE AUT UTOMA OMATA An Informal Picture of Finite Automata,

More information

Propositional and First Order Reasoning

Propositional and First Order Reasoning Propositional and First Order Reasoning Terminology Propositional variable: boolean variable (p) Literal: propositional variable or its negation p p Clause: disjunction of literals q \/ p \/ r given by

More information

Turing machines and linear bounded automata

Turing machines and linear bounded automata and linear bounded automata Informatics 2A: Lecture 30 John Longley School of Informatics University of Edinburgh jrl@inf.ed.ac.uk 25 November 2016 1 / 17 The Chomsky hierarchy: summary Level Language

More information

Overview. Discrete Event Systems Verification of Finite Automata. What can finite automata be used for? What can finite automata be used for?

Overview. Discrete Event Systems Verification of Finite Automata. What can finite automata be used for? What can finite automata be used for? Computer Engineering and Networks Overview Discrete Event Systems Verification of Finite Automata Lothar Thiele Introduction Binary Decision Diagrams Representation of Boolean Functions Comparing two circuits

More information

Linear Algebra, Boolean Rings and Resolution? Armin Biere. Institute for Formal Models and Verification Johannes Kepler University Linz, Austria

Linear Algebra, Boolean Rings and Resolution? Armin Biere. Institute for Formal Models and Verification Johannes Kepler University Linz, Austria Linear Algebra, Boolean Rings and Resolution? Armin Biere Institute for Formal Models and Verification Johannes Kepler University Linz, Austria ACA 08 Applications of Computer Algebra Symbolic Computation

More information

CS481F01 Prelim 2 Solutions

CS481F01 Prelim 2 Solutions CS481F01 Prelim 2 Solutions A. Demers 7 Nov 2001 1 (30 pts = 4 pts each part + 2 free points). For this question we use the following notation: x y means x is a prefix of y m k n means m n k For each of

More information

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism,

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism, CS 54, Lecture 2: Finite Automata, Closure Properties Nondeterminism, Why so Many Models? Streaming Algorithms 0 42 Deterministic Finite Automata Anatomy of Deterministic Finite Automata transition: for

More information

Review Sheet for the Final Exam of MATH Fall 2009

Review Sheet for the Final Exam of MATH Fall 2009 Review Sheet for the Final Exam of MATH 1600 - Fall 2009 All of Chapter 1. 1. Sets and Proofs Elements and subsets of a set. The notion of implication and the way you can use it to build a proof. Logical

More information

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 15-453 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY THURSDAY APRIL 3 REVIEW for Midterm TUESDAY April 8 Definition: A Turing Machine is a 7-tuple T = (Q, Σ, Γ, δ, q, q accept, q reject ), where: Q is a

More information

Deterministic Finite Automata. Non deterministic finite automata. Non-Deterministic Finite Automata (NFA) Non-Deterministic Finite Automata (NFA)

Deterministic Finite Automata. Non deterministic finite automata. Non-Deterministic Finite Automata (NFA) Non-Deterministic Finite Automata (NFA) Deterministic Finite Automata Non deterministic finite automata Automata we ve been dealing with have been deterministic For every state and every alphabet symbol there is exactly one move that the machine

More information

Proofs. Chapter 2 P P Q Q

Proofs. Chapter 2 P P Q Q Chapter Proofs In this chapter we develop three methods for proving a statement. To start let s suppose the statement is of the form P Q or if P, then Q. Direct: This method typically starts with P. Then,

More information

COMP1002 exam study sheet

COMP1002 exam study sheet COMP1002 exam study sheet Propositional statement: expression that has a truth value (true/false). It is a tautology if it is always true, contradiction if always false. Logic connectives: negation ( not

More information

Lecture 1: Logical Foundations

Lecture 1: Logical Foundations Lecture 1: Logical Foundations Zak Kincaid January 13, 2016 Logics have two components: syntax and semantics Syntax: defines the well-formed phrases of the language. given by a formal grammar. Typically

More information

REVIEW QUESTIONS. Chapter 1: Foundations: Sets, Logic, and Algorithms

REVIEW QUESTIONS. Chapter 1: Foundations: Sets, Logic, and Algorithms REVIEW QUESTIONS Chapter 1: Foundations: Sets, Logic, and Algorithms 1. Why can t a Venn diagram be used to prove a statement about sets? 2. Suppose S is a set with n elements. Explain why the power set

More information

Intelligent Agents. Pınar Yolum Utrecht University

Intelligent Agents. Pınar Yolum Utrecht University Intelligent Agents Pınar Yolum p.yolum@uu.nl Utrecht University Logical Agents (Based mostly on the course slides from http://aima.cs.berkeley.edu/) Outline Knowledge-based agents Wumpus world Logic in

More information

Halting and Equivalence of Program Schemes in Models of Arbitrary Theories

Halting and Equivalence of Program Schemes in Models of Arbitrary Theories Halting and Equivalence of Program Schemes in Models of Arbitrary Theories Dexter Kozen Cornell University, Ithaca, New York 14853-7501, USA, kozen@cs.cornell.edu, http://www.cs.cornell.edu/~kozen In Honor

More information

Regular Languages. Problem Characterize those Languages recognized by Finite Automata.

Regular Languages. Problem Characterize those Languages recognized by Finite Automata. Regular Expressions Regular Languages Fundamental Question -- Cardinality Alphabet = Σ is finite Strings = Σ is countable Languages = P(Σ ) is uncountable # Finite Automata is countable -- Q Σ +1 transition

More information

BBM402-Lecture 11: The Class NP

BBM402-Lecture 11: The Class NP BBM402-Lecture 11: The Class NP Lecturer: Lale Özkahya Resources for the presentation: http://ocw.mit.edu/courses/electrical-engineering-andcomputer-science/6-045j-automata-computability-andcomplexity-spring-2011/syllabus/

More information

Complexity Theory. Knowledge Representation and Reasoning. November 2, 2005

Complexity Theory. Knowledge Representation and Reasoning. November 2, 2005 Complexity Theory Knowledge Representation and Reasoning November 2, 2005 (Knowledge Representation and Reasoning) Complexity Theory November 2, 2005 1 / 22 Outline Motivation Reminder: Basic Notions Algorithms

More information

CP405 Theory of Computation

CP405 Theory of Computation CP405 Theory of Computation BB(3) q 0 q 1 q 2 0 q 1 1R q 2 0R q 2 1L 1 H1R q 1 1R q 0 1L Growing Fast BB(3) = 6 BB(4) = 13 BB(5) = 4098 BB(6) = 3.515 x 10 18267 (known) (known) (possible) (possible) Language:

More information

1.5 Non-linear Real Arithmetic

1.5 Non-linear Real Arithmetic A Simplex variant: Transform the satisfiability problem into the form A x = 0 l x u (where l i may be and u i may be + ). Relation to optimization problem is obscured. But: More efficient if one needs

More information

Chapter 2. Reductions and NP. 2.1 Reductions Continued The Satisfiability Problem (SAT) SAT 3SAT. CS 573: Algorithms, Fall 2013 August 29, 2013

Chapter 2. Reductions and NP. 2.1 Reductions Continued The Satisfiability Problem (SAT) SAT 3SAT. CS 573: Algorithms, Fall 2013 August 29, 2013 Chapter 2 Reductions and NP CS 573: Algorithms, Fall 2013 August 29, 2013 2.1 Reductions Continued 2.1.1 The Satisfiability Problem SAT 2.1.1.1 Propositional Formulas Definition 2.1.1. Consider a set of

More information

satisfiability (sat) Satisfiability unsatisfiability (unsat or sat complement) and validity Any Expression φ Can Be Converted into CNFs and DNFs

satisfiability (sat) Satisfiability unsatisfiability (unsat or sat complement) and validity Any Expression φ Can Be Converted into CNFs and DNFs Any Expression φ Can Be Converted into CNFs and DNFs φ = x j : This is trivially true. φ = φ 1 and a CNF is sought: Turn φ 1 into a DNF and apply de Morgan s laws to make a CNF for φ. φ = φ 1 and a DNF

More information

Mathematical Preliminaries. Sipser pages 1-28

Mathematical Preliminaries. Sipser pages 1-28 Mathematical Preliminaries Sipser pages 1-28 Mathematical Preliminaries This course is about the fundamental capabilities and limitations of computers. It has 3 parts 1. Automata Models of computation

More information

Introduction to Artificial Intelligence Propositional Logic & SAT Solving. UIUC CS 440 / ECE 448 Professor: Eyal Amir Spring Semester 2010

Introduction to Artificial Intelligence Propositional Logic & SAT Solving. UIUC CS 440 / ECE 448 Professor: Eyal Amir Spring Semester 2010 Introduction to Artificial Intelligence Propositional Logic & SAT Solving UIUC CS 440 / ECE 448 Professor: Eyal Amir Spring Semester 2010 Today Representation in Propositional Logic Semantics & Deduction

More information

Invariant Generation for P-solvable Loops with Assignments

Invariant Generation for P-solvable Loops with Assignments Invariant Generation for P-solvable Loops with Assignments Laura Kovács EPFL, Swizterland laura.kovacs@epfl.ch Abstract. We discuss interesting properties of a general technique for inferring polynomial

More information

Logical Agents. Chapter 7

Logical Agents. Chapter 7 Logical Agents Chapter 7 Outline Knowledge-based agents Wumpus world Logic in general - models and entailment Propositional (Boolean) logic Equivalence, validity, satisfiability Inference rules and theorem

More information

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata CISC 4090: Theory of Computation Chapter Regular Languages Xiaolan Zhang, adapted from slides by Prof. Werschulz Section.: Finite Automata Fordham University Department of Computer and Information Sciences

More information

Algebras with finite descriptions

Algebras with finite descriptions Algebras with finite descriptions André Nies The University of Auckland July 19, 2005 Part 1: FA-presentability A countable structure in a finite signature is finite-automaton presentable (or automatic)

More information

Turing Machines and Time Complexity

Turing Machines and Time Complexity Turing Machines and Time Complexity Turing Machines Turing Machines (Infinitely long) Tape of 1 s and 0 s Turing Machines (Infinitely long) Tape of 1 s and 0 s Able to read and write the tape, and move

More information