Presentation is loading. Please wait.

Presentation is loading. Please wait.

Catriel Beeri Pls/Winter 2004/5 inductive-revisited 1 Inductive definitions revisited  Generated and Freely generated sets oPattern match, unification.

Similar presentations


Presentation on theme: "Catriel Beeri Pls/Winter 2004/5 inductive-revisited 1 Inductive definitions revisited  Generated and Freely generated sets oPattern match, unification."— Presentation transcript:

1 Catriel Beeri Pls/Winter 2004/5 inductive-revisited 1 Inductive definitions revisited  Generated and Freely generated sets oPattern match, unification oSyntax-directed definitions (of semantics,..)

2 Catriel Beeri Pls/Winter 2004/5 inductive-revisited 2 Generated set: Least set that includes certain constants closed under certain operations (may require elements of some given sets) Examples: NN generated from 0, succ, N generated from 0, 1, addition Int list generated from integers, [], ::  Generated & freely generated sets

3 Catriel Beeri Pls/Winter 2004/5 inductive-revisited 3 Each element has expression tree Leaves labeled by constants/ elements of given sets Internal nodes labeled by operations Can be formulated as inductive definition expression tree isomorphic to proof tree Freely generated: each element has unique tree Example: N generated from 0, succ

4 Catriel Beeri Pls/Winter 2004/5 inductive-revisited 4 Every domain of labeled trees is freely generated A label ~ an operation to construct trees --- a constructor Examples: all data types of OCAML abstract syntax trees

5 Catriel Beeri Pls/Winter 2004/5 inductive-revisited 5 Properties of freely generated domains: inductively defined functions are always well- defined (explains their use in functional pl’s) Membership is decidable Pattern: expression p that has constants and variables as leaves, constructors as internal nodes Pattern match: given expression E, pattern p, is there a variable assignment that maps p to E Has a simple algorithm (Result is the satisfying assignment, or FAIL)

6 Catriel Beeri Pls/Winter 2004/5 inductive-revisited 6 Unification: (a generalization of pattern matching) Given two patterns, is there a variable assignment that makes them equal? (and, is there a best one?) Used in theorem provers, logic programming (prolog), and in type inference (ML) Has an (almost) linear time algorithm

7 Catriel Beeri Pls/Winter 2004/5 inductive-revisited 7 Of interest to us: Goal resolution for semantics relations inductively defined over abstract syntax (a freely generated set) The semantics is syntax-directed The rules are organized by syntax classes Allows to select for each expression candidate applicable rules (pattern match) Conditions in the rules allow to select a unique new goal for recursive calls – no backtracking The goals in premises of a rule are sub-expressions of the goal in the rule’s head –Each recursive call of next, natEval has a smaller argument  termination is guaranteed where do we use here the free generation?


Download ppt "Catriel Beeri Pls/Winter 2004/5 inductive-revisited 1 Inductive definitions revisited  Generated and Freely generated sets oPattern match, unification."

Similar presentations


Ads by Google