Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Generative Story Worlds as Linear Logic Programs

Chris
June 27, 2014

Generative Story Worlds as Linear Logic Programs

Talk for the paper of the same title, available here: http://www.cs.cmu.edu/~cmartens/int7.pdf

Presented at (INT)7 (Intelligent Narrative Technologies) in Milwaukee on June 18, 2014.

Chris

June 27, 2014
Tweet

More Decks by Chris

Other Decks in Programming

Transcript

  1. Generative Story Worlds
    as
    Linear Logic Programs
    Chris Martens, João Ferreira,
    Anne-Gwenn Bosser, and Marc Cavazza
    1
    Presented at Interactive Narrative Technologies
    June 18, 2014

    View Slide

  2. Generative Story Worlds
    as
    Linear Logic Programs
    Chris Martens, João Ferreira,
    Anne-Gwenn Bosser, and Marc Cavazza
    2
    Presented at Interactive Narrative Technologies
    June 18, 2014

    View Slide

  3. 3
    new programming languages
    for digital narratives
    Praxis & Prompter:

    View Slide

  4. 4
    OLD programming languages
    for digital narratives(?)
    LOGIC

    View Slide

  5. 5
    old programming languages
    for digital narratives
    LINEAR LOGIC

    View Slide

  6. 6
    used linear logic as a programming language (Celf)
    for specifying narrative worlds;
    used proof search to generate structured stories.
    What we did:

    View Slide

  7. THREE ACTS
    7
    I. Setup: agent simulation, linear logic, and
    logic programming
    II. Payoff: Stories as Proofs
    III. Promise and Limitations

    View Slide

  8. 8

    View Slide

  9. 9
    greet
    insult
    compliment
    gossip
    flirt
    ...
    social verbs: social state:
    knowledge
    sentiment
    emotional state
    personality
    belief

    View Slide

  10. 10
    verbs: rules
    causal relationships: resource dependencies

    View Slide

  11. RULES
    11
    Narrative Actions
    ~
    Logical implication

    View Slide

  12. 12
    the problem with standard logical implication:
    buy_soda :
    has(Alice, $1) ^ wants(Alice, soda) 㱺
    has(Alice, soda)

    View Slide

  13. LINEAR LOGIC
    13
    A -o B

    View Slide

  14. 14
    buy_soda :
    has(Alice, $1) * wants(Alice, soda) -o
    has(Alice, soda)

    View Slide

  15. 15
    A * B
    A -o B
    !A

    View Slide

  16. 16
    A * B
    A -o {B}
    !A

    View Slide

  17. Logic Programming
    17
    proof search as program execution

    View Slide

  18. 18
    initial
    state
    Σ Δ0
    Celf
    query
    (optional)
    A
    Δ0, …, Δ
    Δ ⊢ A?
    narrative
    actions

    View Slide

  19. Logic Programming
    19
    A -o {B}
    Δ, A → Δ, B
    Δ = arbitrary context of resources A1, …, An

    View Slide

  20. 20
    Example in our paper:
    Shakespearean tragedy world

    View Slide

  21. 21
    Shakespearean tragedy world
    state components:
    character location, possession,
    sentiment toward other characters,
    goals

    View Slide

  22. 22
    Shakespearean tragedy world
    at
    has
    anger
    philia
    depressed

    View Slide

  23. 23
    Shakespearean tragedy world
    !dead
    !killed

    View Slide

  24. 24
    do/insult :
    at C L * at C’ L * anger C C’
    -o {at C L * at C’ L * anger C C’
    anger C’ C * depressed C’}.

    View Slide

  25. 25
    do/compliment :
    at C L * at C’ L * philia C C’
    -o {at C L * at C’ L *
    philia C C’ * philia C’ C}.

    View Slide

  26. 26
    do/murder :
    anger C C’ * anger C C’ * anger C C’ *
    anger C C’ * at C L * at C’ L *
    has C weapon
    -o {at C L * !dead C’ * !murdered C C’ *
    has C weapon}.

    View Slide

  27. 27
    do/mourn :
    at C L * philia C C’ * dead C’
    -o {philia C C’ * at C L *
    depressed C * depressed C}.

    View Slide

  28. 28
    do/becomeSuicidal :
    at C L * depressed C * depressed C *
    depressed C * depressed C
    -o {at C L * suicidal C *
    wants C weapon}.

    View Slide

  29. 29
    do/loot
    : at C L * dead C' * has C' O * wants C O
    -o {at C L * has C O}.

    View Slide

  30. 30
    do/comfort :
    at C L * at C' L *
    suicidal C' * philia C C' * philia C' C
    -o {at C L * at C' L *
    philia C C' * philia C' C *
    philia C' C}.

    View Slide

  31. 31
    initial state

    View Slide

  32. 32
    story_start :
    init -o
    { at romeo town * at montague mon_house *
    at capulet cap_house * at mercutio town *
    at nurse cap_house * at juliet town *
    at tybalt town * at apothecary town *
    has tybalt weapon * has romeo weapon *
    has apothecary weapon *
    ...

    View Slide

  33. 33
    ... *
    anger montague capulet * anger capulet montague *
    anger tybalt romeo * anger capulet romeo *
    anger montague tybalt *
    philia mercutio romeo * philia romeo mercutio *
    philia montague romeo * philia capulet juliet *
    philia juliet nurse * philia nurse juliet *
    neutral nurse romeo * neutral mercutio juliet *
    neutral juliet mercutio *
    neutral apothecary nurse *
    neutral nurse apothecary}.

    View Slide

  34. 34
    final state

    View Slide

  35. 35
    ending_happy : nonfinal *
    actor C * actor C’ *
    at C L * at C’ L * married C C’ -o {final}.
    ending_vengeance : nonfinal *
    actor C1 * actor C2 * actor C3 *
    killed C1 C2 * philia C3 C2 * killed C3 C1
    -o {final}.

    View Slide

  36. 36
    proofs as stories

    View Slide

  37. 37
    query:
    init -o {final}

    View Slide

  38. Nondeterminism
    38
    A -o {B}
    Δ, B
    A -o {C}
    Δ, C
    Δ, A

    View Slide

  39. Nondeterminism
    39
    A -o {B} C -o {D}

    View Slide

  40. Nondeterminism
    40
    A -o {B}
    Δ, B, C
    C -o {D}
    Δ, A, D
    Δ, A, C

    View Slide

  41. Nondeterminism
    41
    A -o {B}
    Δ, B, C
    C -o {D}
    Δ, A, D
    Δ, A, C
    Δ, B, D

    View Slide

  42. 42
    proof of
    init -o {final}:
    function (x:init) =
    let [xs] = r [ys] in …

    View Slide

  43. 43
    ...
    let {[X73, [X74, [X75, [X76, X77]]]]}
    = do/insult/private [a-tybalt, [a-romeo, [X68, [X66, X72]]]] in
    let {[X85, [X86, X87]]}
    = do/becomeSuicidal [a-romeo, [X79, [X41, [X59, [X52, X77]]]]] in
    let {[X88, [X89, [X90, [X91, X92]]]]}
    = do/comfort [a-mercutio, [a-romeo, [X78, [X85, [X86, [X81, X83]]]]]] in
    let {[X101, [!X102, [!X103, X104]]]}
    = do/murder [a-romeo, [a-tybalt, [X58, [X40, [X76, [X51, [X94, [X96, X27]]]]]]]] in
    let {[X105, [X106, [X107, X108]]]}
    = do/compliment/private [a-nurse, [a-juliet, [X46, [X47, X30]]]] in
    let {[X109, [X110, [X111, X112]]]}
    = do/compliment/private [a-juliet, [a-nurse, [X106, [X105, X108]]]] in
    let {[X113, X114]}
    = do/loot [a-romeo, [a-tybalt, [X101, [X102, [X26, X87]]]]] in
    ...

    View Slide

  44. Concurrent Equality
    44
    r1: A -o B r2: C -o D
    “apply r1; apply r2” ~= “apply r2; apply r1”
    if A and C are disjoint

    View Slide

  45. 45
    graphical representation of traces

    View Slide

  46. 46
    init
    do/insult/private
    do/formOpinion/dislike
    do/compliment/witnessed
    do/travelTo
    do/compliment/private
    do/murder
    do/marry
    ending_1
    do/steal
    do/thinkVengefully
    do/mourn
    do/becomeSuicidal
    cleanup/1
    do/eroticize
    do/suicide
    do/flirt/discrete

    View Slide

  47. 47
    do/insult/private
    do/formOpinion/dislike
    do/compliment/witnessed
    do/travelTo
    private
    do/murder
    do/marry
    do/steal
    do/thinkVengefully
    do/mourn
    do/becomeSuicidal
    do/suicide
    ete

    View Slide

  48. 48
    queries on sets of traces

    View Slide

  49. 49
    > exists ending_1
    > exists do/thinkVengefully &&
    ̃link do/thinkVengefully do/murder

    View Slide

  50. generative exploration
    informative structure
    character perspective-agnosticism
    50
    what does this accomplish?

    View Slide

  51. 51
    how do simulation designs fail their authors?

    View Slide

  52. 52
    orphan verbs
    vs causally connected chains

    View Slide

  53. ACT III
    Potential & Limitations
    53

    View Slide

  54. 54
    combining reactive/exploratory
    + goal-driven behavior:
    A -o G vs A -o {B}
    (backward & forward chaining)
    Additional potential of LL

    View Slide

  55. 55
    higher-order rules: (A -o B) -o C
    Additional potential of LL

    View Slide

  56. 56
    higher-order rules: (A -o B) -o C
    “serendipity:”
    Forall L.
    at romeo L * at juliet L
    -o
    {eros romeo juliet
    * at romeo L * at juliet L})
    Additional potential of LL

    View Slide

  57. 57
    Additional potential of LL
    dynamic object generation: Exists x:A. ...
    makeRoom : has(C, magic door) * at C R -o
    {Exists r:room. !adjacent R r}

    View Slide

  58. 58
    limitations

    View Slide

  59. 59
    limitations
    (of the tool)
    (of the underlying formalism)

    View Slide

  60. 60
    limitations of the tool:
    interactivity
    history tracking
    debugging facilities
    drama management

    View Slide

  61. 61
    limitations of the formalism:
    ability to broadcast actions
    nondeterminism and control over probabilities

    View Slide

  62. 62
    what I plan to address:
    interactivity
    debugging facilities
    ability to “broadcast” actions

    View Slide

  63. 63
    PHASES

    View Slide

  64. Phases (Example)
    64
    deduplication
    phase act {

    } quiesced act -o {phase dedup}.
    phase dedup {
    wants C O * wants C O -o {wants C O}.
    } quiesced dedup -o {phase act}.

    View Slide

  65. Phases
    phase p1 = {...}
    phase p2 = {...}
    quiesced p1 -o
    {some_token * phase p2}.
    quiesced p2 -o {phase p1}.
    Blocks connected by specification of quiescence behavior
    65

    View Slide

  66. Phases (Example)
    interactivity
    phase world = {
    rule1 : do Action * … -o {…}.
    rule2 : do Action * … -o {…}.
    }
    phase player = {
    get_input : player_turn -o {read #STDIN}.
    }
    66

    View Slide

  67. 67
    also possible to implement: broadcast

    View Slide

  68. 68
    also ongoing:
    phase invariants
    for each phase, constraints on the context…
    - as an invariant of the phase
    - at quiescence
    programmer-specified, machine-checked!

    View Slide

  69. FINALE
    69

    View Slide

  70. 70
    the point of formalism
    is to be able to run
    readable specifications

    View Slide

  71. 71
    the point of formalism
    is to be able to reason about
    readable specifications

    View Slide

  72. 72

    View Slide

  73. 73

    View Slide

  74. 74
    linear logic can be used as a programming language
    for specifying narrative worlds;
    to generate narratives
    & analyze their structure;
    potentially the basis for a richer PL.
    Takeaway

    View Slide

  75. FINALE
    75
    Celf: https://github.com/clf/celf
    Example from the paper:
    http://tinyurl.com/int2014-clf
    Me: Chris Martens
    @chrisamaphone
    [email protected]
    Planning to graduate Summer 2015

    View Slide

  76. MINUS WORLD
    (bonus slides)
    76

    View Slide

  77. Cut
    77
    Δ1 ⊢ A Δ 2, A ⊢ C
    Δ 1, Δ 2 ⊢ C

    View Slide

  78. Frame Property
    78
    If Δ1 ⊢ A
    then
    Δ1, Δ2 ⊢ A * ⨂Δ2

    View Slide

  79. Frame Property (alt)
    79
    If Δ1 → Δ2
    then
    Δ1, Δ’ → Δ2, Δ’

    View Slide

  80. Relationship between step and
    deductions
    80
    Δ1 → Δ2
    iff for all C
    Δ2 ⊢ C implies Δ1 ⊢ C

    View Slide

  81. 81
    LOGICS
    are formalisms with
    composable consequences

    View Slide

  82. 82
    LOGICS
    are formalisms with
    composable consequences
    Δ ⊢ A Δ’, A ⊢ C
    Δ’, Δ ⊢ C

    View Slide

  83. Phases (Example)
    Broadcast
    phase act {
    do C A * in_room C R -o {broadcast C A R}.
    }
    quiesced act -o {phase broadcast}.
    phase broadcast {
    broadcast C A R * in_room C' R -o
    {notice C' C A * broadcast C A R}.
    }
    quiesced broadcast -o {phase notice}.
    83

    View Slide

  84. Phases (Example)
    Broadcast
    84
    phase notice {
    broadcast C A R * notice C' C A -o
    {react C' C A * in_room C' R * broadcast C A R}.
    }
    quiesced notice * broadcast _ _ _ -o {phase react}.
    phase react {
    react C C' (murder ...) * philia C C' -o {...}
    }
    quiesced react -o {phase act}.

    View Slide

  85. Phases
    delimited subsignatures connected by
    specifications of quiescence behavior.
    85
    quiesced P * State -o {phase P’ * State’}.
    arbitrarily many phases
    looping + branching

    View Slide