430 likes | 692 Views
Semântica de Ações. Ações Básicas, Ações Funcionais e Notação de Dados. Notação de Ações Básica. ações básicas são usadas para especificar fluxo de controle ações básicas não estão relacionadas com nenhuma espécie de informação corrente
E N D
Semântica de Ações Ações Básicas, Ações Funcionais e Notação de Dados
Notação de Ações Básica • ações básicas são usadas para especificar fluxo de controle • ações básicas não estão relacionadas com nenhuma espécie de informação corrente • a execução de uma ação consiste de passos atômicos de execução, feitos por um ou mais agentes • consideraremos um único agente
Ações Básicas • ações primitivas • complete : action . • escape : action . • fail : action . • diverge : action . • commit : action . • unfold : action .
Ações Básicas (cont.) • combinadores de ações • unfolding _ :: action -> action . • _ or _ :: action, action -> action . • _ and _ :: action, action -> action . • _ and then _ :: action, action -> action .
Exemplos de Ações Básicas • complete • complete or fail • complete and then fail • unfolding (unfold or fail)
Semântica da Notação de Ações • Regras de Inferência (Semântica Natural) • antecedente1 antecedente2 ... antecedenten consequente • Ações • t, b, s |- a > o, t’, b’, s’ • Produtores • t, b, s |- y > d
t, b, s |- a1 > completed, t1, b1, s1t, b, s1 |- a2 > completed, t2, b2, s2 mergeable b1 b2 t, b, s|- a1and a2 > completed, t1 ^ t2, b1 + b2, s2 t, b, s |- a1 > o1, t1, b1, s1o1 <> completed t, b, s|- a1and a2 > o1, t1, b1, s1 t, b, s |- a1 > completed, t1, b1, s1t, b, s1 |- a2 > o2, t2, b2, s2 o2 <> completed t, b, s|- a1and a2 > o2, t2, b2, s2 Semântica das Ações Básicas t, b, s |- complete > completed, (), {}, s (COMPLETE) t, b, s |- fail > failed, (), {}, s (FAIL) (AND-1) (AND-2) (AND-3)
Comandos /NanoSpecimen/Abstract Syntax/Comandos grammar: (1) Comando = [[ Identificador := Expressão ]] | [[ while Expressão do Comando end ]] | [[ local Declaração in Comando end ]] | [[ Comando ; Comando ]] .
/NanoSpecimen/Semantic Functions/Comandos • introduces: execute _ . • execute _ :: Comando -> action . • (1) ... • (2) execute [[ whileE:Expressão doC:Comando]] = • unfolding • | | evaluate E • | then • | | | check (it is 1) and then execute C and then unfold • | | or • | | | check not (it is 1) .
(3) … (4) execute [[ C1:Comando ; C2:Comando]] = execute C1and then execute C2 .
Notação de Ações Funcional • ações • give _ :: yielder -> action . • regive : action . • choose _ :: yielder -> action . • check _ :: yielder -> action . • _ then _ :: action, action -> action . • produtores • given _ :: data -> yielder . • given _ # _ :: datum, positive-integer -> yielder . • it : yielder .
Exemplos de Ações Funcionais • give 5 • give sum(3,4) • choose a natural • (check true and then give 1) or (check not true and then give 0)
t, b, s |- a1 > completed, t1, b1, s1t1, b, s1 |- a2 > completed, t2, b2, s2 t, b, s|- a1then a2 > completed, t2, b1 + b2, s2 t, b, s |- a1 > completed, t1, b1, s1t1, b, s1 |- a2 > o2, t2, b2, s2 o2 <> completed t, b, s|- a1then a2 > o2, t2, b2, s2 Semântica das Ações Funcionais t, b, s |- y > d (GIVE) t, b, s|- givey > completed, (d), {}, s (THEN-1) t, b, s |- a1 > o1, t1, b1, s1o1 <> completed (THEN-2) t, b, s|- a1then a2 > o1, t1, b1, s1 (THEN-3)
/NanoSpecimen/Abstract Syntax/Expressões • grammar: • Expressão = Numeral-Inteiro • | Identificador • | [[ if Expressão then Expressão else Expressão ]] • | [[ Identificador ( Expressão ) ]] • | [[ Expressão Operador Expressão ]] • | [[ ( Expressão ) ]] . • Operador = + | - | * | / | = | < .
/NanoSpecimen/Semantic Functions/Expressões • introduces: avalie _ . • avalie _ :: Expressão -> action . • (1) avalie N:Numeral-Inteiro = give the valor-de N . • (2) avalie I:Identificador = • | give the integer bound to token-de I • or • | give the integer stored in the cell bound to token-de I . • (3) avalie [[ I:Identificador ( E:Expressão ) ]] = • | avalie E • then • | enact (application of the abstraction bound to token-de I • to the given integer) .
(4) avalie [[ifE1:Expressão thenE2:Expressão elseE3:Expressão ]] = | avalie E1 then | | (check it is true) and then avalie E2 | or | | (check not(it is true) and then avalie E3 . (5) avalie [[ E1:Expressão O:Operador E2:Expressão ]] = | avalie E1and avalie E2 then | apliqueOperador O . (6) avalie [[ (E:Expressão ) ]] = avalie E .
/NanoSpecimen/Semantic Functions/Operadores • introduces:aplicaOperador _ . • aplicaOperador _ :: Operador -> action . • (1) aplicaOperador “+” = • give sum(the given integer#1, the given integer#2) . • (2) aplicaOperador “-” = • give difference(the given integer#1, the given integer#2) . • (3) aplicaOperador “*” = • give product(the given integer#1, the given integer#2) . • (4) aplicaOperador “/” = • give quotient(the given integer#1, the given integer#2) .
(5) aplicaOperador “=“ = | check (the given integer#1 is the given integer#2) | and then give 1 or | check not(the given integer#1 is the given integer#2) | and then give 0 . (6) aplicaOperador “<“ = | check (the given integer#1 is less than the given integer#2) | and then give 1 or | check not(the given integer#1 is less than the given integer#2) | and then give 0 .
Notação de Dados General. Instant. Tuples. Truth-Values. Numbers. Characters. Lists. Strings. Syntax. Sets. Maps.
Tuplas Generics component = . Basics tuple > component. () : tuple. ( _ , _ ) :: tuple, tuple tuple (total, associative, unit is ()). _? :: tuple -> tuple . _ * :: tuple -> tuple . _ + :: tuple -> tuple . _ - :: tuple, natural -> tuple .
Tuplas (cont.) Specifics • count _ :: tuple -> natural (total). • _ is _ :: tuple, tuple -> truth-value (partial).
Booleanos (Truth-Values) Basics • truth-value = true | false (individual). Specifics • if _ then _ else_ :: truth-value, x, y -> x | y (linear) . • when _ then _ :: truth-value, x - > x (partial) . • there is _ :: x -> truth-value (total) . • not _ :: truth-value -> truth-value (total) . • both _ :: (truth-value,truth-value) -> truth-value . • either _ :: (truth-value,truth-value) -> truth-value .
Números Naturais • Basics • natural = 0 | positive-integer (disjoint). • 0 : natural. • successor _ :: natural -> positive-integer (total, injective). • Specifics • 1, 2, 3, 4, 5, 6, 7, 8, 9 : natural. • _0, _1, _2, _3, _4, _5, _6, _7, _8, _9 : natural-> natural (total). • sum _ :: natural* -> natural • (total, associative, commutative, unit is 0). • product _ :: natural* -> natural • (total, associative, commutative, unit is 1).
Números Inteiros Basics • integer = 0 | nonzero-integer (disjoint). • nonzero-integer = positive-integer | negative-integer (disjoint). • successor _ :: integer -> integer (total, injective). • predecessor _ :: integer -> integer (total, injective). Specifics • negation _ :: integer -> integer (total). • absolute _ :: integer -> integer (total). • difference _ :: (integer, integer) -> integer (total).
Caracteres Basics • character = o . • character of _ :: natural -> character (partial, injective) . • code _ :: character -> natural (total, injective) . Alphanumerics • character >= digit | letter (disjoint) . • digit = ‘0’ | ‘1’ | ... | ‘9’ (individual) . • letter = lowercase letter | uppercase letter (disjoint) . • lowercase _ :: character -> character (total). • uppercase _ :: character -> character (total).
Caracteres (cont.) ASCII • code _ :: character -> natural [max octal “177”] (total) . • character = graphic-character | control-character .
Listas Não-aninhadas • Generics • item = o. • Basics • flat-list = list of item*. • list of _ :: item* -> flat-list (total, injective). • Specifics • _ [_] :: flat-list, item -> flat-list. • items _ :: flat-list -> items* (total, injective). • head _ :: flat-list -> item (partial). • tail _ :: flat-list -> flat-list (partial). • empty-list : flat-list. • concatenation _ :: flat-list* -> flat-list (total, associative, unit is empty-list).
Listas Aninhadas • Generics • leaf = item | o . • Basics • list = list of tree* . • tree = leaf | list (disjoint) . • list of _ :: tree* -> list (total, injective) .
Listas Aninhadas (cont.) • Specifics • _ [ _ ] :: list, tree -> list . • branches _ :: list -> tree* (total, injective) . • leaves _ :: • head _ :: • tail _ :: • empty-list : list . • concatenation _ :: list* -> list (total, associative, unit is empty-list) .
Strings • Basics • character <= item. • string = flat-list [character]. • string of _ :: character* -> string (total, injective). • characters _ :: string -> character* (total, injective). • ““ : string. • _ ^ _ :: string, string -> string (total, associative, unit is ““). • Alphanumerics • lowercase _ :: string -> string (total). • uppercase _ :: string -> string (total). • decimal _ :: string of digit+ -> natural (total). • octal _ :: string of octal-digit+ -> natural (total). • octal-digit = ‘0’ | ‘1’ | ‘2’ | ‘3’ | ‘4’ | ‘5’ | ‘6’ | ‘7’.
Sintaxe (Árvores Sintáticas) • Basics • syntax-tree = character | list [syntax-tree] (disjoint) . • Specifics • [[ ]] : syntax-tree. • [[ _ ]] :: syntax-tree* -> syntax-tree (total) . • [[ _ _ ]] :: syntax-tree*, syntax-tree* -> syntax-tree (total) . • ... • <> : syntax-tree* . • < _ > : syntax-tree* -> syntax-tree (total) . • < _ _ > : syntax-tree*, syntax-tree* -> syntax-tree (total) . • ...
Conjuntos • Generics • nonset-element = o. • _ is _ :: nonset-element, nonset-element -> truth-value (total). • Basics • set = set of element*. • element = nonset-element | set (disjoint). • set of _ :: element* -> set (individual).
Conjuntos (cont.) Specifics • _ [ _ ] :: set, element -> set. • elements _ :: set -> element* (strict, linear). • empty-set : set. • _ [in _ ] :: element, set -> element (partial). • _ [not in _] :: element, set -> element (partial).
Mapeamentos • Generics • nonmap-range = o. • Basics • map = disjoint-union (map of element to range)*. • range = nonmap-range | map (disjoint). • map of _ to _ :: element, range -> map (total, injective). • empty-map : map. • disjoint-union _ :: map* -> map • (partial, associative, commutative, unit is empty-map) . • mapped-set _ :: map -> set (total) .
Mapeamentos (cont.) Specifics • _ [ _ to _ ] :: set, element -> set . • _ at _ :: map, element -> range (partial) . • overlay _ :: map* -> map (total, associative, idempotent, unit is empty-map) . • _ restricted to _ :: map, set -> map (total) . • _ omitting _ :: map, set -> map (total) .
Action Notation/Basic/Data includes: Data Notation/General . • datum <= component . • datum >= truth-value | rational | character | list | set | map | abstraction (disjoint) . • distinct-datum <= datum . • distinct-datum >= truth-value | rational | character | list [distinct-datum] | set [distinct-datum] | map [distinct-datum to distinct-datum] . includes: Data Notation/Instant/Distinction (distinct-datum for s). • data = datum* . • a _, an _, the _, of _, some _ :: data -> data (total) .
Algumas Inclusões entre Sortes de Dados Padrões tuple range component map element nonmap-range truth-value tree set nonset-element rational leaf syntax-tree list approximation integer nonzero-rational item flat-list character natural positive-rational nonzero-integer negative-rational control-character graphic-character string positive-integer negative-integer 0 digit letter
/NanoSpecimen/Abstract Syntax • needs: DataNotation/Characters/ASCII (letter, digit) • closed. • grammar: • Identificadores • Identificador = letter | Identificador letter | Identificador digit . • Literais • Numeral-Inteiro = digit | Numeral-Inteiro digit .
/NanoSpecimen/Semantic Functions/Identificadores • introduces:token-de _ . • token-de _ :: Identificador -> token . • (1) token-de I:Identificador = I . • /NanoSpecimen/Semantic Functions/Literais • introduces:valor-de _ . • valor-de _ :: Numeral-Inteiro -> integer . • (1) valor-de [[ 0 ]] = 0 . • ... • (10) valor-de [[ 9 ]] = 9 . • (11) valor-de [[ N D ]] = sum (product (valor-de N, 10), valor-de D) .
Resumo/Notação de Dados • A notação de tuplas inclui uma forma de expressões regulares. • Tuplas são usadas para prover operações com um número arbitrário de argumentos. • Vários sortes, como component, são deixados abertos para uma especialização quando necessária. • Caracteres podem ser especializados para qualquer conjunto de caracteres desejado, como ASCII, por exemplo.
Resumo/Notação de Dados • Listas, conjuntos e mapeamentos podem ser aninhados, enquanto tuplas podem ser só concatenadas. • Árvores sintáticas têm unicamente caracteres como ramos. Strings são listas planas de caracteres, por isso também árvores sintáticas.