Loading Lion artifact…
Inspect Lion Program Source (JSON)
[
  "begin",
  [
    "relation",
    "ctrl",
    [
      "k",
      "v"
    ],
    {
      "key": [
        "k"
      ]
    }
  ],
  [
    "fact",
    [
      "ctrl",
      "inject_bug",
      false
    ],
    [
      "ctrl",
      "transfer_amt",
      500
    ],
    [
      "ctrl",
      "selected",
      "escrow_pool"
    ]
  ],
  [
    "define",
    "view",
    [
      "lambda",
      [],
      [
        "begin",
        [
          "define",
          "inject_bug",
          [
            "array/head",
            [
              "find",
              "?v",
              [
                "ctrl",
                [
                  "quote",
                  "inject_bug"
                ],
                "?v"
              ]
            ]
          ]
        ],
        [
          "define",
          "amt",
          [
            "array/head",
            [
              "find",
              "?v",
              [
                "ctrl",
                "transfer_amt",
                "?v"
              ]
            ]
          ]
        ],
        [
          "define",
          "sel",
          [
            "array/head",
            [
              "find",
              "?v",
              [
                "ctrl",
                "selected",
                "?v"
              ]
            ]
          ]
        ],
        [
          "define",
          "exact_third",
          [
            "number/divide",
            100,
            3
          ]
        ],
        [
          "define",
          "exact_sum_ok",
          [
            "=",
            [
              "number/add",
              [
                "number/add",
                "exact_third",
                "exact_third"
              ],
              "exact_third"
            ],
            100
          ]
        ],
        [
          "define",
          "cons_inv",
          [
            "proof/invariant",
            {
              "init": [
                "lambda",
                [
                  "s"
                ],
                [
                  "and",
                  [
                    "=",
                    [
                      "object/get",
                      "s",
                      "checking"
                    ],
                    1000
                  ],
                  [
                    "=",
                    [
                      "object/get",
                      "s",
                      "escrow"
                    ],
                    0
                  ],
                  [
                    "=",
                    [
                      "object/get",
                      "s",
                      "supply"
                    ],
                    1000
                  ]
                ]
              ],
              "invariant": [
                "lambda",
                [
                  "s"
                ],
                [
                  "=",
                  [
                    "number/add",
                    [
                      "object/get",
                      "s",
                      "checking"
                    ],
                    [
                      "object/get",
                      "s",
                      "escrow"
                    ]
                  ],
                  [
                    "object/get",
                    "s",
                    "supply"
                  ]
                ]
              ],
              "next": [
                "cond",
                [
                  "inject_bug",
                  [
                    "lambda",
                    [
                      "s",
                      "s2"
                    ],
                    [
                      "and",
                      [
                        "=",
                        [
                          "object/get",
                          "s2",
                          "checking"
                        ],
                        [
                          "number/add",
                          [
                            "object/get",
                            "s",
                            "checking"
                          ],
                          "amt"
                        ]
                      ],
                      [
                        "=",
                        [
                          "object/get",
                          "s2",
                          "escrow"
                        ],
                        [
                          "object/get",
                          "s",
                          "escrow"
                        ]
                      ],
                      [
                        "=",
                        [
                          "object/get",
                          "s2",
                          "supply"
                        ],
                        [
                          "object/get",
                          "s",
                          "supply"
                        ]
                      ]
                    ]
                  ]
                ],
                [
                  "else",
                  [
                    "lambda",
                    [
                      "s",
                      "s2"
                    ],
                    [
                      "or",
                      [
                        "and",
                        [
                          "=",
                          [
                            "object/get",
                            "s2",
                            "checking"
                          ],
                          [
                            "number/subtract",
                            [
                              "object/get",
                              "s",
                              "checking"
                            ],
                            "amt"
                          ]
                        ],
                        [
                          "=",
                          [
                            "object/get",
                            "s2",
                            "escrow"
                          ],
                          [
                            "number/add",
                            [
                              "object/get",
                              "s",
                              "escrow"
                            ],
                            "amt"
                          ]
                        ],
                        [
                          "=",
                          [
                            "object/get",
                            "s2",
                            "supply"
                          ],
                          [
                            "object/get",
                            "s",
                            "supply"
                          ]
                        ]
                      ],
                      [
                        "and",
                        [
                          "=",
                          [
                            "object/get",
                            "s2",
                            "checking"
                          ],
                          [
                            "number/add",
                            [
                              "object/get",
                              "s",
                              "checking"
                            ],
                            "amt"
                          ]
                        ],
                        [
                          "=",
                          [
                            "object/get",
                            "s2",
                            "escrow"
                          ],
                          [
                            "number/subtract",
                            [
                              "object/get",
                              "s",
                              "escrow"
                            ],
                            "amt"
                          ]
                        ],
                        [
                          "=",
                          [
                            "object/get",
                            "s2",
                            "supply"
                          ],
                          [
                            "object/get",
                            "s",
                            "supply"
                          ]
                        ]
                      ]
                    ]
                  ]
                ]
              ],
              "vars": {
                "checking": "value/integer?",
                "escrow": "value/integer?",
                "supply": "value/integer?"
              }
            }
          ]
        ],
        [
          "define",
          "array_frame",
          [
            "proof/smt",
            [
              "array/make",
              "and",
              [
                "quote",
                [
                  "forall",
                  [
                    "x"
                  ],
                  [
                    "implies",
                    [
                      ">=",
                      "x",
                      0
                    ],
                    [
                      ">=",
                      [
                        "bal",
                        "x"
                      ],
                      0
                    ]
                  ]
                ]
              ],
              [
                "quote",
                [
                  ">=",
                  "payer",
                  0
                ]
              ],
              [
                "quote",
                [
                  "!=",
                  "bystander",
                  "payer"
                ]
              ],
              [
                "array/make",
                "=",
                "ledger2",
                [
                  "array/make",
                  "store",
                  "ledger1",
                  "payer",
                  [
                    "array/make",
                    "+",
                    [
                      "quote",
                      [
                        "bal",
                        "payer"
                      ]
                    ],
                    "amt"
                  ]
                ]
              ],
              [
                "quote",
                [
                  "!=",
                  [
                    "select",
                    "ledger2",
                    "bystander"
                  ],
                  [
                    "select",
                    "ledger1",
                    "bystander"
                  ]
                ]
              ]
            ]
          ]
        ],
        [
          "define",
          "bmc_race",
          [
            "proof/bmc",
            {
              "bound": 2,
              "init": [
                "lambda",
                [
                  "s"
                ],
                [
                  "and",
                  [
                    "=",
                    [
                      "object/get",
                      "s",
                      "checking"
                    ],
                    1000
                  ],
                  [
                    "=",
                    [
                      "object/get",
                      "s",
                      "escrow"
                    ],
                    0
                  ],
                  [
                    "=",
                    [
                      "object/get",
                      "s",
                      "supply"
                    ],
                    1000
                  ]
                ]
              ],
              "next": [
                "lambda",
                [
                  "s",
                  "s2"
                ],
                [
                  "and",
                  [
                    "=",
                    [
                      "object/get",
                      "s2",
                      "checking"
                    ],
                    [
                      "number/add",
                      [
                        "object/get",
                        "s",
                        "checking"
                      ],
                      "amt"
                    ]
                  ],
                  [
                    "=",
                    [
                      "object/get",
                      "s2",
                      "escrow"
                    ],
                    [
                      "object/get",
                      "s",
                      "escrow"
                    ]
                  ],
                  [
                    "=",
                    [
                      "object/get",
                      "s2",
                      "supply"
                    ],
                    [
                      "object/get",
                      "s",
                      "supply"
                    ]
                  ]
                ]
              ],
              "property": [
                "lambda",
                [
                  "s"
                ],
                [
                  "=",
                  [
                    "number/add",
                    [
                      "object/get",
                      "s",
                      "checking"
                    ],
                    [
                      "object/get",
                      "s",
                      "escrow"
                    ]
                  ],
                  [
                    "object/get",
                    "s",
                    "supply"
                  ]
                ]
              ],
              "vars": {
                "checking": "value/integer?",
                "escrow": "value/integer?",
                "supply": "value/integer?"
              }
            }
          ]
        ],
        [
          "define",
          "cons_ok",
          [
            "object/get",
            "cons_inv",
            "proved"
          ]
        ],
        [
          "define",
          "nodes",
          [
            "array/make",
            {
              "group": "account",
              "id": "checking_acct",
              "label": "Customer Checking",
              "subtitle": "exact rational balance",
              "tone": "ok"
            },
            {
              "group": "pool",
              "id": "escrow_pool",
              "label": "Atomic Escrow Pool",
              "subtitle": "debit + credit paired",
              "tone": [
                "cond",
                [
                  "inject_bug",
                  "error"
                ],
                [
                  "else",
                  "accent"
                ]
              ]
            },
            {
              "group": "ledger",
              "id": "supply_inv",
              "label": "Total Supply Seal",
              "subtitle": "checking + escrow == supply",
              "tone": [
                "cond",
                [
                  "cons_ok",
                  "ok"
                ],
                [
                  "else",
                  "error"
                ]
              ]
            },
            {
              "group": "audit",
              "id": "bystander_acct",
              "label": "All Other Accounts",
              "subtitle": "frame isolation (QF_AUFLIA)",
              "tone": "ok"
            }
          ]
        ],
        [
          "define",
          "edges",
          [
            "array/make",
            {
              "from": "checking_acct",
              "label": [
                "string/join",
                [
                  "array/make",
                  "hold $",
                  [
                    "number/toString",
                    "amt"
                  ]
                ],
                ""
              ],
              "to": "escrow_pool",
              "tone": "ok"
            },
            {
              "from": "escrow_pool",
              "label": [
                "cond",
                [
                  "inject_bug",
                  "PHANTOM CREDIT (BUG)"
                ],
                [
                  "else",
                  "conserves total"
                ]
              ],
              "to": "supply_inv",
              "tone": [
                "cond",
                [
                  "inject_bug",
                  "error"
                ],
                [
                  "else",
                  "ok"
                ]
              ]
            },
            {
              "from": "supply_inv",
              "label": "untouched (select/store)",
              "to": "bystander_acct",
              "tone": "ok"
            }
          ]
        ],
        [
          "ui/stack",
          {
            "gap": "lg"
          },
          [
            "ui/hero",
            {
              "badges": [
                "quote",
                [
                  {
                    "label": "Unbounded Induction",
                    "tone": "ok"
                  },
                  {
                    "label": "Exact Rationals (0 Cent Drift)",
                    "tone": "ok"
                  },
                  {
                    "label": "QF_AUFLIA Array Frame",
                    "tone": "accent"
                  }
                ]
              ],
              "eyebrow": "Lion-Only Proof 03 · Fintech & Treasury Integrity",
              "subtitle": "Prove double-entry money conservation across infinite transfers and refunds with zero floating-point drift. Inject a realistic double-credit race condition below to watch Lion synthesize the exact phantom-money exploit trace.",
              "title": "Treasury & Double-Entry Conservation Verifier"
            }
          ],
          [
            "ui/grid",
            {
              "cols": 4,
              "gap": "md"
            },
            [
              "ui/metric",
              {
                "caption": "Proven over 0 -> infinity transactions",
                "label": "Conservation Theorem",
                "tone": [
                  "cond",
                  [
                    "cons_ok",
                    "ok"
                  ],
                  [
                    "else",
                    "error"
                  ]
                ],
                "value": [
                  "cond",
                  [
                    "cons_ok",
                    "PROVED"
                  ],
                  [
                    "else",
                    "REFUTED"
                  ]
                ]
              }
            ],
            [
              "ui/metric",
              {
                "caption": "($100 / 3) * 3 == $100 exactly (no float drift)",
                "label": "Exact Rational Split",
                "tone": "ok",
                "value": [
                  "cond",
                  [
                    "exact_sum_ok",
                    "0.00¢ Drift"
                  ],
                  [
                    "else",
                    "Drift"
                  ]
                ]
              }
            ],
            [
              "ui/metric",
              {
                "caption": "McCarthy array axiom: bystander accounts untouched",
                "label": "Account Isolation",
                "tone": "ok",
                "value": [
                  "cond",
                  [
                    [
                      "proof/valid?",
                      [
                        "object/get",
                        "array_frame",
                        "proof"
                      ]
                    ],
                    "Verified"
                  ],
                  [
                    "else",
                    "Failed"
                  ]
                ]
              }
            ],
            [
              "ui/metric",
              {
                "caption": [
                  "cond",
                  [
                    "inject_bug",
                    "Phantom money minted per buggy refund"
                  ],
                  [
                    "else",
                    "Zero unbacked money possible"
                  ]
                ],
                "label": "Phantom Mint Risk",
                "tone": [
                  "cond",
                  [
                    "inject_bug",
                    "error"
                  ],
                  [
                    "else",
                    "ok"
                  ]
                ],
                "value": [
                  "cond",
                  [
                    "inject_bug",
                    [
                      "string/join",
                      [
                        "array/make",
                        "+$",
                        [
                          "number/toString",
                          "amt"
                        ],
                        "/tx"
                      ],
                      ""
                    ]
                  ],
                  [
                    "else",
                    "$0"
                  ]
                ]
              }
            ]
          ],
          [
            "ui/section",
            {
              "badge": [
                "cond",
                [
                  "inject_bug",
                  "Double-Credit Bug Injected"
                ],
                [
                  "else",
                  "Double-Entry Verified"
                ]
              ],
              "step": "01",
              "subtitle": "Toggle the bug injection switch to simulate a classic refund race condition that credits checking without debiting escrow, and adjust the transfer size.",
              "title": "Interactive Transfer & Fault Injection",
              "tone": [
                "cond",
                [
                  "inject_bug",
                  "error"
                ],
                [
                  "else",
                  "ok"
                ]
              ]
            },
            [
              "ui/card",
              [
                "ui/grid",
                {
                  "cols": 2,
                  "gap": "md"
                },
                [
                  "ui/toggle",
                  {
                    "checked": "inject_bug",
                    "label": "Inject Fault: Refund credits Checking without debiting Escrow (breaks conservation)",
                    "onChange": [
                      "quote",
                      [
                        "fact",
                        [
                          "ctrl",
                          "inject_bug",
                          "value"
                        ]
                      ]
                    ]
                  }
                ],
                [
                  "ui/slider",
                  {
                    "label": "Settlement Transfer Amount ($)",
                    "max": 2000,
                    "min": 100,
                    "onChange": [
                      "quote",
                      [
                        "fact",
                        [
                          "ctrl",
                          "transfer_amt",
                          "value"
                        ]
                      ]
                    ],
                    "step": 100,
                    "value": "amt"
                  }
                ]
              ]
            ],
            [
              "cond",
              [
                "inject_bug",
                [
                  "ui/alert",
                  {
                    "title": "Conservation Broken: Phantom Money Created at Depth 1",
                    "tone": "error"
                  },
                  "Lion's inductive prover immediately rejected the buggy transition, and proof/bmc synthesized the concrete counterexample trace below showing checking + escrow exceeding total supply."
                ]
              ]
            ],
            [
              "ui/graph",
              {
                "edges": "edges",
                "height": 220,
                "layout": "layered",
                "nodes": "nodes",
                "onSelect": [
                  "quote",
                  [
                    "fact",
                    [
                      "ctrl",
                      "selected",
                      "value"
                    ]
                  ]
                ],
                "selected": "sel",
                "title": "Ledger Conservation & Frame Isolation Topology"
              }
            ]
          ],
          [
            "ui/section",
            {
              "step": "02",
              "subtitle": "Three distinct formal solvers — unbounded inductive invariants, McCarthy Theory of Arrays + forall E-matching, and bounded model checking — verified by proof/valid?.",
              "title": "Kernel-Verified Financial Proofs"
            },
            [
              "ui/grid",
              {
                "cols": 3,
                "gap": "md"
              },
              [
                "ui/proof",
                {
                  "summary": [
                    "cond",
                    [
                      "cons_ok",
                      "Proves checking + escrow == supply holds after ANY unbounded sequence of holds and refunds."
                    ],
                    [
                      "else",
                      "Refuted: buggy refund transition fails consecution and violates total supply conservation."
                    ]
                  ],
                  "title": "Unbounded Conservation (proof/invariant)",
                  "valid": [
                    "cond",
                    [
                      "cons_ok",
                      [
                        "proof/valid?",
                        [
                          "object/get",
                          "cons_inv",
                          "proof"
                        ]
                      ]
                    ],
                    [
                      "else",
                      false
                    ]
                  ]
                },
                "cons_inv"
              ],
              [
                "ui/proof",
                {
                  "summary": "Proves updating payer in the ledger array leaves every distinct account (bystander != payer) bit-for-bit unchanged.",
                  "title": "Account Frame Isolation (proof/smt)",
                  "valid": [
                    "proof/valid?",
                    [
                      "object/get",
                      "array_frame",
                      "proof"
                    ]
                  ]
                },
                "array_frame"
              ],
              [
                "ui/proof",
                {
                  "summary": "Symbolic BMC unrolling of the buggy refund race condition — synthesizes the exact 2-state phantom-money exploit.",
                  "title": "Phantom Credit Counterexample (proof/bmc)",
                  "valid": false
                },
                "bmc_race"
              ]
            ]
          ]
        ]
      ]
    ],
    {
      "persist": true
    }
  ],
  [
    "view"
  ]
]