Commit ca62044e by Florian Rabe

### no message

parent 6c2eedb4
 namespace http://cds.omdoc.org/examples /T Intuitionistic propositional logic with natural deduction rules and a few example proofs /T We start with the syntax of propositional logic. theory PL : http://cds.omdoc.org/urtheories?LF = # :types The Basic Concepts /T the type of propositions prop : type /T Given [F:prop], the type \$ded F\$ holds the proofs of \$F\$. ded : prop → type  # ded 1 prec 0## ⊦ 1 prec 0role Judgment ## Abbreviations /T The type \$contra\$ abbreviates the judgment of inconsistency. If we can give an element of the type, then every proposition has a proof. contra : type  = {a} ded a # ↯ # Constructors /T The constructors provide the expressions of the types above. true : prop and : prop → prop → prop  # 1 ∧ 2 prec 15 or : prop → prop → prop  # 1 ∨ 2 prec 15 impl : prop → prop → prop  # 1 ⇒ 2 prec 10 not : prop → prop  # ¬ 1 prec 20 /T Equivalence is taken as a non-primitive here and defined such that for [F:prop,G:prop] we define \$F⇔G\$ as \$(F ⇒ G) ∧ (G ⇒ F)\$. equiv : prop → prop → prop  # 1 ⇔ 2 prec 10 = [x,y] (x ⇒ y) ∧ (y ⇒ x) /T Now we describe the proof theory. theory PLNatDed : http://cds.omdoc.org/urtheories?LF = include ?PL /T We use natural deduction proof rules that construct expressions of type \$ded F\$ for some [F:prop]. {For example, assume two propositions [F: prop, G: prop]. {If [p:ded F, q: ded G], then \$andI p q\$ is a proof of \$F∧G\$.} {If [p:ded F∧G], then \$andEl p\$ is a proof of \$F\$.} } trueI : ded true andI : {A,B} ded A → ded B → ded A ∧ B andEl : {A,B} ded A ∧ B → ded A  role ForwardRule andEr : {A,B} ded A ∧ B → ded B  role ForwardRule orIl : {A,B} ded A → ded A ∨ B orIr : {A,B} ded B → ded A ∨ B orE : {A,B,C} ded A ∨ B → (ded A → ded C) → (ded B → ded C) → ded C impI : {A,B} (ded A → ded B) → ded A ⇒ B impE : {A,B} ded A ⇒ B → ded A → ded B  role ForwardRule notI : {A} (ded A → ↯) → ded ¬ A# notI 2 notE : {A} ded ¬ A → ded A → ↯ # notE 2 3 role ForwardRule equivI : {A,B} (ded A → ded B) → (ded B → ded A) → ded A ⇔ B = [A,B,p,q] andI (impI [x] p x) (impI [x] q x) equivEl : {A,B} ded A ⇔ B → ded A → ded B  role ForwardRule = [A,B,p,a] impE (andEl p) a equivEr : {A,B} ded A ⇔ B → ded B → ded A  role ForwardRule = [A,B,p,b] impE (andEr p) b imp2I : {A,B,C} (ded A → (ded B → ded C)) → ded A ⇒ (B ⇒ C) = [A,B,C] [f] impI [p] (impI ([q] f p q)) imp2E : {A,B,C} ded A ⇒ (B ⇒ C) → ded A → ded B → ded C = [A,B,C] [p,q,r] impE (impE p q) r example : {A} ded A ⇒ (A ∧ A) = [A]impI [p]andI p p interactive_example : {A} ded A ⇒ (A ∧ A) = ≪{A} ded A⇒A∧A≫ \ No newline at end of file
 namespace http://cds.omdoc.org/examples theory ProverTest : http://cds.omdoc.org/urtheories?LF = a: type b: type c: type d: type k: a r: a → b role ForwardRule s: a → b → c role ForwardRule t: a → b → c → d q: d → d test : a → a → d  = [x,y] ≪d ≫ theory PLProofs : http://cds.omdoc.org/urtheories?LF = include ?PLNatDed /T this doesn't work currently // test : {a,b} ded (a ∧ b) ⇒ (b ∧ a) = _ // test2 : {a,b} ded (a ∨ b) ⇒ (b ∨ a) = _ theory FOLProofs : http://cds.omdoc.org/urtheories?LF = include ?FOLNatDed // test : {f} ded (forall [x] forall [y] f x y) ⇒ (forall [y] forall [x] f x y) = _ // test2 : {f} ded (exists [x] exists [y] f x y) ⇒ (exists [y] exists [x] f x y) = _
 namespace http://cds.omdoc.org/examples/programs import rules scala://mmt.kwarc.info theory Machine : http://cds.omdoc.org/urtheories?LF = obj: type loc: type command: type add: obj → loc → command get: loc → obj → command update: loc → obj → command delete: loc → obj → command chan: type stdio: chan in : chan → obj → command out: chan → obj → command execute: command → type
 namespace http://cds.omdoc.org/examples/programs theory Syntax : http://cds.omdoc.org/urtheories?LF = tp: type Bool: tp Nat : tp Unit: tp prog: tp → type true : prog Bool false: prog Bool unit : prog Unit zero : prog Nat succ : prog Nat → prog Nat# succ 1 one : prog Nat = succ zero equal : {a} prog a → prog a → prog Bool  # 2 = 3 prec 10 not : prog Bool → prog Bool  # ¬ 1 prec 8 plus : prog Nat → prog Nat → prog Nat  # 1 + 2 prec 20 minus : prog Nat → prog Nat → prog Nat  # 1 - 2 prec 20 seq : {a,b} prog a → prog b → prog b  # 3 ; 4 prec 5 ifte : {a} prog Bool → prog a → prog a → prog a # if 2 then 3 else 4 prec 3 ifte2 : prog Bool → prog Unit → prog Unit = [b,c] if b then c else unit while : prog Bool → prog Unit → prog Unit print : {a} prog a → prog Unit # print 2 read : {a} prog a val : {a,b} prog a → (prog a → prog b) → prog b # val 3 4 Var : tp → type var : {a,b} prog a → (Var a → prog b) → prog b # var 3 4 varref : {a} Var a → prog a # 2 ' prec 30 assign : {a} Var a → prog a → prog Unit # 2 ← 3 prec 10 theory Test : ?Syntax = main = val (read Nat) [x] var zero [y] while (¬ x = y') ( print x; y ← succ y' ) theory Machine : http://cds.omdoc.org/urtheories?LF = obj: type loc: type command: type add: obj → loc → command get: loc → obj → command update: loc → obj → command delete: loc → obj → command chan: type stdio: chan in : chan → obj → command out: chan → obj → command execute: command → type theory OperationalSemantics : http://cds.omdoc.org/urtheories?LF = include ?Syntax include ?Machine objectify : {a} prog a → obj  # objectify 2 varloc: {a} Var a → loc → type # 2 @ 3 eval : {a} prog a → prog a → type # 2 ⟿ 3 prec 3 eval_seq: {a,b, p:prog a, q: prog b, x,y} p⟿x → q⟿y → p;q ⟿ y eval_if_true : {a, c, t,e: prog a, x} c⟿true → t⟿x → if c then t else e ⟿ x eval_if_false: {a, c, t,e: prog a, x} c⟿false → e⟿x → if c then t else e ⟿ x eval_while_true : {c, b, x, y} c⟿true → b⟿x → while c b ⟿ y → while c b ⟿ y eval_while_false: {c, b} c⟿false → while c b ⟿ unit eval_var : {a,b, p: prog a, cont: Var a → prog b, l, x, y} p⟿x → execute (add (objectify x) l) → ({v} v@l → cont v ⟿ y) → (var p cont)⟿y eval_varref : {a,v:Var a,l,x} v@l → execute (get l (objectify x)) → v' ⟿ x eval_assign : {a, v: Var a,p,l,x} p⟿x → v@l → execute (update l (objectify x)) → v←p ⟿ unit eval_print : {a, p: prog a, x} p⟿x → execute (out stdio (objectify x)) → (print p) ⟿ unit eval_read : {a, x: prog a} execute (in stdio (objectify x)) → (read a) ⟿ x \ No newline at end of file
 namespace http://cds.omdoc.org/examples/programs theory OperationalSemantics : http://cds.omdoc.org/urtheories?LF = include ?Syntax include ?Machine objectify : {a} prog a → obj  # objectify 2 varloc: {a} Var a → loc → type # 2 @ 3 eval : {a} prog a → prog a → type # 2 ⟿ 3 prec 3 eval_seq: {a,b, p:prog a, q: prog b, x,y} p⟿x → q⟿y → p;q ⟿ y eval_if_true : {a, c, t,e: prog a, x} c⟿true → t⟿x → if c then t else e ⟿ x eval_if_false: {a, c, t,e: prog a, x} c⟿false → e⟿x → if c then t else e ⟿ x eval_while_true : {c, b, x, y} c⟿true → b⟿x → while c b ⟿ y → while c b ⟿ y eval_while_false: {c, b} c⟿false → while c b ⟿ unit eval_var : {a,b, p: prog a, cont: Var a → prog b, l, x, y} p⟿x → execute (add (objectify x) l) → ({v} v@l → cont v ⟿ y) → (var p cont)⟿y eval_varref : {a,v:Var a,l,x} v@l → execute (get l (objectify x)) → v' ⟿ x eval_assign : {a, v: Var a,p,l,x} p⟿x → v@l → execute (update l (objectify x)) → v←p ⟿ unit eval_print : {a, p: prog a, x} p⟿x → execute (out stdio (objectify x)) → (print p) ⟿ unit eval_read : {a, x: prog a} execute (in stdio (objectify x)) → (read a) ⟿ x \ No newline at end of file
 namespace http://cds.omdoc.org/examples/programs theory Syntax : http://cds.omdoc.org/urtheories?LF = tp: type Bool: tp Nat : tp Unit: tp prog: tp → type true : prog Bool false: prog Bool unit : prog Unit zero : prog Nat succ : prog Nat → prog Nat# succ 1 one : prog Nat = succ zero equal : {a} prog a → prog a → prog Bool  # 2 = 3 prec 10 not : prog Bool → prog Bool  # ¬ 1 prec 8 plus : prog Nat → prog Nat → prog Nat  # 1 + 2 prec 20 minus : prog Nat → prog Nat → prog Nat  # 1 - 2 prec 20 seq : {a,b} prog a → prog b → prog b  # 3 ; 4 prec 5 ifte : {a} prog Bool → prog a → prog a → prog a # if 2 then 3 else 4 prec 3 ifte2 : prog Bool → prog Unit → prog Unit = [b,c] if b then c else unit while : prog Bool → prog Unit → prog Unit print : {a} prog a → prog Unit # print 2 read : {a} prog a val : {a,b} prog a → (prog a → prog b) → prog b # val 3 4 Var : tp → type var : {a,b} prog a → (Var a → prog b) → prog b # var 3 4 varref : {a} Var a → prog a # 2 ' prec 30 assign : {a} Var a → prog a → prog Unit # 2 ← 3 prec 10 theory Test : ?Syntax = main = val (read Nat) [x] var zero [y] while (¬ x = y') ( print x; y ← succ y' )